:root {
  color-scheme: light dark;
  --bg: #fbf3f8;
  --bg-2: #f1e1ee;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-solid: #ffffff;
  --ink: #2a1424;
  --muted: #6d5068;
  --line: rgba(42, 20, 36, 0.12);
  --accent: #be185d; /* white button text on it is 6.0:1 */
  --accent-deep: #9d174d;
  --accent-ink: #ffffff;
  --tile: #ffffff;
  --tile-side: #ecc9de;
  --tile-ink: #2a1424;
  --slot: rgba(42, 20, 36, 0.06);
  --placed: #fbd5ea;
  --placed-side: #e3a3c6;
  --locked: #ffd27a;
  --locked-side: #cf9a2c;
  --good: #2b9a60;
  --good-side: #1f7447;
  --bad: #dc4646;
  --shadow: rgba(110, 20, 70, 0.16);
  --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: #170f1c;
    --bg-2: #22142a;
    --panel: rgba(50, 32, 58, 0.74);
    --panel-solid: #2a1b31;
    --ink: #f8ecf5;
    --muted: #c3a9be;
    --line: rgba(248, 236, 245, 0.12);
    --accent: #f472b6; /* dark button text on it is 6.9:1 */
    --accent-deep: #ec4899;
    --accent-ink: #2a0a1c;
    --tile: #3a2742;
    --tile-side: #0d0710;
    --tile-ink: #f8ecf5;
    --slot: rgba(248, 236, 245, 0.06);
    --placed: #5b2d52;
    --placed-side: #22101f;
    --locked: #e0a933;
    --locked-side: #7a5410;
    --good: #5bd394;
    --good-side: #23774b;
    --bad: #ff7a72;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

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, clock and rounds */
.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; }

.rounds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.round {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 4px 6px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--panel);
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.round:active { transform: scale(0.97); }
.round small { font-size: 0.68rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.round b { font: 600 1.05rem/1.2 var(--display); letter-spacing: 0.08em; }
.round .mark { position: absolute; top: 4px; right: 6px; font-size: 0.75rem; line-height: 1; }
.round.on { border-color: var(--accent); background: var(--panel-solid); box-shadow: 0 4px 14px -6px var(--shadow); }

/* ---------------------------------------------------------------- the board */
.stage { position: relative; }
.board {
  --n: 6;
  padding: 22px 14px 16px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px -24px var(--shadow);
  container-type: inline-size;
}
.stage.veiled .board { filter: blur(9px); pointer-events: none; }
.stage.veiled .board * { visibility: hidden; }
/* Letters size to fit the word across the board (as if six, for shorter words). */
.slots, .tiles { --across: max(var(--n), 6); --gap: min(8px, 1.6cqi); display: flex; justify-content: center; gap: var(--gap); }
.slots { margin-bottom: 22px; }
.slot, .tile {
  width: min(56px, calc((100cqi - (var(--across) - 1) * var(--gap)) / var(--across)));
  aspect-ratio: 1 / 1.12;
  display: grid; place-items: center;
  border-radius: 12px;
  font: 600 min(2rem, calc(55cqi / var(--across)))/1 var(--display);
  text-transform: uppercase;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.slot {
  border: 2px dashed var(--line);
  background: var(--slot);
  color: var(--tile-ink);
  padding: 0;
  transition: transform 0.1s, background 0.12s;
}
.slot.next { border-color: var(--accent); border-style: solid; }
.slot.full { border: 0; background: var(--placed); box-shadow: 0 3px 0 var(--placed-side); animation: drop 0.18s cubic-bezier(0.2, 1.6, 0.4, 1); }
.slot.locked { border: 0; background: var(--locked); color: #2a1d00; box-shadow: 0 3px 0 var(--locked-side); cursor: default; }
.slot.solved { border: 0; background: var(--good); color: #fff; box-shadow: 0 3px 0 var(--good-side); animation: flip 0.45s ease both; animation-delay: calc(var(--i) * 60ms); }
@media (prefers-color-scheme: dark) { .slot.solved { color: #062414; } }
.slot:disabled { cursor: default; }
.tile {
  border: 0;
  padding: 0;
  background: var(--tile);
  color: var(--tile-ink);
  box-shadow: 0 4px 0 var(--tile-side), 0 6px 14px -8px var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s;
}
.tile:not(:disabled):hover { transform: translateY(-1px); }
.tile:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tile-side); }
.tile.used { opacity: 0; pointer-events: none; transform: scale(0.8); }
.board.shake .slots { animation: shake 0.36s ease; }
@keyframes drop { from { transform: translateY(-6px) scale(0.9); } }
@keyframes flip { 40% { transform: rotateX(90deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tools[hidden] { display: none; }

/* the solved word */
.outcome { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); text-align: center; animation: rise 0.3s ease; }
.outcome[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.oc-head { margin: 0; font: 600 1.4rem/1.2 var(--display); }
.oc-mark { margin-right: 8px; }
.oc-sub { margin: 2px 0 0; color: var(--muted); }
.oc-btns { margin-top: 12px; display: flex; justify-content: center; }

/* the curtain over the unstarted or paused words */
.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: 22px;
}
.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; }

.foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------------- buttons */
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn.wide { margin-top: 16px; }
.section-h { margin: 14px 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; gap: 4px; margin: 6px 0 14px; }
.mini { display: grid; place-items: center; width: 32px; height: 36px; border-radius: 9px; background: var(--tile); box-shadow: 0 3px 0 var(--tile-side); font: 600 1.15rem/1 var(--display); }
.mini.hit { background: var(--good); color: #fff; box-shadow: 0 3px 0 var(--good-side); }
.arrow { margin: 0 6px; font: 600 1.3rem/1 var(--display); color: var(--muted); }
.rules { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.95rem; font-weight: 600; }
.grades { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.92rem; }
.grades span { margin-right: 8px; }
.rule-note { margin: 12px 0 0; font-size: 0.9rem; }
.keys, .dailys-keys { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.9; }
.kicker { color: var(--muted); }
.res-row { margin: 6px 0 4px; text-align: center; font-size: 2rem; letter-spacing: 6px; }
.res-row span { display: inline-block; animation: dlg 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.res-time { margin: 0 0 10px; text-align: center; color: var(--muted); }
.res-time b { color: var(--ink); font: 700 1.4rem/1 var(--display); font-variant-numeric: tabular-nums; }
.res-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.res-table th { text-align: left; font-weight: 700; color: var(--muted); padding: 6px 0; }
.res-table td { text-align: right; padding: 6px 0; }
.res-table td.w { font: 600 1.05rem/1 var(--display); letter-spacing: 0.08em; text-align: left; padding-left: 8px; }
.res-table tr + tr { border-top: 1px solid var(--line); }
.wd.today i { outline: 2px dashed var(--accent); outline-offset: -2px; }
.wd.clean i { background: var(--good); color: #fff; }
.wd.helped i { background: color-mix(in srgb, var(--locked) 60%, transparent); }

.toast { z-index: 10; }

@media (max-width: 380px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .board { padding: 18px 10px 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Landscape phones: the rounds and buttons beside the board. */
@media (orientation: landscape) and (max-height: 540px) {
  .app { max-width: 900px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .play {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    grid-template-areas: 'bar stage' 'rounds stage' 'foot stage';
    grid-template-rows: auto auto 1fr;
    column-gap: 18px;
    row-gap: 8px;
    align-items: start;
  }
  .bar { grid-area: bar; }
  .rounds { grid-area: rounds; grid-template-columns: 1fr; }
  .round { flex-direction: row; justify-content: space-between; padding: 6px 12px; }
  .round .mark { position: static; }
  .stage { grid-area: stage; }
  .foot { grid-area: foot; justify-content: flex-start; }
}
/* the same for the site-wide Reduce motion setting (hub/prefs.js) */
