/* Story Lantern v2 — dark, candlelit game-show look. System fonts only (works offline). */
:root {
  --bg: #07060c;
  --panel: #12101c;
  --line: #2b2640;
  --ink: #f4efe6;
  --dim: #a59fb8;
  --amber: #ffb547;
  --ember: #ff6a2b;
  --cyan: #3de0ff;
  --pink: #ff3d8b;
  --lime: #c6ff3d;
  --t0: #ffb547; --t1: #3de0ff; --t2: #ff3d8b; --t3: #c6ff3d;
  --display: Impact, "Haettenschweiler", "Arial Narrow Bold", "Oswald", "Bebas Neue", "Arial Black", sans-serif;
  --body: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --topH: 52px;
  --towerW: 236px;
  --hostH: 92px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; color: var(--ink); font-family: var(--body);
  background: var(--bg) radial-gradient(ellipse 70% 60% at 30% 110%, rgba(255, 140, 40, .16), transparent 70%),
              radial-gradient(ellipse 50% 40% at 90% -10%, rgba(61, 224, 255, .08), transparent 70%);
  background-color: var(--bg);
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
#top {
  height: var(--topH); display: flex; align-items: center; gap: 14px; padding: 0 14px;
  border-bottom: 1px solid var(--line); background: rgba(10, 8, 18, .85);
}
.brand { font-family: var(--display); font-size: 22px; letter-spacing: .08em; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--amber); font-weight: 400; text-shadow: 0 0 12px rgba(255, 181, 71, .6); }
.brand-mark { width: 12px; height: 18px; border-radius: 50% 50% 45% 45%; background: radial-gradient(circle at 50% 70%, #fff3c4, var(--amber) 50%, var(--ember)); box-shadow: 0 0 12px var(--amber); }
#rounds { display: flex; gap: 4px; margin: 0 auto; }
#rounds button {
  background: none; border: 1px solid transparent; border-radius: 999px; padding: 6px 14px; color: var(--dim);
  font-size: 15px; letter-spacing: .06em; text-transform: uppercase;
}
#rounds button[aria-current="true"] { color: var(--bg); background: var(--amber); box-shadow: 0 0 16px rgba(255, 181, 71, .45); }
.tools { display: flex; gap: 6px; align-items: center; }
.tools .icon { width: 38px; height: 36px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 17px; }
.timer { font-variant-numeric: tabular-nums; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 17px; min-width: 72px; }
.timer.running { border-color: var(--lime); color: var(--lime); }
.timer.done { border-color: var(--pink); color: var(--pink); }

/* ---------- main layout ---------- */
#app {
  height: calc(100vh - var(--topH)); display: grid;
  grid-template-columns: minmax(0, 1fr) var(--towerW);
  grid-template-rows: minmax(0, 1fr) var(--hostH);
}
#stage { grid-column: 1; grid-row: 1; overflow: auto; padding: 18px 28px 6px; display: flex; flex-direction: column; min-height: 0; }
#tower { grid-column: 2; grid-row: 1 / span 2; border-left: 1px solid var(--line); background: rgba(14, 12, 24, .7); display: flex; flex-direction: column; padding: 10px 8px; gap: 8px; min-height: 0; }
#host { grid-column: 1; grid-row: 2; display: flex; align-items: center; gap: 14px; padding: 4px 24px 10px; min-width: 0; }

.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: screenIn .35s ease-out; }
.screen.apply, .screen.meaning, .screen.create { justify-content: center; }
.screen.apply .ctrls, .screen.meaning .ctrls, .screen.create .ctrls { margin-top: clamp(10px, 3vh, 40px); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } }
.kicker { font-family: var(--display); letter-spacing: .14em; color: var(--dim); font-size: clamp(16px, 1.1vw + .6vh, 26px); text-transform: uppercase; }
.kicker b { color: var(--amber); font-weight: 400; }
.btn, .sheet button, .tower-tools button, .tc-actions button, .ctrls button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px; font-size: 16px;
}
.btn:hover, .ctrls button:hover { border-color: var(--amber); }
.primary { background: linear-gradient(180deg, #ffc76a, var(--amber)) !important; color: #1b1004 !important; border-color: transparent !important; font-weight: 700; }
.ctrls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; padding-top: 6px; }
.ctrls button { font-size: 15px; padding: 7px 14px; }
.ctrls .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }

/* ---------- start ---------- */
.start { align-items: center; justify-content: center; text-align: center; gap: clamp(10px, 2.2vh, 26px); }
.title {
  font-family: var(--display); font-weight: 400; margin: 0; line-height: .9; letter-spacing: .04em;
  font-size: clamp(56px, 7vw + 4vh, 170px);
  background: linear-gradient(180deg, #fff6dc 10%, var(--amber) 55%, var(--ember)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 150, 40, .35));
}
.tagline { font-family: var(--display); font-size: clamp(22px, 1.6vw + 1.6vh, 46px); letter-spacing: .2em; margin: 0; color: var(--cyan); text-shadow: 0 0 14px rgba(61, 224, 255, .5); }
.tagline .n { color: var(--pink); text-shadow: 0 0 14px rgba(255, 61, 139, .6); }
.sub { color: var(--dim); margin: 0; font-size: clamp(15px, .8vw + .8vh, 22px); }
.team-setup { display: grid; grid-template-columns: repeat(4, minmax(0, 190px)); gap: 12px; }
.team-setup label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.team-setup input { width: 100%; font: inherit; font-size: clamp(16px, .7vw + .8vh, 22px); text-transform: none; letter-spacing: 0; padding: 8px 10px; border-radius: 10px; background: var(--panel); color: var(--ink); border: 2px solid var(--tc); text-align: center; }
.go { font-family: var(--display); font-size: clamp(24px, 1.4vw + 1.6vh, 44px); letter-spacing: .12em; padding: 12px 48px; border-radius: 999px; border: 0; color: #1b1004; background: linear-gradient(180deg, #ffd38a, var(--amber) 60%, var(--ember)); box-shadow: 0 0 30px rgba(255, 150, 40, .45); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 46px rgba(255, 150, 40, .75); } }
.hint-gear { color: var(--dim); font-size: 14px; margin: 0; }

/* ---------- discover: clue screen ---------- */
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.clue-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); gap: clamp(16px, 2.4vw, 44px); align-items: center; }
.art { width: 100%; height: 100%; max-height: 46vh; min-height: 0; display: flex; align-items: center; justify-content: center; }
.art svg { width: 100%; height: 100%; max-height: 46vh; overflow: visible; filter: drop-shadow(0 0 6px rgba(255, 255, 255, .12)); }
.art svg * { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.art .c1 { stroke: var(--amber); } .art .c2 { stroke: var(--cyan); } .art .c3 { stroke: var(--pink); } .art .c4 { stroke: var(--lime); } .art .c5 { stroke: #e9e2d4; }
.art .thin { stroke-width: 3.5; } .art .fat { stroke-width: 9; } .art .dash { stroke-dasharray: 7 9; }
.art text { stroke: none; fill: var(--ink); font: 700 26px var(--body); opacity: 0; transition: opacity .6s ease var(--td, 6s); }
.art .t2 { fill: var(--cyan); } .art .t3 { fill: var(--pink); }
.art.drawn text { opacity: 1; }
.clue-line { font-size: clamp(26px, 2.6vh + 1.35vw, 66px); line-height: 1.22; margin: 0; font-weight: 600; text-wrap: balance; }
.hint-line { margin: clamp(10px, 2vh, 24px) 0 0; font-size: clamp(20px, 1.8vh + .9vw, 44px); color: var(--amber); line-height: 1.25; }
.hint-line::before { content: "HINT  "; font-family: var(--display); letter-spacing: .12em; color: var(--dim); font-size: .7em; }

.tiles { display: flex; justify-content: center; gap: clamp(6px, .7vw, 12px); padding: clamp(8px, 1.6vh, 20px) 0 4px; perspective: 900px; }
.tile { width: var(--tw, 76px); height: calc(var(--tw, 76px) * 1.18); position: relative; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, 1.4, .5, 1); }
.tile .f, .tile .b { position: absolute; inset: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; font-family: var(--display); font-size: calc(var(--tw, 76px) * .72); }
.tile .f { background: linear-gradient(180deg, #1d1930, #13101f); border: 2px solid #3a3358; color: #3a3358; }
.tile .b { background: linear-gradient(180deg, #fff1cf, var(--amber)); color: #1b1004; transform: rotateY(180deg); box-shadow: 0 0 18px rgba(255, 181, 71, .5); text-transform: uppercase; }
.tile.on { transform: rotateY(180deg); }
.tiles.solved .tile .b { animation: tileGlow 1.2s ease-out; }
@keyframes tileGlow { 30% { box-shadow: 0 0 46px #fff3c4, 0 0 90px var(--amber); } }
.pos-tag { text-align: center; color: var(--dim); font-size: clamp(16px, 1vh + .5vw, 24px); letter-spacing: .14em; text-transform: uppercase; min-height: 1.3em; margin: 2px 0 0; }

/* ---------- countdown lantern ---------- */
.countdown { display: flex; align-items: center; gap: 10px; }
.countdown svg { width: 44px; height: 60px; overflow: visible; }
.countdown .cflame { transform-origin: 30px 62px; transform: scale(var(--life, 1)); transition: transform .3s linear; fill: url(#cdGlow); animation: flicker 1.6s ease-in-out infinite; }
.countdown .ctime { font-family: var(--display); font-size: 30px; letter-spacing: .06em; font-variant-numeric: tabular-nums; min-width: 2.6em; }
.countdown.urgent .ctime { color: var(--pink); }
.countdown.urgent .cflame { animation-duration: .35s; filter: hue-rotate(-25deg) saturate(1.6); }
.countdown.urgent svg { animation: shake .3s linear infinite; }
.countdown.paused { opacity: .55; }
.countdown.out .cflame { opacity: 0; }
.countdown.out .ctime { color: var(--dim); }
.countdown .smoke { opacity: 0; }
.countdown.out .smoke { animation: smoke 2.4s ease-out forwards; }
.countdown .cbtn { background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--dim); padding: 3px 8px; font-size: 13px; }
@keyframes flicker { 0%, 100% { transform: scale(var(--life, 1)) skewX(0); } 25% { transform: scale(calc(var(--life, 1) * 1.04), calc(var(--life, 1) * .96)) skewX(3deg); } 60% { transform: scale(calc(var(--life, 1) * .97), calc(var(--life, 1) * 1.05)) skewX(-3deg); } }
@keyframes shake { 25% { transform: translateX(-2px) rotate(-2deg); } 75% { transform: translateX(2px) rotate(2deg); } }
@keyframes smoke { 0% { opacity: .8; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-26px) scale(1.6); } }

/* ---------- discover: meaning / talk ---------- */
.big-word { font-family: var(--display); font-weight: 400; margin: 0; font-size: clamp(56px, 6vh + 3vw, 150px); line-height: 1; letter-spacing: .04em; color: var(--amber); text-shadow: 0 0 26px rgba(255, 150, 40, .45); }
.big-word small { font-family: var(--body); font-size: .26em; color: var(--dim); letter-spacing: .12em; text-transform: uppercase; vertical-align: middle; margin-left: .6em; }
.meaning { gap: clamp(10px, 2.4vh, 30px); }
.def { font-size: clamp(28px, 3vh + 1.3vw, 68px); line-height: 1.2; margin: 0; font-weight: 600; }
.simple { color: var(--lime); font-size: clamp(20px, 1.8vh + .8vw, 40px); margin: 0; }
.example { font-size: clamp(22px, 2.2vh + 1vw, 50px); color: var(--cyan); margin: 0; line-height: 1.3; font-style: italic; }
.example::before { content: "“"; color: var(--dim); } .example::after { content: "”"; color: var(--dim); }
.talk-prompt { font-size: clamp(30px, 3.4vh + 1.4vw, 74px); line-height: 1.2; margin: 0; font-weight: 700; }
.challenge { font-size: clamp(18px, 1.7vh + .7vw, 36px); color: var(--pink); margin: 0; line-height: 1.3; }
.challenge::before { content: "LEVEL UP  "; font-family: var(--display); letter-spacing: .1em; font-size: .8em; color: var(--dim); }
.starter { font-size: clamp(18px, 1.7vh + .7vw, 36px); color: var(--lime); margin: 0; }
.mark { color: var(--amber); }

/* ---------- apply ---------- */
.question { font-size: clamp(30px, 3.4vh + 1.4vw, 72px); line-height: 1.2; font-weight: 700; margin: clamp(8px, 2vh, 28px) 0; text-wrap: balance; }
.question .gap { display: inline-block; min-width: 3.4em; border-bottom: 4px solid var(--amber); }
.opts { display: grid; gap: clamp(8px, 1.6vh, 18px); }
.opts.n2 { grid-template-columns: 1fr 1fr; } .opts.n3 { grid-template-columns: 1fr 1fr 1fr; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; padding: clamp(10px, 1.8vh, 22px) 18px; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); font-size: clamp(22px, 2.2vh + .9vw, 48px); font-weight: 600; transition: transform .15s, border-color .2s, background .2s; }
.opt:hover { border-color: var(--amber); }
.opt .k { font-family: var(--display); font-weight: 400; color: var(--bg); background: var(--dim); border-radius: 8px; padding: 0 10px; font-size: .8em; }
.opt.right { border-color: var(--lime); background: rgba(198, 255, 61, .12); }
.opt.right .k { background: var(--lime); }
.opt.wrong { border-color: var(--pink); background: rgba(255, 61, 139, .1); animation: nope .4s; }
.opt.wrong .k { background: var(--pink); }
@keyframes nope { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.why { margin: clamp(10px, 2vh, 24px) 0 0; font-size: clamp(19px, 1.8vh + .7vw, 38px); line-height: 1.3; min-height: 2.6em; }
.why.good { color: var(--lime); } .why.bad { color: var(--pink); }

/* ---------- create ---------- */
.chips { display: flex; flex-wrap: wrap; gap: clamp(8px, 1.2vw, 18px); margin: clamp(8px, 2vh, 24px) 0; }
.chip { font-family: var(--display); font-size: clamp(30px, 3vh + 1.5vw, 76px); letter-spacing: .05em; padding: 4px 22px; border-radius: 14px; border: 2px solid var(--cyan); color: var(--cyan); text-shadow: 0 0 14px rgba(61, 224, 255, .5); }
.chip:nth-child(2) { border-color: var(--pink); color: var(--pink); } .chip:nth-child(3) { border-color: var(--amber); color: var(--amber); } .chip:nth-child(4) { border-color: var(--lime); color: var(--lime); }
.scene { font-size: clamp(26px, 2.8vh + 1.2vw, 62px); font-weight: 700; margin: 0; line-height: 1.2; }
.task { font-size: clamp(18px, 1.7vh + .7vw, 36px); color: var(--dim); margin: clamp(8px, 1.6vh, 20px) 0 0; }
.model { font-size: clamp(19px, 1.9vh + .75vw, 40px); line-height: 1.35; margin: 0; color: var(--ink); border-left: 4px solid var(--amber); padding-left: 18px; }

/* ---------- recap ---------- */
.recap-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: clamp(8px, 1.2vh, 14px); margin: clamp(8px, 1.4vh, 16px) 0; }
.rc { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; position: relative; min-height: 0; overflow: hidden; }
.rc .w { font-family: var(--display); font-size: clamp(24px, 2.2vh + 1vw, 52px); color: var(--amber); letter-spacing: .04em; line-height: 1.05; }
.rc .d { font-size: clamp(14px, 1.2vh + .5vw, 26px); color: var(--dim); line-height: 1.25; }
.rc.locked { align-items: center; justify-content: center; background: repeating-linear-gradient(135deg, #12101c 0 12px, #171426 12px 24px); }
.rc.locked .w { color: #4b4466; letter-spacing: .25em; }
.rc label { position: absolute; right: 8px; top: 8px; font-size: 13px; color: var(--dim); display: flex; gap: 4px; align-items: center; }
.rc input { width: 20px; height: 20px; accent-color: var(--pink); }
.rc.tick { border-color: var(--pink); }

/* ---------- tower ---------- */
#lanes { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; min-height: 0; }
.lane { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 0; }
.track { position: relative; flex: 1; width: 100%; min-height: 60px; border-radius: 10px; background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .0)); border: 1px solid var(--line); overflow: hidden; }
.track::before { content: ""; position: absolute; left: 50%; top: 6px; bottom: 6px; width: 2px; transform: translateX(-50%); background: repeating-linear-gradient(180deg, var(--line) 0 6px, transparent 6px 12px); }
.climber { position: absolute; left: 50%; bottom: 4px; width: 34px; height: 44px; margin-left: -17px; transform: translateY(calc(var(--h, 0) * -1px)); transition: transform .7s cubic-bezier(.3, 1.5, .5, 1); border: 0; background: none; padding: 0; }
.climber svg { width: 100%; height: 100%; overflow: visible; }
.climber .lglow { fill: var(--tc); filter: drop-shadow(0 0 6px var(--tc)); }
.climber.leader .lglow { animation: flicker 1.2s ease-in-out infinite; }
.lane .score { font-family: var(--display); font-size: 30px; color: var(--tc); text-shadow: 0 0 10px var(--tc); font-variant-numeric: tabular-nums; line-height: 1; }
.lane .name { font-size: 13px; color: var(--ink); text-align: center; line-height: 1.15; width: 100%; height: 2.3em; overflow: hidden; overflow-wrap: anywhere; display: flex; align-items: center; justify-content: center; }
.lane .pm { display: flex; gap: 3px; }
.lane .pm button { width: 22px; height: 22px; padding: 0; font-size: 13px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); line-height: 1; }
.lane .pm .plus { border-color: var(--tc); color: var(--tc); }
.pop { position: absolute; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 24px; color: var(--tc); pointer-events: none; animation: popUp .9s ease-out forwards; text-shadow: 0 0 10px var(--tc); }
@keyframes popUp { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -40px; } }
.tower-tools { display: flex; gap: 6px; justify-content: center; }
.tower-tools button { font-size: 13px; padding: 5px 10px; }
.tower-tools button:disabled { opacity: .4; cursor: default; }
#twistBadge { border: 1px dashed var(--pink); border-radius: 10px; padding: 6px 8px; font-size: 13px; color: var(--pink); text-align: center; line-height: 1.25; }
#twistBadge b { display: block; font-family: var(--display); font-weight: 400; letter-spacing: .08em; font-size: 16px; }
#twistBadge button { margin-top: 4px; font-size: 12px; background: var(--panel); border: 1px solid var(--pink); border-radius: 8px; padding: 2px 8px; }

/* ---------- host ---------- */
#host .spirit { width: 62px; height: 78px; flex: none; overflow: visible; animation: bob 4s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(255, 150, 40, .45)); }
#host .metal, #host .bar { stroke: #6b5a3a; stroke-width: 3; fill: none; }
#host .bar { stroke-width: 2; opacity: .6; }
#host .cap { fill: #241a0c; stroke: #8a6a3a; stroke-width: 2.5; }
#host .glass { fill: rgba(255, 170, 60, .1); stroke: #8a6a3a; stroke-width: 3; }
#host .flame-wrap { transform-origin: 60px 110px; animation: flicker 1.8s ease-in-out infinite; }
#host .eyes { transform-origin: 60px 88px; animation: blink 5s infinite; }
#host .pupil { transition: transform .3s; }
#host .brow { stroke: #1a0f05; stroke-width: 3; stroke-linecap: round; transition: transform .3s; transform-box: fill-box; transform-origin: center; }
#host.mood-smug .b1 { transform: rotate(-12deg) translateY(2px); } #host.mood-smug .b2 { transform: rotate(4deg) translateY(4px); } #host.mood-smug .pupil { transform: translateX(2px); }
#host.mood-shock .brow { transform: translateY(-5px); } #host.mood-shock .flame-wrap { animation: flare .5s ease-out; }
#host.mood-tense .b1 { transform: rotate(14deg); } #host.mood-tense .b2 { transform: rotate(-14deg); } #host.mood-tense .pupil { animation: dart 1s steps(2) infinite; }
#host.mood-bored .brow { transform: translateY(4px); } #host.mood-bored .pupil { transform: translateY(2px); }
#host.talk .spirit { animation: bob 4s ease-in-out infinite, nod .5s ease-out; }
#hostLine { margin: 0; font-size: clamp(18px, 1.3vh + .8vw, 34px); font-style: italic; color: #ffe2b0; position: relative; padding: 8px 18px; border-radius: 16px; background: rgba(255, 181, 71, .07); border: 1px solid rgba(255, 181, 71, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#hostLine.new { animation: typeIn .45s steps(14); }
@keyframes typeIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes nod { 40% { transform: rotate(-6deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes flare { 40% { transform: scale(1.25); } }
@keyframes dart { 50% { transform: translateX(-2px); } 100% { transform: translateX(2px); } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 3, 8, .82); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.sheet { background: #100e1a; border: 1px solid var(--line); border-radius: 18px; padding: 18px 22px; width: min(980px, 100%); max-height: 100%; overflow: auto; }
.sheet.small { width: min(720px, 100%); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: .08em; font-size: 26px; color: var(--amber); }
.sheet-head .warn { color: var(--pink); font-size: 13px; }
.sheet-head button { margin-left: auto; }
.sheet-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
legend { color: var(--dim); padding: 0 6px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
fieldset label { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 15px; }
fieldset input[type=number], fieldset select { width: 90px; font: inherit; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
fieldset select { width: 200px; }
fieldset input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--amber); margin-right: auto; order: -1; }
.ticks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; }
.ticks label { justify-content: flex-start; }
.ticks input { order: 0 !important; margin: 0 !important; }
.ticks .num { color: var(--dim); font-size: 12px; width: 18px; text-align: right; }
.row { display: flex; gap: 6px; flex-wrap: wrap; }
.msg { color: var(--dim); font-size: 14px; margin: 4px 0 0; min-height: 1.2em; }
.danger { border-color: var(--pink) !important; color: var(--pink); }
.keys { width: 100%; border-collapse: collapse; font-size: 15px; }
.keys th { text-align: left; white-space: nowrap; color: var(--amber); padding: 5px 14px 5px 0; vertical-align: top; font-weight: 600; }
.keys td { padding: 5px 0; color: var(--ink); border-bottom: 1px solid var(--line); }

/* plot-twist card */
.twist-card { width: min(640px, 92vw); height: min(440px, 76vh); position: relative; transform-style: preserve-3d; perspective: 1200px; }
.twist-card > div { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .7s cubic-bezier(.3, 1.3, .5, 1); }
.tc-back { background: repeating-linear-gradient(45deg, #1a0f24 0 14px, #230f2e 14px 28px); border: 3px solid var(--pink); display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--display); font-size: 72px; letter-spacing: .1em; color: var(--pink); text-shadow: 0 0 22px var(--pink); line-height: 1; box-shadow: 0 0 60px rgba(255, 61, 139, .35); }
.tc-front { transform: rotateY(180deg); background: radial-gradient(ellipse at 50% 0%, #2a1236, #110b1a 70%); border: 3px solid var(--amber); box-shadow: 0 0 60px rgba(255, 181, 71, .35); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 22px 28px; gap: 6px; }
.twist-card.shown .tc-back { transform: rotateY(-180deg); }
.twist-card.shown .tc-front { transform: rotateY(0); }
.twist-card.shuffle { animation: shuffle .5s ease-in-out; }
@keyframes shuffle { 25% { transform: rotate(-4deg) translateX(-14px); } 75% { transform: rotate(4deg) translateX(14px); } }
.tc-kicker { text-transform: uppercase; font-family: var(--display); letter-spacing: .3em; color: var(--pink); font-size: 18px; }
.tc-icon { font-size: 54px; line-height: 1.1; color: var(--amber); font-family: var(--display); }
.tc-front h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(36px, 5vh + 1.5vw, 64px); letter-spacing: .05em; color: var(--amber); text-transform: uppercase; }
.tc-front p { margin: 0; font-size: clamp(20px, 2.2vh + .8vw, 32px); line-height: 1.3; }
.tc-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }

#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #1d1930; border: 1px solid var(--amber); color: var(--ink); padding: 8px 16px; border-radius: 12px; font-size: 16px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30; }
#toast.show { opacity: 1; }

/* burst sparks */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.spark { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--amber)); box-shadow: 0 0 12px var(--c, var(--amber)); animation: burst .9s cubic-bezier(.1, .7, .3, 1) forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.flash { position: absolute; inset: 0; background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 210, 120, .35), transparent 50%); animation: flash .6s ease-out forwards; }
@keyframes flash { to { opacity: 0; } }

/* ---------- smaller projectors / laptops ---------- */
@media (max-height: 700px) and (min-width: 701px) { :root { --hostH: 74px; } #host .spirit { width: 50px; height: 62px; } }

/* ---------- phone ---------- */
@media (max-width: 700px) {
  :root { --topH: auto; --hostH: auto; }
  body { overflow: auto; }
  #top { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 8px; }
  #rounds { order: 3; width: 100%; overflow-x: auto; margin: 0; }
  #rounds button { padding: 6px 10px; font-size: 13px; }
  .tools { margin-left: auto; }
  #app { height: auto; display: flex; flex-direction: column; }
  #stage { overflow: visible; padding: 12px 14px; }
  #tower { border-left: 0; border-top: 1px solid var(--line); order: 3; }
  #lanes { min-height: 190px; }
  #host { order: 2; padding: 6px 14px; }
  #hostLine { white-space: normal; font-size: 16px; }
  .clue-body { grid-template-columns: 1fr; }
  .art, .art svg { max-height: 30vh; }
  .team-setup { grid-template-columns: 1fr 1fr; width: 100%; }
  .opts.n2, .opts.n3 { grid-template-columns: 1fr; }
  .recap-grid { grid-template-columns: 1fr 1fr; }
  .sheet-grid { grid-template-columns: 1fr; }
  .dhead { flex-wrap: wrap; }
}

/* ---------- reduced motion: calm, no movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .spark, .flash { display: none; }
}
