:root {
  --night: #121827;
  --room: #1c2539;
  --room-2: #253049;
  --ink: #efe7d6;
  --ink-dim: #a3abbe;
  --ink-faint: rgba(239, 231, 214, .18);
  --lamp: #f4dc9a;
  --hand: 'Kalam', 'Comic Sans MS', cursive;
  --body: 'Nunito', system-ui, sans-serif;
  --wobble: 255px 18px 225px 16px / 16px 225px 18px 255px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(ellipse 80% 60% at 50% 28%, #26324d 0%, var(--room) 45%, var(--night) 100%) fixed;
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  overflow-x: hidden;
}
.hand { font-family: var(--hand); font-weight: 400; }

.paper { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.paper .wallpaper { opacity: .2; }
.paper .grain { opacity: .07; mix-blend-mode: overlay; }

/* light beams: colour only exists where the light falls */
.beam-shape { transform-origin: 388px 26px; transform: scale(.02, .02); transition: transform 2.6s cubic-bezier(.25,.7,.2,1); }
.lit .beam-shape { transform: none; }
.mote { animation: drift 9s ease-in-out infinite alternate; }
@keyframes drift { 0% { transform: translate(0, 0); opacity: .15; } 50% { opacity: .7; } 100% { transform: translate(-14px, 22px); opacity: .2; } }
.intro .glow { animation: in 3s ease both; }

.top, #stage, .foot { position: relative; z-index: 1; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 18px clamp(16px, 4vw, 40px); }
.logo { color: var(--ink); text-decoration: none; font-size: 1.35rem; }
.top nav a, .linkish { color: var(--ink-dim); font: inherit; background: none; border: 0; cursor: pointer; text-decoration: underline wavy rgba(239,231,214,.35); text-underline-offset: 5px; }
.top nav a:hover, .linkish:hover { color: var(--ink); }
.foot { text-align: center; color: var(--ink-dim); font-size: .85rem; padding: 40px 16px 28px; }

#stage { max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); min-height: calc(100vh - 160px); }
.screen { animation: in .6s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }

h1, h2, h3 { font-family: var(--hand); font-weight: 400; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); }
h2 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); }
h3 { font-size: 1.5rem; color: var(--lamp); }
p { margin: 0 0 1em; }
.lead { font-size: 1.15rem; color: var(--ink); max-width: 36em; }
.muted { color: var(--ink-dim); }
.small { font-size: .88rem; }

/* hand-drawn buttons and chips */
.btn, .chip {
  font: 400 1.15rem var(--hand); color: var(--ink); cursor: pointer;
  background: transparent; border: 2.2px solid var(--ink); border-radius: var(--wobble);
  padding: .45em 1.2em; transition: transform .15s, background .25s, color .25s;
}
.btn:hover, .chip:hover { transform: rotate(-1deg) scale(1.03); }
.btn:focus-visible, .chip:focus-visible, [role=button]:focus-visible { outline: 2px dashed var(--lamp); outline-offset: 4px; }
.btn.primary { background: var(--ink); color: var(--room); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btns { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 1.4em; }
.chip { font-size: 1.05rem; padding: .25em .9em; border-width: 1.8px; }
.chip[aria-pressed=true] { background: var(--lamp); color: var(--room); border-color: var(--lamp); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }

/* line art */
svg .boil { filter: url(#boil); }
.wash-g { clip-path: circle(0% at 50% 100%); transition: clip-path 1.8s cubic-bezier(.3,.6,.2,1); }
.wash-g.on { clip-path: circle(160% at 50% 100%); }
.twinkle { animation: twinkle 3s ease-in-out infinite alternate; }
.twinkle:nth-child(2n) { animation-delay: -1.4s; }
@keyframes twinkle { to { opacity: .25; } }

/* intro */
.intro { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(20px, 5vw, 60px); align-items: center; padding-top: 3vh; }
.intro-art svg { width: 100%; height: auto; }
.intro .flower .wash-g { clip-path: circle(160% at 50% 100%); }
.intro .flower .wash { opacity: .95; }
.underline { display: block; width: 72%; height: 18px; margin-top: -6px; }

/* steps */
.step { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: clamp(20px, 5vw, 64px); align-items: center; padding-top: 2vh; }
.step-copy { max-width: 520px; }
.progress { display: flex; gap: 8px; margin-bottom: 18px; }
.progress i { width: 26px; height: 6px; border-radius: var(--wobble); background: var(--ink-faint); }
.progress i.on { background: var(--lamp); }

.bodymap svg { width: 100%; max-height: 70vh; }
.zone { cursor: pointer; }
svg [role=button] { outline: none !important; }
.zone .hit { fill: transparent; }
.zone .outline { opacity: 0; transition: opacity .2s; }
.zone:hover .outline, .zone:focus-visible .outline { opacity: .6; }
.zone .wash { opacity: 0; transition: opacity .4s; }
.zone[aria-pressed=true] .wash { opacity: .55; }
.zone[aria-pressed=true] .outline { opacity: 1; }

.q-figure svg { width: 100%; max-width: 300px; }
.answers { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }

/* wheel */
.wheel-screen { display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: clamp(16px, 4vw, 48px); align-items: start; padding-top: 1vh; }
.wheel-wrap svg { width: 100%; max-width: 640px; display: block; margin: 0 auto; overflow: visible; }
.seg { cursor: pointer; }
.seg .wash { opacity: 0; transition: opacity .4s; }
.seg:hover .wash, .seg:focus-visible .wash { opacity: .28; }
.seg.suggest .wash { animation: glow 2.4s ease-in-out infinite alternate; }
.seg.picked .wash { opacity: .95 !important; animation: none; }
.seg.picked { filter: drop-shadow(0 0 16px rgba(246, 223, 160, .35)); }
@keyframes glow { from { opacity: .12; } to { opacity: .42; } }
.seg text { fill: var(--ink); font-family: var(--hand); pointer-events: none; }
.seg.picked text { fill: #151b2a; font-weight: 700; }
.fly { transition: transform 1.5s cubic-bezier(.2,.8,.2,1); }
.center-btn { cursor: pointer; }
.center-btn text { fill: var(--ink); font-family: var(--hand); }

.tray { border: 2px dashed var(--ink-faint); border-radius: var(--wobble); padding: 18px; }
.tray h3 { font-size: 1.3rem; }
.tray-list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; margin-bottom: 14px; }
.tag { display: flex; align-items: center; gap: 10px; font: 1.2rem var(--hand); background: none; border: 0; color: var(--ink); cursor: pointer; padding: 0; text-align: left; }
.tag i { width: 18px; height: 18px; border-radius: 50% 40% 55% 45%; flex: none; }
.tag span.x { color: var(--ink-dim); font-size: .95rem; }
.hint { font-size: .92rem; color: var(--ink-dim); }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* intensity */
.how { max-width: 760px; margin: 0 auto; padding-top: 2vh; }
.dial { display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: center; padding: 18px 0; border-bottom: 1.5px dashed var(--ink-faint); }
.dial svg { width: 120px; height: 130px; }
.dial-word { font: 1.7rem var(--hand); }
.ladder { display: flex; justify-content: space-between; color: var(--ink-dim); font: 1rem var(--hand); }
.ladder span.on { color: var(--ink); text-decoration: underline wavy; text-underline-offset: 4px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; background: none; height: 34px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--ink); border-radius: var(--wobble); }
input[type=range]::-moz-range-track { height: 4px; background: var(--ink); border-radius: 4px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -12px; border-radius: 50% 45% 52% 48%; border: 2.5px solid var(--ink); background: var(--c, var(--lamp)); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--c, var(--lamp)); }

/* result */
.result { position: relative; padding-top: 1vh; }
.beam { position: absolute; top: -140px; left: -10vw; width: 70vw; height: 140vh; pointer-events: none; z-index: -1;
  background: linear-gradient(115deg, transparent 30%, rgba(244,220,154,.10) 45%, rgba(244,220,154,.04) 60%, transparent 70%);
  filter: blur(6px); animation: beam 2.5s ease both; }
@keyframes beam { from { opacity: 0; } }
.result-grid { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: clamp(20px, 5vw, 64px); align-items: start; }
.card-wrap { margin: 0; position: sticky; top: 16px; }
.card-wrap svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 18px 30px rgba(0,0,0,.45)); }
.card-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.eyebrow { font: 1.25rem var(--hand); color: var(--ink-dim); margin: 0; }
.big { font-size: clamp(3rem, 8vw, 5rem); margin: 0; }
.mix { font: 1.3rem var(--hand); color: var(--ink-dim); }
.result-text section { margin-top: 34px; }
.defs { list-style: none; padding: 0; margin: 0; }
.defs li { display: flex; gap: 12px; margin-bottom: 8px; }
.defs i { width: 14px; height: 14px; border-radius: 50% 40% 55% 45%; margin-top: 7px; flex: none; }
.help ol { padding-left: 1.3em; }
.help li { margin-bottom: .8em; }
.help li::marker { font-family: var(--hand); color: var(--lamp); }
.note { border-left: 3px solid var(--lamp); padding-left: 14px; color: var(--ink); }
.player { display: flex; align-items: center; gap: 16px; }
.play { width: 64px; height: 64px; padding: 0; border-radius: 50% 46% 52% 48%; display: grid; place-items: center; flex: none; }
.player canvas { width: 100%; height: 64px; }

/* words */
.words-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; }
.search { font: 1.2rem var(--hand); color: var(--ink); background: transparent; border: 0; border-bottom: 2px solid var(--ink); padding: 6px 2px; width: min(320px, 100%); }
.search::placeholder { color: var(--ink-dim); }
.family { display: grid; grid-template-columns: 110px 1fr; gap: 20px; padding: 26px 0; border-bottom: 1.5px dashed var(--ink-faint); }
.family svg { width: 110px; }
.family h2 { font-size: 2rem; }
.wordlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 24px; }
.word { background: none; border: 0; color: var(--ink); text-align: left; padding: 0; cursor: pointer; font: inherit; }
.word b { font: 400 1.3rem var(--hand); text-decoration: underline 2px; text-decoration-color: var(--c); text-underline-offset: 4px; }
.word span { display: block; color: var(--ink-dim); font-size: .92rem; line-height: 1.4; }
.word.sub b { font-size: 1.1rem; }

dialog { background: var(--room-2); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--wobble); max-width: 520px; padding: 28px; }
dialog::backdrop { background: rgba(8, 11, 20, .7); }

@media (max-width: 820px) {
  .intro, .step, .wheel-screen, .result-grid { grid-template-columns: 1fr; }
  .step .bodymap svg { max-height: 52vh; }
  .card-wrap { position: static; max-width: 420px; }
  .wheel-wrap svg { margin: 0 -8px; width: calc(100% + 16px); }
  .core-seg text { font-size: 34px; }
  .seg text.ring-in { font-size: 25px; }
  .seg text.ring-out { font-size: 23px; }
  .seg text.ring-out.long { font-size: 18px; }
  .family { grid-template-columns: 1fr; }
  .family svg { width: 80px; }
  .dial { grid-template-columns: 80px 1fr; }
  .dial svg { width: 80px; height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  svg .boil { filter: none; }
}
