/* The show's look: navy lozenges on a line, gold letters, orange when locked
   in, green when right, the money tree with the current step lit.
   Spacing runs on 4/8/12/16/24/32, radii on 8/12/16. */
:root {
  --navy: #06103f;
  --panel: rgba(6, 16, 63, 0.62);
  --blue: linear-gradient(180deg, #2f7be0 0%, #0d4fbf 30%, #0838a0 60%, #04205f 100%);
  --lock: linear-gradient(90deg, #f08c00 0%, #ffae00 45%, #ffcc1f 100%);
  --right: linear-gradient(90deg, #4c9d16 0%, #8dce1f 55%, #c2e83a 100%);
  --rim: linear-gradient(180deg, #f4f7fc 0%, #9fb2d2 55%, #e6edf8 100%);
  --edge: #c9d6ec;
  --hairline: rgba(201, 214, 236, 0.2);
  --gold: #f5a300;
  --gold-soft: #ffd76a;
  --orange: #f2911b;
  --text: #f4f6ff;
  --soft: #cfd8ff;
  --muted: #9aa6cf;
  --hex: polygon(4% 0, 96% 0, 100% 50%, 96% 100%, 4% 100%, 0 50%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* Component display rules must never un-hide something marked hidden. */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, #1b2a7a 0%, #070b2b 55%, #02030f 100%) fixed, #02030f;
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Corner tools, above every overlay so language, list and sound always work. */
.bar { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 11; }
.tools { display: flex; gap: 8px; }
.tool { display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(201, 214, 236, 0.5); background: rgba(6, 16, 63, 0.8); font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.tool:hover:not(:disabled) { border-color: var(--edge); }
.tool:disabled { opacity: 0.45; }

/* The stage sits in the middle of the screen; the ladder rides alongside. */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 32px;
  max-width: 1080px; min-height: 100dvh; margin: 0 auto; padding: 72px 24px 32px; }
.play { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.row { position: relative; }
.line { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--edge); opacity: 0.8; }
.loz { position: relative; clip-path: var(--hex); background: var(--rim); padding: 1.5px; }
.loz .in { position: relative; display: flex; align-items: center; min-height: 100%; overflow: hidden; clip-path: var(--hex); background: var(--blue); }
.loz.q .in { min-height: 96px; }
.loz.q p { position: relative; width: 100%; margin: 0; padding: 16px 9%; text-align: center; font-size: clamp(17px, 2.4vw, 22px); line-height: 1.35; text-wrap: balance; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.ans { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; text-align: start; }
.ans .loz { height: 56px; }
.ans .txt { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 10%; font-size: clamp(15px, 2vw, 17px); }
.ans .letter { color: var(--gold); font-weight: 700; }
.ans .opt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ans.lit .opt { color: #000; }
.ans.lit .letter { color: #fff; }
.ans.gone .opt, .ans.gone .letter { visibility: hidden; }
.ans:not(:disabled):hover .in { filter: brightness(1.15); }

.sweep { position: absolute; inset: 0 auto 0 0; width: 35%; pointer-events: none; transform: translateX(-120%);
  background: linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(190,225,255,0.22) 50%, rgba(255,255,255,0) 100%);
  animation: sweep 10s cubic-bezier(0.45, 0, 0.55, 1) infinite; }
@keyframes sweep { 0% { transform: translateX(-120%); } 45% { transform: translateX(380%); } 100% { transform: translateX(380%); } }
.blink { animation: blink 300ms steps(1) 3; }
@keyframes blink { 0% { background: var(--blue); } 50% { background: var(--right); } }

.step { align-self: center; margin: 0; padding: 6px 16px; border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--panel); color: var(--gold-soft); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.step:empty { visibility: hidden; }

.audience { display: flex; align-items: flex-end; gap: 16px; height: 132px; padding: 12px 20px 8px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--hairline); }
.bar-col { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; }
.bar-col i { display: block; width: 100%; max-width: 56px; border-radius: 4px 4px 0 0; background: linear-gradient(var(--gold-soft), var(--orange)); }
.bar-col b { color: var(--gold); }

.host { margin: 0; min-height: 1.45em; text-align: center; font-style: italic; color: var(--soft); font-size: 15px; text-wrap: balance; }
.hint { margin: 0; text-align: center; color: var(--gold-soft); font-weight: 600; }

.controls { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.life { position: relative; display: grid; place-items: center; width: 64px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--edge); background: var(--navy); font-size: 14px; font-weight: 700; }
.life:hover:not(:disabled) { box-shadow: 0 0 0 3px rgba(201, 214, 236, 0.15); }
.life.used { opacity: 0.4; }
.life.used::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #ef4444; font-size: 22px; }
.final, .walk { height: 40px; padding: 0 18px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.final { border: 0; background: var(--lock); color: #1a0f00; font-weight: 800; }
.walk { border: 1px solid var(--hairline); background: var(--panel); color: var(--soft); }
.walk:hover:not(:disabled) { color: var(--text); border-color: var(--edge); }

.ladder { list-style: none; display: flex; flex-direction: column-reverse; gap: 4px; margin: 0; padding: 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--hairline); font-size: 15px; font-variant-numeric: tabular-nums; }
.ladder li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 12px; border-radius: 8px; font-weight: 600; color: var(--gold); }
.ladder li span:first-child { color: var(--muted); font-weight: 500; }
.ladder li.safe, .ladder li.safe span:first-child { color: #fff; }
.ladder li.done { opacity: 0.45; }
.ladder li.now { background: var(--lock); opacity: 1; }
.ladder li.now, .ladder li.now span:first-child { color: #1a0f00; }

/* Overlays: the title card, the end card, the list. */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; grid-template-columns: 100%; place-items: center; padding: 72px 16px 24px; overflow-y: auto;
  background: rgba(2, 3, 15, 0.72); backdrop-filter: blur(6px); }
.card { min-width: 0; max-width: 100%; display: flex; flex-direction: column; gap: 16px; width: min(420px, 100%); padding: 24px; border-radius: 16px;
  background: #0b1240; border: 1px solid rgba(201, 214, 236, 0.4); text-align: center; }
.card.wide { width: min(680px, 100%); max-height: calc(100dvh - 120px); text-align: left; }
.title-card { align-items: center; gap: 20px; padding: 32px 24px 24px;
  background: radial-gradient(ellipse at 50% 0%, #22338f 0%, #0b1240 55%, #070b2b 100%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.title-card > * { width: 100%; }
.title-card > .emblem { width: 168px; }

.emblem { position: relative; display: grid; place-items: center; height: 168px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #3f2a8f 0%, #1a1556 55%, #0a0a2e 100%);
  box-shadow: 0 0 0 3px #f7c948, 0 0 0 7px #0b1240, 0 0 0 9px rgba(247, 201, 72, 0.55), 0 0 40px rgba(247, 201, 72, 0.3); }
.emblem::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 1px solid rgba(247, 201, 72, 0.4); }
.emblem span { position: relative; padding: 0 20px; text-align: center; font-weight: 800; font-size: 19px; line-height: 1.15;
  color: var(--gold-soft); text-shadow: 0 1px 0 #7a4b00, 0 2px 6px rgba(0, 0, 0, 0.6); hyphens: manual; }
.title-card > .emblem.small { width: 112px; height: 112px; }
.emblem.small span { padding: 0 14px; font-size: 13px; }

.facts { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; }
.facts li { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--hairline); color: var(--soft); font-size: 15px; text-align: left; }
.facts b { color: var(--gold-soft); font-size: 20px; font-variant-numeric: tabular-nums; text-align: center; }

.loz-btn { position: relative; height: 56px; padding: 1.5px; border: 0; background: var(--rim); clip-path: var(--hex); }
.loz-btn span { display: grid; place-items: center; height: 100%; clip-path: var(--hex); background: var(--lock); color: #1a0f00;
  font-weight: 800; font-size: 18px; transition: filter 120ms; }
.loz-btn:hover span { filter: brightness(1.08); }
.loz-btn:active span { filter: brightness(0.95); }
.loz-btn:focus-visible { outline: none; }
.loz-btn:focus-visible span { filter: brightness(1.15); }

.result { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 800; color: var(--gold-soft); text-wrap: balance; }
.sub { margin: -8px 0 0; color: var(--soft); font-variant-numeric: tabular-nums; }
.save { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.save label { color: var(--muted); font-size: 14px; }
.saveRow { display: flex; gap: 8px; }
.saveRow input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(201, 214, 236, 0.45);
  background: var(--navy); color: var(--text); font: inherit; outline: none; }
.saveRow input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 163, 0, 0.25); }
.saveRow button { height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--gold); color: #1a0f00; font-weight: 800; }
.placed { margin: 0; font-weight: 700; color: var(--gold-soft); }
.endBtns { display: flex; flex-direction: column; gap: 12px; }
.ghost { height: 48px; padding: 0 16px; border: 1px solid rgba(201, 214, 236, 0.45); border-radius: 12px; background: none; font-weight: 600; }
.ghost:hover { border-color: var(--edge); }

.topHead { display: flex; justify-content: space-between; align-items: center; }
.topHead h2 { margin: 0; color: var(--gold-soft); font-size: 22px; }
.tableWrap { overflow: auto; }
#topTable { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
#topTable th { padding: 8px; border-bottom: 1px solid var(--hairline); color: var(--muted); font-weight: 600; text-align: left; white-space: nowrap; }
#topTable td { padding: 8px; border-bottom: 1px solid rgba(201, 214, 236, 0.1); white-space: nowrap; }
#topTable td.name { white-space: normal; word-break: break-word; }
#topTable tr.me td { color: var(--gold-soft); font-weight: 700; }
#topTable .num { text-align: right; }
.empty { color: var(--muted); }

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; align-items: start; padding: 68px 16px 24px; }
  .ladder { display: none; }
  .answers { grid-template-columns: 1fr; gap: 10px; }
  .loz.q .in { min-height: 88px; }
  .controls { gap: 8px; }
  .life { width: 56px; }
}
@media (prefers-reduced-motion: reduce) { .sweep { display: none; } .blink { animation: none; } }
@media (min-width: 761px) { .step { display: none; } }
.note { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(245, 163, 0, 0.12); border: 1px solid rgba(245, 163, 0, 0.4); color: var(--gold-soft); font-weight: 600; }
