/* The glass bridge: a sky event field (the bridge and the line) beside a navy panel. Base in ../style.css. */
.stage { display: grid; }
.field { position: relative; overflow: hidden; background: var(--sky); color: var(--ink); padding: 0 var(--pad) 22px; display: flex; flex-direction: column; }
.field > * { position: relative; }
/* One giant pictogram, cropped off the field's edge. Navy, since the field is sky. */
.giant { position: absolute; top: 62px; right: calc(-1 * clamp(28px, 5vw, 80px)); width: clamp(120px, 22vw, 300px); aspect-ratio: 1; color: var(--ink); }
.giant svg { width: 100%; height: 100%; display: block; }
@media (max-width: 899px) { .giant { top: 36px; right: -22vw; width: 64vw; color: rgba(20, 33, 61, 0.14); } }
.field h1 { font-size: clamp(36px, 9vw, 68px); margin: 22px 0 20px; max-width: min(6.5em, calc(100% - clamp(80px, 16vw, 220px))); }
.of { font-size: 16px; letter-spacing: 0; }

/* The bridge: start, ten rows of two panes, the prize. Unknown panes are outlined, safe ones white,
   broken ones a dashed hole. The player crossing is a navy square on their pane. */
.bridge { display: grid; grid-template-columns: minmax(0, 0.7fr) repeat(10, minmax(0, 1fr)) minmax(0, 0.9fr); gap: clamp(4px, 0.7vw, 8px); max-width: 760px; align-items: stretch; }
/* The end zones' text is taken out of flow so it never sets the bridge's height (that stretched the panes when the
   winner's name went in). contain: size did the same but collapsed the zones to nothing in iOS Safari. */
.bridge .end-zone { position: relative; overflow: hidden; border: 2px solid var(--ink); font: 800 clamp(9px, 1.3vw, 13px) / 1.1 var(--font); letter-spacing: 0.06em; text-transform: uppercase; text-align: center; }
.bridge .end-zone span { position: absolute; inset: 0; display: grid; place-items: center; writing-mode: vertical-rl; transform: rotate(180deg); }
.bridge .end-zone.prize { background: var(--ink); color: #fff; }
.bridge .row { display: grid; gap: clamp(4px, 0.7vw, 8px); }
.pane { aspect-ratio: 1; outline: 2px solid rgba(20, 33, 61, 0.4); outline-offset: -2px; display: grid; place-items: center; transition: background 0.15s var(--ease); }
.pane.safe { background: #fff; outline-color: #fff; }
.pane { position: relative; }
.pane.broken { outline: 2px dashed var(--ink); background: transparent; animation: shatter 0.35s var(--ease) both; }
.pane .crack { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: square; }
.pane .who { width: 72%; aspect-ratio: 1; background: var(--ink); color: #fff; display: grid; place-items: center; font: 800 clamp(10px, 1.6vw, 16px) / 1 var(--font); font-variant-numeric: tabular-nums; }
.pane .who.you { background: var(--orange); color: var(--ink); }
.pane .who.fall { animation: fall 0.4s var(--ease) both; }
@keyframes shatter { from { transform: scale(0.85); } }
@keyframes fall { to { transform: scale(0.2); opacity: 0; } }

/* The line: one square per player. Out players fade, the crosser is white, the winner navy; yours is marked with a bar. */
.line { --g: clamp(4px, 0.7vw, 8px); container-type: inline-size; list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: var(--g); max-width: 760px; align-items: start; }
/* Squares sized from the line's width, not aspect-ratio alone: iOS Safari stretched grid items to the text height. */
.line li { position: relative; aspect-ratio: 1; height: calc((100cqw - 9 * var(--g)) / 10); outline: 2px solid var(--ink); outline-offset: -2px; display: grid; place-items: center; font: 800 clamp(12px, 1.8vw, 18px) / 1 var(--font); font-variant-numeric: tabular-nums; }
.line li.out { opacity: 0.3; text-decoration: line-through; }
.line li.now { background: #fff; outline-color: #fff; }
.line li.won { background: var(--ink); color: #fff; outline-color: var(--ink); animation: pop 0.4s var(--ease) both; }
.line li.you::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 5px; background: var(--ink); }
@keyframes pop { from { transform: scale(1.4); } }

.status { display: flex; gap: clamp(24px, 5vw, 56px); margin-top: 26px; padding-top: 10px; border-top: 2px solid var(--ink); }
.num { font-size: clamp(30px, 7vw, 56px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }

.panel { background: var(--navy); color: #fff; padding: 24px var(--pad) 28px; }
.soft, .ev.soft { color: var(--navy-soft); }
.panel-title { font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.02em; line-height: 1.05; }
.panel .more { display: inline-block; margin-top: 28px; color: #fff; }

/* Your turn: the row's two panes pulse white-outlined until you pick one. */
.prompt { min-height: 44px; margin: 0 0 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.prompt span { flex: 1 1 100%; }
.prompt b { font-size: clamp(26px, 5vw, 40px); font-weight: 800; letter-spacing: -0.03em; margin-right: 8px; }
.prompt a { color: inherit; margin-left: 8px; }
.prompt button { min-width: 96px; padding: 12px 16px; border: 2px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink); font: 800 13px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
@media (hover: hover) { .prompt button:hover { background: var(--orange); border-color: var(--orange); } }
.prompt button:active { transform: scale(0.97); }
.pane.choose { cursor: pointer; outline: 3px solid #fff; outline-offset: -3px; animation: ask 1s var(--ease) infinite alternate; }
.pane.choose:focus-visible { outline-color: var(--ink); }
@media (hover: hover) { .pane.choose:hover { background: var(--orange); outline-color: var(--orange); animation: none; } }
@keyframes ask { to { background: rgba(255, 255, 255, 0.35); } }

/* Your guesses: two square options, the chosen one filled white. */
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; max-width: 420px; }
.mode button { padding: 12px 10px; border: 2px solid #fff; border-radius: 0; background: transparent; color: #fff; font: 800 13px var(--font); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.mode button[aria-checked="true"] { background: #fff; color: var(--ink); }
@media (hover: hover) { .mode button:hover:not(:disabled) { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.mode button:disabled { cursor: default; opacity: 0.5; }
.mode button[aria-checked="true"]:disabled { opacity: 1; }

/* The spot picker: ten square tiles, two rows of five. */
.pick-label { margin-top: 22px; }
@media (min-width: 900px) { .field .prompt { margin-top: 28px; } }
.spots { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 8px; max-width: 420px; }
.spots button { aspect-ratio: 1; border: 2px solid #fff; border-radius: 0; background: transparent; color: #fff; font: 800 clamp(22px, 4vw, 30px) var(--font); font-variant-numeric: tabular-nums; cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease); }
@media (hover: hover) { .spots button:hover { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.spots button[aria-checked="true"] { background: #fff; color: var(--ink); }
.spots button:active { transform: scale(0.97); }
.spots button:disabled { cursor: default; opacity: 0.5; }
.spots button[aria-checked="true"]:disabled { opacity: 1; }

.cta { display: inline-block; margin-top: 20px; padding: 16px 24px; border: 2px solid #fff; border-radius: 0; background: #fff; color: var(--ink); font: 800 14px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease); }
@media (hover: hover) { .cta:hover:not(:disabled) { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.cta:active { transform: scale(0.97); }
.cta:disabled { opacity: 0.5; cursor: default; }

.end { margin-top: 0; }
.end .big { font-size: clamp(44px, 5.6vw, 84px); font-weight: 800; letter-spacing: -0.05em; line-height: 0.9; margin: 12px 0 6px; font-variant-numeric: tabular-nums; }
.end .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 22px 0 26px; padding-top: 10px; border-top: 2px solid rgba(255, 255, 255, 0.3); }
.end .stats .val { font-size: clamp(20px, 4.4vw, 26px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.end .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.end button { display: inline-flex; align-items: center; gap: 10px; padding: 14px 20px; border: 2px solid #fff; border-radius: 0; background: transparent; color: #fff; font: 800 13px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.end button.primary { background: #fff; color: var(--ink); }
@media (hover: hover) { .end button:hover { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.end button .icon { width: 18px; height: 18px; }
.end .fine { margin: 14px 0 0; font-size: 14px; }

/* 1,000 bridges: wins by spot as columns, yours white, the rest outlined. */
.runs { margin-top: 26px; padding-top: 10px; border-top: 2px solid rgba(255, 255, 255, 0.3); }
.runs .cols { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; align-items: end; height: 120px; margin-top: 12px; }
.runs .cols i { display: block; background: transparent; outline: 2px solid var(--navy-soft); outline-offset: -2px; min-height: 2px; transition: height 0.5s var(--ease); }
.runs .cols i.mine { background: #fff; outline-color: #fff; }
.runs .labels { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; margin-top: 6px; text-align: center; font: 800 12px var(--font); color: var(--navy-soft); }
.runs .labels .mine { color: #fff; }
.runs p.sum { margin-top: 12px; font-size: 16px; }

/* The math: the bell of wins by spot, the counting argument, and longer bridges on a green field. */
.math { padding-top: clamp(40px, 7vw, 72px); }
.math h2 { font-size: clamp(36px, 6vw, 64px); padding-bottom: 14px; border-bottom: var(--rule) solid var(--ink); }
.math .therefore { margin-top: clamp(20px, 3vw, 32px); font-size: clamp(18px, 2vw, 22px); max-width: 36em; color: var(--ink-soft); }
.math .ladder { list-style: none; margin: clamp(20px, 3vw, 32px) 0 0; padding: 0; max-width: 900px; }
.math .ladder li { display: grid; grid-template-columns: 6em 6em 1fr; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px solid rgba(20, 33, 61, 0.15); }
.math .ladder b { font-size: clamp(17px, 2vw, 22px); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.math .ladder i { display: block; height: 14px; min-width: 2px; background: var(--ink); }
.math .ladder .best { border-top: var(--rule) solid var(--ink); border-bottom: var(--rule) solid var(--ink); }
.math .ladder .best i { background: var(--orange); }
.math .steps-math { margin: clamp(28px, 4vw, 44px) 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 14px; max-width: 40em; }
.math .steps-math li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 12px; font-size: clamp(17px, 1.8vw, 20px); color: var(--ink-soft); }
.math .steps-math li::before { content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; background: var(--ink); color: #fff; font-weight: 800; }
.math .steps-math b { color: var(--ink); }
.math .worked { margin-top: clamp(24px, 4vw, 40px); font-size: clamp(28px, 5.6vw, 72px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.math .worked .hl { background: var(--orange); padding: 0 0.12em; }
.math .worked .eq { display: block; font-size: 0.55em; color: var(--ink-soft); letter-spacing: -0.01em; margin-bottom: 0.2em; }
.math .odds { margin-top: clamp(32px, 5vw, 56px); background: var(--green); color: #fff; padding: clamp(20px, 4vw, 40px); }
.math .odds h3 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.02em; }
.math table { width: 100%; border-collapse: collapse; margin: 18px 0 20px; }
.math th, .math td { padding: 12px 0; border-top: 2px solid rgba(255, 255, 255, 0.5); text-align: left; vertical-align: baseline; }
.math th { font-weight: 700; font-size: 17px; padding-right: 16px; }
.math td { text-align: right; font-size: clamp(24px, 4vw, 44px); font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.math td .sub { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0; opacity: 0.9; }
.math .odds p { max-width: 40em; color: rgba(255, 255, 255, 0.92); }
.math .source { margin-top: 32px; font-size: 15px; color: var(--ink-soft); max-width: 60em; }

@media (min-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1.55fr) minmax(380px, 1fr); min-height: 100svh; }
  .field { padding-bottom: 36px; }
  .field h1 { margin: 30px 0 auto; }
  .bridge { margin-top: 28px; }
  .panel { padding-top: 76px; padding-bottom: 36px; display: flex; flex-direction: column; }
  .panel .more { margin-top: auto; padding-top: 28px; align-self: flex-start; }
}
/* Phones, mid-crossing: the title and giant pictogram give their room to the bridge, the prompt and the line. */
@media (max-width: 899px) {
  .playing .field h1, .playing .giant { display: none; }
  .playing .field .prompt { margin-top: 16px; }
}
@media (max-width: 640px) {
  .status .num { font-size: 30px; }
  .math .ladder li { grid-template-columns: 4.6em 4.6em 1fr; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { .pane.choose, .pane.broken, .pane .who.fall, .line li.won { animation: none; } }
