/*
 * Cozy Sudoku — the whole look lives here.
 *
 * Rules of thumb the rest of the file follows:
 *  - Warm neutrals, never pure white or pure black. Paper, not screen.
 *  - Two-layer shadows: a hard 2px "lip" plus a soft ambient blur. That is what
 *    makes a flat rectangle feel like a physical tile you could pick up.
 *  - Generous radii and generous space. Cramped is the opposite of cozy, so
 *    when in doubt add air rather than another border.
 *  - Every theme sets the same token names, so nothing below needs to branch.
 */

/* Nunito, SIL Open Font License 1.1 — self-hosted latin subset, variable 400-800. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------- themes -- */

:root {
  --r-xl: 30px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --lip: 0 2px 0;
  --ease: cubic-bezier(.34, 1.4, .5, 1);
  --font: 'Nunito', ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
          "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="cream"] {
  --bg: #f5ecdd;
  --bg-2: #ecdfc9;
  --board: #fffbf4;
  --cell-alt: #fdf5ea;
  --line: rgba(140, 105, 70, .15);
  --line-strong: rgba(122, 90, 58, .40);
  --text: #52402f;
  --muted: #9c876f;
  --chip: #fdf6ec;
  --sel: #f3d0a8;
  --sel-ink: #b3702f;
  --peer: rgba(216, 176, 132, .17);
  --same: rgba(216, 176, 132, .38);
  --bad: #d0655f;
  --bad-soft: rgba(208, 101, 95, .17);
  --given-chip: rgba(126, 94, 62, .17);
  --tile-hi: #fffdf8;
  --tile-lo: #f6ead7;
  --pale: #fffbf4;
  --shadow: rgba(126, 94, 62, .17);
  --shadow-lip: rgba(126, 94, 62, .12);
  --grain: .035;
}

:root[data-theme="sage"] {
  --bg: #e8ede1;
  --bg-2: #d8e3cd;
  --board: #fafcf7;
  --cell-alt: #f2f7ec;
  --line: rgba(88, 116, 78, .15);
  --line-strong: rgba(74, 100, 66, .38);
  --text: #42513b;
  --muted: #849377;
  --chip: #f4f8ef;
  --sel: #cbe0b6;
  --sel-ink: #567a41;
  --peer: rgba(150, 186, 130, .18);
  --same: rgba(150, 186, 130, .38);
  --bad: #c96a63;
  --bad-soft: rgba(201, 106, 99, .16);
  --given-chip: rgba(72, 96, 64, .16);
  --tile-hi: #fdfffb;
  --tile-lo: #ecf4e5;
  --pale: #fafcf7;
  --shadow: rgba(72, 96, 64, .16);
  --shadow-lip: rgba(72, 96, 64, .11);
  --grain: .035;
}

:root[data-theme="blush"] {
  --bg: #f5e8e6;
  --bg-2: #eed9d7;
  --board: #fff9f8;
  --cell-alt: #fdefee;
  --line: rgba(150, 100, 100, .14);
  --line-strong: rgba(140, 88, 88, .36);
  --text: #59403f;
  --muted: #a28584;
  --chip: #fdf2f1;
  --sel: #f4cbc6;
  --sel-ink: #b0645d;
  --peer: rgba(226, 168, 164, .19);
  --same: rgba(226, 168, 164, .40);
  --bad: #cc5f5f;
  --bad-soft: rgba(204, 95, 95, .17);
  --given-chip: rgba(122, 80, 80, .15);
  --tile-hi: #fffbfa;
  --tile-lo: #fbe8e6;
  --pale: #fff9f8;
  --shadow: rgba(122, 80, 80, .16);
  --shadow-lip: rgba(122, 80, 80, .11);
  --grain: .035;
}

:root[data-theme="sky"] {
  --bg: #e5edf3;
  --bg-2: #d4e2ee;
  --board: #f8fcff;
  --cell-alt: #eef5fb;
  --line: rgba(80, 110, 140, .14);
  --line-strong: rgba(68, 96, 126, .36);
  --text: #3e4e5c;
  --muted: #7d8f9d;
  --chip: #f2f8fc;
  --sel: #bfd9ec;
  --sel-ink: #47738f;
  --peer: rgba(150, 190, 220, .19);
  --same: rgba(150, 190, 220, .40);
  --bad: #c8635e;
  --bad-soft: rgba(200, 99, 94, .16);
  --given-chip: rgba(64, 90, 116, .15);
  --tile-hi: #fbfeff;
  --tile-lo: #e7f1f9;
  --pale: #f8fcff;
  --shadow: rgba(64, 90, 116, .16);
  --shadow-lip: rgba(64, 90, 116, .11);
  --grain: .035;
}

:root[data-theme="honey"] {
  --bg: #f7edd2;
  --bg-2: #efe0b4;
  --board: #fffcf0;
  --cell-alt: #fdf6e2;
  --line: rgba(150, 115, 40, .15);
  --line-strong: rgba(130, 98, 34, .40);
  --text: #57451d;
  --muted: #a08d60;
  --chip: #fdf7e6;
  --sel: #f4d98e;
  --sel-ink: #a87d20;
  --peer: rgba(224, 190, 110, .18);
  --same: rgba(224, 190, 110, .40);
  --bad: #cf655e;
  --bad-soft: rgba(207, 101, 94, .17);
  --given-chip: rgba(134, 102, 40, .16);
  --tile-hi: #fffef6;
  --tile-lo: #f7ecd0;
  --pale: #fffcf0;
  --shadow: rgba(134, 102, 40, .17);
  --shadow-lip: rgba(134, 102, 40, .12);
  --grain: .035;
}

:root[data-theme="lavender"] {
  --bg: #ece7f4;
  --bg-2: #ded5ec;
  --board: #fbfaff;
  --cell-alt: #f3f0fa;
  --line: rgba(110, 95, 150, .14);
  --line-strong: rgba(95, 80, 135, .36);
  --text: #48405c;
  --muted: #8d84a3;
  --chip: #f5f2fb;
  --sel: #d3c7ee;
  --sel-ink: #6f5aa8;
  --peer: rgba(178, 160, 220, .18);
  --same: rgba(178, 160, 220, .38);
  --bad: #cc5f6a;
  --bad-soft: rgba(204, 95, 106, .16);
  --given-chip: rgba(90, 74, 130, .15);
  --tile-hi: #fdfcff;
  --tile-lo: #eee9f8;
  --pale: #fbfaff;
  --shadow: rgba(90, 74, 130, .16);
  --shadow-lip: rgba(90, 74, 130, .11);
  --grain: .035;
}

:root[data-theme="dusk"] {
  --bg: #26201e;
  --bg-2: #191514;
  --board: #332c28;
  --cell-alt: #3a322e;
  --line: rgba(255, 240, 224, .085);
  --line-strong: rgba(255, 236, 214, .28);
  --text: #eddfd0;
  --muted: #a08e7d;
  --chip: #3c3330;
  --sel: #74594a;
  --sel-ink: #f4cfa6;
  --peer: rgba(214, 170, 126, .12);
  --same: rgba(214, 170, 126, .24);
  --bad: #e08078;
  --bad-soft: rgba(224, 128, 120, .19);
  --given-chip: rgba(0, 0, 0, .26);
  --tile-hi: #413833;
  --tile-lo: #2e2724;
  --pale: #f6ece0;
  --shadow: rgba(0, 0, 0, .42);
  --shadow-lip: rgba(0, 0, 0, .3);
  --grain: .05;
}

:root[data-theme="forest"] {
  --bg: #1e2621;
  --bg-2: #141a16;
  --board: #2a352d;
  --cell-alt: #303c33;
  --line: rgba(226, 255, 234, .08);
  --line-strong: rgba(216, 245, 224, .27);
  --text: #ddeadd;
  --muted: #8ba18d;
  --chip: #334036;
  --sel: #4f6b52;
  --sel-ink: #b9e0b4;
  --peer: rgba(150, 205, 155, .12);
  --same: rgba(150, 205, 155, .24);
  --bad: #e0837b;
  --bad-soft: rgba(224, 131, 123, .19);
  --given-chip: rgba(0, 0, 0, .26);
  --tile-hi: #3a473c;
  --tile-lo: #253028;
  --pale: #eaf4e8;
  --shadow: rgba(0, 0, 0, .42);
  --shadow-lip: rgba(0, 0, 0, .3);
  --grain: .05;
}

:root[data-theme="midnight"] {
  --bg: #1d222e;
  --bg-2: #131722;
  --board: #293040;
  --cell-alt: #2f374a;
  --line: rgba(224, 234, 255, .085);
  --line-strong: rgba(214, 226, 252, .28);
  --text: #dfe6f2;
  --muted: #8a93a8;
  --chip: #313a4e;
  --sel: #4b5a80;
  --sel-ink: #b6c8f0;
  --peer: rgba(150, 175, 230, .12);
  --same: rgba(150, 175, 230, .24);
  --bad: #e0807e;
  --bad-soft: rgba(224, 128, 126, .19);
  --given-chip: rgba(0, 0, 0, .28);
  --tile-hi: #333c52;
  --tile-lo: #232a3a;
  --pale: #edf1fa;
  --shadow: rgba(0, 0, 0, .45);
  --shadow-lip: rgba(0, 0, 0, .32);
  --grain: .05;
}

/* ------------------------------------------------------------------ base -- */

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(130% 100% at 50% -15%, var(--bg) 0%, var(--bg-2) 78%) fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}

/* A whisper of paper grain. Without it the flat fills read as plastic. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

h1, h2 { margin: 0; font-weight: 800; letter-spacing: -.015em; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
a { color: inherit; }

/* --------------------------------------------------------------- topbar -- */

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
}

.title-block { text-align: center; min-width: 0; }
.title-block h1 { font-size: 22px; line-height: 1.1; }
.sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .2s;
}
.sub.holding { color: var(--sel-ink); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--muted);
  min-width: 44px;
  text-align: right;
}
.timer[hidden] { display: none; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--chip);
  box-shadow: var(--lip) var(--shadow-lip), 0 5px 14px -8px var(--shadow);
  color: var(--muted);
  transition: transform .13s var(--ease), color .13s;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:hover { color: var(--text); }
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.ghost-btn { width: 38px; height: 38px; border-radius: 12px; }
.ghost-btn svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- board -- */

/* `main` has to lay itself out: .shell's gap only separates header / main /
   footer, so with main left as a plain block the board and the tile pad sat
   flush against each other with zero space between them. */
main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.board-wrap { position: relative; }

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1;
  background: var(--board);
  border-radius: var(--r-xl);
  padding: 12px;
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 2px 5px -2px var(--shadow-lip),
    0 2px 0 var(--shadow-lip),
    0 1px 2px var(--shadow-lip),
    0 16px 38px -14px var(--shadow);
  overflow: hidden;
  touch-action: manipulation;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 4px;
  transition: background-color .16s ease;
  cursor: pointer;
  user-select: none;
}
/* Box seams: heavier rules every third column and row, none on the outside. */
.cell.seam-x { border-right: 2.5px solid var(--line-strong); }
.cell.seam-y { border-bottom: 2.5px solid var(--line-strong); }
.cell.edge-x { border-right: 0; }
.cell.edge-y { border-bottom: 0; }

.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.bad  { background: var(--bad-soft); }
.cell.sel  { background: var(--sel); }

/* The selection also gets a ring, so it stays obvious on a shaded row. */
.cell.sel::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 9px;
  box-shadow: 0 0 0 2.5px var(--sel-ink);
  z-index: 2;
  pointer-events: none;
}

@media (hover: hover) {
  .cell:hover { background: var(--peer); }
  .cell.sel:hover { background: var(--sel); }
}

.cell .glyph {
  width: 70%;
  height: 70%;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

/*
 * Every filled square carries a physical tile, which is most of what makes the
 * board feel cozy rather than like a spreadsheet with pictures in it.
 *
 * Givens are pressed *into* the board — flat, faintly recessed, part of the
 * printed grid. The player's own answers are laid *on top* of it: a lit face,
 * a bright top edge and a small drop shadow. So the difference between "this
 * was here when I started" and "I put this here" is something you feel rather
 * than something you have to work out.
 */
.cell.given::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 10px;
  background: var(--given-chip);
  box-shadow: inset 0 1.5px 3px -1px var(--shadow);
  z-index: 0;
}

.cell.guess::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 10px;
  background: linear-gradient(157deg, var(--tile-hi) 12%, var(--tile-lo) 100%);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    0 1px 0 var(--shadow-lip),
    0 3px 6px -2px var(--shadow);
  z-index: 0;
}

/* Lift the artwork off its tile face by a hair. */
.cell.given .glyph { filter: drop-shadow(0 .5px 0 var(--shadow-lip)); }
.cell.guess .glyph { filter: drop-shadow(0 1px 1.5px var(--shadow-lip)); }

/* A placed tile drops in with a small overshoot — the tactile bit. */
.cell.pop .glyph { animation: pop .28s var(--ease); }
@keyframes pop {
  0%   { transform: scale(.4); opacity: 0; }
  70%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

.cell.bad .glyph { animation: shake .32s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2.5px); }
  75% { transform: translateX(2.5px); }
}

/* A finished row / column / box gets a soft sweep of light.
   This animates the cell itself rather than ::before, because ::before now
   carries the tile face — sweeping it would blank the tile mid-animation. */
.cell.cleared { animation: sweep .66s ease; }
.cell.cleared .glyph { animation: lift .66s var(--ease); }
@keyframes sweep {
  0%, 100% { background-color: transparent; }
  35% { background-color: var(--sel); }
}
@keyframes lift {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-2.5px) scale(1.07); }
}

/* Pencil marks. */
.notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 94%;
  height: 94%;
  place-items: center;
  pointer-events: none;
  position: relative;
  z-index: 1;
}
.notes .glyph { width: 80%; height: 80%; opacity: .75; }
/* Candidates the game worked out sit fainter than marks you made yourself. */
.notes.auto .glyph { opacity: .32; }

.board-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  border-radius: var(--r-xl);
  background: color-mix(in srgb, var(--board) 90%, transparent);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  z-index: 3;
}
.board-veil[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--sel-ink);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ side -- */

.side { display: flex; flex-direction: column; gap: 13px; }

.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 7px; }

.pad-btn {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: var(--r-sm);
  background: linear-gradient(157deg, var(--tile-hi) 10%, var(--tile-lo) 100%);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    var(--lip) var(--shadow-lip),
    0 5px 12px -8px var(--shadow);
  display: grid;
  place-items: center;
  transition: transform .15s var(--ease), opacity .2s, background-color .16s, box-shadow .15s;
}
/* Positioned off the button box rather than sized with width/height %.
   The button's inner grid track is content-sized, so a percentage width
   collapsed to the SVG's intrinsic 24px — which is why these tiles came out
   noticeably smaller than the identical artwork on the board. */
.pad-btn .glyph {
  position: absolute;
  inset: 15%;
  width: auto;
  height: auto;
  pointer-events: none;
}
.pad-btn:active { transform: translateY(2px); box-shadow: none; }

/* A picked-up tile lifts off the row and keeps a ring, so it is obvious that
   tapping it again puts it down. Being stuck holding a tile with no way out
   was the worst bit of the first version. */
.pad-btn.armed {
  background: var(--sel);
  box-shadow: 0 0 0 2.5px var(--sel-ink), 0 12px 20px -10px var(--shadow);
  transform: translateY(-5px);
}
.pad-btn.armed:active { transform: translateY(-3px); }
.pad-btn.done { opacity: .32; }

.pad-count {
  position: absolute;
  bottom: 2px;
  right: 5px;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.pad-btn.armed .pad-count { color: var(--sel-ink); }
.pad-btn.done .pad-count { opacity: 0; }

.pad-hint {
  margin: -2px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  opacity: .8;
  min-height: 17px;
  transition: color .2s, opacity .2s;
}
.pad-hint.holding { color: var(--sel-ink); opacity: 1; }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }

.tool {
  border: 0;
  border-radius: var(--r-md);
  background: var(--chip);
  box-shadow: var(--lip) var(--shadow-lip), 0 5px 12px -8px var(--shadow);
  padding: 11px 4px 10px;
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  position: relative;
  transition: transform .13s var(--ease), color .15s;
}
.tool svg { width: 21px; height: 21px; }
.tool:hover { color: var(--text); }
.tool:active { transform: translateY(2px); box-shadow: none; }
.tool:disabled { opacity: .38; cursor: default; transform: none; }
.tool[aria-pressed="true"] { background: var(--sel); color: var(--sel-ink); }
.tool em {
  position: absolute;
  top: 6px;
  right: 9px;
  font-style: normal;
  font-size: 8.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .6;
}

/* ----------------------------------------------------------------- about -- */

.noscript {
  background: var(--chip);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

/* ------------------------------------------------------- the about page -- */

.page-head { display: grid; gap: 14px; padding-top: 4px; }
.page-head h1 { font-size: 25px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-self: start;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--chip);
  box-shadow: var(--lip) var(--shadow-lip);
  border-radius: 999px;
  padding: 8px 15px 8px 11px;
  transition: transform .13s var(--ease), color .15s;
}
.back svg { width: 17px; height: 17px; }
.back:hover { color: var(--text); }
.back:active { transform: translateY(2px); box-shadow: none; }

.prose { color: var(--muted); max-width: 64ch; }
.prose h2 { font-size: 16px; color: var(--text); margin: 26px 0 8px; }
.prose h2:first-child { margin-top: 4px; }
.prose p { margin: 0 0 11px; font-size: 14.5px; line-height: 1.72; }
.prose strong { color: var(--text); font-weight: 700; }
.prose a { color: var(--sel-ink); text-decoration: none; border-bottom: 1px solid var(--sel); }

.foot {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: .75;
  padding: 4px 0 2px;
}
.foot a { text-decoration: none; border-bottom: 1px solid var(--line); }

/* --------------------------------------------------------------- sheets -- */

.sheet {
  border: 0;
  padding: 0;
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  border-radius: var(--r-xl);
  background: var(--board);
  color: var(--text);
  box-shadow: 0 28px 70px -14px rgba(0, 0, 0, .38);
  overflow: auto;
}
.sheet::backdrop { background: rgba(38, 28, 22, .46); backdrop-filter: blur(4px); }
.sheet form { padding: 24px 24px 18px; }
.sheet h2 { font-size: 19px; }

.group-label {
  margin: 22px 0 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}

.sheet-foot { display: flex; gap: 10px; margin: 24px 0 0; padding: 0; }
.sheet-foot button {
  flex: 1;
  border: 0;
  border-radius: var(--r-md);
  padding: 13px;
  font-weight: 800;
  font-size: 14.5px;
  transition: transform .13s var(--ease);
}
.sheet-foot button:active { transform: translateY(2px); }
.ghost { background: var(--chip); color: var(--muted); box-shadow: var(--lip) var(--shadow-lip); }
.ghost.danger { color: var(--bad); flex: 0 0 34%; }
.primary { background: var(--sel); color: var(--sel-ink); box-shadow: var(--lip) var(--shadow-lip); }

/* Daily card */
.daily-card {
  width: 100%;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--cell-alt);
  box-shadow: var(--lip) var(--shadow-lip);
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  margin-top: 16px;
  transition: transform .13s var(--ease);
}
.daily-card:active { transform: translateY(2px); box-shadow: none; }
.daily-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--sel);
  color: var(--sel-ink);
  flex: none;
}
.daily-mark svg { width: 22px; height: 22px; }
.daily-text { flex: 1; min-width: 0; }
.daily-text strong { display: block; font-size: 15.5px; }
.daily-text small { color: var(--muted); font-size: 12px; }
.daily-badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--sel-ink);
  background: var(--sel);
  padding: 5px 10px;
  border-radius: 999px;
  flex: none;
}
.daily-badge:empty { display: none; }

/* Difficulty list */
.level-list { display: grid; gap: 8px; }
.level-btn {
  border: 0;
  width: 100%;
  border-radius: var(--r-md);
  background: var(--chip);
  box-shadow: var(--lip) var(--shadow-lip);
  padding: 13px 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  transition: transform .13s var(--ease);
}
.level-btn:active { transform: translateY(2px); box-shadow: none; }
.level-btn strong { font-size: 15px; }
.level-btn small { color: var(--muted); font-size: 12px; flex: 1; }
.level-dots { display: flex; gap: 3.5px; flex: none; align-self: center; }
.level-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); opacity: .25; }
.level-dots i.on { opacity: 1; background: var(--sel-ink); }

/* Option grids */
.set-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.set-btn {
  position: relative;
  border: 0;
  border-radius: var(--r-md);
  background: var(--chip);
  box-shadow: var(--lip) var(--shadow-lip);
  padding: 12px 6px 10px;
  display: grid;
  justify-items: center;
  gap: 7px;
  transition: transform .13s var(--ease);
}
/* Locked sets keep their art visible — the artwork is the sales pitch — just
   dimmed enough that the padlock reads as the reason they will not select. */
.set-btn.locked .set-preview, .set-btn.locked b { opacity: .6; }
.set-btn.locked small { opacity: .75; }
.set-btn .lock {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 13px;
  height: 13px;
  color: var(--muted);
}
.premium-copy { margin: 0 2px 4px; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.set-btn:active { transform: translateY(2px); }
.set-btn.on { background: var(--sel); box-shadow: 0 0 0 2.5px var(--sel-ink); }
.set-preview { display: flex; gap: 4px; }
.set-preview .glyph { width: 18px; height: 18px; }
.set-btn b { font-size: 12.5px; font-weight: 800; }
.set-btn small { font-size: 10px; color: var(--muted); }
.set-btn.on small { color: var(--sel-ink); opacity: .85; }

.theme-list { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-btn {
  width: 48px; height: 48px;
  border: 0;
  border-radius: 15px;
  box-shadow: var(--lip) var(--shadow-lip);
  position: relative;
  transition: transform .13s var(--ease);
}
.theme-btn:active { transform: translateY(2px); }
.theme-btn.on { box-shadow: 0 0 0 2.5px var(--sel-ink); }
.theme-btn span { position: absolute; inset: 27%; border-radius: 7px; }

/* Switches */
.switch-list { display: grid; }
.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row .label { flex: 1; }
.switch-row b { display: block; font-size: 14px; font-weight: 700; }
.switch-row small { color: var(--muted); font-size: 11.5px; line-height: 1.4; }

.switch {
  flex: none;
  width: 46px; height: 27px;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background-color .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--board);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .22s var(--ease);
}
.switch[aria-checked="true"] { background: var(--sel-ink); }
.switch[aria-checked="true"]::after { transform: translateX(19px); }

/* ----------------------------------------------------------------- stats -- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 16px; }
.stat { background: var(--chip); border-radius: var(--r-md); padding: 13px 6px; text-align: center; }
.stat b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat small { font-size: 10.5px; color: var(--muted); font-weight: 600; }

.stat-table { display: grid; }
.stat-row {
  display: grid;
  grid-template-columns: 1fr 46px 46px 58px;
  gap: 10px;
  align-items: baseline;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row.head {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding-bottom: 7px;
}
.stat-row b { font-weight: 700; }
.stat-row span { font-variant-numeric: tabular-nums; text-align: right; }
.stat-row .dim { color: var(--muted); opacity: .6; }

.stat-note { margin: 18px 0 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); opacity: .85; }

/* Win */
.win .win-art { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.win .win-art .glyph { width: 36px; height: 36px; animation: rise .5s var(--ease) backwards; }
@keyframes rise { from { transform: translateY(16px) scale(.4); opacity: 0; } }
.win h2 { text-align: center; font-size: 23px; }
.win-line { text-align: center; color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }

/* ------------------------------------------------------------------ wide -- */

@media (min-width: 760px) {
  /* One column at every width. A two-column desktop layout was tried and
     dropped: squeezing the pad into a side rail made the tile artwork smaller
     than the tiles on the board, which is exactly backwards — the pad is what
     you aim at. Extra width goes into a bigger board instead. */
  .shell { max-width: 588px; gap: 24px; }
  main { gap: 22px; }
  .title-block h1 { font-size: 25px; }
  .pad { gap: 9px; }
  .tools { gap: 11px; }
  .tool { padding: 13px 6px 12px; font-size: 12.5px; }
  .tool svg { width: 22px; height: 22px; }
}

@media (max-width: 400px) {
  body { padding-left: 12px; padding-right: 12px; }
  .pad { gap: 5px; }
  .tools { gap: 7px; }
  .tool span { font-size: 10.5px; }
  .board { padding: 9px; border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

:focus-visible { outline: 2.5px solid var(--sel-ink); outline-offset: 2px; border-radius: 8px; }
.cell:focus-visible { outline-offset: -3px; }
