:root {
  --bg: #0b0b10;
  --panel: #15151e;
  --panel-2: #1d1d28;
  --line: #2a2a38;
  --text: #e9e9f1;
  --muted: #9a9ab0;
  --accent: #3fbf6a;
  --accent-2: #8df0ad;
  --accent-ink: #06130a;
  --correct: #2e9e4f;
  --partial: #c9a227;
  --wrong: #3a3a48;
  --danger: #c94f4f;
  --radius: 10px;
  --gutter: 16px;
  --name-col: 150px;
  --col: 112px;
  --cols: 7;        /* attribute columns; app.js sets it from game.js FIELDS */
  --fast: 120ms;
  --flip: 1000ms;   /* set from game.js REVEAL at start-up */
  --stagger: 550ms;
  --tap: 44px;            /* smallest touch target (Apple HIG) */
  --field: 48px;          /* input, Guess and tab height: --tap + 4 */
  --tile-edge: #6a6a82;   /* 1px outline on grey tiles and the dashed preview tiles */
  --danger-text: #ff8a8a; /* error text */
  --partial-ink: #1a1500; /* text on yellow */
  --bleed: 8px;           /* on a phone the tiles reach this far past the gutter */
  --sug-max: 320px;       /* typeahead height; app.js lowers it to fit above the keyboard */
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
  min-height: 100vh;
  display: flow-root; /* WebKit: stops the footer's bottom margin collapsing out of the min-height (30px of extra scroll) */
}
a { color: var(--accent); }
button { font: inherit; }
/* Read by screen readers, not shown. */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* One focus ring for links, buttons and tabs; the input keeps its own. */
:where(a, button, [role="tab"]):focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Backdrop: a green glow and a comic halftone, all drawn in CSS. */
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 50% -5%, rgba(63, 191, 106, 0.28), transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.07) 1.2px, transparent 1.5px) 0 0 / 14px 14px,
    var(--bg);
  mask-image: linear-gradient(180deg, rgba(0,0,0,1) 0%, rgba(0,0,0,0.55) 40%, rgba(0,0,0,0.35) 100%);
}
/* The hero layer: a hex mesh, three energy streaks and six drifting orbs in the stones' colours. */
.hero { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: max(1200px, 100%); height: 520px; opacity: 0.8; }
.hero .orb { transform-box: fill-box; transform-origin: center; animation: drift 14s ease-in-out infinite alternate; }
.hero .o2 { animation-duration: 17s; animation-delay: -4s; }
.hero .o3 { animation-duration: 12s; animation-delay: -7s; }
.hero .o4 { animation-duration: 19s; animation-delay: -2s; }
.hero .o5 { animation-duration: 16s; animation-delay: -9s; }
.hero .o6 { animation-duration: 13s; animation-delay: -5s; }
.hero .streaks { animation: sweep 9s linear infinite; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(28px, -18px) scale(1.12); } }
@keyframes sweep { from { transform: translateX(-60px); opacity: 0.5; } 50% { opacity: 1; } to { transform: translateX(60px); opacity: 0.5; } }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px var(--gutter) 6px; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.emblem { display: inline-flex; position: relative; filter: drop-shadow(0 4px 10px rgba(63,191,106,0.35)); }
.emblem .rings { position: absolute; inset: 0; animation: spin 24s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.brand h1 { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: -0.02em; line-height: 1; text-transform: uppercase; }
.brand h1 a {
  text-decoration: none;
  background: linear-gradient(180deg, #ffffff 0%, #d9dce6 50%, #8e94a8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #1c1c26);
}
.brand h1 a span { background: linear-gradient(180deg, var(--accent-2), var(--accent) 60%, #1f7a40); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.02em; }
.icons { display: flex; gap: 8px; }
.icon {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); cursor: pointer; display: grid; place-items: center; font-weight: 700;
}
.icon:hover { background: var(--panel-2); border-color: var(--accent); }
.icon:disabled { opacity: 0.5; cursor: default; }

main { max-width: 1100px; margin: 0 auto; padding: 0 var(--gutter); }

/* The Doomsday strip */
.doomsday {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px;
  margin: 6px auto 12px; padding: 8px 14px; border-radius: 999px; width: max-content; max-width: 100%;
  background: linear-gradient(90deg, rgba(63,191,106,0.12), rgba(63,191,106,0.04));
  border: 1px solid rgba(63,191,106,0.35); font-size: 13px; letter-spacing: 0.04em;
}
.dd-label { text-transform: uppercase; font-weight: 800; color: var(--accent-2); display: inline-flex; align-items: center; gap: 8px; }
.dd-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.dd-clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.dd-when { color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; background: var(--panel); padding: 4px; border-radius: 24px; width: max-content; max-width: 100%; margin: 0 auto 6px; border: 1px solid var(--line); }
.mode { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.mode svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mode[aria-selected="true"] { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); font-weight: 800; }
.mode:disabled { opacity: 0.5; cursor: default; }
.mode-desc { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.today { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.today b { color: var(--text); }

.guess-form { margin: 8px auto 6px; max-width: 560px; }
.combo { position: relative; display: flex; gap: 8px; }
.guess-input {
  flex: 1; min-width: 0; min-height: var(--field); padding: 12px 14px; font-size: 17px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.guess-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.guess-btn {
  min-height: var(--field); padding: 12px 18px; border-radius: var(--radius); border: 0; background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  font-weight: 800; cursor: pointer; box-shadow: 0 6px 16px rgba(63,191,106,0.25);
}
.guess-btn:disabled, .guess-input:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; margin: 0; padding: 6px; list-style: none;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  max-height: var(--sug-max); overflow: auto;
}
.suggestions li { min-height: var(--tap); padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--panel); }
.suggestions .alias { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { text-align: center; color: var(--muted); min-height: 1.4em; margin: 4px 0 10px; font-size: 14px; }

/* The colour key under the input, one line down to 320px */
.key { display: flex; justify-content: center; align-items: center; gap: 4px 8px; margin: 2px 0 0; padding: 0; list-style: none; white-space: nowrap; font-size: 12px; line-height: 1.5; color: var(--muted); }
.key[hidden] { display: none; }
.key li { display: inline-flex; align-items: center; }
.key .swatch { width: 20px; height: 18px; margin-right: 4px; flex: none; }

/* The load error */
.notice { margin: 12px 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); text-align: center; }
.notice h2 { margin: 0 0 6px; font-size: 18px; }
.notice p { margin: 0 0 12px; color: var(--muted); }
.notice.error { border-color: var(--danger); }
.notice.error h2 { color: var(--danger-text); }
.notice .btn { min-width: 120px; }
.load-error .key, .load-error .empty { display: none; }

.board { margin: 0 calc(-1 * var(--gutter)); }
.grid-scroll { overflow-x: auto; padding: 0 var(--gutter) 8px; scrollbar-width: thin; }
.grid { display: grid; grid-template-columns: minmax(var(--name-col), 1.4fr) repeat(var(--cols), minmax(var(--col), 1fr)); gap: 6px; min-width: 100%; }
.grid .head {
  position: sticky; top: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.grid .head svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.grid .head.name { text-align: left; align-items: flex-start; justify-content: flex-end; }
.tile {
  min-height: 72px; border-radius: 10px; padding: 8px 6px; display: grid; place-items: center; text-align: center;
  font-size: 13px; line-height: 1.25; background: linear-gradient(180deg, #41414f, var(--wrong)); overflow-wrap: anywhere;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 6px rgba(0,0,0,0.35);
}
.tile.fresh { animation: flip var(--flip) cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i) * var(--stagger)); backface-visibility: hidden; }
.tile.name { background: linear-gradient(180deg, #23232f, var(--panel-2)); font-weight: 700; font-size: 14px; text-align: left; justify-items: start; padding-left: 10px; }
.tile.correct { background: linear-gradient(180deg, #38b45b, var(--correct)); color: var(--accent-ink); } /* dark ink: light text on green was 2.8:1 */
.tile.partial { background: linear-gradient(180deg, #d9b23a, var(--partial)); color: var(--partial-ink); }
.tile.wrong { box-shadow: inset 0 0 0 1px var(--tile-edge), 0 2px 6px rgba(0,0,0,0.35); }
.tile .sub { color: inherit; font-size: 12px; }
.name .real { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.tile.name .score { display: none; } /* shown on phones */
@keyframes flip { from { transform: perspective(600px) rotateY(90deg); opacity: 0; } 40% { opacity: 1; } to { transform: perspective(600px) rotateY(0); opacity: 1; } }

/* A guess is one .guess group: the name, seven tile buttons, a detail line. Wide screens keep the 8-column grid. */
.guess { display: contents; }
button.tile { appearance: none; border: 0; font-family: inherit; color: var(--text); cursor: pointer; position: relative; padding-top: 16px; } /* wide screens: room for the mark in the corner, so it never sits on the text */
button.tile.correct { color: var(--accent-ink); }
button.tile.partial { color: var(--partial-ink); }
.tile .lbl { position: absolute; top: 4px; right: 4px; display: flex; }
.tile .lt { display: none; }
.mk, .ar { width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mk .fill { fill: currentColor; stroke: none; }
.tile[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); } /* outside the tile: inside it the 4 px ring touched the 3 px of padding on a phone card; it fits the 6 px gap */
.tile[aria-expanded="true"]:focus-visible { outline-offset: 4px; } /* past the ring, so the keyboard outline does not cover it */
.detail { grid-column: 1 / -1; margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; line-height: 1.4; text-align: left; }

/* The card layout, used by the help's example row at every width and by the board on phones */
.guess.example { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.guess.example > .tile { grid-column: span 3; min-height: var(--tap); }
.guess.example > .tile:nth-child(n + 6) { grid-column: span 4; }
.guess.example > .tile:not(.name) { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px; padding: 5px 3px 6px; font-size: 12px; line-height: 1.25; text-align: left; }
.guess.example > .tile.name { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-height: 0; padding: 0 calc(var(--gutter) - var(--bleed)); background: none; box-shadow: none; color: var(--text); font-size: 16px; line-height: 1.3; text-align: left; }
.guess.example .name .real { display: inline; font-size: 12px; }
.guess.example .name .score { display: inline; margin-left: auto; font-size: 13px; font-weight: 700; color: var(--muted); }
.guess.example .tile .lbl { position: static; display: flex; align-items: center; justify-content: space-between; gap: 2px; font-size: 11px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.guess.example .tile .lt { display: inline; }
.guess.example .tile .val { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; overflow-wrap: break-word; hyphens: manual; }
.guess.example .tile .sub { display: flex; align-items: center; gap: 4px; font-size: 12px; }
/* The empty state's preview row: same shape, dashed, never inside #grid */
.guess.ghost > .tile { background: transparent; box-shadow: none; border: 1px dashed var(--tile-edge); color: var(--muted); cursor: default; }
.guess.ghost > .tile.name { border: 0; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 24px var(--gutter); }

/* Clue modes: Quote, Emoji */
.clue { max-width: 640px; margin: 4px auto 14px; }
.clue-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 20px; text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}
.clue-card .quote { font-size: 24px; line-height: 1.35; font-weight: 600; margin: 0; }
.clue-card .quote::before { content: "\201C"; color: var(--accent); margin-right: 2px; }
.clue-card .quote::after { content: "\201D"; color: var(--accent); margin-left: 2px; }
.clue-card .emoji { font-size: 56px; line-height: 1.2; letter-spacing: 0.15em; margin: 0; }
.clue-card .clue-sub { color: var(--muted); font-size: 13px; margin: 10px 0 0; text-transform: uppercase; letter-spacing: 0.08em; }
.hints { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.hints li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; display: flex; gap: 10px; align-items: baseline; }
.hints li.revealed { animation: pop 320ms ease both; }
.hints li b { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.hints li.locked { color: var(--muted); border-style: dashed; animation: none; }
.hints li.ready { padding: 0; border-color: rgba(63,191,106,0.5); background: linear-gradient(90deg, rgba(63,191,106,0.14), transparent); }
.hint-btn { width: 100%; min-height: var(--tap); text-align: left; padding: 10px 12px; border: 0; background: transparent; color: var(--accent-2); font-weight: 700; cursor: pointer; border-radius: 10px; }
.hint-btn::before { content: "💡 "; }
.hint-btn:hover { background: rgba(63,191,106,0.12); }
.hints li.revealed { border-color: var(--line); }
.chips { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips li { padding: 8px 12px; border-radius: 999px; background: linear-gradient(180deg, #41414f, var(--wrong)); font-size: 14px; display: inline-flex; gap: 8px; align-items: center; }
.chips li.correct { background: linear-gradient(180deg, #38b45b, var(--correct)); color: var(--accent-ink); font-weight: 700; }
.chips li.fresh { animation: flip var(--flip) cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.result {
  margin: 18px auto 24px; max-width: 640px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
}
.result h2 { margin: 0 0 14px; font-size: 28px; position: relative; display: inline-block; padding: 4px 10px; isolation: isolate; }
.result h2 .burst { position: absolute; inset: -20px -34px -10px; z-index: -1; opacity: 0.9; }
.result h2 .burst svg { width: 100%; height: 100%; }
.result h2.won { color: #0b0b10; text-shadow: none; }
.result .lead { color: var(--muted); margin: 0 0 12px; }
.result .faster { margin: -4px 0 12px; padding: 8px 12px; border-radius: 10px; background: rgba(63,191,106,0.10); border: 1px solid rgba(63,191,106,0.35); font-size: 15px; }
.result .faster b { color: var(--accent-2); }
.card { display: grid; grid-template-columns: 1fr; gap: 6px 14px; margin: 10px 0; }
.card dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.card dd { margin: 0 0 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.btn { min-height: var(--tap); padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.btn.quiet { background: transparent; }
.countdown { color: var(--muted); font-variant-numeric: tabular-nums; }
.notes { color: var(--muted); font-size: 14px; }
.reveal { text-align: center; margin: 6px 0 0; }

.foot { max-width: 1100px; margin: 20px auto 30px; padding: 0 var(--gutter); color: var(--muted); font-size: 13px; }
.foot .dexverse { margin: 0 0 6px; }
.foot .dexverse b { color: var(--accent-2); letter-spacing: 0.02em; }
.foot .also a { margin: 0 2px; }

.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; max-width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-body { padding: 20px; }
.dialog h2 { margin: 0 0 10px; }
.dialog h2[tabindex="-1"]:focus { outline: none; } /* the help's title takes focus on open; it is not a control */
.swatch { display: inline-grid; place-items: center; width: 26px; height: 22px; border-radius: 5px; vertical-align: middle; margin-right: 6px; font-size: 13px; }
.swatch.correct { background: var(--correct); color: var(--accent-ink); } .swatch.partial { background: var(--partial); color: var(--partial-ink); } .swatch.wrong { background: var(--wrong); color: var(--text); }
.small { font-size: 13px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 8px 0 14px; }
.stat-row b { display: block; font-size: 26px; }
.stat-row span { font-size: 12px; color: var(--muted); }
.dist { display: grid; gap: 4px; margin-bottom: 14px; }
.dist .bar { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 6px; font-size: 13px; }
.dist .fill { background: var(--wrong); border-radius: 4px; padding: 2px 6px; min-width: 22px; text-align: right; }
.dist .fill.me { background: var(--correct); color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  .tile.fresh, .chips li.fresh, .hints li, .hero .orb, .hero .streaks, .emblem .rings { animation: none; }
  .dd-dot { animation: none; }
}

/* Today's board */
.leaderboard { margin: 0 auto 24px; max-width: 640px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,0.45); }
.leaderboard h2 { margin: 0 0 4px; font-size: 20px; }
.leaderboard h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.leaderboard .fun { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.lb-table { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lb-table li { display: grid; grid-template-columns: 32px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-size: 14px; }
.lb-table li.me { background: linear-gradient(90deg, rgba(63,191,106,0.25), rgba(63,191,106,0.08)); border: 1px solid rgba(63,191,106,0.5); font-weight: 700; }
.lb-table .rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-table li.me .rank { color: var(--accent-2); }
.lb-table .handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-table .num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.lb-table li.me .num { color: var(--text); }
.lb-empty { color: var(--muted); font-size: 14px; margin: 4px 0; }
.lb-you { margin: 12px 0 0; font-size: 14px; color: var(--muted); line-height: 1.6; }
.lb-you b { color: var(--text); }
.link-btn { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
/* 44px hit area for links in running text: padding out, margin back in */
.link-btn, .notes a, .foot p a { display: inline-block; padding: 14px 6px; margin: -14px -6px; }
.handle-row { display: flex; gap: 8px; margin: 8px 0 6px; }
.handle-row .guess-input { flex: 1; }
.handle-error { color: var(--danger-text); font-size: 13px; min-height: 1.3em; margin: 0 0 6px; }
.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 14px; margin: 4px 0 10px; color: var(--muted); }
.check input { width: 24px; height: 24px; flex: none; }

/* Phones: 640px and narrower, the one breakpoint */
@media (max-width: 640px) {
  /* Header: emblem, wordmark and the two icons on one 44px row, the tagline under it */
  .top { flex-wrap: wrap; justify-content: flex-start; column-gap: 10px; row-gap: 0; padding: 8px var(--gutter) 0; }
  .brand, .brand > div { display: contents; }
  .emblem { order: 1; }
  .emblem svg { width: 44px; height: 44px; }
  .brand h1 { order: 2; flex: 1; min-width: 0; font-size: 26px; }
  .brand h1 a { display: inline-block; padding: 9px 0; margin: -9px 0; background-origin: content-box; }
  .icons { order: 3; gap: 4px; }
  .tag { order: 4; flex: 0 0 100%; margin: 2px 0 0; font-size: 13px; }

  /* Doomsday strip: one line */
  .doomsday { flex-wrap: nowrap; white-space: nowrap; gap: 0 6px; margin: 6px auto 8px; padding: 6px 8px; font-size: 12px; letter-spacing: 0; }
  .dd-label { text-transform: none; }
  .dd-when { display: none; }

  /* Four mode tabs, one row, icon over label */
  .modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; width: 100%; padding: 2px; margin: 0 0 6px; }
  .mode { flex-direction: column; justify-content: center; align-items: center; gap: 2px; min-height: var(--field); padding: 4px 0; font-size: 12px; font-weight: 600; line-height: 1.2; }
  .mode[aria-selected="true"] { font-weight: 700; }
  .mode svg { width: 16px; height: 16px; }
  .mode-desc { margin: 4px 0 2px; }
  .today { margin: 0 0 6px; }

  /* Input row, status line, empty state */
  .guess-form { max-width: none; margin: 6px 0 4px; scroll-margin-top: 8px; }
  .guess-btn { padding: 0 16px; }
  .status { margin: 2px 0 6px; }
  .empty { padding: 10px 0 6px; font-size: 14px; }
  .empty p { margin: 0 0 6px; }

  /* The board has no sideways scroll: each guess is a card of a name line, 4 tiles, 3 tiles and a detail line */
  .board { margin: 0 calc(var(--bleed) * -1); }
  .grid-scroll { overflow: visible; padding: 0 0 8px; }
  .grid { display: block; min-width: 0; }
  .grid .head { display: none; }
  .grid .guess { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; padding: 10px 0 12px; }
  .grid .guess + .guess { border-top: 1px solid var(--line); }
  .grid .guess:first-of-type { padding-top: 4px; }
  .grid .guess > .tile { grid-column: span 3; min-height: var(--tap); }
  .grid .guess > .tile:nth-child(n + 6) { grid-column: span 4; }
  .grid .guess > .tile:not(.name) { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px; padding: 5px 3px 6px; font-size: 12px; line-height: 1.25; text-align: left; }
  .grid .guess > .tile.name { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-height: 0; padding: 0 calc(var(--gutter) - var(--bleed)); background: none; box-shadow: none; color: var(--text); font-size: 16px; line-height: 1.3; text-align: left; }
  .grid .guess .name .real { display: inline; font-size: 12px; }
  .grid .guess .name .score { display: inline; margin-left: auto; font-size: 13px; font-weight: 700; color: var(--muted); }
  .grid .guess .tile .lbl { position: static; display: flex; align-items: center; justify-content: space-between; gap: 2px; font-size: 11px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
  .grid .guess .tile .lt { display: inline; }
  .grid .guess .tile .val { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; overflow-wrap: break-word; hyphens: manual; }
  .grid .guess .tile .sub { display: flex; align-items: center; gap: 4px; font-size: 12px; }

  /* Result, board, dialogs */
  .result { margin: 14px 0 20px; padding: 16px; scroll-margin-top: 8px; }
  .result h2 { font-size: 24px; }
  .result h2 .burst { inset: -20px -22px -10px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .actions .btn { padding: 10px 4px; }
  .actions .btn.primary { grid-column: 1 / -1; }
  .leaderboard { margin: 0 0 20px; padding: 16px; }
  .dialog { width: calc(100% - 16px); max-width: 560px; }
  .dialog-body { padding: 16px 12px; }
  .dialog h2 { font-size: 20px; }
  .dialog .actions .btn.primary { grid-column: auto; }
  .dialog .guess.example { margin: 0 -6px; }
  .dialog > form > .btn { width: 100%; }
  .handle-row .btn { flex: none; }

  /* Footer: Also-play links are 44px pills; the credit link keeps its place in the sentence */
  .foot { margin: 16px 0 24px; font-size: 13px; }
  .foot .dexverse { margin: 0 0 14px; }
  .foot .also { display: inline-flex; flex-wrap: wrap; align-items: center; vertical-align: middle; }
  .foot .also[hidden] { display: none; }
  .foot .also a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: var(--tap); padding: 0 10px; margin: 0; }
}
