/* KenKen for Paul ─ styles
   A quiet, paper-and-ink look: neutrals everywhere, one muted blue used only
   for the things you are pointing at. Tokens first, then page shell, home,
   board, pad, sheets, dialogs, motion. */

/* ─────────────────────────────────────────────────────────── tokens ── */

:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;

  --page: #ecebe7;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --surface-3: #e4e2dd;
  --hover: rgba(20, 20, 20, 0.045);
  --ink: #1a1a1a;
  --ink-2: #5c5b57;
  --ink-3: #9b9994;
  --line: rgba(20, 20, 20, 0.08);
  --line-2: rgba(20, 20, 20, 0.14);

  --primary: #1a1a1a;
  --primary-ink: #ffffff;
  --primary-hover: #2e2e2e;

  --accent: #3866d0;
  --accent-soft: rgba(56, 102, 208, 0.1);

  --good: #2e8b57;
  --good-soft: rgba(46, 139, 87, 0.12);
  --bad: #cf4540;
  --bad-soft: rgba(207, 69, 64, 0.12);
  --note: #a8690f;
  --note-soft: rgba(168, 105, 15, 0.09);
  --gold: #b88a2e;

  --grid: #e6e4df;
  --cage: #1f1f1f;
  --band: rgba(20, 20, 20, 0.032);
  --sel: rgba(56, 102, 208, 0.09);
  --veil: rgba(247, 246, 243, 0.74);
  --key-edge: #e3e1db;
  --toast-bg: #1a1a1a;
  --toast-ink: #ffffff;

  /* Optional cage tints: barely-there paper colours. */
  --t0: #f1f3f8; --t1: #f0f4f0; --t2: #f7f3ea; --t3: #f6f0f1; --t4: #eef3f5; --t5: #f3f1f6;
  /* Activity heatmap: one muted blue, light to dark. */
  --h0: #edece8; --h1: #cdd8ef; --h2: #9cb2e2; --h3: #6689d4; --h4: #3563c4;

  --shadow-1: 0 1px 2px rgba(20, 20, 20, 0.05);
  --shadow-2: 0 1px 2px rgba(20, 20, 20, 0.04), 0 8px 24px -12px rgba(20, 20, 20, 0.18);
  --shadow-3: 0 24px 60px -20px rgba(20, 20, 20, 0.3), 0 2px 8px rgba(20, 20, 20, 0.06);
  --shadow-app: 0 30px 80px -30px rgba(20, 20, 20, 0.3), 0 0 0 1px rgba(20, 20, 20, 0.06);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --soft-spring: cubic-bezier(0.3, 1.2, 0.5, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #09090a;
  --bg: #111113;
  --surface: #1a1a1d;
  --surface-2: #222226;
  --surface-3: #2d2d32;
  --hover: rgba(255, 255, 255, 0.05);
  --ink: #ededef;
  --ink-2: #a5a5ab;
  --ink-3: #6f6f76;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);

  --primary: #ededef;
  --primary-ink: #111113;
  --primary-hover: #ffffff;

  --accent: #7f9ce8;
  --accent-soft: rgba(127, 156, 232, 0.14);

  --good: #5fb98b;
  --good-soft: rgba(95, 185, 139, 0.14);
  --bad: #e8716b;
  --bad-soft: rgba(232, 113, 107, 0.14);
  --note: #d6a14c;
  --note-soft: rgba(214, 161, 76, 0.1);
  --gold: #d6aa55;

  --grid: #29292e;
  --cage: #d9d9dd;
  --band: rgba(255, 255, 255, 0.028);
  --sel: rgba(127, 156, 232, 0.13);
  --veil: rgba(17, 17, 19, 0.74);
  --key-edge: #0b0b0c;
  --toast-bg: #ededef;
  --toast-ink: #111113;

  --t0: #1d1e24; --t1: #1c211e; --t2: #22201b; --t3: #221d1f; --t4: #1b2023; --t5: #1f1d23;
  --h0: #222226; --h1: #2a3553; --h2: #3b5089; --h3: #5a77c4; --h4: #8ea8ee;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.7);
  --shadow-3: 0 30px 70px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-app: 0 30px 80px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ─────────────────────────────────────────────────────────── base ── */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  transition: background-color 0.4s;
}

button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

kbd {
  font: inherit; font-size: 11.5px; font-weight: 600;
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 6px; background: var(--surface); color: var(--ink-2);
  box-shadow: 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2);
}

/* ────────────────────────────────────────────────────────── shell ── */

.stage {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px 16px;
}

.app {
  position: relative;
  width: min(100%, 460px);
  height: min(calc(100% - 44px), 720px);
  min-height: 600px;
  background: var(--bg);
  border-radius: 26px;
  box-shadow: var(--shadow-app);
  overflow: hidden;
  isolation: isolate;
  user-select: none; -webkit-user-select: none;
  transition: background-color 0.4s;
}

.web-credit {
  margin: 0; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-3);
}
.web-credit b { color: var(--ink-2); font-weight: 600; }
.web-credit span { opacity: 0.5; }
.web-credit a {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ink-2); text-decoration: none; padding: 4px 8px; border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.web-credit a:hover { background: var(--hover); color: var(--ink); }
.web-credit .ic { width: 14px; height: 14px; }

@media (max-width: 520px), (max-height: 640px) {
  .stage { padding: 0; }
  .app { width: 100%; height: 100%; min-height: 0; border-radius: 0; box-shadow: none; }
  .web-credit { display: none; }
}

/* In the Mac app the window is the frame. */
html.native body { background: var(--bg); }
html.native .stage { padding: 0; }
html.native .app { width: 100%; height: 100%; min-height: 0; border-radius: 0; box-shadow: none; }
html.native .web-credit { display: none; }

.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* ────────────────────────────────────────────────────────── views ── */

.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 0 20px 16px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateX(28px);
  transition: opacity 0.3s var(--ease), transform 0.5s var(--ease), visibility 0s linear 0.5s;
}
.view.is-left { transform: translateX(-28px); }
.view.is-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity 0.35s var(--ease) 0.05s, transform 0.5s var(--ease), visibility 0s;
}

.bar {
  flex: none; height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.bar-actions { display: flex; align-items: center; gap: 2px; }

.bar-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  animation: fadeSlide 0.6s var(--ease) both;
}
.bar-logo { width: 22px; height: 22px; color: var(--ink); flex: none; }

.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  display: grid; place-items: center;
  background: transparent; color: var(--ink-2);
  transition: background 0.2s, color 0.2s, transform 0.25s var(--spring);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:active { transform: scale(0.9); }

/* ─────────────────────────────────────────────────────────── home ── */

.home-body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 12px;
  padding: 0 2px 2px; margin: 0 -2px;
  scrollbar-width: none;
}
.home-body::-webkit-scrollbar { display: none; }

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 6px; }

.logo-grid {
  position: relative; width: 72px; height: 72px; padding: 0; border: 0;
  border-radius: 18px; overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform 0.45s var(--spring);
  animation: logoIn 0.8s var(--spring) both;
}
.logo-grid:hover { transform: rotate(-3deg) scale(1.04); }
.logo-grid:active { transform: scale(0.95); }
.logo-grid::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--cage);
}
.logo-grid .lg-cells {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
}
.logo-grid .lg-cells span { position: relative; box-shadow: inset -1px -1px 0 var(--grid); }
.logo-grid .lg-cells span:nth-child(3n) { box-shadow: inset 0 -1px 0 var(--grid); }
.logo-grid .lg-cells span:nth-child(n+7) { box-shadow: inset -1px 0 0 var(--grid); }
.logo-grid .lg-cells span:nth-child(9) { box-shadow: none; }
.logo-grid .lg-cells span.sel { background: var(--sel); }
.logo-grid em {
  position: absolute; top: 2.5px; left: 3.5px;
  font-style: normal; font-size: 6.5px; font-weight: 600; color: var(--ink-3); line-height: 1;
}
.logo-grid b {
  position: absolute; inset: 0; display: grid; place-items: center; padding-top: 3px;
  font-size: 12px; font-weight: 500; color: var(--ink);
  animation: pop 0.45s var(--spring) both; animation-delay: var(--delay, 0s);
}
.logo-grid .lg-cells span.sel b { color: var(--accent); }
.logo-grid svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.logo-grid svg path { stroke: var(--cage); stroke-width: 2; stroke-linecap: round; fill: none; }
@keyframes logoIn {
  from { opacity: 0; transform: scale(0.7) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}

.title {
  margin: 16px 0 0; font-family: var(--font-display);
  font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.035em;
  animation: fadeSlide 0.7s var(--ease) 0.08s both;
}
.title-for { color: var(--ink-3); font-weight: 600; }
.byline {
  margin: 6px 0 0; font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  animation: fadeSlide 0.7s var(--ease) 0.16s both;
}

.card {
  background: var(--surface); border-radius: 20px;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-1);
}
.setup {
  padding: 14px; display: flex; flex-direction: column; gap: 14px;
  animation: rise 0.7s var(--ease) 0.2s both;
}
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 2px 8px; }
.field-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.field-value { font-size: 12.5px; font-weight: 500; color: var(--ink-2); text-align: right; }
.field-value.swap { animation: swapIn 0.35s var(--ease); }

/* Segmented control with a sliding thumb. */
.seg {
  position: relative; display: flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border-radius: 12px;
}
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; width: 0;
  border-radius: 9px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--line);
  transition: transform 0.42s var(--soft-spring), width 0.42s var(--soft-spring);
}
:root[data-theme="dark"] .seg-thumb { background: var(--surface-3); }
.seg button {
  position: relative; z-index: 1; flex: 1; min-width: 0; height: 34px;
  border: 0; border-radius: 9px; background: none;
  font-size: 14.5px; font-weight: 500; color: var(--ink-3);
  transition: color 0.25s, transform 0.25s var(--spring);
}
.seg button:hover { color: var(--ink-2); }
.seg button[aria-checked="true"] { color: var(--ink); font-weight: 600; }
.seg button:active { transform: scale(0.94); }
.seg-diff button { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 13.5px; }

/* Difficulty as little signal bars: quieter than colour-coding. */
.pips { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 10px; }
.pips i { width: 2.5px; border-radius: 1px; background: currentColor; opacity: 0.22; transition: opacity 0.3s, transform 0.35s var(--spring); }
.pips i:nth-child(1) { height: 4px; } .pips i:nth-child(2) { height: 6px; }
.pips i:nth-child(3) { height: 8px; } .pips i:nth-child(4) { height: 10px; }
.pips[data-n="1"] i:nth-child(-n+1), .pips[data-n="2"] i:nth-child(-n+2),
.pips[data-n="3"] i:nth-child(-n+3), .pips[data-n="4"] i:nth-child(-n+4) { opacity: 1; }
.seg-diff button[aria-checked="true"] .pips i { transform: scaleY(1.1); }

.ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.op {
  position: relative; height: 50px; border: 0; border-radius: 9px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: transparent; color: var(--ink-3);
  transition: background 0.3s var(--ease), color 0.3s, box-shadow 0.3s, transform 0.25s var(--spring);
}
.op b { font-size: 20px; line-height: 1; font-weight: 400; }
.op span { font-size: 10px; font-weight: 500; letter-spacing: 0.02em; }
.op:hover { color: var(--ink-2); }
.op[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--line); }
:root[data-theme="dark"] .op[aria-pressed="true"] { background: var(--surface-3); }
.op:active { transform: scale(0.93); }
.op.pop b { animation: opPop 0.5s var(--spring); }
.op.nope { animation: shake 0.42s; }
@keyframes opPop { 0% { transform: scale(0.6) rotate(-25deg); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: none; } }

.home-actions { display: flex; gap: 8px; animation: rise 0.7s var(--ease) 0.28s both; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border: 0; border-radius: 12px;
  font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: transform 0.25s var(--spring), box-shadow 0.25s, background 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn .ic { width: 17px; height: 17px; }
.btn-primary {
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 18px -10px rgba(0, 0, 0, 0.45);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.96); }
.btn-primary .ic { stroke-width: 2; }
.btn-big { flex: 1; height: 54px; border-radius: 16px; font-size: 16px; }
.btn-soft { background: var(--surface-2); color: var(--ink); }
.btn-soft:hover { background: var(--surface-3); }
.btn-kbd {
  margin-left: 2px; min-width: 0; height: 19px; padding: 0 6px; font-size: 11px; border-radius: 5px;
  background: rgba(127, 127, 127, 0.22); color: inherit; box-shadow: none; opacity: 0.8;
}

.btn-continue {
  flex: 1.15; height: 54px; padding: 0 14px 0 10px; border-radius: 16px; justify-content: flex-start; gap: 10px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-1);
  animation: rise 0.5s var(--spring) both;
}
.btn-continue:hover { box-shadow: 0 0 0 1px var(--line-2), var(--shadow-2); }
.continue-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; min-width: 0; }
.continue-text b { font-size: 15px; font-weight: 600; }
.continue-text small { font-size: 11.5px; font-weight: 500; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.continue-arrow { margin-left: auto; width: 14px; height: 14px; color: var(--ink-3); }
.home-actions.has-continue .btn-big { flex: 1; font-size: 15px; }
.home-actions.has-continue .btn-big .btn-kbd { display: none; }
.home-actions.has-continue .btn-continue { order: -1; }

.ring { width: 34px; height: 34px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; stroke: var(--surface-3); }
.ring .ring-fill {
  stroke: var(--ink); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0));
  transition: stroke-dashoffset 0.8s var(--ease);
}

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; animation: rise 0.7s var(--ease) 0.36s both; }
.q {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 11px 12px; border-radius: 14px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.q-top {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  white-space: nowrap;
}
.q-top .ic { width: 12px; height: 12px; stroke-width: 2; }
.q b { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q.flame.lit .q-top .ic { color: var(--gold); animation: flicker 1.8s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.12) rotate(-5deg); } }

/* ─────────────────────────────────────────────────────────── game ── */

.game-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.meta-size { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.meta-ops { font-size: 13px; font-weight: 500; letter-spacing: 0.12em; color: var(--ink-3); white-space: nowrap; }
@media (max-width: 420px) { .meta-ops { display: none; } }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 999px;
  color: var(--ink-2); background: var(--surface-2);
}

.timer {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 10px;
  border: 0; border-radius: 999px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line);
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  transition: transform 0.25s var(--spring), box-shadow 0.2s;
}
.timer:hover { box-shadow: 0 0 0 1px var(--line-2), var(--shadow-1); }
.timer:active { transform: scale(0.95); }
.timer .ic { width: 13px; height: 13px; color: var(--ink-3); stroke-width: 2.4; }
.timer.no-time { padding: 0; width: 34px; justify-content: center; }
.timer.no-time span { display: none; }

.board-area { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 2px 0 12px; }

.board-frame {
  --cell: 60px; --cage-w: 2.5px;
  position: relative;
  width: var(--S, 360px); height: var(--S, 360px);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: transform 0.4s var(--spring);
}
.board-frame::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 6;
  box-shadow: inset 0 0 0 calc(var(--cage-w) + 0.5px) var(--cage);
}
.board-frame.pending { opacity: 0; transform: scale(0.97); }
.board-frame.enter { animation: boardIn 0.55s var(--ease) both; }
.board-frame.leave { animation: boardOut 0.22s var(--ease) both; }
.board-frame.solved { animation: solvedBounce 0.7s var(--spring); }
.board-inner { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; transition: filter 0.35s var(--ease); }
.board-frame.paused .board-inner { filter: blur(10px); }

.tints, .cells {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
}
.tints { z-index: 0; }
.tints i { background: transparent; transition: background 0.45s var(--ease); }
.app.color-cages .tints i { background: var(--tint); }
.tints .t0 { --tint: var(--t0); } .tints .t1 { --tint: var(--t1); } .tints .t2 { --tint: var(--t2); }
.tints .t3 { --tint: var(--t3); } .tints .t4 { --tint: var(--t4); } .tints .t5 { --tint: var(--t5); }
.tints.enter i { animation: fadeIn 0.6s var(--ease) both; animation-delay: calc((var(--r) + var(--c)) * 18ms); }

.band {
  position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none;
  background: var(--band); opacity: 0;
  transition: transform 0.3s var(--soft-spring), opacity 0.25s;
}
.band-row { width: 100%; height: var(--cell); }
.band-col { height: 100%; width: var(--cell); }
.app.highlight .has-sel .band { opacity: 1; }

.cursor {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell);
  pointer-events: none; opacity: 0;
  transition: transform 0.3s var(--soft-spring), opacity 0.2s;
}
.has-sel .cursor { opacity: 1; }
.cursor-fill { z-index: 2; background: var(--sel); }
.cursor-ring { z-index: 7; }
.cursor-ring::before {
  content: ""; position: absolute; inset: 2px;
  border-radius: min(calc(var(--cell) * 0.14), 10px);
  box-shadow: 0 0 0 2px var(--accent);
  transition: box-shadow 0.25s;
}
.notes-mode .cursor-ring::before { box-shadow: 0 0 0 2px var(--note); }
.notes-mode .cursor-fill { background: var(--note-soft); }
.cursor-ring.bump::before { animation: ringBump 0.34s var(--spring); }
@keyframes ringBump { 0% { transform: scale(0.88); } 100% { transform: scale(1); } }

.cells { z-index: 3; }
.cell {
  position: relative; cursor: pointer;
  box-shadow: inset -1px -1px 0 var(--grid);
}
.cell::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--flash, transparent); opacity: 0;
}
.cell .lbl {
  position: absolute; z-index: 2;
  top: max(5px, calc(var(--cell) * 0.085)); left: max(6px, calc(var(--cell) * 0.1));
  font-size: clamp(9px, calc(var(--cell) * 0.19), 16px); line-height: 1;
  font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
  color: var(--ink-2);
  transition: color 0.3s;
}
.cell .lbl.good { color: var(--good); }
.cell .lbl.bad { color: var(--bad); }
.cell .lbl.flash { animation: lblPop 0.5s var(--spring); }
.cell .v {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding-top: calc(var(--cell) * 0.1);
  font-family: var(--font-display);
  font-size: min(calc(var(--cell) * 0.48), 54px); font-weight: 500; line-height: 1;
  color: var(--ink);
  transition: color 0.25s;
}
.cell .v.pop { animation: pop 0.4s var(--spring); }
.cell .v.out { animation: popOut 0.2s var(--ease) forwards; }
.cell.same .v { color: var(--accent); }
.cell.hinted .v { color: var(--accent); }
.cell.hinted::before {
  content: ""; position: absolute; z-index: 2; top: 6px; right: 6px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}
.cell.dup .v, .cell.wrong .v { color: var(--bad); }
.cell.shake .v { animation: shake 0.42s; }
.cell.flash-good::after { --flash: var(--good-soft); animation: flash 0.8s var(--ease) var(--delay, 0s); }
.cell.flash-line::after { --flash: var(--accent-soft); animation: flash 0.7s var(--ease) var(--delay, 0s); }
.cell.flash-bad::after { --flash: var(--bad-soft); animation: flash 0.7s var(--ease); }
.cell.win::after { --flash: var(--good-soft); animation: flash 1s var(--ease) var(--delay, 0s) both; }
.cell.win .v { animation: winWave 0.8s var(--spring) var(--delay, 0s) both; }

.cell .nt {
  position: absolute; z-index: 1;
  inset: calc(var(--cell) * 0.27) calc(var(--cell) * 0.07) calc(var(--cell) * 0.05);
  display: grid; grid-template-columns: repeat(var(--m), 1fr); grid-template-rows: repeat(var(--m), 1fr);
  font-size: clamp(8px, calc(var(--cell) * 0.16), 17px); font-weight: 500; line-height: 1;
  color: var(--ink-2);
}
.cell .nt span { display: grid; place-items: center; animation: notePop 0.3s var(--spring); }

.cells.enter .lbl { animation: lblIn 0.5s var(--spring) both; animation-delay: calc((var(--r) + var(--c)) * 22ms + 160ms); }
.cells.enter .v:not(:empty) { animation: pop 0.45s var(--spring) both; animation-delay: calc((var(--r) + var(--c)) * 22ms + 200ms); }

.burst {
  position: absolute; left: 50%; top: 50%; z-index: 4; pointer-events: none;
  width: 100%; height: 100%; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--accent);
  transform: translate(-50%, -50%) scale(0.3); opacity: 1;
  animation: burst 0.7s var(--ease) forwards;
}
.burst.spark { width: 4px; height: 4px; box-shadow: none; background: var(--accent); animation: spark 0.7s var(--ease) forwards; }

.cage-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; overflow: visible; }
.cage-svg path { fill: none; stroke: var(--cage); stroke-width: var(--cage-w); stroke-linecap: round; }
.cage-svg.draw path {
  stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0;
  animation: drawLine 0.55s var(--ease) forwards; animation-delay: var(--d, 0s);
}

.veil, .loader {
  position: absolute; inset: 0; z-index: 8; border-radius: inherit;
  display: grid; place-items: center;
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.veil { background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.veil.open, .loader.open { opacity: 1; }
.veil-card { display: flex; flex-direction: column; align-items: center; gap: 12px; transform: translateY(10px) scale(0.97); transition: transform 0.5s var(--spring); }
.veil.open .veil-card { transform: none; }
.veil-title { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.veil-time { font-family: var(--font-display); font-size: 44px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; margin-bottom: 6px; }
.veil .btn-primary { min-width: 170px; }
.veil-row { display: flex; gap: 8px; }
.veil-row .btn { height: 38px; font-size: 13.5px; padding: 0 14px; }

.loader { flex-direction: column; align-content: center; gap: 14px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); pointer-events: none; }
.loader-grid { display: grid; grid-template-columns: repeat(3, 12px); gap: 4px; }
.loader-grid i { width: 12px; height: 12px; border-radius: 3px; background: var(--ink); animation: loaderPulse 1.1s var(--ease) infinite; }
.loader-grid i:nth-child(1) { animation-delay: 0s; } .loader-grid i:nth-child(2), .loader-grid i:nth-child(4) { animation-delay: 0.1s; }
.loader-grid i:nth-child(3), .loader-grid i:nth-child(5), .loader-grid i:nth-child(7) { animation-delay: 0.2s; }
.loader-grid i:nth-child(6), .loader-grid i:nth-child(8) { animation-delay: 0.3s; } .loader-grid i:nth-child(9) { animation-delay: 0.4s; }
@keyframes loaderPulse { 0%, 100% { transform: scale(0.55); opacity: 0.15; } 45% { transform: scale(1); opacity: 0.8; } }

/* ──────────────────────────────────────────────────────── pad/tools ── */

.pad { flex: none; display: grid; grid-template-columns: repeat(var(--n, 6), 1fr); gap: 6px; }
.key {
  position: relative; height: 52px; border: 0; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 1.5px 0 var(--key-edge);
  font-family: var(--font-display);
  font-size: 22px; font-weight: 500; color: var(--ink);
  transition: transform 0.2s var(--spring), box-shadow 0.15s, background 0.2s, color 0.25s, font-size 0.25s var(--spring);
  animation: keyIn 0.45s var(--spring) both; animation-delay: calc(var(--k) * 28ms + 200ms);
}
.key:hover { background: var(--surface-2); }
.key:active, .key.pressed { transform: translateY(1.5px) scale(0.96); box-shadow: 0 0 0 1px var(--line), 0 0 0 var(--key-edge); }
.key .kbar {
  position: absolute; left: 30%; right: 30%; bottom: 7px; height: 2px; border-radius: 2px;
  background: var(--surface-3); overflow: hidden;
}
.key .kbar::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--ink-3);
  transform-origin: left; transform: scaleX(var(--p, 0));
  transition: transform 0.45s var(--soft-spring), background 0.3s;
}
.key.done { color: var(--ink-3); }
.key.done .kbar::after { background: var(--good); }
.notes-mode .key { font-size: 16px; color: var(--note); }

.tools { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.tool {
  position: relative; height: 54px; border: 0; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: transparent; color: var(--ink-2);
  font-size: 11px; font-weight: 500;
  transition: background 0.2s, color 0.2s, transform 0.25s var(--spring);
}
.tool .ic { width: 20px; height: 20px; transition: transform 0.35s var(--spring); }
.tool:hover { background: var(--hover); color: var(--ink); }
.tool:active { transform: scale(0.92); }
.tool:active .ic { transform: rotate(-8deg); }
.tool[aria-pressed="true"] { color: var(--note); background: var(--note-soft); }
.tool[aria-pressed="true"] .ic { transform: rotate(-10deg) translateY(-1px); }
.tool-badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  font-size: 8.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-style: normal;
  padding: 2px 5px; border-radius: 99px;
  background: var(--surface-2); color: var(--ink-3);
  transition: background 0.25s, color 0.25s, transform 0.35s var(--spring);
}
.tool[aria-pressed="true"] .tool-badge { background: var(--note); color: var(--bg); }
.tool-count { background: var(--surface-2); color: var(--ink-2); }
.tool.nope { animation: shake 0.42s; }

/* ───────────────────────────────────────────────────────── layers ── */

.layer { position: absolute; inset: 0; z-index: 30; }
.scrim {
  position: absolute; inset: 0; background: rgba(10, 10, 12, 0.28);
  opacity: 0; transition: opacity 0.35s var(--ease);
}
.layer.open .scrim { opacity: 1; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: calc(100% - 40px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 50px -24px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--line);
  transform: translateY(104%);
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
}
.layer.open .sheet { transform: none; }
.sheet::before {
  content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
  border-radius: 2px; background: var(--line-2);
}
#sheet-stats { height: calc(100% - 40px); }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 22px 16px 6px 22px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.025em; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 18px 28px; scrollbar-width: thin; }
.sheet-body > * { animation: rise 0.55s var(--ease) both; }
.sheet-body > *:nth-child(2) { animation-delay: 0.04s; } .sheet-body > *:nth-child(3) { animation-delay: 0.08s; }
.sheet-body > *:nth-child(4) { animation-delay: 0.12s; } .sheet-body > *:nth-child(5) { animation-delay: 0.16s; }
.sheet-body > *:nth-child(n+6) { animation-delay: 0.2s; }

/* stats */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; height: 30px; padding: 0 12px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 500;
  box-shadow: 0 0 0 1px var(--line);
  transition: background 0.25s, color 0.25s, transform 0.25s var(--spring);
}
.chip-btn:active { transform: scale(0.93); }
.chip-btn.on { background: var(--primary); color: var(--primary-ink); box-shadow: none; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 11px 12px; border-radius: 14px; background: var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.tile-top { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.tile-top .ic { width: 12px; height: 12px; stroke-width: 2; }
.tile b { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.tile small { font-size: 11px; font-weight: 400; color: var(--ink-3); margin-top: -2px; }

.panel { padding: 14px 14px 12px; border-radius: 18px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.panel-head h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.panel-head span { font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.empty { padding: 22px 8px; text-align: center; font-size: 13px; font-weight: 500; color: var(--ink-3); }

.bars { display: block; width: 100%; height: 150px; overflow: visible; }
.bars .gl { stroke: var(--line); stroke-width: 1; }
.bars .gt { fill: var(--ink-3); font-size: 10px; font-weight: 500; }
.bars .bar { fill: var(--accent); transform-box: fill-box; transform-origin: 50% 100%; animation: barUp 0.7s var(--soft-spring) both; transition: opacity 0.2s; }
.bars .hit { fill: transparent; cursor: pointer; }
.bars.hovering .bar { opacity: 0.3; }
.bars.hovering .bar.on { opacity: 1; }
.bars .avg { stroke: var(--ink-2); stroke-width: 1.25; stroke-dasharray: 3 4; }
.avg-key { display: inline-block; width: 14px; height: 0; margin: 0 5px 3px 0; vertical-align: middle; border-top: 1.25px dashed var(--ink-2); }
@keyframes barUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heat i {
  aspect-ratio: 1; border-radius: 3px; background: var(--h0);
  animation: fadeIn 0.4s var(--ease) both; animation-delay: calc(var(--k) * 4ms);
  transition: transform 0.2s var(--spring);
}
.heat i:hover { transform: scale(1.3); }
.heat i[data-l="1"] { background: var(--h1); } .heat i[data-l="2"] { background: var(--h2); }
.heat i[data-l="3"] { background: var(--h3); } .heat i[data-l="4"] { background: var(--h4); }
.heat i.today { box-shadow: 0 0 0 1.5px var(--ink-2); }
.heat i.future { visibility: hidden; }
.heat-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.legend { display: flex; align-items: center; gap: 3px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

.best-table { display: grid; grid-template-columns: 44px repeat(4, 1fr); gap: 4px 6px; align-items: center; font-size: 13px; font-weight: 500; }
.best-table .bh { font-size: 11px; font-weight: 500; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.best-table .bs { color: var(--ink-2); font-size: 12.5px; }
.best-table .bt { padding: 6px 8px; border-radius: 8px; background: var(--surface-2); text-align: left; }
.best-table .bt.none { color: var(--ink-3); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.best-table .bt.hot { background: var(--accent-soft); color: var(--accent); }
.best-table .row-dim { opacity: 0.35; }

.danger-link {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  height: 42px; border: 0; border-radius: 12px; background: transparent;
  color: var(--bad); font-size: 13.5px; font-weight: 500;
  transition: background 0.2s;
}
.danger-link:hover { background: var(--bad-soft); }
.danger-link .ic { width: 16px; height: 16px; }

/* settings */
.group { margin-bottom: 16px; }
.group-title { margin: 0 6px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.rows { border-radius: 16px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 54px; }
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 500; }
.row-desc { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.row .seg { flex: none; width: 190px; }
.row .seg button { height: 28px; font-size: 12.5px; }

.switch { position: relative; flex: none; width: 44px; height: 26px; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3);
  transition: background 0.3s var(--ease);
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 0.42s var(--spring), width 0.2s var(--ease);
}
.switch input:checked + span { background: var(--primary); }
:root[data-theme="dark"] .switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:active + span::after { width: 27px; }
.switch input:checked:active + span::after { transform: translateX(13px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.range { -webkit-appearance: none; appearance: none; width: 130px; height: 4px; border-radius: 2px; background: var(--surface-3); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.06); cursor: pointer; }
.range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }

.about { display: flex; align-items: center; gap: 14px; padding: 14px; }
.about img { width: 50px; height: 50px; border-radius: 12px; }
.about-name { font-size: 15px; font-weight: 600; }
.about-meta { font-size: 12.5px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.about-links { display: flex; gap: 8px; padding: 0 14px 14px; }
.about-links a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px;
  border-radius: 10px; background: var(--surface-2); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500;
  transition: background 0.2s, transform 0.25s var(--spring);
}
.about-links a:hover { background: var(--surface-3); }
.about-links a:active { transform: scale(0.96); }
.about-links .ic { width: 15px; height: 15px; }

/* help */
.help { font-size: 14px; line-height: 1.55; font-weight: 400; color: var(--ink-2); }
.rule { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.rule p { margin: 0; }
.rule b { color: var(--ink); font-weight: 600; }
.rule-n {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
}
.examples { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 4px 0 16px 34px; }
.ex { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.ex-cage { display: flex; border-radius: 7px; box-shadow: inset 0 0 0 2px var(--cage); background: var(--surface); overflow: hidden; }
.ex-cage i {
  position: relative; width: 34px; height: 34px; display: grid; place-items: center; padding-top: 5px;
  font-style: normal; font-size: 16px; font-weight: 500; color: var(--ink);
}
.ex-cage i + i { box-shadow: inset 1px 0 0 var(--grid); }
.ex-cage em { position: absolute; top: 3px; left: 4px; font-style: normal; font-size: 8.5px; font-weight: 600; color: var(--ink-2); line-height: 1; }
.help-h { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.help-h .ic { width: 16px; height: 16px; }
.keys { border-radius: 14px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.keys div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 14px; font-size: 13px; }
.keys div + div { box-shadow: inset 0 1px 0 var(--line); }
.keys span:first-child { display: flex; align-items: center; gap: 3px; color: var(--ink-3); }

/* dialogs */
.dialog-layer { display: grid; place-items: center; padding: 20px; }
.dialog {
  position: relative; width: 100%; max-width: 350px;
  padding: 26px 20px 18px; border-radius: 24px;
  background: var(--surface); box-shadow: var(--shadow-3);
  text-align: center;
  opacity: 0; transform: translateY(16px) scale(0.94);
  transition: transform 0.55s var(--spring), opacity 0.25s var(--ease);
}
.layer.open .dialog { opacity: 1; transform: none; }
.dialog h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }
.dialog p { margin: 6px 0 0; font-size: 14px; font-weight: 400; color: var(--ink-2); line-height: 1.45; }
.dialog-actions { display: flex; gap: 8px; margin-top: 20px; }
.dialog-actions .btn { flex: 1; height: 46px; }
.confirm .btn-primary.danger { background: var(--bad); color: #fff; box-shadow: none; }

.win-badge { position: relative; width: 72px; height: 72px; margin: -2px auto 12px; }
.win-badge svg { position: relative; width: 100%; height: 100%; }
.wb-ring, .wb-check { fill: none; stroke: var(--good); stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.wb-ring { stroke-width: 3.5; }
.wb-check { stroke-width: 4.5; }
.layer.open .wb-ring { animation: draw 0.6s var(--ease) 0.15s forwards; }
.layer.open .wb-check { animation: draw 0.4s var(--ease) 0.6s forwards; }
.layer.open .win-badge svg { animation: badgePop 0.7s var(--spring) 0.05s both; }
.win-sub { font-size: 13px !important; color: var(--ink-3) !important; }
.win-time { margin: 14px 0 4px; font-family: var(--font-display); font-size: 50px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.win-record {
  display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 2px; padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--ink);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  animation: pop 0.6s var(--spring) 0.8s both;
}
.win-record .ic { width: 14px; height: 14px; color: var(--gold); }
.win-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 16px; }
.win-stats div { display: flex; flex-direction: column; gap: 3px; padding: 10px 4px; border-radius: 12px; background: var(--surface-2); }
.win-stats b { font-size: 16px; font-weight: 600; }
.win-stats span { font-size: 10.5px; font-weight: 500; color: var(--ink-3); }
.layer.open .win-stats div { animation: rise 0.5s var(--spring) both; }
.layer.open .win-stats div:nth-child(1) { animation-delay: 0.5s; } .layer.open .win-stats div:nth-child(2) { animation-delay: 0.56s; }
.layer.open .win-stats div:nth-child(3) { animation-delay: 0.62s; } .layer.open .win-stats div:nth-child(4) { animation-delay: 0.68s; }

.toast {
  position: absolute; left: 50%; bottom: 150px; z-index: 50;
  max-width: calc(100% - 40px); padding: 9px 15px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px;
  background: var(--toast-bg); color: var(--toast-ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow-2);
  opacity: 0; transform: translate(-50%, 12px) scale(0.95); pointer-events: none;
  transition: transform 0.45s var(--spring), opacity 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast .ic { width: 15px; height: 15px; }

.tip {
  position: absolute; z-index: 60; left: 0; top: 0; padding: 6px 9px; border-radius: 8px;
  background: var(--toast-bg); color: var(--toast-ink); font-size: 12px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow-2); pointer-events: none;
  opacity: 0; transform: translate(-50%, calc(-100% - 6px)) scale(0.92);
  transition: opacity 0.15s, transform 0.2s var(--spring);
}
.tip.show { opacity: 1; transform: translate(-50%, calc(-100% - 10px)) scale(1); }
.tip small { display: block; font-size: 11px; opacity: 0.7; font-weight: 400; }

/* ─────────────────────────────────────────────────────── keyframes ── */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes swapIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes drawLine { 0% { stroke-dashoffset: 1; opacity: 0; } 15% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; filter: blur(2px); } 55% { transform: scale(1.1); opacity: 1; filter: blur(0); } 100% { transform: scale(1); opacity: 1; } }
@keyframes popOut { to { transform: scale(0.5); opacity: 0; filter: blur(2px); } }
@keyframes notePop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes lblIn { from { opacity: 0; transform: translate(-3px, -3px) scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes lblPop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes keyIn { from { opacity: 0; transform: translateY(10px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 18% { transform: translateX(-4px); } 36% { transform: translateX(4px); } 54% { transform: translateX(-3px); } 72% { transform: translateX(2px); } 88% { transform: translateX(-1px); } }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes winWave { 0% { transform: scale(1); } 40% { transform: scale(1.22) translateY(-5%); color: var(--good); } 100% { transform: scale(1); color: var(--good); } }
@keyframes boardIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes boardOut { to { opacity: 0; transform: scale(0.97); } }
@keyframes solvedBounce { 0% { transform: scale(1); } 30% { transform: scale(1.025); } 60% { transform: scale(0.995); } 100% { transform: scale(1); } }
@keyframes burst { to { transform: translate(-50%, -50%) scale(1.4); opacity: 0; } }
@keyframes spark { 0% { transform: translate(-50%, -50%) rotate(var(--a)) translateY(0) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(var(--a)) translateY(calc(var(--cell) * -0.7)) scale(0.2); opacity: 0; } }
@keyframes badgePop { from { transform: scale(0.5) rotate(-15deg); opacity: 0; } to { transform: none; opacity: 1; } }

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

/* ─────────────────────────────────────────── wide screens (website only) ──
   On a laptop or monitor the website spreads out: two columns on the home
   screen, three around the board, and centred windows instead of sheets.
   Everything here is scoped to html:not(.native), so the Mac app keeps its
   compact single-column layout no matter how it is resized. */

.desk-only { display: none; }
.game-layout, .game-controls { display: contents; }
.tool-kbd { display: none; }
.btn-ghost { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }

@media (min-width: 980px) and (min-height: 620px) {
  html:not(.native) .stage { padding: 0; }
  html:not(.native) .app { width: 100%; height: 100%; min-height: 0; border-radius: 0; box-shadow: none; }
  html:not(.native) .web-credit { display: none; }
  html:not(.native) .view { padding: 0 40px 28px; }
  html:not(.native) .bar { width: 100%; max-width: 1240px; margin: 0 auto; height: 76px; }

  /* Home: story on the left, setup on the right. */
  html:not(.native) .home-body {
    display: grid; grid-template-columns: minmax(0, 1fr) 440px;
    grid-template-rows: 1fr auto auto auto 1fr;
    grid-template-areas: "hero ." "hero setup" "hero actions" "hero quick" "hero .";
    align-content: center; column-gap: clamp(48px, 8vw, 120px); row-gap: 12px;
    width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 2px 48px;
  }
  html:not(.native) .hero { grid-area: hero; align-items: flex-start; text-align: left; align-self: center; padding: 0; }
  html:not(.native) .setup { grid-area: setup; }
  html:not(.native) .home-actions { grid-area: actions; }
  html:not(.native) .quick { grid-area: quick; }
  html:not(.native) .logo-grid { width: 116px; height: 116px; border-radius: 26px; }
  html:not(.native) .logo-grid em { top: 4px; left: 5px; font-size: 10px; }
  html:not(.native) .logo-grid b { font-size: 19px; padding-top: 5px; }
  html:not(.native) .logo-grid svg path { stroke-width: 2.6px; vector-effect: non-scaling-stroke; }
  html:not(.native) .logo-grid::after { box-shadow: inset 0 0 0 2.6px var(--cage); }
  html:not(.native) .title { margin-top: 30px; font-size: clamp(46px, 4.6vw, 64px); letter-spacing: -0.045em; line-height: 1.02; }
  html:not(.native) .title-for { display: block; }
  html:not(.native) .byline { margin-top: 14px; font-size: 14px; }
  html:not(.native) .hero-desc { display: block; max-width: 440px; margin: 22px 0 0; font-size: 16px; line-height: 1.6; color: var(--ink-2); animation: fadeSlide 0.7s var(--ease) 0.24s both; }
  html:not(.native) .hero-keys {
    display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 22px;
    font-size: 13px; color: var(--ink-3); animation: fadeSlide 0.7s var(--ease) 0.3s both;
  }
  html:not(.native) .hero-keys span { display: inline-flex; align-items: center; gap: 4px; }
  html:not(.native) .hero-links { display: flex; gap: 10px; margin-top: 30px; animation: fadeSlide 0.7s var(--ease) 0.36s both; }
  html:not(.native) .hero-links .btn { text-decoration: none; font-size: 14px; height: 42px; }

  /* Game: details | board | controls. */
  html:not(.native) .game-layout {
    display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr) minmax(230px, 290px);
    gap: clamp(24px, 3vw, 44px); align-items: center;
    flex: 1; min-height: 0; width: 100%; max-width: 1240px; margin: 0 auto;
  }
  html:not(.native) .board-area { height: 100%; padding: 4px 0 8px; }
  html:not(.native) .board-frame { border-radius: 18px; }
  html:not(.native) #timer-btn { display: none; }

  html:not(.native) .game-side { display: flex; flex-direction: column; gap: 10px; animation: rise 0.6s var(--ease) 0.1s both; }
  .side-card { padding: 14px 16px; border-radius: 16px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
  .side-clock-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .side-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
  .side-clock { font-family: var(--font-display); font-size: 44px; font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; }
  .side-pause { margin-top: 8px; width: 100%; height: 38px; font-size: 13.5px; }
  .side-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; color: var(--ink-3); }
  .side-row b { font-weight: 600; color: var(--ink); }
  .side-rows { display: flex; flex-direction: column; gap: 9px; }
  .side-bar { position: relative; height: 4px; margin-top: 10px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
  .side-bar i { position: absolute; inset: 0; border-radius: inherit; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform 0.5s var(--soft-spring); }
  html:not(.native) .side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .side-actions .btn { height: 40px; font-size: 13.5px; padding: 0 10px; }

  html:not(.native) .game-controls { display: flex; flex-direction: column; gap: 12px; animation: rise 0.6s var(--ease) 0.16s both; }
  html:not(.native) .pad { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  html:not(.native) .pad[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
  html:not(.native) .key { height: auto; aspect-ratio: 1.2; font-size: 28px; border-radius: 14px; }
  html:not(.native) .notes-mode .key { font-size: 20px; }
  html:not(.native) .tools { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 0; }
  html:not(.native) .tool {
    flex-direction: row; justify-content: flex-start; gap: 9px; height: 46px; padding: 0 12px;
    font-size: 13.5px; background: var(--surface); box-shadow: 0 0 0 1px var(--line);
  }
  html:not(.native) .tool:hover { background: var(--surface-2); }
  html:not(.native) .tool[aria-pressed="true"] { background: var(--note-soft); box-shadow: 0 0 0 1px var(--note); }
  html:not(.native) .tool .ic { width: 18px; height: 18px; }
  html:not(.native) .tool-badge { position: static; margin-left: -2px; }
  html:not(.native) .tool-kbd { display: inline-grid; margin-left: auto; min-width: 20px; height: 20px; font-size: 11px; }
  html:not(.native) .shortcut-card {
    display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 14px;
    box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; color: var(--ink-3);
  }
  .shortcut-card div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .shortcut-card span { display: inline-flex; align-items: center; gap: 3px; }
  .shortcut-card kbd { min-width: 20px; height: 20px; font-size: 11px; }

  /* Sheets become centred windows. */
  html:not(.native) .scrim { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
  html:not(.native) .sheet {
    left: 50%; right: auto; top: 50%; bottom: auto;
    width: min(560px, calc(100% - 64px)); max-height: min(780px, calc(100% - 64px));
    border-radius: 22px; opacity: 0;
    transform: translate(-50%, -47%) scale(0.97);
    transition: transform 0.45s var(--spring), opacity 0.25s var(--ease);
    box-shadow: var(--shadow-3);
  }
  html:not(.native) .layer.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  html:not(.native) .sheet::before { display: none; }
  html:not(.native) .sheet-head { padding: 22px 18px 6px 24px; }
  html:not(.native) .sheet-body { padding: 8px 24px 26px; }
  html:not(.native) #sheet-stats { width: min(880px, calc(100% - 64px)); height: min(840px, calc(100% - 64px)); }
  html:not(.native) #stats-body { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: max-content; column-gap: 12px; align-content: start; }
  html:not(.native) #stats-body > .chips,
  html:not(.native) #stats-body > .tiles,
  html:not(.native) #stats-body > .panel-best,
  html:not(.native) #stats-body > .danger-link { grid-column: 1 / -1; }
  html:not(.native) #stats-body .tiles { grid-template-columns: repeat(6, 1fr); }
  html:not(.native) #stats-body .panel-best .best-table { grid-template-columns: 56px repeat(4, 1fr); gap: 5px 10px; }
  html:not(.native) .toast { bottom: 48px; }
}
