:root {
  color-scheme: dark;
  --paper: #0b0811;
  --surface: rgba(25, 20, 34, 0.72);
  --surface-solid: #191522;
  --ink: #f6f1fb;
  --muted: #b9afc4;
  --line: rgba(255, 255, 255, 0.12);
  --iris: #b9a0ff;
  --iris-deep: #68499f;
  --gold: #d5b36a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --paper: #f7f5fa;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --ink: #292331;
  --muted: #686071;
  --line: rgba(48, 37, 59, 0.14);
  --iris: #68499f;
  --iris-deep: #4f357d;
  --gold: #8a651f;
  --shadow: 0 24px 80px rgba(50, 36, 65, 0.12);
}

:root[data-theme="aurora"] {
  color-scheme: dark;
  --paper: #071316;
  --surface: rgba(12, 32, 35, 0.72);
  --surface-solid: #10282b;
  --ink: #f1fbf7;
  --muted: #a9c8c1;
  --line: rgba(185, 245, 228, 0.14);
  --iris: #8ee7cc;
  --iris-deep: #399a86;
  --gold: #efd68d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 16% 3%, color-mix(in srgb, var(--iris-deep) 22%, transparent), transparent 34rem),
    radial-gradient(circle at 86% 24%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed; left: 1rem; top: -4rem; z-index: 20;
  padding: .7rem 1rem; border-radius: 999px; background: var(--ink); color: var(--paper);
}
.skip-link:focus { top: 1rem; }

.ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.ambient::before, .ambient::after {
  content: ""; position: absolute; width: 26rem; aspect-ratio: 1; border-radius: 50%; filter: blur(80px); opacity: .12;
}
.ambient::before { background: var(--iris); top: -12rem; left: -9rem; }
.ambient::after { background: var(--gold); right: -14rem; top: 34vh; }

.site-header {
  position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 2rem; width: min(1180px, calc(100% - 2rem)); margin: 1rem auto 0;
  padding: .7rem .8rem .7rem 1rem; border: 1px solid var(--line); border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(24px) saturate(130%);
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.brand { display: inline-flex; gap: .42rem; align-items: center; font: 600 1.05rem/1 var(--serif); letter-spacing: .02em; view-transition-name: arcana-brand; }
.brand img { width: 1.55rem; height: 1.55rem; border-radius: .42rem; filter: drop-shadow(0 0 .55rem color-mix(in srgb, var(--iris) 35%, transparent)); }
.site-nav { display: flex; justify-content: center; gap: clamp(.8rem, 3vw, 2rem); font-size: .86rem; color: var(--muted); }
.site-nav a:hover, .site-nav a:focus-visible { color: var(--ink); }
.header-tools { display: flex; align-items: center; gap: .55rem; }
.locale-link { padding: .35rem .55rem; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .08em; }
.theme-switcher { display: flex; padding: .25rem; border: 1px solid var(--line); border-radius: 999px; }
.theme-switcher button { width: 1.6rem; height: 1.6rem; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.theme-switcher button::before { content: ""; display: block; width: .62rem; height: .62rem; margin: auto; border-radius: 50%; background: currentColor; }
.theme-switcher button[data-theme="aurora"]::before { background: linear-gradient(135deg,#93edd1,#b5a2ff); }
.theme-switcher button.is-active { background: color-mix(in srgb, var(--iris) 18%, transparent); color: var(--iris); }

.shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.breadcrumb { padding: 2.4rem 0 1.25rem; color: var(--muted); font-size: .78rem; letter-spacing: .03em; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: .5rem; opacity: .55; }

.card-hero { display: grid; grid-template-columns: minmax(210px, 340px) minmax(0, 1fr); align-items: start; gap: clamp(2rem, 7vw, 6rem); padding: 2.5rem 0 5rem; }
.card-portrait { position: relative; justify-self: center; width: min(100%, 37vh, 340px); margin: 0; padding: clamp(.75rem, 2vw, 1.15rem); border: 1px solid var(--line); border-radius: 30px; background: var(--surface); box-shadow: var(--shadow); view-transition-name: arcana-card-art; }
.card-portrait::before { content: ""; position: absolute; inset: 10% -8%; z-index: -1; border-radius: 40%; background: color-mix(in srgb, var(--card-accent, var(--iris)) 24%, transparent); filter: blur(50px); }
.card-portrait img { width: 100%; height: auto; aspect-ratio: 3 / 5; border-radius: 18px; object-fit: contain; }
.card-intro { padding-top: clamp(1rem, 6vh, 4.5rem); }
.eyebrow { margin: 0 0 .65rem; color: var(--iris); font-size: .7rem; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; }
.card-intro h1, .page-hero h1 { margin: 0; max-width: 15ch; font: 500 clamp(3rem, 8vw, 6.6rem)/.95 var(--serif); letter-spacing: -.055em; view-transition-name: arcana-title; }
.keyword { margin: 1.2rem 0 1.35rem; color: var(--gold); font: italic 1.18rem/1.45 var(--serif); }
.lede { max-width: 42rem; margin: 0; color: var(--muted); font: 1.08rem/1.75 var(--sans); }
.orientation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 2rem; }
.orientation-grid article { padding: 1.1rem 1.15rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.orientation-grid h2 { margin: 0 0 .4rem; font-size: .7rem; letter-spacing: .15em; text-transform: uppercase; }
.orientation-grid p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.6; }

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: clamp(2rem, 6vw, 5.5rem); align-items: start; }
.article { max-width: 750px; }
.article section { padding: 2.7rem 0; border-top: 1px solid var(--line); }
.article h2 { margin: 0 0 1rem; font: 500 clamp(1.8rem, 4vw, 2.8rem)/1.12 var(--serif); letter-spacing: -.025em; }
.article h3 { margin: 1.8rem 0 .5rem; font: 600 1.2rem/1.3 var(--serif); }
.article p { margin: 0 0 1rem; color: var(--muted); }
.article strong { color: var(--ink); }
.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.context-grid article { padding: 1.25rem; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.context-grid h3 { margin-top: 0; }
.context-grid p { margin-bottom: 0; font-size: .93rem; }
.practice { padding: 1.5rem !important; border: 1px solid color-mix(in srgb, var(--gold) 32%, var(--line)) !important; border-radius: 24px; background: color-mix(in srgb, var(--gold) 7%, var(--surface)); }
.practice blockquote { margin: 0 0 1rem; color: var(--ink); font: italic clamp(1.35rem,3vw,2rem)/1.45 var(--serif); }
.practice p:last-child { margin-bottom: 0; }
.faq details { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; color: var(--ink); font-weight: 650; }
.faq details p { margin: .7rem 0 0; }

.article-aside { position: sticky; top: 6.5rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); backdrop-filter: blur(18px); }
.article-aside p { margin: .5rem 0 1rem; color: var(--muted); font-size: .86rem; }
.text-link { display: inline-flex; align-items: center; gap: .5rem; color: var(--iris); font-size: .85rem; font-weight: 700; }
.text-link span { transition: transform .2s ease; }
.text-link:hover span { transform: translateX(.25rem); }

.related { margin: 5rem 0; }
.related__head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.related h2 { margin: 0; font: 500 clamp(2rem,4vw,3.4rem)/1 var(--serif); }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.related-card { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 1rem; padding: .75rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); transition: transform .25s ease, border-color .25s ease; }
.related-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb,var(--iris) 45%,var(--line)); }
.related-card img { border-radius: 10px; }
.related-card small { color: var(--muted); }
.related-card strong { display: block; font: 600 1rem var(--serif); }

.page-hero { padding: clamp(4rem,10vw,8rem) 0 4rem; }
.page-hero h1 { max-width: 12ch; }
.page-hero .lede { margin-top: 1.5rem; max-width: 50rem; }
.deck-section { padding: 2rem 0 5rem; }
.deck-section__head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.4rem; }
.deck-section h2 { margin: 0; font: 500 clamp(2rem,5vw,3.4rem)/1 var(--serif); }
.deck-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; }
.deck-card { position: relative; min-width: 0; }
.deck-card img { width: 100%; border-radius: 14px; box-shadow: 0 14px 30px rgba(0,0,0,.14); transition: transform .28s ease; }
.deck-card:hover img { transform: translateY(-5px) rotate(-.5deg); }
.deck-card strong { display: block; margin-top: .7rem; font: 600 .98rem/1.2 var(--serif); }
.deck-card small { display: block; margin-top: .2rem; overflow: hidden; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }

.draw-panel { max-width: 780px; margin: 0 auto 5rem; padding: clamp(1.2rem,4vw,2.5rem); border: 1px solid var(--line); border-radius: 30px; background: var(--surface); box-shadow: var(--shadow); }
.draw-panel fieldset { padding: 0; border: 0; margin: 0 0 1.5rem; }
.draw-panel legend { margin-bottom: .7rem; font-weight: 700; }
.topic-options { display: flex; flex-wrap: wrap; gap: .6rem; }
.topic-options label { cursor: pointer; }
.topic-options input { position: absolute; opacity: 0; }
.topic-options span, .count-options button { display: inline-flex; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.topic-options input:checked + span, .count-options button.is-active { border-color: var(--iris); background: color-mix(in srgb,var(--iris) 13%,transparent); color: var(--ink); }
.count-options { display: flex; gap: .5rem; }
.draw-button { min-height: 48px; padding: .75rem 1.2rem; border: 0; border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 750; cursor: pointer; }
.draw-button:hover { background: var(--iris); }

.draw-stage {
  position: relative; min-height: 520px; margin: 0 auto 5rem; padding: 2rem 1rem 3rem; overflow: hidden;
  border: 1px solid var(--line); border-radius: 34px; background:
    radial-gradient(circle at 50% 70%, color-mix(in srgb,var(--iris-deep) 15%,transparent), transparent 45%),
    color-mix(in srgb,var(--surface) 82%,transparent); box-shadow: var(--shadow);
}
.draw-stage__head { position: relative; z-index: 4; text-align: center; }
.draw-stage__head h2 { margin: .2rem 0 .35rem; font: 500 clamp(2rem,5vw,3.4rem)/1 var(--serif); }
.draw-stage__head p:last-child { margin: 0; color: var(--muted); }
.choice-deck {
  display: flex; justify-content: center; align-items: flex-end; min-height: 335px; max-width: 880px;
  margin: .5rem auto 0; padding: 2rem 4rem 1rem; perspective: 1400px;
}
.choice-card {
  position: relative; flex: 0 0 clamp(105px,12vw,145px); width: clamp(105px,12vw,145px); aspect-ratio: 280 / 480;
  margin-left: -4rem; padding: 0; border: 0; border-radius: 15px; background: transparent; cursor: pointer;
  transform: translateY(var(--y)) rotate(var(--angle)); transform-origin: 50% 110%;
  transition: transform .28s cubic-bezier(.2,.8,.2,1), filter .28s ease, opacity .28s ease;
}
.choice-card:first-child { margin-left: 0; }
.choice-card:not(:disabled):hover, .choice-card:not(:disabled):focus-visible {
  z-index: 5; transform: translateY(-28px) rotate(0deg) scale(1.07); filter: drop-shadow(0 22px 24px rgba(0,0,0,.27));
}
.choice-card__inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .68s cubic-bezier(.2,.72,.15,1); }
.choice-card__face { position: absolute; inset: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.36); border-radius: 15px; background: var(--surface-solid); backface-visibility: hidden; box-shadow: 0 16px 34px rgba(0,0,0,.24); }
.choice-card__face img { width: 100%; height: 100%; object-fit: cover; }
.choice-card__front { transform: rotateY(180deg); }
.choice-card.is-chosen { z-index: 8; transform: translateY(-38px) rotate(0deg) scale(1.1); filter: drop-shadow(0 28px 35px rgba(0,0,0,.32)); }
.choice-card.is-chosen .choice-card__inner { transform: rotateY(180deg); }
.choice-card.is-chosen.is-reversed .choice-card__front img { transform: rotate(180deg); }
.choice-card:disabled:not(.is-chosen) { cursor: default; }
.choice-card__position { position: absolute; z-index: 3; top: -.55rem; right: -.55rem; display: grid; width: 1.75rem; aspect-ratio: 1; place-items: center; border: 1px solid color-mix(in srgb,var(--gold) 55%,white); border-radius: 50%; background: var(--paper); color: var(--gold); box-shadow: 0 8px 20px rgba(0,0,0,.3); font-size: .72rem; font-weight: 800; }
.draw-stage.is-shuffling .choice-card { animation: shuffle-deal 1s cubic-bezier(.22,.8,.2,1) both; animation-delay: calc(var(--order) * 35ms); }
@keyframes shuffle-deal {
  0% { opacity: 0; transform: translateX(var(--shuffle-x)) translateY(70px) rotate(0deg) scale(.86); }
  28% { opacity: 1; transform: translateX(var(--shuffle-mid)) translateY(-18px) rotate(var(--angle-opposite)); }
  55% { transform: translateX(var(--shuffle-mid-opposite)) translateY(5px) rotate(var(--angle-soft)); }
  100% { transform: translateY(var(--y)) rotate(var(--angle)); }
}
.draw-result { display: grid; gap: 1rem; margin-top: 2rem; scroll-margin-top: 7rem; }
.draw-result__head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: .6rem; }
.draw-result__head h2 { margin: 0; font: 500 clamp(2.2rem,5vw,3.8rem)/1 var(--serif); }
.draw-result__actions { display: flex; align-items: center; gap: .65rem; }
.retry-button, .change-button { min-height: 42px; padding: .6rem .9rem; border-radius: 999px; cursor: pointer; }
.retry-button { border: 0; background: var(--ink); color: var(--paper); font-weight: 700; }
.retry-button span { display: inline-block; margin-left: .35rem; transition: transform .28s ease; }
.retry-button:hover span { transform: rotate(-90deg); }
.change-button { border: 1px solid var(--line); background: transparent; color: var(--muted); }
.drawn-card { display: grid; grid-template-columns: minmax(145px,190px) 1fr; gap: clamp(1.4rem,4vw,3rem); padding: clamp(1.2rem,3vw,2.1rem); scroll-margin-top: 6rem; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.drawn-card.is-latest { animation: reveal .65s cubic-bezier(.2,.8,.2,1) both; }
.drawn-card__image { align-self: start; }
.drawn-card__image img { width: 100%; border-radius: 14px; box-shadow: 0 18px 38px rgba(0,0,0,.2); }
.drawn-card.is-reversed .drawn-card__image img { transform: rotate(180deg); }
.drawn-card__copy { min-width: 0; }
.drawn-card__title { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.drawn-card h3 { margin: 0; font: 500 clamp(2rem,4vw,3.2rem)/1 var(--serif); }
.drawn-card p { color: var(--muted); }
.drawn-card__keyword { flex: 0 0 auto; margin: 0; color: var(--gold) !important; font: italic 1rem/1.4 var(--serif); text-align: right; }
.drawn-card__section { padding: 1.2rem 0; border-bottom: 1px solid var(--line); }
.drawn-card__section h4 { margin: 0 0 .45rem; color: var(--ink); font-size: .78rem; letter-spacing: .03em; }
.drawn-card__section p { max-width: 68ch; margin: 0; line-height: 1.72; }
.drawn-card__section--lead p { color: var(--ink); font: 1.02rem/1.72 var(--serif); }
.drawn-card__reflection { margin: 1.35rem 0 0; padding-left: 1.1rem; border-left: 2px solid var(--gold); color: var(--ink); font: italic 1.16rem/1.55 var(--serif); }
.drawn-card__reflection span { display: block; margin-bottom: .35rem; color: var(--muted); font: 700 .68rem/1.4 var(--sans); letter-spacing: .04em; }
.drawn-card__action { padding-top: .8rem; border-top: 1px solid var(--line); }
.drawn-card__action span { color: var(--gold); margin-right: .45rem; }
@keyframes reveal { from { opacity: 0; transform: translateY(18px) scale(.98); } }

.policy { max-width: 760px; padding: 4rem 0 7rem; }
.policy h1 { margin: 0 0 1.2rem; font: 500 clamp(3rem,8vw,5.5rem)/.95 var(--serif); letter-spacing: -.05em; view-transition-name: arcana-title; }
.policy h2 { margin: 2.8rem 0 .75rem; font: 600 1.6rem var(--serif); }
.policy p, .policy li { color: var(--muted); }
.notice { padding: 1.2rem 1.3rem; border-left: 2px solid var(--gold); background: color-mix(in srgb,var(--gold) 7%,transparent); }

.site-footer { margin-top: 5rem; border-top: 1px solid var(--line); }
.footer-inner { display: grid; grid-template-columns: 1fr auto; gap: 2rem; width: min(1120px,calc(100% - 2rem)); margin: auto; padding: 2rem 0 3rem; }
.footer-inner p { max-width: 38rem; color: var(--muted); font-size: .84rem; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 1rem; color: var(--muted); font-size: .82rem; }

:focus-visible { outline: 2px solid var(--iris); outline-offset: 4px; }

@media (max-width: 900px) {
  .site-header { grid-template-columns: auto 1fr; }
  .site-nav { display: none; }
  .header-tools { justify-self: end; }
  .card-hero { grid-template-columns: minmax(180px, 280px) 1fr; gap: 2rem; }
  .card-portrait { width: min(100%, 35vh, 280px); }
  .card-intro { padding-top: 1rem; }
  .article-layout { grid-template-columns: 1fr; }
  .article-aside { position: static; }
  .deck-grid { grid-template-columns: repeat(4, 1fr); }
  .related-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .site-header { width: calc(100% - 1rem); margin-top: .5rem; border-radius: 15px; }
  .theme-switcher { display: none; }
  .shell { width: min(100% - 1.25rem, 1120px); }
  .card-hero { grid-template-columns: 1fr; padding-top: .5rem; }
  .card-portrait { width: min(72vw, 280px); margin: auto; }
  .card-intro { padding-top: .5rem; }
  .card-intro h1, .page-hero h1 { font-size: clamp(2.8rem,15vw,4.7rem); }
  .orientation-grid, .context-grid { grid-template-columns: 1fr; }
  .deck-grid { grid-template-columns: repeat(2, 1fr); gap: 1.2rem .7rem; }
  .draw-stage { min-height: 445px; padding: 1.5rem .4rem 2rem; border-radius: 24px; }
  .draw-stage__head { padding: 0 .75rem; }
  .choice-deck { min-height: 270px; padding: 2rem 3rem .5rem; }
  .choice-card { flex-basis: 105px; width: 105px; margin-left: -3.45rem; }
  .draw-result__head { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .draw-result__actions { width: 100%; }
  .drawn-card { grid-template-columns: 100px 1fr; gap: 1rem; }
  .drawn-card__title { align-items: flex-start; flex-direction: column; }
  .drawn-card__keyword { text-align: left; }
  .drawn-card h3 { font-size: 1.5rem; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-links { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
