/* Sudoku Studio — Classical direction. Tokens mirrored from the design system
   (design_handoff_sudoku_studio/classical/styles.css); layout is app-specific. */

/* — Fonts (self-hosted OFL woff2, latin subset) — */
@font-face {
  font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/CormorantGaramond-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/CormorantGaramond-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/Lora-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/Lora-SemiBold.woff2') format('woff2');
}

/* — Tokens — */
:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201f1d;
  --color-accent: #b68235;
  --color-accent-2: #ac803e;
  --color-divider: color-mix(in srgb, #201f1d 16%, transparent);

  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #fff3e4;
  --color-accent-200: #ffe3bf;
  --color-accent-300: #facb8d;
  --color-accent-400: #e1ad66;
  --color-accent-500: #c28d41;
  --color-accent-600: #a06f24;
  --color-accent-700: #7d5411;
  --color-accent-800: #5a3b0a;
  --color-accent-900: #3a270d;

  --color-accent-2-700: #79561f;
  --color-accent-2-800: #573d14;

  /* The nine as dealt — deliberately lighter than the thin grid hairlines so
     untouched marks read as texture, never competing with ink. */
  --note-untouched: #cbc7c7;

  --font-heading: 'Cormorant Garamond', system-ui, serif;
  --font-heading-weight: 600;
  --font-body: 'Lora', system-ui, serif;

  --space-1: 4.6px;
  --space-2: 9.2px;
  --space-3: 13.8px;
  --space-4: 18.4px;
  --space-6: 27.6px;
  --space-8: 36.8px;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 7px;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);

  /* Derived board line colors */
  --line-thin: color-mix(in srgb, var(--color-text) 12%, transparent);
  --line-thick: color-mix(in srgb, var(--color-text) 42%, transparent);
  --board-border: color-mix(in srgb, var(--color-text) 64%, transparent);
  --desk: color-mix(in srgb, var(--color-text) 5%, var(--color-bg));
}

/* — Base — */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  color: var(--color-text);
}
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — Scale-to-fit stage: fixed 978x790 design, zoomed uniformly to fill the
   window (set by fitToWindow in app.js). overflow:hidden -> never a scrollbar. — */
html, body { height: 100%; overflow: hidden; }
.desk {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--color-bg);
}
.app-window {
  position: relative;
  flex: none;
  width: 978px;
  height: auto;
  background: var(--color-bg);
  overflow: hidden;
}
.content { transition: filter 0.25s; }
.content.paused { filter: blur(7px); pointer-events: none; }

/* — Buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 13px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: calc(var(--space-2) * 0.85) var(--space-3);
  border-radius: var(--radius-md);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
/* Hover tints apply only on hover-capable devices (desktop always matches, so
   the cascade is unchanged there — hovers stay ahead of their :active rules);
   touch devices skip them, so taps never leave a sticky hover state. */
@media (hover: hover) {
  .btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
  .btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
  .btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
  .cell:hover .note-slot:not(.pencilled) { color: var(--note-untouched); }
}
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }

/* — Tags — */
.tag {
  display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: calc(var(--radius-md) * 0.75);
}
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* — Cards — */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md);
  background: transparent; border: 1px solid var(--color-divider);
}
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); line-height: 1.2; }

/* — App header — */
.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px; height: 52px; border-bottom: 1px solid var(--color-divider);
}
.wordmark {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 15px; letter-spacing: 0.01em;
}
.titlebar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* — Body layout — */
.body { display: flex; gap: 28px; padding: 22px 28px 26px; }
.left-col { display: flex; flex-direction: column; gap: 16px; }
.right-col { width: 300px; display: flex; flex-direction: column; gap: 16px; }

/* — Toolbar — */
.toolbar { display: flex; align-items: flex-end; gap: 16px; }
.toolbar-left { display: flex; flex-direction: column; }
.elapsed-label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.elapsed-row { display: flex; align-items: baseline; gap: 10px; }
.timer { font-family: var(--font-heading); font-variant-numeric: tabular-nums; font-size: 34px; line-height: 1; }
.trend-micro {
  display: flex; align-items: center; gap: 5px; font-size: 12px;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.trend-micro-mark { font-weight: 700; font-size: 14px; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* Trend state colors (applied to the mark glyphs) */
.trend-improving { color: var(--color-accent-700); }
.trend-plateau { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.trend-declining { color: var(--color-accent-2-700); }
.trend-calibrating { color: color-mix(in srgb, var(--color-text) 45%, transparent); }

/* — Board — */
.board-wrap { position: relative; width: 594px; height: 594px; }
.board {
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  width: 100%; height: 100%;
  border: 2px solid var(--board-border); border-radius: var(--radius-sm);
  background: var(--color-bg);
}
.cell {
  position: relative;
  display: flex; align-items: center; justify-content: center; box-sizing: border-box;
  padding: 0; border: 0;
  border-top: 1px solid var(--line-thin); border-left: 1px solid var(--line-thin);
  background: transparent; cursor: pointer; user-select: none;
  /* 30px, up from the handoff's 27: scan-tested 2026-07-22 — zero misses/FPs
     and ~600ms faster row scans at 30px; same face, larger cut. */
  font-family: var(--font-heading); font-size: 30px; line-height: 1;
  color: var(--color-accent-700); font-weight: 500;
  transition: background 0.12s;
}
/* Pencil-note grid: every empty, non-given cell carries all nine, always.
   Digit d occupies slot d-1, row-major — position alone identifies it. */
.cell-notes {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 5px; box-sizing: border-box;
}
.note-slot {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: 11px; line-height: 1; letter-spacing: 0.01em;
  transition: color 0.1s; /* graphite landing + hover fade — the motion ceiling */
}
/* On the board, untouched marks surface only under the pointer (deliberate
   override of the always-visible concept; the hover rule lives in the
   (hover:hover) block by the button hovers). The slots still occupy their grid
   positions; only the color hides. Pencilled marks never hide. The magnifier's
   .sel-note-slot is the always-on detail view and is untouched by this. */
.note-slot:not(.pencilled) { color: transparent; }
.note-slot.pencilled { color: var(--color-neutral-600); }
.cell.has-value .cell-notes { display: none; } /* hidden while a value is present, never deleted */
.cell.edge-top { border-top: 0; }
.cell.edge-left { border-left: 0; }
.cell.thick-top { border-top: 2px solid var(--line-thick); }
.cell.thick-left { border-left: 2px solid var(--line-thick); }
.cell.given { color: var(--color-text); font-weight: 600; cursor: default; }
.cell.selected {
  background: color-mix(in srgb, var(--color-accent) 16%, transparent);
  box-shadow: inset 0 0 0 2px var(--color-accent);
}
.cell:focus-visible { outline-offset: -2px; }
.board.locked .cell { cursor: default; }
.board-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-divider); border-radius: var(--radius-sm);
  background: var(--color-bg); font-style: italic;
  color: color-mix(in srgb, var(--color-text) 45%, transparent);
}

/* — Selected-cell card (the cell itself is the picker) — */
.card-head { display: flex; align-items: baseline; justify-content: space-between; }
.sel-coords { font-size: 10px; letter-spacing: 0.04em; color: color-mix(in srgb, var(--color-text) 42%, transparent); }
.sel-body { display: flex; gap: 14px; align-items: flex-start; }
.sel-magnifier {
  position: relative; flex: none; width: 112px; height: 112px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb, var(--color-text) 22%, transparent); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-accent) 8%, transparent);
}
/* Value mode: the cell's 30px digit at the card's scale (30px × 112/66, floored). */
.sel-value { font-family: var(--font-heading); font-size: 50px; line-height: 1; }
.sel-magnifier.is-given .sel-value { color: var(--color-text); font-weight: 600; }
.sel-magnifier.is-filled .sel-value { color: var(--color-accent-700); font-weight: 500; }
.sel-notes {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 8px; box-sizing: border-box;
}
.sel-note-slot {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: 18px; line-height: 1;
  color: var(--note-untouched);
}
.sel-note-slot.pencilled { color: var(--color-neutral-600); }
/* No digits while a value is shown or nothing is selected. */
.sel-magnifier.has-value .sel-notes, .sel-magnifier.sel-none .sel-notes { display: none; }
.sel-legend { display: flex; flex-direction: column; gap: 9px; padding-top: 2px; }
.sel-legend-row { display: flex; align-items: baseline; gap: 8px; }
.sel-swatch { font-family: var(--font-body); font-size: 15px; }
.swatch-untouched { color: var(--note-untouched); }
.swatch-pencilled { color: var(--color-neutral-600); }
.swatch-inked { font-family: var(--font-heading); font-size: 19px; line-height: 1; color: var(--color-accent-700); }
.sel-legend-label { font-size: 11.5px; line-height: 1.35; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.sel-caption { font-size: 11px; line-height: 1.45; color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.sel-divider { height: 1px; background: var(--color-divider); margin: 6px 0 2px; }
.tally-kicker {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.tally { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.tally-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 0; border-radius: 3px; background: color-mix(in srgb, var(--color-text) 4%, transparent);
}
.tally-digit { font-family: var(--font-heading); font-size: 15px; line-height: 1; }
.tally-count { font-size: 9.5px; line-height: 1; color: color-mix(in srgb, var(--color-text) 42%, transparent); font-variant-numeric: tabular-nums; }

/* — Skill card — */
.skill-head { display: flex; align-items: baseline; justify-content: space-between; }
.skill-head .card-title { font-size: 27px; }
.skill-score { font-variant-numeric: tabular-nums; font-size: 13px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.skill-denom { opacity: 0.5; }
.skill-track { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--color-text) 10%, transparent); overflow: hidden; }
.skill-fill { height: 100%; width: 0%; background: var(--color-accent); border-radius: 999px; transition: width 0.5s ease; }
.trend-block { display: flex; align-items: flex-start; gap: 9px; margin-top: 6px; }
.trend-mark { font-weight: 700; font-size: 19px; line-height: 1; margin-top: 1px; }
.trend-word { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 15px; line-height: 1.2; }
.trend-desc { font-size: 12px; line-height: 1.4; color: color-mix(in srgb, var(--color-text) 58%, transparent); }
.skill-accuracy { font-style: italic; }
.spark-wrap { margin-top: 8px; }
.spark-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: color-mix(in srgb, var(--color-text) 50%, transparent); margin-bottom: 4px; }
.spark { width: 100%; height: 38px; display: block; overflow: visible; }

/* — This-puzzle card — */
.stat-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; font-size: 13px; }
.stat-label { color: color-mix(in srgb, var(--color-text) 58%, transparent); }
.stat-difficulty { font-family: var(--font-heading); }
.stat-clues { color: color-mix(in srgb, var(--color-text) 45%, transparent); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.stat-best { color: var(--color-accent-700); }
.stat-caption { font-size: 11.5px; line-height: 1.4; color: color-mix(in srgb, var(--color-text) 48%, transparent); margin-top: 4px; }

/* — Footer — */
.footer { display: flex; justify-content: space-between; align-items: baseline; padding: 0 3px; font-size: 12px; color: color-mix(in srgb, var(--color-text) 52%, transparent); }

/* — Pause overlay — */
.overlay-pause {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--color-bg) 52%, transparent);
  cursor: pointer; /* click anywhere resumes (handler in app.js); look otherwise unchanged */
}
.pause-inner { text-align: center; animation: sdk-pop 0.25s ease; }
.pause-kicker {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 55%, transparent); margin-bottom: 8px;
}
.pause-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 40px; line-height: 1; margin-bottom: 18px; }
.pause-continue { font-size: 15px; padding: 12px 30px; }

/* — Completion summary — */
.overlay-summary {
  /* Fixed to the viewport (not the zoom-scaled #appWindow) so the scrim covers
     the whole window, including the letterbox margins around the stage. */
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--color-neutral-900) 42%, transparent);
  animation: sdk-fade 0.2s ease;
}
.summary-card {
  width: min(430px, 100%); display: flex; flex-direction: column; gap: 12px;
  padding: 26px; border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg); border: 1px solid var(--color-divider);
  animation: sdk-pop 0.3s ease;
}
.summary-bar { height: 3px; width: 46px; background: var(--color-accent); transform-origin: left; animation: sdk-sweep 0.5s ease; }
.summary-kicker { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--color-accent); }
.summary-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 30px; line-height: 1.05; }
.summary-time-row { display: flex; align-items: baseline; gap: 12px; margin-top: 2px; }
.summary-time { font-family: var(--font-heading); font-variant-numeric: tabular-nums; font-size: 46px; line-height: 1; }
.summary-sub { font-size: 13px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.summary-best {
  align-self: flex-start; margin: 2px 0; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--color-accent-2) 14%, transparent); color: var(--color-accent-2-800);
  animation: sdk-ring 1.4s ease 0.3s 2;
}
.summary-divider { height: 1px; background: var(--color-divider); margin: 4px 0; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; }
.summary-row .stat-value { font-family: var(--font-heading); }
.summary-delta { color: var(--color-accent-700); font-variant-numeric: tabular-nums; }
.summary-tier { font-size: 13px; font-style: italic; color: var(--color-accent-700); margin-top: 2px; }
.summary-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* — Completion summary · skill-trajectory (zen) card — */
.summary-journey { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.summary-journey-label {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.summary-spark-wrap { position: relative; width: 100%; height: 44px; }
.summary-spark { width: 100%; height: 100%; display: block; overflow: visible; }
.summary-spark .spark-area { stroke: none; fill: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.summary-spark .spark-line {
  fill: none; stroke: var(--color-accent); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
/* The "you are here" node — an HTML dot (not an SVG circle) so the stretched,
   non-uniform preserveAspectRatio="none" viewBox can't distort it to an ellipse. */
.summary-spark-head {
  position: absolute; left: 100%; top: 50%; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-accent); transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 16%, transparent);
  animation: sdk-breathe 2.4s ease-in-out infinite;
}
.summary-journey-caption {
  font-size: 12px; font-style: italic; line-height: 1.4;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}

/* — Cherry-blossom celebration (fires on solve, app.js sprinklePetals) — */
.petal-layer { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.petal {
  position: absolute; top: -6%; width: 12px; height: 12px;
  border-radius: 150% 0 150% 0; /* soft petal silhouette */
  background: linear-gradient(135deg,
    color-mix(in srgb, #ffd7e6 88%, white), color-mix(in srgb, #f6a5c0 82%, transparent));
  opacity: 0; will-change: transform, opacity;
  animation-name: sdk-petal-fall; animation-timing-function: ease-in-out; animation-iteration-count: 1;
}
.petal--b { background: linear-gradient(135deg,
    color-mix(in srgb, #ffe3ef 90%, white), color-mix(in srgb, #f2b8cf 80%, transparent)); }
.petal--c { background: linear-gradient(135deg,
    color-mix(in srgb, #ffccdd 86%, white), color-mix(in srgb, #e98bb0 80%, transparent)); }

/* — Toast — */
.toast {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--color-surface); border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-md); border-radius: var(--radius-md);
  padding: 9px 16px; font-size: 13px; font-style: italic;
  color: color-mix(in srgb, var(--color-text) 75%, transparent);
  animation: sdk-toast 0.25s ease;
}

/* — Keyframes — */
@keyframes sdk-pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes sdk-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sdk-sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes sdk-toast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sdk-ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent-2) 55%, transparent); }
  70% { box-shadow: 0 0 0 15px transparent; }
  100% { box-shadow: 0 0 0 15px transparent; }
}
/* Gentle breathing pulse for the trajectory "you are here" node. */
@keyframes sdk-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.55); opacity: 0.5; }
}
/* Falling cherry-blossom petal: drifts and rotates as it descends, then fades.
   Per-petal randomness (--drift/--spin/--fall/--petal-opacity) is set in app.js. */
@keyframes sdk-petal-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: var(--petal-opacity, 0.82); }
  25% { transform: translate(calc(var(--drift, 40px) * 0.6), calc(var(--fall, 1000px) * 0.25)) rotate(calc(var(--spin, 360deg) * 0.25)); }
  50% { transform: translate(calc(var(--drift, 40px) * -0.4), calc(var(--fall, 1000px) * 0.5)) rotate(calc(var(--spin, 360deg) * 0.5)); }
  75% { transform: translate(calc(var(--drift, 40px) * 0.5), calc(var(--fall, 1000px) * 0.75)) rotate(calc(var(--spin, 360deg) * 0.75)); }
  90% { opacity: var(--petal-opacity, 0.82); }
  100% { transform: translate(calc(var(--drift, 40px) * -0.2), var(--fall, 1000px)) rotate(var(--spin, 360deg)); opacity: 0; }
}

/* — Respect reduced-motion: no petals, no breathing, trajectory line appears
   instantly (drawn statically). The app had no reduced-motion handling before. — */
@media (prefers-reduced-motion: reduce) {
  .petal { display: none !important; }
  .summary-spark-head { animation: none; }
}

/* — Mobile (touch) layout — the master gate. Everything below matches only
   when the primary input can't hover AND is coarse: phones and tablets.
   Desktop browsers and the Electron app (mouse-driven at every window width,
   min 587px) never match, so the desktop experience is untouched. — */

/* Touch-only elements (the card's tap/hold panel + Erase button) hide on
   hover-capable devices. Declared BEFORE the gate so the gate's equal-
   specificity display rules win on touch devices. The only ungated addition —
   it matches nothing but the two new elements. */
.touch-only { display: none; }

@media (hover: none) and (pointer: coarse) {
  /* Document flow scrolls; iOS rubber-band shows the html background — match it.
     overflow-y:auto re-opens vertical scrolling (the desktop base sets
     overflow:hidden on html, and a longhand overrides only its own axis). */
  html { height: auto; overflow-x: hidden; overflow-y: auto; background: var(--color-bg); }
  body.desk {
    height: auto; min-height: 100vh; min-height: 100dvh;  /* vh fallback line first; dvh iOS 15.4+ */
    overflow: visible; display: block;
  }
  .app-window { width: 100%; }

  /* Compact titlebar + safe areas (env() is 0 until viewport-fit=cover lands). */
  .titlebar {
    height: auto; min-height: 52px;
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }

  /* Single column: titlebar → toolbar → board → cards → footer. */
  .body { flex-direction: column; gap: 16px; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
  .right-col { width: auto; }

  /* Toolbar: timer row above, four equal-width ≥44px buttons below. */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar-right { margin-left: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .btn { min-height: 44px; }              /* covers toolbar, Continue, summary actions, Erase */
  .toolbar-right .btn { padding-inline: 4px; }

  /* Board: full-width square (rotation-proof via aspect-ratio), capped at the
     desktop 594px. Board taps only select (app.js gate), so ~40px cells are fine. */
  .board-wrap { width: min(100%, 594px); height: auto; aspect-ratio: 1 / 1; margin-inline: auto; }
  .cell { font-size: clamp(18px, 5.8vw, 30px); }
  .cell-notes { padding: 2px; }
  .note-slot { font-size: clamp(8px, 2.3vw, 11px); }

  /* Magnifier becomes the digit picker: 160px → interior slots ≈47px ≥ 44px. */
  .sel-magnifier { width: 160px; height: 160px; }
  .sel-value { font-size: 72px; }
  .sel-note-slot { font-size: 26px; }
  .sel-note-slot:active { color: var(--color-neutral-700); }  /* press feedback incl. during long-press */

  /* Swap the mouse legend/caption for the touch panel + Erase. */
  .sel-legend, .sel-caption { display: none; }
  .sel-touch-panel { display: flex; flex-direction: column; gap: 10px; flex: 1; padding-top: 2px; }
  .sel-erase { display: inline-flex; margin-top: auto; }  /* re-opens .touch-only's display:none */

  /* Touch hardening: no double-tap zoom (pan/pinch preserved), no tap flash,
     no iOS callout/selection on the two text-bearing interactive surfaces. */
  body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .board, .sel-magnifier { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

  /* Overlays pin to the viewport (the page scrolls on mobile; desktop keeps
     position:absolute over its fixed stage). */
  .overlay-pause { position: fixed; inset: 0; }
  .toast { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); }
  .summary-card { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
}


/* ---------------------------------------------------------------------------
   Injected by scripts/sync-sudoku.mjs — link back to the rest of shawnrb.com.
   Fixed, because .desk is height:100vh; overflow:hidden and will clip anything
   added to the normal flow. Palette is this app's own, not the main site's.
   -------------------------------------------------------------------------- */
.site-return {
  position: fixed;
  inset-block-end: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 999;
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--color-divider);
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  line-height: 1;
  color: var(--color-neutral-700);
  text-decoration: none;
  transition: color 140ms ease, border-color 140ms ease;
}

.site-return:hover,
.site-return:focus-visible {
  color: var(--color-accent-700);
  border-color: var(--color-accent-400);
}

@media print {
  .site-return { display: none; }
}
