:root {
  --bg: #121213;
  --bg-elevated: #1c1c1e;
  --border: #3a3a3c;
  --border-soft: #565758;
  --text: #ffffff;
  --text-dim: #a7a7a7;
  --accent: #6e56cf;
  --accent-hover: #7f68db;
  --on-accent: #ffffff;
  --correct: #2e7d46;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --danger: #d24444;
  --radius: 10px;
  --max-width: 480px;
  --hover-bg: #262629;
  --bg-glow: #1a1a1d;
  --logo-glow: #ffffff;
  --key-bg: #818384;
  --key-text: #ffffff;
  --key-absent-bg: #3a3a3c;
  --key-absent-text: #8a8a8a;
  --toast-bg: #ffffff;
  --toast-text: #121213;
  --toast-border: transparent;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Themes -- cosmetic only. The colour-blind toggle below always overrides
   --correct/--present regardless of which theme is active (it's declared
   after these blocks with equal-or-higher specificity), so accessibility
   never depends on theme choice. Each theme still picks its own
   correct/present/absent trio that's distinguishable on its own. */
body[data-theme="matrix"] {
  --bg: #000000;
  --bg-glow: #001a00;
  --bg-elevated: #041a04;
  --border: #0a3d0a;
  --border-soft: #1a6b1a;
  --text: #33ff66;
  --text-dim: #22a347;
  --accent: #17c44a;
  --accent-hover: #33e066;
  --on-accent: #001400;
  --correct: #14802f;
  --present: #9c7a0e;
  --absent: #0a1a0a;
  --danger: #ff4d4d;
  --hover-bg: #0a2a0a;
  --logo-glow: #33ff66;
  --key-bg: #0f3d18;
  --key-text: #33ff66;
  --key-absent-bg: #0a1a0a;
  --key-absent-text: #1f7a3a;
  /* On-theme console toast: black with a green outline, instead of the default white card. */
  --toast-bg: #000000;
  --toast-text: #33ff66;
  --toast-border: #17c44a;
  --font-family: "Courier New", Consolas, "SFMono-Regular", Menlo, monospace;
}

body[data-theme="light"] {
  --bg: #ffffff;
  --bg-glow: #eef0f5;
  --bg-elevated: #f5f5f7;
  --border: #d1d1d6;
  --border-soft: #b0b0b8;
  --text: #1c1c1e;
  --text-dim: #6e6e73;
  --accent: #6e56cf;
  --accent-hover: #5940b5;
  --on-accent: #ffffff;
  --correct: #2e7d46;
  --present: #9c7f0a;
  --absent: #d1d1d6;
  --danger: #c8302f;
  --hover-bg: #ececef;
  --logo-glow: #1c1c1e;
  --key-bg: #e4e4e8;
  --key-text: #1c1c1e;
  --key-absent-bg: #d1d1d6;
  --key-absent-text: #6e6e73;
  /* The default white toast would be invisible against this theme's white page -- invert it. */
  --toast-bg: #1c1c1e;
  --toast-text: #ffffff;
}

* { box-sizing: border-box; }

/* Guard against any `display` rule elsewhere accidentally overriding the
   browser's default [hidden] behaviour (author styles beat the UA
   stylesheet at equal specificity, so a plain `.foo { display: block }`
   rule can silently defeat `<div hidden>` on the same element). */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(circle at top, var(--bg-glow), var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  transition: background 0.2s ease, color 0.2s ease;
}

/* `background` above doesn't actually help here -- browsers don't interpolate between two
   radial-gradient values via `transition`, so a theme switch would otherwise be a hard, flickery
   cut. applyTheme() (app.js) retriggers this brief opacity dip to mask it instead. */
body.theme-flash { animation: theme-flash 0.25s ease; }
@keyframes theme-flash {
  0% { opacity: 0.55; }
  100% { opacity: 1; }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Colour-blind friendly palette (Wordle's "high contrast" scheme):
   orange for correct, blue for present -- distinguishable under the
   common red-green deficiencies, unlike the default green/yellow. */
body.colorblind {
  --correct: #f5793a;
  --present: #85c0f9;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

.topbar-right { display: flex; gap: 6px; flex-shrink: 0; }

.logo {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--logo-glow), var(--accent-hover));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo span { color: var(--accent-hover); -webkit-text-fill-color: var(--accent-hover); }
.game-number {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-dim);
  -webkit-text-fill-color: var(--text-dim);
  vertical-align: middle;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
a.icon-btn { text-decoration: none; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:hover { background: var(--hover-bg); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.used { border-color: var(--accent); color: var(--accent-hover); }
.icon-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.hint-banner {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  color: var(--accent-hover);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.hint-banner[hidden] { display: none; }

.definition-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border-color: var(--border-soft);
  color: var(--text);
}
.definition-banner strong { color: var(--accent-hover); text-transform: uppercase; }
.definition-banner button {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.definition-banner button:hover { color: var(--text); }

.stuck-nudge {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 30px 10px 12px;
  font-size: 0.85rem;
  text-align: left;
}
.stuck-nudge[hidden] { display: none; }
.stuck-nudge-text { margin: 0 0 8px; }
.stuck-nudge-actions { display: flex; gap: 8px; }
.stuck-nudge-btn {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.stuck-nudge-btn:hover { background: var(--accent-hover); }
.stuck-nudge-btn[hidden] { display: none; }
.stuck-nudge-btn-quiet { background: transparent; border-color: var(--border); color: var(--text); }
.stuck-nudge-btn-quiet:hover { background: var(--hover-bg); }
.stuck-nudge-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.stuck-nudge-close:hover { color: var(--text); }

.board-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}
.board-hint[hidden] { display: none; }

.lookup-indicator {
  margin: 0;
  font-size: 0.8rem;
  color: var(--accent-hover);
  text-align: center;
  animation: lookup-pulse 1.1s ease-in-out infinite;
}
.lookup-indicator[hidden] { display: none; }

@keyframes lookup-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.board-row.completed { cursor: pointer; }
.board-row.completed:hover .tile { filter: brightness(1.12); }

/* Standalone pages (e.g. reset-password) that show one modal as the page content,
   not as an overlay -- CSS instead of inline styles so style-src can stay 'self'. */
.game-static-modal { justify-content: flex-start; padding-top: 40px; }
.modal-static { position: static; max-width: 360px; width: 100%; }
.link-block { display: block; text-align: center; text-decoration: none; }

.game {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 10px 10px;
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr); /* MAX_GUESSES -- fixed across every word-length variant */
  gap: 6px;
  width: 100%;
  /* --word-length is set once from JS (app.js, see WORD_LENGTH) -- scales the board down for
     the 3/4/5-letter variants instead of stretching the same 6-wide tiles sideways. */
  max-width: calc(320px * var(--word-length, 6) / 6);
  aspect-ratio: var(--word-length, 6) / 6.3;
  margin: 0 auto;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(var(--word-length, 6), 1fr);
  gap: 6px;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  user-select: none;
  transition: transform 0.1s ease;
}

.tile.filled { border-color: var(--border-soft); animation: pop 0.18s ease; }
.tile.hint-filled:not(.correct):not(.present):not(.absent) {
  border-color: var(--accent);
  color: var(--accent-hover);
}
.tile.correct { background: var(--correct); border-color: var(--correct); }
.tile.present { background: var(--present); border-color: var(--present); }
.tile.absent { background: var(--absent); border-color: var(--absent); }

.tile.flip {
  animation: flip 0.5s ease forwards;
}

/* Per-keyframe easing (ease-in to the edge-on midpoint, ease-out back down) instead of one
   flat curve for the whole turn -- reads as a physical flip rather than a linear rotation.
   perspective() gives the rotation actual foreshortening instead of looking flat. */
@keyframes flip {
  0% { transform: perspective(400px) rotateX(0deg); animation-timing-function: ease-in; }
  50% { transform: perspective(400px) rotateX(90deg); animation-timing-function: ease-out; }
  100% { transform: perspective(400px) rotateX(0deg); }
}

/* Backspace: a quick shrink-and-settle on the tile just emptied (app.js: flashEraseTile). */
.tile.erasing { animation: erase 0.12s ease; }
@keyframes erase {
  0% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* New day loading in while the player's looking at it (app.js: playFreshBoardWave) -- reuses the
   same pop a typed letter gets, just retriggered on an empty tile. */
.tile.fresh-pop { animation: pop 0.25s ease; }

/* One-off reveal for the tile a hint fills in -- distinct from (and more specific than,
   so it wins over) the plain .tile.filled pop every other typed letter gets. Triggered by
   app.js adding/removing this class; :not(...) keeps it from replaying on ordinary re-renders. */
.tile.hint-filled.hint-reveal {
  animation: hint-glow 0.6s ease;
}
@keyframes hint-glow {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 var(--accent); }
  55% { transform: scale(1.12); box-shadow: 0 0 14px 3px var(--accent); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

@keyframes pop {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.board-row.shake { animation: shake 0.4s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* A quick press-down the instant Enter is hit (app.js: pressCurrentRow), fired before the
   request goes out so the row feels accepted even while the network is still slow. */
.board-row.row-press { animation: row-press 0.1s ease; }
@keyframes row-press {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

/* Staggered per-tile delays turn this into a left-to-right wave instead of every tile
   bouncing in unison. Timings (90ms step, 0.5s bounce) are mirrored in app.js as
   WIN_TILE_STAGGER_MS/WIN_BOUNCE_MS, which delay the result modal until the wave finishes. */
.board-row.win .tile {
  animation: bounce 0.5s ease;
}
.board-row.win .tile:nth-child(1) { animation-delay: 0ms; }
.board-row.win .tile:nth-child(2) { animation-delay: 90ms; }
.board-row.win .tile:nth-child(3) { animation-delay: 180ms; }
.board-row.win .tile:nth-child(4) { animation-delay: 270ms; }
.board-row.win .tile:nth-child(5) { animation-delay: 360ms; }
.board-row.win .tile:nth-child(6) { animation-delay: 450ms; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-14px); }
  50% { transform: translateY(0); }
}

.board-wrap { position: relative; width: 100%; }

/* One-off burst behind the board on a win (app.js: playWinFlourish) -- theme-matched (sparkles
   for Classic/Light, falling 0/1 glyphs for Matrix), never shown on a reload. */
.win-flourish {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}
.flourish-bit {
  position: absolute;
  top: -10px;
  font-size: 1rem;
  color: var(--accent-hover);
  animation: flourish-fall 1.1s ease-in forwards;
}
body[data-theme="matrix"] .flourish-bit { color: var(--text); font-family: var(--font-family); }
@keyframes flourish-fall {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(var(--drift, 0px), 140px); opacity: 0; }
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  flex: 1;
  min-width: 0;
  height: 52px;
  max-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: var(--key-bg);
  color: var(--key-text);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.key:active,
.key.key-pressed {
  transform: scale(0.9);
  filter: brightness(0.85);
}
/* .key-pressed: added briefly by app.js on a physical keydown, so the on-screen key flashes
   the same way tapping it does -- otherwise a physical-keyboard player never sees a keypress
   land anywhere. filter (not a background colour) so it reads correctly over every key colour
   (default/correct/present/absent) in every theme without new tokens. */
/* flex: 1.5 gives ENTER / backspace room to fit their label on a narrow phone (a 390px screen
   otherwise squeezes them to letter-key width and the word overflows the key). Caps still apply. */
.key.wide { flex: 1.5; max-width: 64px; font-size: 0.7rem; }
/* One-off pop on a key whose status just moved up a rank (app.js: renderKeyboardStatus's
   `justChanged`) -- draws the eye to what was just learned without animating the whole keyboard
   on every guess. */
.key.key-reveal { animation: key-reveal 0.3s ease; }
@keyframes key-reveal {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.18); }
}
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent {
  background: var(--key-absent-bg);
  color: var(--key-absent-text);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.toast-region {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300; /* above .modal-backdrop (200) so toasts raised while a dialog is open stay visible */
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--toast-border);
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  animation: toast-in 0.15s ease;
}
.toast-error { border-left: 4px solid var(--danger); }
/* .toast-region has pointer-events: none so toasts never block taps on the board underneath --
   a clickable toast (see showToast's onClick option) opts back in just for itself. */
.toast-clickable { cursor: pointer; pointer-events: auto; }
.toast-clickable:hover, .toast-clickable:focus-visible { filter: brightness(1.12); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.toast-out { animation: toast-out 0.18s ease forwards; }
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none; }

/* Added by closeModal() (app.js) instead of hiding instantly -- removed once the exit animation
   finishes (or its fallback timeout fires). anyModalOpen() treats this the same as closed, so
   input unlocks immediately rather than waiting out the animation. */
.modal-backdrop.modal-backdrop-closing { animation: backdrop-out 0.16s ease forwards; }
.modal-backdrop.modal-backdrop-closing .modal { animation: modal-out 0.16s ease forwards; }
@keyframes backdrop-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes modal-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

.modal {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px;
  max-width: 400px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modal-in 0.18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 { margin-top: 0; }
.modal-sub { color: var(--text-dim); font-size: 0.9rem; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 0.95rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-row:hover { background: var(--hover-bg); }

.menu-row-danger { color: var(--danger); }

.menu-row-icon { font-size: 1.15rem; flex-shrink: 0; width: 24px; text-align: center; }
.menu-row-label { flex: 1; }

.menu-row-switch {
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-soft);
  position: relative;
  transition: background 0.15s ease;
}
.menu-row-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.menu-row[aria-pressed="true"] .menu-row-switch { background: var(--accent); }
.menu-row[aria-pressed="true"] .menu-row-switch::after { transform: translateX(16px); }
.modal-close:hover { background: var(--hover-bg); color: var(--text); }

.menu-section-label {
  margin: 14px 0 2px;
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.menu-version {
  margin: 14px 0 0;
  padding: 0 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

.theme-dot {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
}
.theme-dot-classic { background: linear-gradient(135deg, #121213, #6e56cf); }
.theme-dot-matrix { background: linear-gradient(135deg, #000000, #17c44a); }
.theme-dot-light { background: linear-gradient(135deg, #ffffff, #6e56cf); }

.theme-check { flex-shrink: 0; color: var(--accent-hover); font-weight: 700; opacity: 0; }

/* Puzzle-length switcher (More menu) -- one page per length (public/3,4,5/index.html, and the
   original at /), so switching is a plain navigation, not a state change. */
.length-switcher {
  display: flex;
  gap: 8px;
  padding: 2px 10px 4px;
}
.length-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}
.length-chip:hover { background: var(--hover-bg); }
.length-chip[aria-current="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}
.theme-option[aria-checked="true"] .theme-check { opacity: 1; }

.help-example { display: flex; gap: 4px; margin: 10px 0 6px; }
.help-example .tile { width: 40px; height: 40px; font-size: 1.1rem; }

.share-app-preview { justify-content: center; margin: 4px auto 18px; }
.share-app-preview .tile { animation: pop 0.25s ease backwards; }
.share-app-preview .tile:nth-child(1) { animation-delay: 0s; }
.share-app-preview .tile:nth-child(2) { animation-delay: 0.05s; }
.share-app-preview .tile:nth-child(3) { animation-delay: 0.1s; }
.share-app-preview .tile:nth-child(4) { animation-delay: 0.15s; }
.share-app-preview .tile:nth-child(5) { animation-delay: 0.2s; }
.share-app-preview .tile:nth-child(6) { animation-delay: 0.25s; }

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}
.swatch.correct { background: var(--correct); }
.swatch.present { background: var(--present); }
/* --absent is tuned to sit on --bg (the board), not --bg-elevated (this modal) -- in Matrix
   theme the two are nearly identical, so the legend swatch would be invisible. --border-soft
   reads clearly on --bg-elevated in every theme (it's already an elevated-surface fill, see
   .menu-row-switch) and still reads as "muted", not "wrong". */
.swatch.absent { background: var(--border-soft); }

.help-footer { color: var(--text-dim); font-size: 0.85rem; margin-top: 16px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--text-dim); }
.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 1rem;
}
.auth-form input:focus { outline: 2px solid var(--accent); }

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-primary.btn-danger { background: var(--danger); }
.btn-primary.btn-danger:hover { filter: brightness(1.1); }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); display: block; text-align: center; text-decoration: none; margin-bottom: 10px; }
.btn-secondary:hover { background: var(--hover-bg); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-hover);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
  text-decoration: underline;
}

.form-error { color: var(--danger); font-size: 0.85rem; min-height: 1.1em; }
.form-hint { color: var(--text-dim); font-size: 0.8rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 4px;
}
.stat-value { font-size: 1.3rem; font-weight: 800; }
/* The result screen's streak counts up from N-1 to N (app.js: animateStreakCount) -- this pop
   lands on the actual new value. */
.stat-value.stat-pop { animation: stat-pop 0.4s ease; }
@keyframes stat-pop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.25); }
}
.stat-label { font-size: 0.68rem; color: var(--text-dim); text-align: center; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.03em; }

.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
/* Wraps (3 + 2) on phones instead of overflowing the card. */
.stats-grid-5 { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }

.stats-distribution { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.dist-num { width: 12px; color: var(--text-dim); text-align: right; flex-shrink: 0; }
.dist-bar-track { flex: 1; min-width: 0; }
.dist-bar {
  min-width: 24px;
  /* --border-soft, not --absent: this sits on --bg-elevated (the stats modal), and --absent is
     tuned for --absent tiles on --bg instead -- in Matrix theme the two are nearly identical,
     making every non-highlighted bar invisible. See the .swatch.absent comment above. */
  background: var(--border-soft, #565758);
  color: var(--text);
  font-weight: 700;
  text-align: right;
  padding: 2px 6px;
  border-radius: 3px;
  box-sizing: border-box;
  transition: width 0.3s ease;
}
.dist-bar.dist-bar-highlight { background: var(--accent); color: var(--on-accent); }

.share-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 4px 0 14px;
  cursor: pointer;
}
.share-toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.result-word {
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 8px 0 2px;
  color: var(--accent-hover);
}
.result-definition { color: var(--text-dim); margin-bottom: 16px; }
.result-hint-note { color: var(--present); font-size: 0.85rem; margin-top: -8px; margin-bottom: 12px; }
.result-next-game { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 12px; }
.result-next-game-fyi { font-size: 0.75rem; opacity: 0.75; }

@media (max-width: 360px) {
  .tile { font-size: 1.25rem; }
  .key { height: 46px; font-size: 0.75rem; }
}

/* Admins see an extra header icon (word list admin) alongside the ones
   every player gets -- shrink icons/logo so up to 6 topbar-right icons
   plus help still fit a narrow phone without overflowing off-screen. */
@media (max-width: 420px) {
  .icon-btn { width: 32px; height: 32px; font-size: 0.85rem; }
  .topbar-right { gap: 4px; }
  .logo { font-size: 1.05rem; }
}

/* Collapse every CSS animation/transition to (near) nothing rather than disabling it --
   `animation: none` would also skip whatever state a keyframe's 100% rule sets (e.g. a tile
   ending up coloured), where a near-zero duration still finishes on the next frame. app.js
   mirrors this via matchMedia for its own setTimeout-driven waits (flip colour timing, the
   win-wave delay before the result modal), which this rule can't reach. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
