/* Speed Word Search
   Same look as Odd One Out: chunky tiles on a dotted background,
   with bright highlighter strokes for the words you find. */

:root {
  --bg: #e3ebf3;
  --bg-dot: #cfdbe7;
  --surface: #ffffff;
  --surface-edge: #cbd8e5;
  --ink: #152230;
  --muted: #5b6f84;
  --tile: #ffffff;
  --tile-ink: #152230;
  --tile-edge: #b3c3d3;
  --odd: #f2b23a;
  --odd-edge: #c98a14;
  --right: #2fae6c;
  --right-edge: #1f8350;
  --wrong: #e2604f;
  --blue: #3e6fe0;
  --blue-edge: #2a52b3;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
/* dark: follows the device unless the player has picked a side in Settings */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111c26;
    --bg-dot: #1a2835;
    --surface: #182633;
    --surface-edge: #24384a;
    --ink: #eef3f8;
    --muted: #8ea2b6;
    --tile: #f3f6fa;
    --tile-ink: #152230;
    --tile-edge: #92a5b8;
    --blue: #5b86f0;
    --blue-edge: #3b63c7;
  }
}
:root[data-theme="dark"] {
  --bg: #111c26;
  --bg-dot: #1a2835;
  --surface: #182633;
  --surface-edge: #24384a;
  --ink: #eef3f8;
  --muted: #8ea2b6;
  --tile: #f3f6fa;
  --tile-ink: #152230;
  --tile-edge: #92a5b8;
  --blue: #5b86f0;
  --blue-edge: #3b63c7;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body { height: 100%; overflow: hidden; }
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  padding: max(clamp(10px, 2.2vh, 20px), env(safe-area-inset-top)) 16px max(clamp(10px, 2.2vh, 20px), env(safe-area-inset-bottom));
}
/* every screen fits the height it's given: sizes shrink on short screens */
.screen {
  width: 100%;
  max-width: 440px;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(8px, 1.8vh, 16px);
}
.screen[hidden], .sheet[hidden], .sheet-back[hidden] { display: none; }
.screen.center { align-items: center; text-align: center; }

/* ---- the logo: a little grid of letter tiles with one word highlighted ---- */
.logo { display: grid; grid-template-columns: repeat(3, auto); gap: 5px; justify-content: center; }
.logo i {
  width: clamp(18px, 3.2vh, 24px); height: clamp(18px, 3.2vh, 24px); border-radius: 7px;
  background: var(--tile); box-shadow: 0 3px 0 var(--tile-edge);
  font: 900 clamp(11px, 1.9vh, 14px)/1 var(--font); font-style: normal; color: var(--tile-ink);
  display: grid; place-items: center;
}
.logo i.on { background: var(--odd); box-shadow: 0 3px 0 var(--odd-edge); color: #2a1c00; }
.logo-spin i.on { animation: blink 1.2s ease-in-out infinite; }
.logo-spin i.on:nth-child(5) { animation-delay: 0.15s; }
.logo-spin i.on:nth-child(9) { animation-delay: 0.3s; }
@keyframes blink { 50% { background: var(--tile); box-shadow: 0 3px 0 var(--tile-edge); color: var(--tile-ink); } }

/* ---- type ---- */
.title { font-size: clamp(1.8rem, 6vh, 2.5rem); line-height: 1; margin: clamp(8px, 1.6vh, 14px) 0 0; font-weight: 900; letter-spacing: -0.03em; text-align: center; }
.heading { font-size: 1.6rem; margin: 0; font-weight: 900; letter-spacing: -0.01em; }
.lede { margin: 0; font-size: 1.05rem; color: var(--muted); }
.date { margin: 6px 0 0; text-align: center; color: var(--muted); font-weight: 700; }
.quiet { margin: 0; color: var(--muted); }
.small { font-size: 0.9rem; }
.center-text { text-align: center; }

/* ---- buttons ---- */
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--odd); outline-offset: 3px; }
.big {
  appearance: none; border: 0; width: 100%;
  border-radius: 16px;
  background: var(--blue);
  box-shadow: 0 5px 0 var(--blue-edge);
  color: #fff;
  font-size: clamp(1.05rem, 2.6vh, 1.25rem); font-weight: 900;
  padding: clamp(11px, 2vh, 16px) 20px;
  margin-bottom: 5px;
  transition: transform 0.06s, box-shadow 0.06s;
}
.big:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-edge); }
.big:disabled { opacity: 0.6; }
.big.done-btn { background: var(--surface); color: var(--ink); box-shadow: 0 5px 0 var(--surface-edge); border: 1.5px solid var(--surface-edge); }
.soft {
  appearance: none; flex: 1;
  border: 1.5px solid var(--surface-edge);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--surface-edge);
  padding: clamp(9px, 1.7vh, 13px) 12px; font-weight: 800;
  margin-bottom: 4px;
}
.soft:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--surface-edge); }
.link { appearance: none; border: 0; background: none; color: var(--muted); font-weight: 700; padding: 8px; }
.icon {
  appearance: none; width: 40px; height: 40px; border-radius: 12px;
  border: 1.5px solid var(--surface-edge); background: var(--surface);
  display: grid; place-items: center; fill: var(--ink);
}

/* ---- menu ---- */
.brand { padding: 0; flex: none; }
.today-card {
  background: var(--surface);
  border: 1.5px solid var(--surface-edge);
  border-radius: 20px;
  padding: clamp(10px, 2vh, 16px);
  display: grid; gap: clamp(8px, 1.4vh, 12px);
  flex: none;
}
.menu-row { flex: none; }
.today-line { margin: 0; text-align: center; font-weight: 700; color: var(--muted); }
.today-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.menu-row { display: flex; gap: 10px; }
.panel {
  background: var(--surface);
  border: 1.5px solid var(--surface-edge);
  border-radius: 20px;
  padding: clamp(10px, 1.8vh, 14px) 16px;
  display: flex; flex-direction: column; gap: clamp(6px, 1.2vh, 10px);
  min-height: 0;
  flex: 0 1 auto;
}
.panel-h { margin: 0; font-size: 1.05rem; font-weight: 900; }
/* only scrolls if a huge group won't fit, which a small server never reaches */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(5px, 1vh, 8px); min-height: 0; overflow-y: auto; }
.people li { display: flex; align-items: center; gap: 10px; font-weight: 700; min-width: 0; }
.people .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .face {
  width: clamp(26px, 4vh, 34px); height: clamp(26px, 4vh, 34px); border-radius: 10px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  font-size: 0.85rem; font-weight: 900; color: #fff;
}
.people .face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.people .state { margin-left: auto; font-size: 0.9rem; color: var(--muted); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.people .state.is-done { color: var(--right); }
.people .state.is-playing { color: var(--odd); }

/* ---- game ---- */
.game { justify-content: flex-start; }
.hud { display: flex; align-items: center; gap: 12px; flex: none; }
.progress { flex: 1; display: grid; gap: 6px; }
.round-label { font-weight: 800; font-size: 0.95rem; color: var(--muted); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.bars li { height: 7px; border-radius: 4px; background: var(--surface-edge); }
.bars li.done { background: var(--right); }
.bars li.now { background: var(--odd); }
.penalty {
  font-weight: 900; color: #fff; background: var(--wrong);
  border-radius: 999px; padding: 3px 10px; font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.clock-wrap { display: flex; justify-content: center; flex: none; }
.clock {
  margin: 0;
  font-size: min(17vw, clamp(2.2rem, 8.5vh, 4.4rem));
  font-weight: 900; line-height: 1; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.clock.frozen { color: var(--muted); }
.prompt { margin: -4px 0 0; text-align: center; color: var(--muted); font-weight: 700; font-size: clamp(0.85rem, 2vh, 1rem); flex: none; }

.tiles {
  flex: 1 1 auto; min-height: 0; max-height: 470px;
  display: grid; grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: clamp(6px, 1.4vh, 12px);
  padding-bottom: 5px;
}
.tile {
  appearance: none; width: 100%;
  min-height: 0; height: 100%; padding: 4px 16px;
  border: 0; border-radius: clamp(12px, 2vh, 16px);
  background: var(--tile); color: var(--tile-ink);
  box-shadow: 0 5px 0 var(--tile-edge);
  font-size: clamp(1rem, 3.1vh, 1.35rem); font-weight: 900; line-height: 1.1;
  touch-action: manipulation;
  transition: transform 0.06s, box-shadow 0.06s;
}
.tile:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--tile-edge); }
.tile:disabled { cursor: default; }
.tile.wrong {
  background: transparent; color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--surface-edge);
  text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--wrong);
  transform: translateY(5px);
}
.tile.right {
  background: var(--odd); color: #2a1c00;
  box-shadow: 0 5px 0 var(--odd-edge);
  animation: pop 0.35s ease-out;
}
.tile.shake { animation: shake 0.3s; }
@keyframes shake {
  20% { transform: translate(-7px, 5px); }
  60% { transform: translate(7px, 5px); }
}
@keyframes pop {
  40% { transform: scale(1.05) rotate(-2deg); }
}
.tiles.fresh .tile { animation: rise 0.25s ease-out both; }
.tiles.fresh .tile:nth-child(2) { animation-delay: 0.03s; }
.tiles.fresh .tile:nth-child(3) { animation-delay: 0.06s; }
.tiles.fresh .tile:nth-child(4) { animation-delay: 0.09s; }
.tiles.fresh .tile:nth-child(5) { animation-delay: 0.12s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* keeps its space even when empty, so nothing jumps */
.toast {
  flex: none;
  min-height: calc(3 * 1.3em + 2 * clamp(7px, 1.4vh, 12px));
  line-height: 1.3;
  font-size: clamp(0.78rem, 1.9vh, 0.95rem) !important;
  margin: 0;
  padding: clamp(7px, 1.4vh, 12px) 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid var(--surface-edge);
  border-left: 6px solid var(--right);
  color: var(--muted); font-size: 0.95rem;
}
.toast b { color: var(--ink); }

/* ---- paused ---- */
.pause-badge {
  width: 76px; height: 76px; border-radius: 22px;
  background: var(--odd); box-shadow: 0 6px 0 var(--odd-edge);
  display: grid; place-items: center; fill: #2a1c00;
  transform: rotate(-6deg);
}

/* ---- results ---- */
.done-head { text-align: center; display: grid; gap: clamp(3px, 0.8vh, 6px); justify-items: center; flex: none; }
.done-buttons { display: grid; gap: 8px; flex: none; }
.final {
  margin: 2px 0 0;
  font-size: min(17vw, clamp(2.4rem, 9vh, 4.6rem));
  font-weight: 900; line-height: 1; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.breakdown { margin: 0; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.stamp {
  margin-top: 4px; padding: 4px 12px; border-radius: 999px;
  background: var(--right); color: #fff; font-weight: 900; font-size: 0.9rem;
  transform: rotate(-3deg);
}
.stamp[hidden] { display: none; }
.review {
  margin: 0; padding: 0; list-style: none;
  display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: clamp(5px, 1.2vh, 10px);
  flex: 1 1 auto; min-height: 0; max-height: 330px;
}
.review li { min-height: 0; }
.review button {
  appearance: none; width: 100%; height: 100%; min-height: 0; text-align: left;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--surface-edge);
  border-radius: 14px;
  font-weight: 800; font-size: clamp(0.85rem, 2.2vh, 1rem);
}
.review .num { color: var(--muted); font-weight: 800; flex: none; }
.review .ans {
  padding: 2px 9px; border-radius: 8px; background: var(--odd); color: #2a1c00;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.review .time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; white-space: nowrap; flex: none; }
.review .time .x { color: var(--wrong); }
.words { display: flex; flex-wrap: wrap; gap: 6px; }
.words .w {
  padding: 4px 10px; border-radius: 8px;
  background: var(--bg); color: var(--muted);
  font-weight: 700;
}
.words .w.odd { background: var(--odd); color: #2a1c00; }
.why { margin: 0; color: var(--muted); }
.why b { color: var(--ink); }

/* ---- sheets ---- */
.sheet-back { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  max-height: 92vh; max-height: 92dvh; overflow: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px max(20px, env(safe-area-inset-bottom));
  display: grid; gap: 14px;
  animation: slide 0.22s ease-out;
}
@keyframes slide { from { transform: translateY(40px); opacity: 0; } }
.sheet { gap: clamp(8px, 1.6vh, 14px); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--bg); border-radius: 16px; padding: 12px 14px;
  display: grid; gap: 2px;
}
.stat .n { font-size: clamp(1.3rem, 3.6vh, 1.7rem); font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- terms and privacy pages ---- */
html:has(.doc), html:has(.doc) body { overflow: auto; height: auto; }
.doc { max-width: 640px; margin: 0 auto; padding: 32px 16px 48px; -webkit-user-select: text; user-select: text; }
.doc h1 { font-size: 2rem; margin: 0 0 4px; }
.doc h2 { font-size: 1.2rem; margin: 28px 0 6px; }
.doc p, .doc li { color: var(--ink); }
.doc .quiet { margin-bottom: 20px; }
.doc a { color: var(--blue); }

/* the explanation box keeps its space between rounds */
.toast[hidden] { display: block; visibility: hidden; }

/* results rows look and feel like the game's other buttons, with an arrow */
.review button {
  box-shadow: 0 4px 0 var(--surface-edge);
  margin-bottom: 4px;
  transition: transform 0.06s, box-shadow 0.06s;
}
.review button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--surface-edge); }
.review .chev {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: var(--muted); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}

/* centred titles everywhere */
.heading, .panel-h { text-align: center; }

/* how to play: one short line per rule, each with a small tile icon */
.rules-list { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(8px, 1.6vh, 14px); }
.rules-list li { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: clamp(0.9rem, 2.1vh, 1rem); line-height: 1.3; }
.rules-list b { color: var(--ink); }
.ri {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  background: var(--tile); box-shadow: 0 4px 0 var(--tile-edge);
  display: grid; place-items: center;
}
.ri svg { width: 22px; height: 22px; fill: none; stroke: var(--tile-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ri-odd { background: var(--odd); box-shadow: 0 4px 0 var(--odd-edge); transform: rotate(-8deg); }
.ri-wrong { background: var(--wrong); box-shadow: 0 4px 0 #b7473a; }
.ri-wrong svg { stroke: #fff; }
.ri:not(.ri-odd):not(.ri-wrong) { border: 1.5px solid var(--surface-edge); }
#stats .quiet, .people .quiet { text-align: center; width: 100%; }

/* round details: the five words as a neat stack of mini tiles, like the game */
#round-sheet .heading { margin-bottom: -2px; }
#round-words { display: grid; grid-template-columns: 1fr; gap: 8px; }
#round-words .w {
  display: block; text-align: center;
  padding: clamp(7px, 1.4vh, 10px) 12px; border-radius: 12px;
  background: var(--tile); color: var(--tile-ink);
  box-shadow: 0 3px 0 var(--tile-edge); margin-bottom: 3px;
  font-weight: 900; font-size: clamp(0.95rem, 2.3vh, 1.1rem);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#round-words .w.odd { background: var(--odd); color: #2a1c00; box-shadow: 0 3px 0 var(--odd-edge); }
#round-why { text-align: center; }

/* one feel throughout: headings, single lines and messages are centred;
   lists that line up in columns (rules, players, rounds) stay left-aligned so they're easy to scan */
.lede, .quiet, .date, .today-line, .prompt, .breakdown, .why { text-align: center; }
#next-board { text-align: center; }
.round-label { text-align: center; }
.toast { text-align: center; border-left: 1.5px solid var(--surface-edge); border-top: 4px solid var(--right); }
.stat { justify-items: center; text-align: center; }
/* keep "Round 3 of 5" in the true middle of the screen */
.hud { display: grid; grid-template-columns: 56px 1fr 56px; }
.hud .penalty { justify-self: end; }
.hud .penalty[hidden] { display: none; }

/* testing mode: a strip across the top of every screen */
.test-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: calc(env(safe-area-inset-top) + 5px) 12px 5px;
  background: repeating-linear-gradient(-45deg, var(--odd) 0 14px, #f5c25c 14px 28px);
  color: #2b1d00; font-weight: 900; font-size: 13px; letter-spacing: .04em;
  text-align: center; text-transform: uppercase; box-shadow: 0 2px 0 var(--odd-edge);
}
.test-banner[hidden] { display: none; }
body.testing #app { padding-top: calc(env(safe-area-inset-top) + 36px); }

/* leaderboard */
.menu-row .soft { flex: 1; min-width: 0; padding-left: 4px; padding-right: 4px; font-size: clamp(0.82rem, 3.9vw, 1rem); white-space: nowrap; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 2px solid var(--surface-edge); }
.tab {
  flex: 1; border: 0; border-radius: 10px; padding: 8px 0; font: inherit; font-weight: 900;
  background: transparent; color: var(--muted); cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 0 var(--surface-edge); }
.ranks { max-height: 46vh; }
.ranks .pos { width: 1.6em; text-align: center; font-weight: 900; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.ranks .pos.p1 { color: var(--odd); }
.ranks .tag { font-size: 0.72rem; font-weight: 900; color: var(--odd-edge); margin-left: 4px; }

/* ---- panels (How to play, stats, leaderboard, round review) fill the screen ---- */
.sheet-back { display: none !important; }
.sheet {
  top: 0; bottom: 0; left: 0; right: 0; z-index: 40;
  max-width: none; max-height: none; height: 100vh; height: 100dvh;
  border-radius: 0; overflow: hidden;
  padding: max(clamp(10px, 2.2vh, 20px), env(safe-area-inset-top)) max(16px, calc((100% - 440px) / 2)) max(20px, env(safe-area-inset-bottom));
  align-content: start; grid-template-rows: auto;
  animation: slide-in 0.2s ease-out;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.back {
  justify-self: start; display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: var(--bg); color: var(--ink); font: inherit; font-weight: 900;
  padding: 5px 12px 5px 6px; margin-left: 0; min-height: 32px; box-sizing: border-box; border-radius: 12px; cursor: pointer;
}
.back svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.back:active { filter: brightness(1.2); }
.ranks { max-height: none; min-height: 0; overflow: hidden; }

/* test banner sits at the bottom, clear of Discord's own buttons at the top */
.test-banner { top: auto; bottom: 0; padding: 5px 12px calc(env(safe-area-inset-bottom) + 5px); box-shadow: 0 -2px 0 var(--odd-edge); }
body.testing #app { padding-top: max(clamp(10px, 2.2vh, 20px), env(safe-area-inset-top)); padding-bottom: calc(env(safe-area-inset-bottom) + 36px); }
body.testing .sheet { padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }

/* the round's difficulty, shown beside the question */
.level {
  display: inline-block; margin-right: 8px; padding: 1px 10px; border-radius: 999px;
  font-size: 0.85em; font-weight: 900; color: #fff; vertical-align: 1px;
}
.level[hidden] { display: none; }
.level.easy { background: #2e9b63; }
.level.medium { background: #5b86f0; }
.level.hard { background: #e2604f; }

/* ---- tutorial ---- */
.tut { justify-content: flex-start; }
.tut-top { display: flex; align-items: center; justify-content: space-between; flex: none; min-height: 40px; }
.tut-dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.tut-dots li { width: 8px; height: 8px; border-radius: 4px; background: var(--surface-edge); transition: width 0.2s; }
.tut-dots li.on { width: 22px; background: var(--odd); }
.tut-dots li.past { background: var(--right); }
.tut-body { display: grid; gap: 6px; text-align: center; flex: none; }
.tut-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: clamp(6px, 1.4vh, 12px); }
.tut-stage .tiles { flex: 1 1 auto; max-height: 380px; }
.tut-stage .tile { font-size: clamp(0.95rem, 2.7vh, 1.2rem); }
.tut-pills { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tut-pills .level { margin: 0; font-size: 1rem; padding: 4px 14px; }
.tut-card {
  background: var(--surface); border: 1.5px solid var(--surface-edge); border-radius: 18px;
  padding: 14px 16px; display: grid; gap: 10px;
}
.tut-card .row { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.tut-card .row .ri { flex: none; }
.tut-sum { display: flex; justify-content: center; align-items: baseline; gap: 8px; flex-wrap: wrap; font-weight: 900; font-size: 1.15rem; }
.tut-sum .pen { color: var(--wrong); }
.tut-sum .tot { color: var(--right); }
.tut-note { margin: 0; min-height: 2.9em; text-align: center; font-weight: 700; color: var(--muted); flex: none; }
.tut-note.good { color: var(--right-edge); }
.tut-note.bad { color: var(--wrong); }
#tut-again { width: 100%; }

/* Discord on phones covers the top of the game with its own bar: keep clear of it */
html.discord-mobile #app,
html.discord-mobile body.testing #app { padding-top: calc(env(safe-area-inset-top) + 60px); }
html.discord-mobile .sheet { padding-top: calc(env(safe-area-inset-top) + 60px); }

/* ================================================================ word search */
:root { --extreme: #7b3fd1; }
.level.extreme { background: var(--extreme); }

/* the HUD: pause, words found, today's level */
.hud .found-count { justify-self: center; font-weight: 900; color: var(--muted); font-size: 0.95rem; }
.hud .level { justify-self: end; margin: 0; white-space: nowrap; font-size: 0.8rem; }
.hud { grid-template-columns: 56px 1fr auto; }
.theme-line { margin: -4px 0 0; text-align: center; color: var(--muted); font-weight: 700; font-size: clamp(0.85rem, 2vh, 1rem); flex: none; }
.theme-line b { color: var(--ink); }

/* the board fills whatever room is left; JS keeps it square */
.board-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board {
  position: relative; flex: none;
  background: var(--tile); border-radius: clamp(12px, 2vh, 18px);
  box-shadow: 0 5px 0 var(--tile-edge);
  touch-action: none; cursor: crosshair;
  margin-bottom: 5px;
}
.board svg { position: absolute; inset: 4%; width: 92%; height: 92%; overflow: visible; pointer-events: none; }
.board .cells {
  position: absolute; inset: 4%;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  pointer-events: none;
}
.board .cells span {
  display: grid; place-items: center;
  color: var(--tile-ink); font-weight: 900; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.board .cells span.anchor { color: #fff; }
.board line { stroke-linecap: round; }
.board line.found { opacity: 0.75; }
.board line.drag { opacity: 0.55; }
.board line.miss { opacity: 0.6; animation: fade 0.45s ease-out forwards; }
.board line.pop { animation: pop-line 0.3s ease-out; }
.board circle.anchor { fill: var(--blue); }
@keyframes fade { to { opacity: 0; } }
@keyframes pop-line { from { opacity: 1; stroke-width: 1; } }
.board.fresh { animation: rise 0.3s ease-out both; }

/* the words to find */
.word-list {
  flex: none; list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(4px, 0.9vh, 7px);
}
.word-list li {
  padding: clamp(2px, 0.5vh, 4px) 9px; border-radius: 9px;
  background: var(--surface); border: 1.5px solid var(--surface-edge);
  font-weight: 900; font-size: clamp(0.78rem, 1.9vh, 0.95rem); letter-spacing: 0.03em;
  transition: background 0.2s, color 0.2s;
}
.word-list li.got { color: #1a1300; text-decoration: line-through; text-decoration-thickness: 2px; border-color: transparent; }
.word-list li .t { font-weight: 700; margin-left: 6px; opacity: 0.8; font-variant-numeric: tabular-nums; text-decoration: none; display: inline-block; }

/* results: the starting board with every word marked, and your times */
#done .board-wrap { flex: 1 1 auto; }
#done .board { cursor: default; }
.splits { flex: none; }
.done-meta { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.done-meta .level { margin: 0; }
.done-meta .theme { font-weight: 800; color: var(--muted); }

/* menu: today's level beside the line */
.today-line .level { margin: 0 4px; font-size: 0.85rem; }

/* tutorial boards */
.tut-stage .board-wrap { flex: 1 1 auto; max-height: 330px; }
.tut-sum .ok { color: var(--right); }
.levels-list { display: grid; gap: 8px; }
.levels-list .row { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--muted); }
.levels-list .row .level { flex: none; width: 92px; text-align: center; margin: 0; }

/* how to play: the highlighter icon */
.ri-hi { background: var(--odd); box-shadow: 0 4px 0 var(--odd-edge); transform: rotate(-8deg); }
.ri-hi svg { stroke: #2a1c00; }

/* the game clock: small and quiet, so it doesn't pull your eye off the grid */
#game .clock {
  font-size: clamp(1.25rem, 3.4vh, 1.6rem);
  letter-spacing: -0.01em;
  color: var(--muted);
}
#game .theme-line { margin-top: -2px; }
/* the clock is hidden while playing; your time shows at the end */
#game .clock-wrap { display: none; }

/* ---- shared tidy-up: key information sits in the middle of the screen ---- */
/* tutorial: progress dots in the middle, Skip on the right */
.tut-top { display: grid; grid-template-columns: 1fr auto 1fr; }
.tut-top .tut-dots { justify-self: center; }
.tut-top #tut-skip { justify-self: end; }
.tut-stage { align-items: stretch; text-align: center; }
.tut-card .quiet { text-align: center; }
.lede[hidden], .breakdown[hidden] { display: none; }
/* How to play, stats and round panels: Back at the top, the content centred below it
   (the leaderboard stays top-aligned so the tabs don't jump when lists change length) */
#rules:not([hidden]), #stats:not([hidden]), #round-sheet:not([hidden]) { display: flex; flex-direction: column; }
#rules > .back, #stats > .back, #round-sheet > .back { align-self: flex-start; flex: none; }
#round-sheet > .back + * { margin-top: auto; }   /* (How to play and Stats are top-aligned like the other screens) */
#round-sheet > :last-child { margin-bottom: auto; }
/* the HUD keeps "3 of 8 found" in the true middle; today's level sits beside the theme, like Odd One Out's question line */
.hud { grid-template-columns: 56px 1fr 56px; }
.theme-line .level { font-size: 0.85em; }
#rules #tut-again { flex: none; }
.tut-card .row, .levels-list .row { text-align: left; }

/* tutorial: a preview of the results screen */
.tut-result { justify-items: center; text-align: center; gap: 6px; padding: 18px 16px; }
.tut-result .k { font-weight: 800; color: var(--muted); }
.tut-result .tt { font-size: clamp(2.2rem, 7vh, 3.2rem); font-weight: 900; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tut-result .word-list { margin-top: 8px; }
/* tutorial: Back on the left, Next on the right */
.tut-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: none; }
.big.secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--surface-edge); box-shadow: 0 5px 0 var(--surface-edge); }
.big.secondary:active { box-shadow: 0 1px 0 var(--surface-edge); }
.big.secondary:disabled { opacity: 0.4; }

.today-line[hidden] { display: none; }
/* the top bar: pause on the left, today's level and theme in the middle */
.hud .theme-line { margin: 0; justify-self: center; }
.hud .theme-line .level { margin-right: 10px; }

/* stats: small grouped rows, so the whole page fits without scrolling */
#stat-grid { display: grid; gap: clamp(8px, 1.6vh, 14px); grid-template-columns: none; }
.stat-group h3 { margin: 0 0 6px; font-size: 0.8rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.stat-row { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 8px; }
.stat-row .stat { padding: clamp(6px, 1.2vh, 10px) 6px; border-radius: 14px; }
.stat-row .stat .n { font-size: clamp(1.05rem, 2.8vh, 1.35rem); }
.stat-row .stat .k { font-size: 0.78rem; line-height: 1.2; }
.stat-row .stat .k.lvl { color: #fff; padding: 0 8px; border-radius: 999px; }
.stat-row .stat .k.lvl.easy { background: #2e9b63; }
.stat-row .stat .k.lvl.medium { background: #5b86f0; }
.stat-row .stat .k.lvl.hard { background: #e2604f; }
.stat-row .stat .k.lvl { white-space: nowrap; font-size: 0.72rem; padding: 0 6px; }

/* test mode: choose the level */
.pick-level { display: grid; gap: 6px; }
.pick-level[hidden] { display: none; }
.pick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pick-row .level {
  margin: 0; border: 0; cursor: pointer; padding: 7px 2px; font-size: clamp(0.72rem, 3.3vw, 0.85rem);
  white-space: nowrap; opacity: 0.45; box-shadow: 0 3px 0 rgb(0 0 0 / 0.25);
}
.pick-row .level[aria-pressed="true"] { opacity: 1; outline: 2.5px solid var(--ink); outline-offset: 2px; }
.pick-row .level:disabled { cursor: wait; }

/* ---- short screens (a phone on its side): logo and title sit side by side so the menu still fits ---- */
@media (max-height: 430px) {
  .menu .brand { display: grid; grid-template-columns: auto auto; column-gap: 14px; justify-content: center; align-items: center; }
  .menu .brand .logo { grid-row: 1 / 3; }
  .menu .brand .title { margin: 0; text-align: left; font-size: 1.6rem; align-self: end; }
  .menu .brand .date { margin: 2px 0 0; text-align: left; align-self: start; }
}

/* ---- big screens (desktop, tablet): the whole game grows with the window instead of staying phone-sized ---- */
@media (min-height: 800px) and (min-width: 760px) {
  html { font-size: clamp(16px, 2vh, 26px); }
  body { font-size: clamp(17px, 2.1vh, 28px); }
  .screen { max-width: clamp(440px, 56vh, 760px); }
  .sheet { padding-inline: max(16px, calc((100% - clamp(440px, 56vh, 760px)) / 2)); }
}

/* ---- settings ---- */
.screen.menu { position: relative; }
.cog { position: absolute; top: 0; right: 0; color: var(--ink); }
.cog svg { fill: none; stroke: currentColor; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; font-weight: 800; }
.switch {
  appearance: none; border: 0; padding: 0; flex: none; position: relative;
  width: 52px; height: 30px; border-radius: 15px; background: var(--surface-edge); transition: background 0.15s;
}
.switch i {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 0 rgb(0 0 0 / 0.18); transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--blue, var(--accent)); }
.switch[aria-checked="true"] i { transform: translateX(22px); }

:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
#settings .soft { flex: none; height: auto; }

/* sheets scroll when their content doesn't fit (a long leaderboard, a phone on its side) rather than being cut off */
.sheet { overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.ranks { overflow-y: auto; }
@media (max-height: 480px) {
  #stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  #stat-grid > *, .stat-group, .stat-row, .stat { min-width: 0; }
  .stat .n { font-size: 1.15rem; }
  .stat .k { font-size: 0.78rem; }
}

/* the tutorial on a short screen: tighter text and buttons so the steps still fit */
@media (max-height: 480px) {
  .tut { gap: 6px; }
  .tut .heading { font-size: 1.25rem; }
  .tut .lede { font-size: 0.95rem; line-height: 1.3; }
  .tut-nav .big { padding-top: 9px; padding-bottom: 9px; min-height: 0; }
  .tut-note { min-height: 0; margin: 0; }
}
.tab[hidden] { display: none; }
.tabs[hidden] { display: none; }

/* other games, in Settings */
.other-h { margin: 6px 0 0; font-size: 0.85rem; font-weight: 800; color: var(--muted, inherit); opacity: 0.75; text-align: center; }
.other-games { display: flex; justify-content: center; gap: 14px; flex: none; }
.other-games button { flex: none; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 22%; line-height: 0; }
.other-games img { width: clamp(56px, 20vw, 76px); height: auto; aspect-ratio: 1; border-radius: 22%; display: block; box-shadow: 0 3px 0 rgba(0,0,0,0.25); }
.other-games button:active { transform: translateY(2px); }
.other-games button { width: auto; height: auto; min-height: 0; min-width: 0; box-shadow: none; background: none; }
.other-h { margin-top: auto; }

/* shown on the first tutorial step for players who have been through an older tutorial */
.tut-updated { margin: 0 auto; padding: 5px 12px; border-radius: 999px; background: var(--surface-edge); font-size: 0.82rem; font-weight: 800; text-align: center; color: var(--ink); }
.tut-updated[hidden] { display: none; }
@media (max-height: 480px) { .tut-updated { padding: 2px 10px; font-size: 0.72rem; } }

/* ---- colour-blind mode: blue and orange instead of green and red, with a mark beside the colour ---- */
:root[data-cb="1"] { --good: #0072b2; --bad: #d55e00; --right: #0072b2; --right-edge: #00507d; --wrong: #d55e00; }

.rank-line { margin: 0; text-align: center; font-weight: 900; color: var(--accent, var(--blue)); font-variant-numeric: tabular-nums; }

/* ---- practice: a blue strip along the bottom ---- */
.practice-banner { background: repeating-linear-gradient(-45deg, #3e6fe0 0 14px, #5b86f0 14px 28px); color: #fff; box-shadow: 0 -2px 0 #2a52b3; }
body.practicing #app { padding-bottom: calc(env(safe-area-inset-bottom) + 36px); }
body.practicing .sheet { padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }

/* Practice: a quiet button, almost the colour of the page, so the eye stays on Play and Results */
.practice-btn {
  flex: none; width: 100%; box-shadow: none; font-weight: 700; color: var(--muted);
  background: color-mix(in srgb, var(--bg) 88%, var(--surface)); border-color: color-mix(in srgb, var(--bg) 80%, var(--surface-edge));
}
.practice-btn:active:not(:disabled) { transform: none; box-shadow: none; background: var(--surface); }

/* ---- the board was rebuilt: a small tab on the right edge, and the page it opens ---- */
.notice-tab {
  position: fixed; right: 0; top: 62px;
  width: 32px; height: 44px; padding: 0;
  border: 0; border-radius: 14px 0 0 14px;
  background: #e2483d; color: #fff; font-size: 1.5rem; font-weight: 900; line-height: 1;
  box-shadow: -2px 3px 0 rgba(0, 0, 0, 0.35);
  z-index: 5;
}
.notice-tab:active { transform: translateX(2px); }
.notice-tab[hidden] { display: none; }
.screen.notice { justify-content: space-between; }
.notice-body { flex: 1; display: grid; align-content: center; justify-items: center; gap: 14px; }
.notice-badge {
  width: 76px; height: 76px; border-radius: 22px;
  background: #e2483d; box-shadow: 0 6px 0 #a42e26;
  display: grid; place-items: center; color: #fff; font-size: 3rem; font-weight: 900;
}

/* Settings: 'Our other games' pinned to the bottom, the same in every game */
#settings:not([hidden]) { display: flex; flex-direction: column; }
#settings > .back { align-self: flex-start; flex: none; }
#settings > * { flex: none; }

/* Practice: a pop-up with the game's levels, like the language pop-up */
.practice-pop { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.practice-pop[hidden] { display: none; }
.practice-card { background: var(--surface); border-radius: 22px; padding: 18px; width: 100%; max-width: 340px; }
.practice-card h3 { margin: 0 0 14px; text-align: center; font-weight: 900; font-size: 1.3rem; color: var(--ink); }
.practice-row { display: grid; gap: 10px; }
.practice-row button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--surface-edge); background: var(--bg); color: var(--ink); font: inherit; font-weight: 900; font-size: 1.1rem; text-align: left; cursor: pointer; }
.practice-row button:active { transform: translateY(1px); }
.practice-row i { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* language: the flag on the leaderboard, and the pop-up of languages opened from Settings */
.lb-flag { position: absolute; top: calc(max(clamp(10px, 2.2vh, 20px), env(safe-area-inset-top))); right: max(16px, calc((100% - 440px) / 2)); z-index: 3; line-height: 0; padding: 7px 8px; border: 0; border-radius: 12px; background: var(--bg); cursor: pointer; }
.lb-flag svg { width: 30px; height: 20px; border-radius: 3px; display: block; }
.lb-drop { position: absolute; top: calc(max(clamp(10px, 2.2vh, 20px), env(safe-area-inset-top)) + 40px); right: max(16px, calc((100% - 440px) / 2)); z-index: 4; display: grid; gap: 6px; padding: 8px; background: var(--surface); border: 2px solid var(--surface-edge); border-radius: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .3); }
.lb-drop[hidden] { display: none; }
.lb-opt { border: 3px solid transparent; background: var(--bg); border-radius: 10px; padding: 6px 8px; line-height: 0; cursor: pointer; }
.lb-opt svg { width: 38px; height: 25px; border-radius: 3px; display: block; }
.lb-opt[aria-pressed="true"] { border-color: var(--blue); }

/* Language: a button like Support, opening a pop-up of the four languages in a 2x2 grid */
#lang-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.lang-cur svg { width: 26px; height: 18px; border-radius: 3px; display: block; }
.lang-pop { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.lang-pop[hidden] { display: none; }
.lang-card { background: var(--surface); border-radius: 22px; padding: 18px; width: 100%; max-width: 340px; }
.lang-card h3 { margin: 0 0 14px; text-align: center; font-weight: 900; font-size: 1.3rem; color: var(--ink); }
.lang-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0; }
.flag { display: grid; justify-items: center; gap: 8px; padding: 14px 8px; border-radius: 16px; border: 3px solid transparent; background: var(--bg); color: var(--ink); font: inherit; font-weight: 800; line-height: 1.2; opacity: 1; cursor: pointer; }
.flag svg { width: 64px; height: 43px; border-radius: 6px; display: block; }
.flag[aria-pressed="true"] { border-color: var(--accent, var(--blue, #5b86f0)); }

html.discord-mobile .lb-flag { top: calc(env(safe-area-inset-top) + 60px); }
html.discord-mobile .lb-drop { top: calc(env(safe-area-inset-top) + 100px); }
