/* Overlays inside the stage: poster, guess card, game, end screen. They sit
   on the illustrated world, so they use the stage tokens in both themes. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 44px;
  padding: 0.35em 1.1em;
  border: var(--stroke) solid var(--stage-ink);
  border-radius: 14px;
  background: var(--stage-accent);
  color: var(--stage-on-accent);
  box-shadow: 3px 3px 0 var(--stage-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--step-0);
  cursor: pointer;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--stage-ink); }
.btn.ghost { background: var(--stage-card); color: var(--stage-ink); }
.btn.small { min-height: 36px; padding-inline: 0.8em; font-size: var(--step--1); }
.btn:disabled { cursor: default; background: var(--stage-muted-bg); color: var(--stage-muted); box-shadow: none; }
kbd { font-family: var(--font-body); font-size: 0.8em; opacity: 0.7; }
.card {
  border: var(--stroke) solid var(--stage-ink);
  border-radius: var(--radius);
  background: var(--stage-card);
  color: var(--stage-ink);
  box-shadow: var(--lift) var(--lift) 0 var(--stage-ink);
}

/* ---------- poster ---------- */
/* The card sits over the sky, top left: the hosts stand at the bottom of the frame. */
.poster {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: clamp(12px, 3vw, 40px);
  background: linear-gradient(160deg, var(--stage-scrim) 0%, transparent 55%);
}
@media (max-aspect-ratio: 1/1) {
  .poster { background: linear-gradient(180deg, var(--stage-scrim) 0%, var(--stage-scrim) 20%, transparent 55%); }
}
@container stage (max-height: 420px) {
  .poster { padding: 10px 14px; }
  .poster-card { gap: 0.35rem; }
  .poster-title { font-size: var(--step-2); }
  .poster-sub { font-size: var(--step-0); }
  .poster-meta { display: none; }
  .big-play { min-height: 44px; font-size: var(--step-1); }
}
@container stage (max-height: 320px) {
  .poster-sub { display: none; } /* title and Play only: the card stays above the hosts' heads */
}
.poster-card { max-width: 30rem; display: grid; gap: 0.6rem; justify-items: start; color: var(--stage-card); }
.poster-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--step-3);
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
  text-shadow: 3px 3px 0 var(--stage-ink);
}
.poster-sub { margin: 0; font-size: var(--step-1); text-shadow: 1px 1px 0 var(--stage-ink); }
.poster-meta { margin: 0; font-size: var(--step--1); opacity: 0.95; text-shadow: 1px 1px 0 var(--stage-ink); }
.big-play {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 56px;
  padding: 0.4em 1.4em 0.4em 1em;
  border: var(--stroke) solid var(--stage-ink);
  border-radius: 999px;
  background: var(--stage-mille);
  color: var(--stage-ink);
  box-shadow: var(--lift) var(--lift) 0 var(--stage-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--step-2);
  cursor: pointer;
}
.big-play svg { width: 1.3em; height: 1.3em; fill: currentColor; }
.big-play:hover { background: var(--stage-mille-hover); }

/* ---------- guess ---------- */
/* The card is centred by auto margins, not by place-items: when it is taller
   than the stage it starts at the top and scrolls, instead of losing its top. */
.guess, .game, .end {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: start center;
  padding: clamp(8px, 2vw, 24px);
  background: var(--stage-scrim);
  overflow-y: auto;
}
.guess-card, .game-inner { margin-block: auto; }
.guess-card { width: min(36rem, 100%); padding: clamp(14px, 2.5vw, 26px); display: grid; gap: 0.7rem; }
.guess-kicker { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: var(--step--1); letter-spacing: 0.1em; text-transform: uppercase; color: var(--stage-million-ink); }
.guess-q { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); line-height: 1.12; text-wrap: balance; }
.guess-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 10px; }
.guess-options button {
  min-height: 60px;
  padding: 0.3em 0.6em;
  border: var(--stroke) solid var(--stage-ink);
  border-radius: 16px;
  background: var(--stage-bg);
  color: var(--stage-ink);
  box-shadow: 3px 3px 0 var(--stage-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--step-1);
  line-height: 1.1;
  cursor: pointer;
}
.guess-options button:hover:not(:disabled) { background: var(--stage-hover); }
.guess-options button:disabled { cursor: default; }
.guess-options button[data-res="right"] { background: var(--stage-good-bg); border-color: var(--stage-good); color: var(--stage-good); }
.guess-options button[data-res="wrong"] { opacity: 0.6; }
.guess-feedback { margin: 0; min-height: 1.5em; font-weight: 700; font-size: var(--step-1); }
.older { border-top: 2px dashed var(--stage-line); padding-top: 0.5rem; }
.older summary { cursor: pointer; font-family: var(--font-display); font-weight: 800; color: var(--stage-milliard-ink); }
.older p { margin: 0.4em 0 0; font-size: var(--step--1); }
#guess-continue { justify-self: end; }

/* ---------- game ---------- */
.game { background: var(--stage-scrim-deep); }
.game-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.game-inner { position: relative; width: min(46rem, 100%); display: grid; gap: 0.6rem; justify-items: center; text-align: center; color: var(--stage-card); }
.game-title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); text-shadow: 2px 2px 0 var(--stage-ink); }
.game-digits {
  margin: 0;
  padding: 0.05em 0.4em;
  border: var(--stroke) solid var(--stage-ink);
  border-radius: 14px;
  background: var(--stage-card);
  color: var(--stage-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 1rem + 4vw, 3.6rem);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  box-shadow: 3px 3px 0 var(--stage-ink);
}
.rail { position: relative; width: min(30rem, 100%); height: 14px; border: 2px solid var(--stage-ink); border-radius: 999px; background: var(--stage-card); overflow: hidden; }
.rail-fill { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: linear-gradient(90deg, var(--stage-mille), var(--stage-million), var(--stage-milliard)); }
.rail-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--stage-ink); }
.rail-mark.m1 { left: 33.3%; }
.rail-mark.m2 { left: 66.6%; }
.game-toast { margin: 0; min-height: 3em; max-width: 36rem; font-weight: 700; text-shadow: 1px 1px 0 var(--stage-ink); }
.tap {
  width: clamp(84px, 16vw, 120px);
  aspect-ratio: 1;
  max-width: 100%;
  border: var(--stroke) solid var(--stage-ink);
  border-radius: 50%;
  background: var(--stage-mille);
  color: var(--stage-ink);
  box-shadow: var(--lift) var(--lift) 0 var(--stage-ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem);
  cursor: pointer;
}
.tap:active { transform: translate(2px, 2px) scale(0.97); box-shadow: 1px 1px 0 var(--stage-ink); }
.machines { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.machine {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 8px 6px;
  border: var(--stroke) solid var(--stage-ink);
  border-radius: 14px;
  background: var(--stage-card);
  color: var(--stage-ink);
  font-size: var(--step--1);
  line-height: 1.2;
}
.machine img { height: clamp(36px, 7vw, 64px); width: auto; }
.machine strong { font-family: var(--font-display); font-size: var(--step-0); }
.machine[data-state="locked"] img { filter: grayscale(1); opacity: 0.55; }
.machine[data-state="on"] { background: var(--stage-good-bg); }
.game-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.floater { position: absolute; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: var(--stage-mille); text-shadow: 1px 1px 0 var(--stage-ink); pointer-events: none; animation: float-up 0.9s ease-out forwards; }
@keyframes float-up { to { transform: translateY(-60px); opacity: 0; } }

/* ---------- end ---------- */
.end-inner { width: min(46rem, 100%); padding: clamp(14px, 2.5vw, 28px); border: var(--stroke) solid var(--stage-ink); border-radius: var(--radius); background: var(--stage-card); color: var(--stage-ink); box-shadow: var(--lift) var(--lift) 0 var(--stage-ink); }
.end-title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); line-height: 1.1; text-wrap: balance; }
.end h3 { margin: 1em 0 0.3em; font-family: var(--font-display); font-size: var(--step-1); }
.recap { margin: 0; padding-inline-start: 1.4em; display: grid; gap: 0.25em; }
.recap li::marker { font-family: var(--font-display); font-weight: 800; color: var(--stage-million-ink); }
.end-actions { margin-top: 1rem; }
.credits, .sources { margin: 0; padding-inline-start: 1.2em; font-size: var(--step--1); display: grid; gap: 0.2em; }
.sources a { color: var(--stage-milliard-ink); overflow-wrap: anywhere; }

/* ---------- short stages: a phone held sideways, a tablet ---------- */
@container stage (max-height: 420px) {
  .guess { padding-block: 6px; }
  .guess-card { gap: 0.4rem; padding: 10px 14px; }
  .guess-q { font-size: var(--step-1); }
  .guess-options button { min-height: 44px; font-size: var(--step-0); }
  .guess-feedback { min-height: 1.2em; font-size: var(--step-0); }
}
/* the game side by side: counter and +1 on the left, the machines on the right (a tablet) */
@container stage (max-height: 620px) and (orientation: landscape) {
  .game { padding-block: 6px; }
  .game-inner {
    grid-template-columns: auto 1fr;
    grid-template-areas: "title title" "digits rail" "digits toast" "tap machines" "actions machines";
    gap: 6px 12px;
    align-items: center;
  }
  .game-title { grid-area: title; }
  .game-digits { grid-area: digits; min-width: 13ch; font-size: 1.9rem; } /* as wide as 1 000 000 000: nothing shifts while counting */
  .rail { grid-area: rail; }
  .game-toast { grid-area: toast; min-height: 1.3em; font-size: var(--step--1); }
  .tap { grid-area: tap; width: 84px; font-size: 1.7rem; }
  .machines { grid-area: machines; }
  .machine img { height: 44px; }
  .game-actions { grid-area: actions; flex-direction: column; align-self: start; }
}
/* ...and tighter on a phone held sideways, where the title gives way */
@container stage (max-height: 420px) and (orientation: landscape) {
  .game-inner { grid-template-areas: "digits rail" "digits toast" "tap machines" "actions machines"; }
  .game-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tap { width: 76px; font-size: 1.6rem; }
  .machine { padding: 4px 6px; }
  .machine img { height: 26px; }
  .machine .btn.small { min-height: 30px; }
  .game-actions .btn { min-height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .floater { animation: none; display: none; }
  .btn:active, .tap:active { transform: none; }
}
