/* Will the tiles spell a word: a yellow event field (the row of tiles and the dump button) beside a navy panel.
   Base in ../style.css. */
.stage { display: grid; }
.field { position: relative; overflow: hidden; background: var(--yellow); color: var(--ink); padding: 0 var(--pad) 22px; display: flex; flex-direction: column; }
.field > * { position: relative; }
.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 22px; max-width: min(6.5em, calc(100% - clamp(80px, 16vw, 220px))); }

/* The row: one white tile per letter, the letter big and its points small in the corner. Tiles share the width,
   so 10 still fit a phone. Sized from the row's width (container units), not aspect-ratio alone (iOS Safari). */
.row { --n: 7; --g: clamp(4px, 1vw, 10px); container-type: inline-size; list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: var(--g); max-width: 760px; align-items: start; }
.row li { --s: min(96px, calc((100cqw - (var(--n) - 1) * var(--g)) / var(--n))); position: relative; height: var(--s); max-width: 96px; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: calc(var(--s) * 0.56); line-height: 1; }
.row li sub { position: absolute; right: 8%; bottom: 6%; font-size: calc(var(--s) * 0.2); font-weight: 700; line-height: 1; }
/* A word we won't print lands face down: navy tiles, no letters. */
.row li.down { background: var(--ink); }
.row li.empty { background: transparent; outline: 2px solid rgba(20, 33, 61, 0.35); outline-offset: -2px; }
/* A blank tile: no letter; once it's part of a word, the letter it stands for shows faintly. */
.row li .fill { opacity: 0.45; }
.row li.land { animation: land 0.32s var(--ease) both; }
.row.word li { background: var(--ink); color: #fff; }
@keyframes land { from { transform: translateY(-70%) rotate(-8deg); opacity: 0; } }

.verdict { margin-top: 18px; min-height: 1.1em; font-size: clamp(24px, 4.4vw, 36px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.also { margin-top: 6px; min-height: 1.5em; font-size: 17px; font-weight: 700; }

/* Controls on the field, under the row, so each dump and its tiles are on screen together. */
.controls { margin-top: 18px; }
/* Blank tiles On / Off: two halves of one switch, the chosen side filled. */
.blanks { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; max-width: 520px; }
.blanks .note { text-transform: none; letter-spacing: 0; font-weight: 700; opacity: 0.75; }
.seg { display: grid; grid-template-columns: 1fr 1fr; flex: none; width: 140px; }
.seg button { height: 40px; border: 2px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); font: 800 14px var(--font); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.seg button + button { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
@media (hover: hover) { .seg button:hover:not([aria-checked="true"]) { background: var(--orange); border-color: var(--orange); } }
.count { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; margin-top: 8px; max-width: 520px; }
.count button { min-width: 0; padding: 0; height: 44px; border: 2px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); font: 800 17px var(--font); font-variant-numeric: tabular-nums; cursor: pointer; }
.count button[aria-checked="true"] { background: var(--ink); color: #fff; }
@media (hover: hover) { .count button:hover { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.dump { margin-top: 12px; width: 100%; max-width: 520px; padding: 18px 24px; border: 0; border-radius: 0; background: var(--ink); color: #fff; font: 800 15px var(--font); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
@media (hover: hover) { .dump:hover:not(:disabled) { background: var(--orange); color: var(--ink); } }
/* Every press shows: the button dips and flashes orange, and the tiles redeal (see game.js), even when the new row
   looks like the last one. */
.dump:active, .dump.pressed { transform: scale(0.97); background: var(--orange); color: var(--ink); }
.dump:disabled { opacity: 0.6; cursor: default; }

.status { display: flex; gap: clamp(24px, 5vw, 56px); margin-top: 22px; 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; }

/* The odds for the tile count you picked: in order, and rearranged. */
.odds { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 24px; padding-top: 10px; border-top: 2px solid rgba(255, 255, 255, 0.3); }
.odds .val { font-size: clamp(24px, 4.6vw, 34px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }

.sim { margin-top: 22px; }
.cta { display: inline-block; 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; }
@media (hover: hover) { .cta:hover:not(:disabled) { background: var(--orange); border-color: var(--orange); color: var(--ink); } }
.cta:disabled { opacity: 0.5; cursor: default; }
.runs { margin-top: 16px; }
.runs .big { font-size: clamp(36px, 5vw, 56px); font-weight: 800; letter-spacing: -0.04em; line-height: 0.95; margin-top: 8px; font-variant-numeric: tabular-nums; }
.runs .words { margin-top: 12px; font-size: 15px; }
.runs p.sum { margin-top: 10px; font-size: 16px; }

/* The math: a ladder of tile counts and their odds, the reasoning, and in-order vs rearranged 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 10em 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.42em; color: var(--ink-soft); letter-spacing: -0.01em; margin-bottom: 0.3em; overflow-wrap: anywhere; }
.math .odds-box { margin-top: clamp(32px, 5vw, 56px); background: var(--green); color: #fff; padding: clamp(20px, 4vw, 40px); }
.math .odds-box 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: 10px 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(20px, 3.4vw, 36px); font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 12px; }
.math thead th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.math thead th:not(:first-child) { text-align: right; }
.math .odds-box 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; }
  .row { margin-top: 32px; }
  .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: once you're dumping, the title and giant pictogram give their room to the tiles and the button. */
@media (max-width: 899px) {
  .playing .field h1, .playing .giant { display: none; }
  .playing .row { margin-top: 22px; }
  .verdict { margin-top: 14px; }
}
@media (max-width: 640px) {
  .status .num { font-size: 30px; }
  .math .ladder li { grid-template-columns: 4.6em 8em 1fr; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { .row li.land { animation: none; } }
