/* ============ NICHE — alpine dusk ============ */
:root {
  --ink: #f6f0e6;
  --muted: rgba(246, 240, 230, .66);
  --faint: rgba(246, 240, 230, .40);
  --panel: rgba(19, 16, 42, .62);
  --panel-hi: rgba(255, 255, 255, .055);
  --line: rgba(255, 255, 255, .11);
  --line-hi: rgba(255, 255, 255, .22);

  --amber: #ffb547;
  --coral: #ff7a5c;
  --t1: #a9b8c9;
  --t2: #5fd3a2;
  --t3: #5aa8ff;
  --t4: #b88cff;
  --t5: #ffb547;
  --bad: #ff5d6c;

  --r: 24px;
  --fd: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --fm: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  --p: 0;           /* climb progress 0..1.4, drives parallax */
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #0d0b22;
  color: var(--ink);
  font-family: var(--fd);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- SKY ---------- */
#sky {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    linear-gradient(180deg, #0c0a24 0%, #1d1748 24%, #4a2a6a 42%, #b2506f 56%, #ff8a5c 66%, #ffc477 76%, #ffd9a0 100%);
}
.sky-dark {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #05040f 0%, #0b0a24 60%, #1a1438 100%);
  opacity: calc(var(--p) * .62);
  transition: opacity 1.6s ease;
}
.sun {
  position: absolute; left: 64%; top: 50%;
  width: 34vmin; height: 34vmin; border-radius: 50%;
  background: radial-gradient(circle, #fff1c9 0%, #ffc070 35%, rgba(255, 140, 90, .35) 62%, transparent 72%);
  transform: translate(-50%, calc(var(--p) * 30vh));
  filter: blur(.5px);
  transition: transform 1.6s cubic-bezier(.2, .8, .2, 1);
}
#fx { position: absolute; inset: 0; width: 100%; height: 100%; }
#range { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 64vh; }
#range .layer { transition: transform 1.6s cubic-bezier(.2, .8, .2, 1); }
#fog {
  position: absolute; inset: 0 -6%; pointer-events: none;
  background:
    radial-gradient(60% 40% at 30% 60%, rgba(220, 215, 240, .55), transparent 70%),
    radial-gradient(50% 35% at 75% 45%, rgba(220, 215, 240, .5), transparent 70%),
    linear-gradient(180deg, rgba(200, 195, 225, .15), rgba(200, 195, 225, .55));
  opacity: 0; transition: opacity 1.4s ease;
}
body.w-fog #fog { opacity: 1; animation: drift 9s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translateX(-3%); } to { transform: translateX(3%); } }

/* ---------- LAYOUT ---------- */
#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }
.screen {
  display: none;
  min-height: 100vh; min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; animation: rise .55s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- HOME ---------- */
#home { flex-direction: column; align-items: center; justify-content: center; gap: 30px; }
.brand { text-align: center; }
.logo { display: inline-flex; align-items: center; gap: 14px; }
.logo-mark { width: 54px; height: 54px; color: var(--amber); filter: drop-shadow(0 6px 24px rgba(255, 181, 71, .45)); }
.logo h1 {
  margin: 0; font-size: clamp(64px, 14vw, 116px); line-height: .9; font-weight: 800; letter-spacing: -.045em;
  background: linear-gradient(180deg, #fff8ec 20%, #ffd6a1 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 10px 50px rgba(255, 170, 100, .18);
}
.tag { margin: 12px 0 0; font-size: clamp(17px, 2.4vw, 21px); color: var(--muted); }
.tag em { font-style: normal; color: var(--amber); }

.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; width: min(760px, 100%); }
.mode-card {
  position: relative; text-align: left; display: flex; flex-direction: column; gap: 10px;
  padding: 24px 24px 22px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  overflow: hidden; isolation: isolate;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), border-color .25s, box-shadow .25s;
}
.mode-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .9;
  background: radial-gradient(120% 80% at 100% 0%, rgba(255, 181, 71, .22), transparent 55%);
}
.mode-card.endless::before { background: radial-gradient(120% 80% at 100% 0%, rgba(184, 140, 255, .26), transparent 55%); }
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-4px); border-color: var(--line-hi); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .6); outline: none; }
.eyebrow { font-family: var(--fm); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.eyebrow b { color: var(--ink); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.endless .dot { background: var(--t4); box-shadow: 0 0 12px var(--t4); }
.mode-title { font-size: clamp(24px, 3.2vw, 30px); font-weight: 700; line-height: 1.08; letter-spacing: -.02em; }
.mode-meta { color: var(--muted); font-size: 14.5px; min-height: 1.4em; }
.cta { margin-top: 6px; font-weight: 700; color: var(--amber); display: inline-flex; gap: 6px; align-items: center; }
.endless .cta { color: var(--t4); }
.cta i { font-style: normal; transition: transform .25s; }
.mode-card:hover .cta i { transform: translateX(4px); }
.mode-card.done .cta { color: var(--ink); }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; }
.tier-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px; border-radius: 999px;
  background: rgba(10, 8, 28, .45); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tier-chip i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.tier-chip b { color: var(--ink); font-weight: 600; }
.tier-chip span { font-family: var(--fm); font-size: 12px; }

.home-nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pill {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: rgba(10, 8, 28, .45);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 14.5px; transition: border-color .2s, background .2s;
}
.pill:hover { border-color: var(--line-hi); background: rgba(255, 255, 255, .08); }

/* ---------- PLAY ---------- */
#play { flex-direction: column; gap: 18px; max-width: 900px; margin: 0 auto; }
.hud { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(10, 8, 28, .5); color: var(--muted);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: color .2s, border-color .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-hi); }
.icon-btn svg { width: 18px; height: 18px; }
.hud-mid { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
#hud-mode { font-family: var(--fm); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
#hud-round { font-weight: 700; font-size: 17px; }
.hud-right { display: flex; align-items: center; gap: 12px; }
.hud-extra { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); }
.tank { width: 11px; height: 20px; border-radius: 4px; border: 1.5px solid var(--t2); position: relative; }
.tank::after { content: ""; position: absolute; inset: 2px; border-radius: 2px; background: var(--t2); box-shadow: 0 0 8px var(--t2); }
.tank.empty { border-color: rgba(255, 255, 255, .2); }
.tank.empty::after { display: none; }
.hud-pick { font-family: var(--fm); font-size: 13px; padding: 3px 8px; border-radius: 8px; background: rgba(255, 255, 255, .07); margin-left: 4px; }
.streak { font-family: var(--fm); font-size: 12.5px; color: var(--amber); padding: 3px 8px; border-radius: 8px; background: rgba(255, 181, 71, .12); }
.hud-score { display: inline-flex; align-items: baseline; gap: 5px; padding: 8px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.hud-score b { font-family: var(--fm); font-size: 20px; }
.hud-score small { color: var(--muted); font-size: 12px; }
.hud-score.bump { animation: bump .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes bump { 40% { transform: scale(1.14); } }

.play-body { flex: 1; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; align-items: stretch; }
/* altimeter */
.altimeter { display: flex; justify-content: center; padding: 40px 0 18px 16px; }
.alt-track { position: relative; width: 8px; height: 100%; min-height: 320px; border-radius: 99px; background: rgba(10, 8, 28, .55); border: 1px solid var(--line); }
.alt-marks { position: absolute; inset: 0; }
.alt-mark { position: absolute; right: 16px; transform: translateY(50%); font-family: var(--fm); font-size: 10px; color: var(--faint); white-space: nowrap; }
.alt-mark::after { content: ""; position: absolute; right: -13px; top: 50%; width: 8px; height: 1px; background: var(--line-hi); }
.alt-fill { position: absolute; left: -1px; right: -1px; bottom: -1px; height: 0; border-radius: 99px; background: linear-gradient(0deg, var(--t2), var(--t3), var(--t4), var(--t5)); box-shadow: 0 0 18px rgba(255, 181, 71, .45); transition: height 1.2s cubic-bezier(.2, .8, .2, 1); }
.alt-climber { position: absolute; left: 50%; bottom: 0; width: 18px; height: 18px; margin: 0 0 -9px -9px; border-radius: 50%; background: #fff6e5; box-shadow: 0 0 0 4px rgba(255, 181, 71, .35), 0 0 22px var(--amber); transition: bottom 1.2s cubic-bezier(.2, .8, .2, 1); }
.alt-climber span { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); font-family: var(--fm); font-size: 11px; font-weight: 700; white-space: nowrap; padding: 3px 7px; border-radius: 7px; background: rgba(10, 8, 28, .8); border: 1px solid var(--line); }

.stage { display: flex; flex-direction: column; gap: 16px; justify-content: center; min-width: 0; }

.quirk {
  align-self: flex-start; display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; border-radius: 16px;
  background: linear-gradient(90deg, rgba(var(--qc, 255, 181, 71), .2), rgba(10, 8, 28, .5)); border: 1px solid rgba(var(--qc, 255, 181, 71), .45);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: quirkIn .7s cubic-bezier(.2, 1.4, .3, 1);
}
@keyframes quirkIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
.quirk-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; background: rgba(var(--qc, 255, 181, 71), .22); }
.quirk-text { display: flex; flex-direction: column; line-height: 1.25; }
.quirk-text b { font-size: 15px; }
.quirk-text span { font-size: 13.5px; color: var(--muted); }

.card {
  position: relative; padding: clamp(24px, 4vw, 40px); border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .06);
  overflow: hidden;
}
.card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(90% 60% at 0% 0%, rgba(255, 255, 255, .06), transparent 60%); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.topic { font-family: var(--fm); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--amber); }
.letter { font-family: var(--fm); font-weight: 700; font-size: 14px; padding: 5px 11px; border-radius: 10px; background: rgba(255, 122, 92, .18); border: 1px solid rgba(255, 122, 92, .5); color: #ffc4b4; }
.prompt { margin: 0; font-size: clamp(28px, 5vw, 46px); line-height: 1.05; font-weight: 700; letter-spacing: -.025em; text-wrap: balance; transition: opacity 1.2s ease, filter 1.2s ease; }
.prompt.mirror { transform: scaleX(-1); display: inline-block; }
.prompt.fogged { opacity: .04; filter: blur(10px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chips:empty { display: none; }
.chip { padding: 6px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; background: rgba(var(--cc), .16); border: 1px solid rgba(var(--cc), .5); animation: rise .35s ease; }

.answer-zone { display: flex; flex-direction: column; gap: 10px; }
.answer-row { display: flex; gap: 12px; align-items: center; }
.timer { position: relative; width: 64px; height: 64px; flex: none; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.t-bg { fill: rgba(10, 8, 28, .6); stroke: var(--line); stroke-width: 3; }
.t-fg { fill: none; stroke: var(--amber); stroke-width: 3.4; stroke-linecap: round; stroke-dasharray: 119.38; stroke-dashoffset: 0; transition: stroke .3s; }
#timer-n { position: relative; font-family: var(--fm); font-weight: 700; font-size: 18px; }
.timer.low .t-fg { stroke: var(--bad); }
.timer.low #timer-n { color: #ffb3ba; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* answer field: frosted glass with a gradient rim that lights up on focus */
#form { flex: 1; display: flex; min-width: 0; position: relative; border-radius: 20px; }
#form::before {
  content: "›"; position: absolute; left: 20px; top: 50%; transform: translateY(-54%);
  z-index: 1; font: 700 26px/1 var(--fm); color: var(--faint); pointer-events: none; transition: color .25s, transform .25s;
}
#form:focus-within::before { color: var(--amber); transform: translate(3px, -54%); }
#input {
  flex: 1; min-width: 0; height: 64px; padding: 0 72px 0 50px; border-radius: 20px;
  color: var(--ink); caret-color: var(--amber);
  border: 1.5px solid transparent;
  background:
    linear-gradient(180deg, rgba(30, 25, 64, .78), rgba(16, 13, 38, .82)) padding-box,
    linear-gradient(120deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .06) 45%, rgba(255, 255, 255, .16)) border-box;
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  font: 600 21px/1 var(--fd); letter-spacing: -.01em; outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 18px 44px -20px rgba(0, 0, 0, .8);
  transition: box-shadow .3s, background .3s;
}
#input::placeholder { color: rgba(246, 240, 230, .34); font-weight: 500; }
#input:focus {
  background:
    linear-gradient(180deg, rgba(34, 28, 72, .85), rgba(18, 14, 42, .88)) padding-box,
    linear-gradient(120deg, #ffc565, #ff7a5c 40%, #b88cff 75%, #5aa8ff) border-box;
  box-shadow: 0 0 0 5px rgba(255, 170, 90, .10), 0 0 40px -6px rgba(255, 150, 90, .35), 0 18px 44px -20px rgba(0, 0, 0, .8);
}
#input:disabled { opacity: .6; }
body.w-whiteout #input {
  color: transparent; caret-color: #fff;
  background:
    repeating-linear-gradient(135deg, rgba(230, 236, 255, .20) 0 10px, rgba(230, 236, 255, .10) 10px 20px) padding-box,
    linear-gradient(120deg, #e8eeff, #9fb8ff) border-box;
}
.go {
  position: absolute; right: 9px; top: 9px; bottom: 9px; width: 46px; border: 0; border-radius: 14px;
  background: linear-gradient(135deg, #ffc565, #ff8d5c); color: #2a1408; display: grid; place-items: center;
  box-shadow: 0 6px 20px -6px rgba(255, 140, 90, .9);
  transition: transform .15s, opacity .25s, filter .25s, box-shadow .25s;
}
#input:placeholder-shown + .go { opacity: .32; filter: saturate(.3); box-shadow: none; }
.go:hover { transform: translateX(2px); }
.go:active { transform: scale(.92); }
.go svg { width: 22px; height: 22px; }
.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.under { display: flex; align-items: center; gap: 16px; padding-left: 76px; min-height: 24px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255, 255, 255, .25); }
.link:hover { color: var(--ink); }
.feedback { font-size: 14px; color: #ffb3ba; margin-left: auto; text-align: right; }
.feedback.ok { color: var(--t2); }
.feedback.ask { color: var(--muted); animation: fade .25s ease-out; }
.dym {
  font: inherit; font-weight: 700; color: var(--amber); background: rgba(255, 181, 71, .1); cursor: pointer;
  border: 1px solid rgba(255, 181, 71, .35); border-radius: 8px; padding: 1px 8px; margin: 0 1px;
  transition: background .15s, border-color .15s, transform .15s;
}
.dym:hover, .dym:focus-visible { background: rgba(255, 181, 71, .22); border-color: var(--amber); transform: translateY(-1px); outline: none; }
.dym-hint { font-family: var(--fm); font-size: 11px; color: var(--faint); margin-left: 4px; white-space: nowrap; }

/* reveal */
.reveal {
  padding: 22px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); animation: rise .45s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column; gap: 18px;
}
.reveal-head { display: flex; align-items: center; gap: 16px; }
.badge {
  flex: none; padding: 10px 14px; border-radius: 14px; font-weight: 800; font-size: 15px; letter-spacing: .02em;
  color: #120f26; background: var(--bc, var(--t5)); box-shadow: 0 0 30px -4px var(--bc, var(--t5));
}
.badge.miss { background: rgba(255, 255, 255, .1); color: var(--muted); box-shadow: none; }
.r-main { flex: 1; min-width: 0; }
.r-answer { font-size: 24px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.r-sub { color: var(--muted); font-size: 14px; }
.r-pts { font-family: var(--fm); font-weight: 700; font-size: 28px; color: var(--bc, var(--amber)); }
.badge.pop { animation: badgePop .65s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes badgePop { 0% { transform: scale(.3) rotate(-12deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.reveal.t3 .r-pts, .reveal.t4 .r-pts, .reveal.t5 .r-pts { text-shadow: 0 0 22px var(--bc); }
.reveal.t4 { border-color: var(--bc); box-shadow: 0 0 60px -18px var(--bc); }
.reveal.t5 { border-color: var(--bc); box-shadow: 0 0 90px -14px var(--bc), inset 0 0 40px -20px var(--bc); }
.reveal.t5 .badge.pop {
  background: linear-gradient(110deg, var(--bc) 35%, #fff6dc 50%, var(--bc) 65%) 0 0 / 260% 100%;
  animation: badgePop .65s cubic-bezier(.2, 1.6, .4, 1) both, shimmer 1.8s linear .65s infinite;
}
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -130% 0; } }
.reveal.t5 .r-answer { animation: glowText 2.4s ease-in-out infinite; }
@keyframes glowText { 50% { text-shadow: 0 0 18px rgba(255, 181, 71, .55); } }

/* celebration layers */
#party { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 62; }
.flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 61; opacity: 0;
  background: radial-gradient(circle at var(--x) var(--y), var(--c), transparent 65%);
  mix-blend-mode: screen; animation: flash var(--ms) ease-out forwards;
}
@keyframes flash { 0% { opacity: var(--o); } 100% { opacity: 0; } }
.shock {
  position: fixed; z-index: 63; pointer-events: none; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%;
  border: 3px solid var(--c); box-shadow: 0 0 18px var(--c), inset 0 0 10px var(--c); opacity: 0;
  animation: shock .85s cubic-bezier(.15, .8, .25, 1) var(--d) forwards;
}
@keyframes shock { 0% { transform: scale(.2); opacity: 1; } 100% { transform: scale(var(--s)); opacity: 0; } }
.stamp {
  position: fixed; left: 50%; top: 36%; z-index: 64; pointer-events: none; white-space: nowrap;
  font-weight: 800; font-style: italic; letter-spacing: -.02em; font-size: clamp(44px, 9vw, 96px); color: var(--c);
  text-shadow: 0 0 36px var(--c), 0 5px 0 rgba(12, 9, 30, .55);
  animation: stamp 1.8s cubic-bezier(.2, .9, .2, 1) forwards;
}
.stamp.big { font-size: clamp(64px, 15vw, 170px); -webkit-text-stroke: 2px #fff6dc; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.6) rotate(-10deg); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(.92) rotate(-5deg); }
  24% { transform: translate(-50%, -50%) scale(1.05) rotate(-5deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-5deg); }
  100% { opacity: 0; transform: translate(-50%, -64%) scale(1) rotate(-5deg); }
}
body.glory #sky { animation: glory 2.6s ease-out; }
@keyframes glory { 0% { filter: none; } 15% { filter: brightness(1.35) saturate(1.4) hue-rotate(-12deg); } 100% { filter: none; } }
@media (prefers-reduced-motion: reduce) { .stamp, .shock { display: none; } .badge.pop { animation: none; } }

.r-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.r-lists h4 { margin: 0 0 6px; font-family: var(--fm); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.r-lists p { margin: 0; font-size: 15px; color: var(--muted); }
.r-lists p b { color: var(--ink); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 52px; padding: 0 22px; border-radius: 16px;
  border: 1px solid var(--line-hi); background: rgba(255, 255, 255, .07); font-weight: 700; font-size: 16px; transition: transform .15s, background .2s;
}
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn:active { transform: scale(.97); }
.btn.primary { border: 0; background: linear-gradient(135deg, #ffc565, #ff8d5c); color: #2a1408; box-shadow: 0 14px 40px -14px rgba(255, 140, 90, .8); }
.btn.ghost { background: none; border-color: var(--line); }
kbd { font-family: var(--fm); font-size: 12px; padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, .15); }

/* ---------- END ---------- */
#end { align-items: center; justify-content: center; }
.end-card {
  width: min(560px, 100%); padding: clamp(24px, 5vw, 40px); border-radius: 28px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, .8);
}
.end-alt { display: flex; justify-content: center; align-items: baseline; gap: 6px; margin-top: 10px; }
.end-alt b { font-family: var(--fm); font-size: clamp(56px, 13vw, 86px); line-height: 1; letter-spacing: -.04em; background: linear-gradient(180deg, #fff8ec, #ffc477); -webkit-background-clip: text; background-clip: text; color: transparent; }
.end-alt span { font-family: var(--fm); font-size: 22px; color: var(--muted); }
.end-title { margin: 6px 0 4px; font-size: 22px; font-weight: 700; }
.end-score { display: flex; justify-content: center; gap: 14px; color: var(--muted); font-family: var(--fm); font-size: 14px; }
.end-rows { display: flex; flex-direction: column; gap: 6px; margin: 22px 0; text-align: left; max-height: 40vh; overflow: auto; }
.end-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--panel-hi); }
.end-row i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.end-row .q { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.end-row .a { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.end-row .pt { font-family: var(--fm); font-size: 14px; }
.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* post score + leaderboard */
.end-post { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: -6px 0 20px; padding: 16px; border-radius: 16px; background: var(--panel-hi); border: 1px solid var(--line); }
.post-form { display: flex; gap: 8px; width: 100%; max-width: 380px; }
.post-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); padding: 11px 14px; border-radius: 12px;
  background: rgba(8, 6, 22, .55); border: 1px solid var(--line); outline: none; transition: border-color .15s, box-shadow .15s;
}
.post-form input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255, 181, 71, .18); }
.post-form .btn { flex: none; }
.post-done { margin: 0; color: var(--muted); }
.post-done b { color: var(--amber); }
.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, .05); margin-bottom: 14px; }
.tab { flex: 1; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.tab[aria-selected="true"] { color: #120f26; background: var(--amber); }
.board { display: flex; flex-direction: column; gap: 4px; max-height: 55vh; overflow: auto; }
.b-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto 56px; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.b-row:nth-child(1) .b-rank { color: #ffb547; } .b-row:nth-child(2) .b-rank { color: #d9e1ea; } .b-row:nth-child(3) .b-rank { color: #e0a070; }
.b-row.you { background: rgba(255, 181, 71, .12); box-shadow: inset 0 0 0 1px rgba(255, 181, 71, .45); }
.b-rank { font-family: var(--fm); font-weight: 700; color: var(--faint); text-align: right; }
.b-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-name small { font-family: var(--fm); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--amber); margin-left: 4px; }
.b-meta { font-size: 12px; color: var(--muted); white-space: nowrap; letter-spacing: -1px; }
.b-pts { font-family: var(--fm); font-weight: 700; text-align: right; }
.b-gap { text-align: center; color: var(--faint); }
.board-empty, .board-foot { margin: 6px 0 0; color: var(--muted); text-align: center; font-size: 14px; }
@media (max-width: 520px) { .b-row { grid-template-columns: 26px minmax(0, 1fr) 52px; } .b-meta { display: none; } }
.end-foot { margin: 16px 0 0; color: var(--faint); font-size: 13.5px; font-family: var(--fm); }

/* ---------- MODAL ---------- */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 5, 18, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.modal-box {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 28px; border-radius: 26px;
  background: rgba(22, 19, 48, .92); border: 1px solid var(--line-hi); box-shadow: 0 40px 120px -30px #000; animation: rise .35s cubic-bezier(.2, .8, .2, 1);
}
.modal-x { position: absolute; right: 16px; top: 16px; }
.modal-box h3 { margin: 0 0 16px; font-size: 26px; letter-spacing: -.02em; padding-right: 50px; }
.modal-box p { color: var(--muted); margin: 0 0 12px; }
.modal-box h5 { margin: 20px 0 10px; font-family: var(--fm); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.rules { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.rules li b { color: var(--ink); }
.rules .n { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-family: var(--fm); font-size: 12px; background: rgba(255, 181, 71, .15); color: var(--amber); }
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qitem { display: flex; gap: 10px; padding: 10px; border-radius: 12px; background: var(--panel-hi); font-size: 13.5px; color: var(--muted); line-height: 1.3; }
.qitem b { display: block; color: var(--ink); font-size: 14px; }
.qitem .qi { font-size: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 14px 8px; border-radius: 14px; background: var(--panel-hi); text-align: center; }
.stat b { display: block; font-family: var(--fm); font-size: 24px; }
.stat span { font-size: 12px; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist-row { display: grid; grid-template-columns: 84px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.dist-bar { height: 12px; border-radius: 6px; background: var(--c); box-shadow: 0 0 10px -2px var(--c); min-width: 3px; transition: width .6s; }
.dist-row span:last-child { font-family: var(--fm); text-align: right; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 20; transform: translate(-50%, 20px);
  padding: 12px 18px; border-radius: 14px; background: rgba(250, 246, 238, .97); color: #17142e; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; box-shadow: 0 20px 50px -20px #000; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* screen shake for avalanche */
body.quake #app { animation: quake .6s cubic-bezier(.36, .07, .19, .97); }
@keyframes quake { 15%, 55% { transform: translate(-6px, 3px); } 35%, 75% { transform: translate(6px, -3px); } }

/* thin air vignette */
body.w-thin #sky::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(10, 0, 30, .75)); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 680px) {
  .modes { grid-template-columns: 1fr; }
  .mode-card { padding: 20px; }
  .play-body { grid-template-columns: 1fr; }
  .altimeter { display: none; }
  #hud-round::after { content: " · " attr(data-alt); color: var(--amber); font-family: var(--fm); font-size: 13px; font-weight: 500; }
  .timer { width: 54px; height: 54px; }
  #input { height: 56px; font-size: 18px; padding-left: 40px; }
  #form::before { left: 15px; font-size: 22px; }
  .go { top: 7px; bottom: 7px; right: 7px; }
  .go { width: 42px; }
  .under { padding-left: 0; }
  .r-lists { grid-template-columns: 1fr; }
  .qgrid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .hud-score b { font-size: 17px; }
  .reveal-head { flex-wrap: wrap; }
  .r-pts { font-size: 22px; }
  #play { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
