:root {
  color-scheme: light dark;
  --bg: #f4f7ef;
  --bg-2: #e6eedd;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --ink: #17251d;
  --muted: #56685d;
  --line: rgba(23, 37, 29, 0.12);
  --accent: #157a52; /* white button text on it is 5.4:1 */
  --accent-deep: #0f6342;
  --accent-ink: #ffffff;
  --cell-ink: #1d2b23;
  --sel: #157a52;
  --hint: #e0692e;
  --good: #2b9a60;
  --gold: #ffd166;
  --shadow: rgba(20, 60, 40, 0.16);
  --mark-opacity: 0.42;
  --display: Fredoka, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --text: Nunito, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a16;
    --bg-2: #18231d;
    --panel: rgba(34, 48, 40, 0.74);
    --panel-solid: #1f2b25;
    --ink: #e7f1ea;
    --muted: #a6b8ad;
    --line: rgba(231, 241, 234, 0.12);
    --accent: #4fcf93;
    --accent-deep: #2fae74;
    --accent-ink: #072215;
    --cell-ink: #e7f1ea;
    --sel: #4fcf93;
    --hint: #ff9a5c;
    --good: #5bd394;
    --shadow: rgba(0, 0, 0, 0.4);
    --mark-opacity: 0.5;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font: 600 16px/1.4 var(--text);
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(180deg, var(--bg), var(--bg-2)) fixed var(--bg);
}
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.app {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------------------------------------------------------------- header */
.logo { margin: 0; font: 700 2.1rem/1 var(--display); color: var(--accent-deep); letter-spacing: 0.01em; }
@media (prefers-color-scheme: dark) { .logo { color: var(--accent); } }
.day { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }

/* ---------------------------------------------------------------- theme and clock */
.play { display: flex; flex-direction: column; gap: 10px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.theme { margin: 0; display: flex; flex-direction: column; min-width: 0; }
.theme small { font-size: 0.68rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.theme b { font: 600 1.35rem/1.15 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock {
  margin: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font: 600 1.1rem/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.clock svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.clock.done { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.clock.done svg { stroke: currentColor; }

/* ---------------------------------------------------------------- board */
.stage { position: relative; }
.board {
  --n: 10;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 2%;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px -24px var(--shadow);
  container-type: inline-size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
.board:focus-visible { outline-offset: 3px; }
.grid, .marks { position: absolute; inset: 2%; width: 96%; height: 96%; }
.grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); }
.marks { overflow: visible; }
.cell {
  display: grid; place-items: center;
  font: 600 calc(96cqi / var(--n) * 0.56) / 1 var(--display);
  color: var(--cell-ink);
  position: relative;
  transition: color 0.15s, transform 0.15s;
}
.cell.on { color: var(--accent-ink); transform: scale(1.08); }
@media (prefers-color-scheme: dark) { .cell.on { color: #072215; } }
.cell.cur::after { content: ''; position: absolute; inset: 8%; border-radius: 50%; border: 2px dashed var(--accent); }
.marks line { stroke-linecap: round; }
.marks .found { stroke-opacity: var(--mark-opacity); }
.marks .found.fresh { animation: ink 0.35s ease-out; }
@keyframes ink { from { stroke-opacity: 0.9; stroke-width: 0.95; } }
.marks .live { stroke: var(--sel); stroke-opacity: 0.85; }
.marks .miss { stroke: var(--muted); stroke-opacity: 0.4; animation: fade 0.45s ease forwards; }
@keyframes fade { to { stroke-opacity: 0; } }
.marks .anchor { fill: var(--sel); fill-opacity: 0.85; }
.marks .ring { fill: none; stroke: var(--hint); stroke-width: 0.08; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { stroke-opacity: 0.35; } }
.board.won .cell { animation: wave 0.6s ease both; animation-delay: calc(var(--d) * 30ms); }
@keyframes wave { 40% { transform: translateY(-14%) scale(1.1); } }
.stage.veiled .board { filter: blur(9px); pointer-events: none; }
.stage.veiled .board * { visibility: hidden; }

/* the curtain over an unstarted or paused grid */
.curtain {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 24px;
  text-align: center;
  border-radius: 20px;
}
.curtain[hidden] { display: none; }
.curtain h2 { margin: 0; font: 700 1.9rem/1.1 var(--display); color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .curtain h2 { color: var(--accent); } }
.curtain p { margin: 0 0 10px; max-width: 300px; color: var(--muted); }
.curtain .kicker { margin: 0; }
.curtain .btn { min-width: 150px; }

.pick { margin: -2px 0 0; min-height: 1.6em; text-align: center; font: 600 1.15rem/1.4 var(--display); letter-spacing: 0.18em; color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .pick { color: var(--accent); } }

/* ---------------------------------------------------------------- word list */
.words-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.words li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font: 600 0.95rem/1.2 var(--display);
  letter-spacing: 0.06em;
  transition: background 0.2s, color 0.2s;
}
.words li.got { background: transparent; color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.words li.got i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.words li.hinted:not(.got) { border-color: var(--hint); }
.words li.fresh { animation: pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { from { transform: scale(1.25); } }
.foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------------- buttons */
.btn.wide { margin-top: 16px; }
.section-h { margin: 4px 0 8px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

/* ---------------------------------------------------------------- dialogs */
@keyframes dlg { from { opacity: 0; transform: scale(0.95); } }
.lead { margin: 0 0 12px; }
.example { display: flex; align-items: center; justify-content: center; margin: 6px 0 14px; }
.mini { display: grid; place-items: center; width: 40px; height: 40px; font: 600 1.3rem/1 var(--display); }
.cap { display: flex; border-radius: 999px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.rules { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.95rem; font-weight: 600; }
.rule-note { margin: 12px 0 0; font-size: 0.9rem; }
.keys { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.9; }
.kicker { color: var(--muted); }
.res-time { margin: 4px 0 2px; text-align: center; font: 700 3rem/1 var(--display); font-variant-numeric: tabular-nums; }
.res-sub { margin: 0 0 10px; text-align: center; color: var(--muted); }
.res-words { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.res-words li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--line); font: 600 0.85rem/1.3 var(--display); letter-spacing: 0.05em; }
.res-words li i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.res-words li.h::after { content: '💡'; font-size: 0.75rem; }
.wd.today i { outline: 2px dashed var(--accent); outline-offset: -2px; }
.wd.won i { background: var(--accent); color: var(--accent-ink); }
.wd.hinted i { background: color-mix(in srgb, var(--accent) 40%, transparent); }

.toast { z-index: 10; }

@media (max-width: 380px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .board { border-radius: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .words li { font-size: 0.85rem; padding: 4px 9px; }
}
/* Landscape phones: the whole grid beside the words, sized by the height. */
@media (orientation: landscape) and (max-height: 540px) {
  .app { max-width: 920px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .play {
    display: grid;
    grid-template-columns: min(calc(100dvh - 92px), 55vw) 1fr;
    grid-template-areas: 'stage bar' 'stage pick' 'stage words' 'stage foot';
    grid-template-rows: auto auto 1fr auto;
    column-gap: 18px;
    row-gap: 6px;
    align-items: start;
  }
  .stage { grid-area: stage; }
  .bar { grid-area: bar; }
  .pick { grid-area: pick; text-align: left; }
  .words-wrap { grid-area: words; }
  .foot { grid-area: foot; }
}
/* the same for the site-wide Reduce motion setting (hub/prefs.js) */
