/* Boggle: midnight dark theme to match rolandwillis.co.uk. Teal for selection, amber for replay. */
:root {
  color-scheme: dark;
  --bg: #070a12;
  --ink: #f5f7fb;
  --ink-soft: #929cad;
  --accent: #62e6d5;
  --accent-soft: #7ee8dc;
  --accent-ink: #04201c;
  --border: rgba(255, 255, 255, .09);
  --replay: #ffbe48;
  --replay-ink: #3a2300;
  --replay-text: #ffd27a;
  --danger: #ff8a98;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
/* Soft colour glows and a faint blueprint grid, same as the landing page. Both are
   fixed layers behind the page (not background-attachment, which iOS ignores). */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(circle at 15% 8%, rgba(82, 89, 255, .17), transparent 28rem),
    radial-gradient(circle at 88% 30%, rgba(0, 214, 201, .12), transparent 30rem),
    radial-gradient(circle at 50% 100%, rgba(186, 68, 255, .10), transparent 32rem);
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 80%); mask-image: linear-gradient(to bottom, black, transparent 80%);
}
button, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 4px; }
.game { max-width: 1040px; margin: 0 auto; padding: 10px 16px 24px; }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 9px); gap: 3px; transform: rotate(-9deg); }
.brand-mark i { width: 9px; height: 9px; background: var(--ink); border-radius: 2px; }
.brand-mark i:last-child { background: var(--accent); box-shadow: 0 0 12px rgba(98, 230, 213, .7); }
.game-title { margin: 0; font-size: 29px; line-height: 1; font-weight: 850; letter-spacing: -1.4px; }
.game-title > span { color: var(--accent); }
.tagline { display: none; }
.header-controls { display: flex; align-items: center; gap: 4px; }
.sound-toggle { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); }
.sound-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .sound-slash { display: none; }
.sound-toggle[aria-pressed="false"] { color: var(--ink-soft); }
.sound-toggle[aria-pressed="false"] .sound-waves { display: none; }
.sound-toggle[aria-pressed="false"] .sound-slash { display: block; }
.size-control { display: flex; gap: 5px; align-items: center; }
.size-control label { font-size: 11px; font-weight: 650; color: var(--ink-soft); }
.board-size-select { min-height: 44px; padding: 0 7px; border: 0; border-radius: 8px; color: var(--ink); background: transparent; font-size: 14px; font-weight: 700; cursor: pointer; }
.board-size-select:disabled { opacity: .65; cursor: default; }
.play-layout, .playfield, .word-panel { min-width: 0; }
.status-bar { display: flex; align-items: center; gap: 28px; border-top: 1px solid var(--border); padding: 8px 4px 4px; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-time { margin-right: auto; flex-direction: row; align-items: center; gap: 9px; }
.stat-time > div { display: flex; flex-direction: column; }
.timer-icon { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.stat-value { font-size: 25px; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.8px; }
.stat-time .stat-value { font-size: 29px; }
.stat-time.is-urgent { color: var(--danger); }
/* Last 10 s: the readout beats once a second (restarted from ui.js so it lines up with the tick). */
.stat-time .stat-value { transform-origin: left center; }
.stat-time .stat-value.beat { animation: timer-beat .9s ease-out; }
.stat-time.is-final .stat-value.beat { animation-name: timer-beat-final; }
@keyframes timer-beat {
  0% { transform: scale(1); text-shadow: 0 0 0 transparent; }
  12% { transform: scale(1.14); text-shadow: 0 0 16px rgba(255, 138, 152, .7); }
  100% { transform: scale(1); text-shadow: 0 0 0 transparent; }
}
@keyframes timer-beat-final {
  0% { transform: scale(1); text-shadow: 0 0 0 transparent; }
  12% { transform: scale(1.28); text-shadow: 0 0 26px rgba(255, 138, 152, .95); }
  100% { transform: scale(1); text-shadow: 0 0 0 transparent; }
}
.word-strip { height: 40px; display: grid; align-items: center; text-align: center; padding: 5px 4px 10px; }
.word-prompt { color: var(--ink-soft); font-size: 12px; }
.current-word { display: none; font-size: 20px; font-weight: 800; letter-spacing: 2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.submission-feedback { display: none; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.last-candidate { font-weight: 800; letter-spacing: .5px; overflow-wrap: anywhere; }
.verdict { color: var(--ink-soft); }
.verdict-accepted { color: var(--accent); }
.verdict-accepted::before { content: "✓ "; }
.verdict-rejected { color: var(--danger); }
[data-phase="playing"] .word-strip.has-feedback .word-prompt { display: none; }
[data-phase="playing"] .word-strip.has-feedback .submission-feedback { display: flex; }
.word-strip.has-word .word-prompt, [data-phase="playing"] .word-strip.has-word .submission-feedback { display: none; }
.word-strip.has-word .current-word { display: block; }
.board-area { margin: 0; scroll-margin-top: 12px; }
.board {
  position: relative; display: grid; gap: 7px; padding: 10px 10px 13px;
  border-radius: 19px; background: linear-gradient(160deg, #111b2e, #0a111f); border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 0 70px rgba(98, 230, 213, .07), inset 0 1px 0 rgba(255, 255, 255, .07);
  user-select: none; -webkit-user-select: none; touch-action: none;
  container-type: inline-size;
}
.board .tile {
  position: relative; z-index: 1; display: flex; justify-content: center; align-items: center; min-width: 0;
  aspect-ratio: 1; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .13);
  background: linear-gradient(155deg, #2a3750, #1a2438); color: var(--ink);
  box-shadow: 0 3px 0 #090e1a, 0 6px 10px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .14);
  font-size: min(var(--tile-font, 2.1rem), var(--tile-scale, 10cqi)); font-weight: 750; line-height: 1;
  cursor: default; transition: background 90ms ease, box-shadow 90ms ease, color 90ms ease;
}
[data-phase="playing"] .tile { cursor: crosshair; }
.board .tile-duo { font-size: min(calc(var(--tile-font, 2.1rem) * .78), calc(var(--tile-scale, 10cqi) * .78)); letter-spacing: -1px; }
.board .tile.selected { background: linear-gradient(155deg, #8cf2e5, var(--accent)); border-color: #b9fbf2; color: var(--accent-ink); box-shadow: 0 0 24px rgba(98, 230, 213, .6), 0 1px 0 #1f8c80; }
.board-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.board-path-line { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 5px rgba(98, 230, 213, .85)); }
.board .tile.tile-replay { background: linear-gradient(155deg, #ffd47a, var(--replay)); border-color: #ffe3a6; color: var(--replay-ink); box-shadow: 0 0 24px rgba(255, 190, 72, .5), 0 3px 0 #a56f12; }
.board-replay-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; fill: none; stroke: var(--replay-ink); stroke-width: 2px; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 1.5px #fff2cf) drop-shadow(0 0 1.5px #fff2cf); }
.replay-arrowhead { fill: var(--replay-ink); stroke-width: 1.5px; }
.replay-status { margin: 13px 0 0; padding: 0 3px; font-size: 12px; font-weight: 650; text-align: center; color: var(--replay-text); }
.replay-status:empty { display: none; }
.controls { display: flex; gap: 10px; margin-top: 20px; }
.btn { min-height: 48px; border-radius: 12px; padding: 12px 18px; border: 1px solid transparent; font-size: 14px; font-weight: 750; transition: background 100ms ease; }
.btn-primary { flex: 1; display: flex; align-items: center; justify-content: space-between; background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 26px rgba(98, 230, 213, .28), 0 2px 0 #1f8c80; }
.btn-primary > span { font-size: 21px; line-height: 1; color: var(--accent-ink); }
.btn-primary:active { background: #45cdbd; box-shadow: none; }
.btn-secondary { background: transparent; border-color: rgba(255, 255, 255, .2); color: var(--ink); }
[data-phase="ready"] #new-round, [data-phase="finished"] #start-game, [data-phase="playing"] .controls { display: none; }
.play-hint { margin: 14px 0 0; text-align: center; color: var(--ink-soft); font-size: 11px; }
[data-phase="ready"] .play-hint, [data-phase="finished"] .play-hint { display: none; }
/* Retain the lifecycle announcement without repeating the visible review prompt. */
.round-message { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.round-message:empty { display: none; }
.word-panel { margin-top: 25px; }
.eyebrow { font-size: 9px; letter-spacing: 1.4px; font-weight: 750; color: var(--accent-soft); margin: 0 0 10px; line-height: 1.6; }
.how-to-play { padding: 2px 4px; }
.how-to-play h2 { margin: 0 0 12px; font-size: 27px; line-height: 1.12; letter-spacing: -1px; }
.how-to-play > p:not(.eyebrow) { font-size: 13px; line-height: 1.7; color: var(--ink-soft); margin: 0 0 12px; max-width: 34em; }
.how-to-play .how-to-footer { color: var(--ink); font-weight: 700; }
[data-phase="ready"] .found-words, [data-phase="playing"] .how-to-play, [data-phase="finished"] .how-to-play { display: none; }
.found-words h2, .results-title { margin: 0 0 12px; font-size: 17px; letter-spacing: -.4px; font-weight: 750; }
.found-words-count, .results-missed-count { margin-left: 6px; font-size: 12px; font-weight: 650; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.empty-hint { color: var(--ink-soft); font-size: 13px; line-height: 1.7; margin: 0; }
.found-words-list, .results-missed-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-content: start; gap: 7px; }
.found-words-list { max-height: 154px; overflow-y: auto; padding: 3px; margin: -3px; }
.found-words-list:empty { display: none; }
.found-word { max-width: 100%; display: inline-flex; align-items: baseline; gap: 6px; padding: 8px 11px; border-radius: 7px; background: rgba(98, 230, 213, .12); box-shadow: inset 0 0 0 1px rgba(98, 230, 213, .3); color: var(--ink); font-size: 12px; font-weight: 700; }
.found-word-points { color: var(--accent-soft); font-size: 10px; }
.results { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.results-title { font-size: 24px; letter-spacing: -.7px; }
.results-stats, .results-note { font-size: 12px; line-height: 1.7; color: var(--ink-soft); margin: 0 0 12px; }
.results-note { color: var(--danger); }
.review-hint { font-size: 11px; line-height: 1.6; margin: 0 0 12px; color: var(--ink-soft); }
.review-hint > span { display: block; color: var(--accent-soft); }
.results-missed { max-height: 280px; overflow-y: auto; padding: 5px; margin: -5px; scrollbar-color: rgba(255, 255, 255, .28) transparent; }
.result-word { min-width: 0; max-width: 100%; }
.result-word-text, .found-word-text { overflow-wrap: anywhere; }
.result-word-replay { min-width: 44px; max-width: 100%; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .03); color: var(--ink); font-size: 12px; font-weight: 650; }
.found .result-word-replay { background: rgba(98, 230, 213, .12); border-color: rgba(98, 230, 213, .4); }
.result-word-tick, .result-word-points { color: var(--accent-soft); }
.result-word-replay.replay-selected { background: var(--replay); color: var(--replay-ink); border-color: #ffe3a6; box-shadow: 0 0 18px rgba(255, 190, 72, .45); }
.result-word-replay.replay-selected .result-word-tick, .result-word-replay.replay-selected .result-word-points { color: var(--replay-ink); }
.game-footer { margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 10px; letter-spacing: .5px; color: var(--ink-soft); }
[data-phase="playing"] .game-footer { display: none; }
@media (hover: hover) {
  .btn-primary:hover { background: #8cf2e5; }
  .sound-toggle:hover { background: rgba(255, 255, 255, .07); }
  .btn-secondary:hover, .board-size-select:not(:disabled):hover { background: rgba(255, 255, 255, .07); }
  .result-word-replay:hover { border-color: rgba(98, 230, 213, .6); background: rgba(255, 255, 255, .07); }
  .result-word-replay.replay-selected:hover { background: var(--replay); }
}
@media (min-width: 600px) and (max-width: 859px) {
  .game { max-width: 560px; padding-top: 22px; }
}
@media (min-width: 860px) {
  .game { padding: 22px 40px 28px; }
  .game-header { margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
  .game-title { font-size: 36px; }
  .tagline { display: block; margin: 0 auto 0 8px; font-size: 12px; color: var(--ink-soft); }
  .play-layout { display: grid; grid-template-columns: minmax(0, 480px) minmax(240px, 1fr); gap: 48px; align-items: start; }
  .status-bar { border-top: 0; padding-top: 0; gap: 44px; }
  .stat-label { font-size: 11px; }
  .stat-value { font-size: 28px; }
  .stat-time .stat-value { font-size: 34px; }
  .word-strip { height: 48px; }
  .word-prompt { font-size: 13px; }
  .board { gap: 10px; padding: 14px 14px 18px; border-radius: 22px; }
  .board .tile { border-radius: 12px; }
  .word-panel { margin-top: 9px; padding-top: 16px; border-top: 2px solid rgba(98, 230, 213, .55); }
  .how-to-play { padding: 0; }
  .how-to-play h2 { font-size: 36px; letter-spacing: -1.3px; margin: 20px 0; }
  .how-to-play > p:not(.eyebrow) { font-size: 14px; }
  .found-words-list { max-height: 240px; }
  .results-missed { max-height: 340px; }
  .game-footer { text-align: left; margin-top: 40px; }
}
@media (max-width: 359px) {
  .game { padding-inline: 10px; }
  .board { gap: 5px; padding: 8px 8px 11px; border-radius: 15px; }
  .board .tile { border-radius: 7px; }
  .size-control label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  /* No movement: keep the urgency as a steady glow instead of a beat. */
  .stat-time .stat-value.beat { animation: none; }
  .stat-time.is-critical .stat-value { text-shadow: 0 0 14px rgba(255, 138, 152, .6); }
}
