:root {
  color-scheme: light dark;
  --bg: #f6efe2;
  --bg-2: #efe4cf;
  --panel: rgba(255, 252, 245, 0.7);
  --panel-solid: #fffaf1;
  --ink: #231d2c;
  --muted: #6a5f72; /* 4.8:1 on --bg-2, the darkest page colour */
  --line: rgba(35, 29, 44, 0.12);
  --accent: #ff6b9e;
  --accent-deep: #d9437a;
  --accent-ink: #33041a;
  --tile: #fffaf0;
  --tile-edge: rgba(35, 29, 44, 0.13);
  --tile-side: #d9c9ab;
  --tile-hover: #fff4dc;
  --sel: #231d2c;
  --sel-ink: #fffaf0;
  --sel-side: #000;
  --shadow: rgba(80, 55, 20, 0.14);
  --good: #2b9a60;
  --herring: #e3a417;
  --herring-bg: #ffe8a6;
  --herring-ink: #4a3300;
  --miss: #dc4646;
  --miss-bg: #ffd2cd;
  --pill-ink: #231d2c;
  --p0: #ffd66e;
  --p1: #9fe3c4;
  --p2: #a9d3ff;
  --p3: #ffb8cf;
  --p4: #cdbdff;
  --p5: #ffc79c;
  --lost: #ddd2c0;
  --radius: 16px;
  --display: Fraunces, Georgia, 'Times New Roman', serif;
  --display-weight: 800; /* the weight hub/game.css gives display text */
  --text: Lexend, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16131b;
    --bg-2: #1c1823;
    --panel: rgba(42, 36, 51, 0.72);
    --panel-solid: #241f2c;
    --ink: #f3ede3;
    --muted: #b2a9bc;
    --line: rgba(243, 237, 227, 0.12);
    --accent: #ff7aa8;
    --accent-deep: #c94677;
    --accent-ink: #2b0516;
    --tile: #2c2735;
    --tile-edge: rgba(255, 255, 255, 0.07);
    --tile-side: #0c0a10;
    --tile-hover: #352f40;
    --sel: #f3ede3;
    --sel-ink: #16131b;
    --sel-side: #8f859b;
    --shadow: rgba(0, 0, 0, 0.35);
    --good: #5bd394;
    --herring: #f2c14e;
    --herring-bg: #574412;
    --herring-ink: #ffe9b0;
    --miss: #ff7a72;
    --miss-bg: #5c2427;
    --pill-ink: #1b1721;
    --p0: #f1c75b;
    --p1: #86d3b1;
    --p2: #91c1f1;
    --p3: #f1a4bf;
    --p4: #b9a8f1;
    --p5: #f1b487;
    --lost: #4a4354;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 1.4px),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  background-size: 22px 22px, 100% 100%;
  background-attachment: fixed;
}

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

/* ---------------------------------------------------------------- header */
.logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.05rem;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 72;
}
.logo span:last-child { color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .logo span:last-child { color: var(--accent); } }
.day { margin: 4px 0 0; font-size: 0.78rem; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; }

@media (prefers-color-scheme: dark) { .banner a { color: var(--accent); } }

/* ---------------------------------------------------------------- board */
.play { display: flex; flex-direction: column; gap: 12px; }
.prompt { margin: 2px 0 0; text-align: center; font-size: 0.92rem; color: var(--muted); min-height: 1.4em; }
.prompt b { color: var(--ink); font-weight: 600; letter-spacing: 0.04em; }

.board { display: flex; flex-direction: column; gap: 8px; }
.solved { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.solved:empty { display: none; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid:empty { display: none; }
@media (min-width: 500px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.tile {
  position: relative;
  height: 62px;
  padding: 0 4px;
  border-radius: var(--radius);
  border: 1.5px solid var(--tile-edge);
  background: var(--tile);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 600;
  font-size: 1.06rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 var(--tile-side), 0 8px 16px -6px var(--shadow);
  transition: transform 0.13s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.15s ease, color 0.15s ease, box-shadow 0.13s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.tile.l6 { font-size: 0.98rem; letter-spacing: 0.04em; }
.tile.l7 { font-size: 0.9rem; letter-spacing: 0.03em; }
@media (hover: hover) { .tile:not(.sel):hover { background: var(--tile-hover); } }
.tile:active:not(.sel) { transform: translateY(2px); box-shadow: 0 2px 0 var(--tile-side), 0 4px 8px -6px var(--shadow); }
.tile.sel {
  background: var(--sel);
  color: var(--sel-ink);
  border-color: var(--sel);
  transform: translateY(-3px);
  box-shadow: 0 6px 0 var(--sel-side), 0 14px 20px -8px var(--shadow);
}
.tile.hit { background: var(--c, var(--p0)); color: var(--pill-ink); border-color: transparent; transform: translateY(-4px) scale(1.04); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18); }
.tile.herring { background: var(--herring-bg); color: var(--herring-ink); border-color: var(--herring); animation: wobble 0.55s ease; }
.tile.miss { background: var(--miss-bg); border-color: var(--miss); animation: shake 0.42s ease; }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg) translateY(-2px); }
  45% { transform: rotate(3deg); }
  70% { transform: rotate(-1.5deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%, 55% { transform: translateX(-7px); }
  35%, 75% { transform: translateX(7px); }
  90% { transform: translateX(-2px); }
}
.tile.ghost { position: fixed; margin: 0; z-index: 20; pointer-events: none; }

.pill {
  position: relative;
  height: 54px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--c, var(--p0));
  color: var(--pill-ink);
  font-weight: 700;
  font-size: 1.06rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 rgba(35, 29, 44, 0.16);
  overflow: hidden;
}
.pill.lost { background: var(--lost); color: var(--ink); box-shadow: none; border: 1.5px dashed var(--line); }
.pill .h { display: inline-block; transition: margin 0.32s cubic-bezier(0.3, 1.5, 0.5, 1); }
.pill.split .h + .h { margin-left: 0.7em; }
.pill.l12 { font-size: 0.94rem; letter-spacing: 0.03em; }
.pill.l14 { font-size: 0.84rem; letter-spacing: 0.02em; }
.pill.arrive { animation: fuse 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.pill.arrive::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.75) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: shine 0.7s 0.12s ease-out forwards;
}
.pill.cheer { animation: cheer 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes fuse { 0% { transform: scale(0.94, 1.08); } 45% { transform: scale(1.06, 0.94); } 100% { transform: none; } }
@keyframes shine { to { transform: translateX(120%); } }
@keyframes cheer { 40% { transform: translateY(-7px) rotate(-1.5deg); } }
.pill[data-i='0'], .tile[data-c='0'] { --c: var(--p0); }
.pill[data-i='1'], .tile[data-c='1'] { --c: var(--p1); }
.pill[data-i='2'], .tile[data-c='2'] { --c: var(--p2); }
.pill[data-i='3'], .tile[data-c='3'] { --c: var(--p3); }
.pill[data-i='4'], .tile[data-c='4'] { --c: var(--p4); }
.pill[data-i='5'], .tile[data-c='5'] { --c: var(--p5); }

/* ---------------------------------------------------------------- hud */
.hud { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 26px; }
.lives { display: flex; align-items: center; gap: 6px; }
.lives-label { font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-right: 2px; }
.lives i {
  width: 22px; height: 12px;
  border-radius: 999px;
  background: var(--ink);
  transition: background 0.2s ease, transform 0.2s ease;
}
.lives i.gone { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.lives i.pop { animation: lifepop 0.5s ease; }
@keyframes lifepop { 0% { transform: scale(1); background: var(--miss); } 35% { transform: scale(1.5); background: var(--miss); } 100% { transform: scale(1); } }
.herring-count { margin: 0; font-size: 0.8rem; color: var(--muted); }
.herring-count b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- buttons */
.controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- herring shelf */
.shelf { margin-top: 4px; padding: 12px 14px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.shelf h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 0.78rem; font-weight: 500; color: var(--muted); }
.shelf h2 svg { width: 26px; height: 13px; fill: var(--miss); flex: none; }
.shelf h2 svg circle { fill: var(--panel-solid); }
.shelf ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.shelf li {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--herring-bg);
  color: var(--herring-ink);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.shelf li.new { animation: chip 0.45s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes chip { from { opacity: 0; transform: translateY(6px) scale(0.8); } }

/* ---------------------------------------------------------------- dialogs */
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(8px); } }

.lead { margin: 0 0 12px; line-height: 1.45; }
.example { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.mini {
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--tile);
  border: 1.5px solid var(--tile-edge);
  box-shadow: 0 3px 0 var(--tile-side);
  font-weight: 600; font-size: 0.85rem; letter-spacing: 0.06em;
}
.mini.joined { background: var(--p1); color: var(--pill-ink); border-color: transparent; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); font-weight: 700; }
.op { color: var(--muted); font-weight: 600; }
.rules { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.4; font-size: 0.93rem; }
.dot { flex: none; width: 22px; height: 22px; border-radius: 7px; margin-top: 1px; }
.dot.ok { background: var(--good); }
.dot.herring { background: var(--herring); }
.dot.miss { background: var(--miss); }
.rule-note { margin: 0 0 10px; line-height: 1.45; font-size: 0.92rem; }
.keys { margin: 4px 0 16px; font-size: 0.82rem; color: var(--muted); }
@media (hover: none) and (pointer: coarse) { .keys { display: none; } }

/* results */
.kicker { color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .kicker { color: var(--accent); } }
.res-line { margin: -4px 0 12px; color: var(--muted); font-size: 0.92rem; }
.res-line b { color: var(--ink); font-weight: 600; }
.res-words { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.res-words li { padding: 8px 6px; border-radius: 10px; text-align: center; font-weight: 700; font-size: 0.82rem; letter-spacing: 0.05em; text-transform: uppercase; background: var(--c, var(--p0)); color: var(--pill-ink); }
.res-words li.lost { background: var(--lost); color: var(--ink); }
.res-words li[data-i='0'] { --c: var(--p0); }
.res-words li[data-i='1'] { --c: var(--p1); }
.res-words li[data-i='2'] { --c: var(--p2); }
.res-words li[data-i='3'] { --c: var(--p3); }
.res-words li[data-i='4'] { --c: var(--p4); }
.res-words li[data-i='5'] { --c: var(--p5); }
.res-row { margin: 0 0 6px; font-size: 1.15rem; line-height: 1.35; letter-spacing: 0.04em; word-break: break-all; }
.res-herrings { margin: 0 0 14px; font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.res-herrings b { color: var(--ink); font-weight: 600; letter-spacing: 0.03em; }
.res-herrings s { text-decoration: none; opacity: 0.75; }
.res-actions .btn { flex: 1; }
.section-h { margin: 20px 0 10px; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.wd.won i { border: 0; background: var(--p1); color: var(--pill-ink); }
.wd.perfect i { border: 0; background: var(--p0); color: var(--pill-ink); }
.wd.lost i { border: 0; background: var(--lost); }
.wd.today i { border-style: solid; border-color: var(--accent); }
.countdown b { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-note { margin: 0 0 6px; font-weight: 500; }

.toast { z-index: 30; width: max-content; }
.toast b { font-weight: 700; letter-spacing: 0.04em; }
.toast.herring { background: var(--herring-bg); color: var(--herring-ink); box-shadow: 0 0 0 1.5px var(--herring), 0 8px 24px rgba(20, 10, 30, 0.25); }
.toast.miss { background: var(--miss); color: #fff; }

@media (max-width: 420px) {
  .logo { font-size: 1.8rem; }
  .icon-btn { width: 36px; height: 36px; border-radius: 11px; }
  .tile { height: 58px; font-size: 1rem; }
  .tile.l6 { font-size: 0.9rem; }
  .tile.l7 { font-size: 0.8rem; letter-spacing: 0.02em; }
  .pill { height: 50px; font-size: 0.92rem; letter-spacing: 0.04em; }
  .pill.l12 { font-size: 0.82rem; letter-spacing: 0.02em; }
  .pill.l14 { font-size: 0.74rem; letter-spacing: 0.01em; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Phones under 360px (320px ones especially): the header row and the result buttons only fit
   with a smaller logo and font. The icon buttons keep their 36px tap size. */
@media (max-width: 359px) {
  .top, .top-side { gap: 4px; }
  .logo { font-size: 1.5rem; }
  .res-actions .btn { padding: 0 12px; font-size: 0.88rem; white-space: nowrap; }
}
/* the same for the site-wide Reduce motion setting (hub/prefs.js) */
