:root {
  --ink: #0c1a22;
  --ink-mid: #163041;
  --ink-lit: #1f4458;
  --paper: #f3efe6;
  --paper-edge: #e4ddd0;
  --line: #c9c0b0;
  --line-strong: #2a3f4c;
  --accent: #0f8a7a;
  --accent-lit: #14b8a4;
  --warn: #c45c26;
  --given: #132833;
  --entry: #0f6e62;
  --conflict: #b42318;
  --select: rgba(15, 138, 122, 0.18);
  --peer: rgba(15, 138, 122, 0.08);
  /* Tertiary: other cells sharing the selected digit */
  --same: rgba(212, 160, 40, 0.38);
  --same-ring: rgba(212, 160, 40, 0.7);
  --shadow: rgba(4, 12, 18, 0.45);
  --font-display: "Syne", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;
  /* Shared play layout metrics — themes skin these, don't relocate them */
  --chrome-top-h: 56px;
  --tools-h: 72px;
  --pad-h: 56px;
  --scene-gap: 10px;
  --scene-pad-x: 10px;
  /* App shell insets (ad clearance is applied once here — not also on body) */
  --content-inset-top: 6px;
  --content-inset-x: 10px;
  --content-inset-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  /* Nudge the game column independently of the backdrop card */
  --content-offset-x: 0px;
  --content-offset-y: 0px;
  /* Backdrop card insets (themes that show a card); content ignores these */
  --card-inset-top: 0px;
  --card-inset-x: 0px;
  --card-inset-bottom: 0px;
  --board-width-pct: 97%;
  --app-max-w: 480px;
  --board-max: 460px;
  --controls-rail-w: 0px;
  /* Width available to the square board (phone: nearly full viewport) */
  --board-width-cap: 97vw;
  /* Definite lengths only — used for width and cell font calc() */
  --board-size: min(
    var(--board-width-cap),
    calc(100dvh - var(--fg-ad-h) - var(--content-inset-top) - var(--content-inset-bottom) - var(--chrome-top-h) - var(--tools-h) - var(--pad-h) - (var(--scene-gap) * 4) - 16px),
    var(--board-max)
  );
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fg-ad-h: 0px;
}

/* rem-design: 1rem === 1px (scales evenly with html font-size) */
html {
  font-size: 1px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  height: 100%;
}

body {
  /* Explicit — html is 1px; don't inherit that onto text */
  font-size: 16px;
  font-family: var(--font-display);
  color: var(--paper);
  background: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
  overflow-y: auto;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(20, 184, 164, 0.16), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 80%, rgba(196, 92, 38, 0.08), transparent 50%),
    linear-gradient(165deg, #102633 0%, var(--ink) 55%, #081218 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image:
    linear-gradient(rgba(243, 239, 230, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 239, 230, 0.35) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

/*
 * During play, .app owns ad clearance. body.fg-ads-reserve would double it.
 * Splash keeps body reserve so the menu clears the banner.
 */
html.is-playing body.fg-ads-reserve {
  padding-top: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--app-max-w);
  margin: 0 auto;
  padding:
    calc(var(--fg-ad-h) + var(--content-inset-top))
    var(--content-inset-x)
    var(--content-inset-bottom);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  box-sizing: border-box;
}

/*
 * Phone / narrow: rail is a transparent pass-through so .tools and .pad-wrap
 * remain flex children of .scene (same stack as before the aside wrap).
 */
.controls-rail {
  display: contents;
}

/*
 * Optional theme panel behind the game (most themes on, two off).
 * Positioned in .app's content box — ad clearance is already in .app padding.
 */
.backdrop-card {
  display: none;
  position: absolute;
  z-index: 0;
  pointer-events: none;
  top: var(--card-inset-top);
  right: var(--card-inset-x);
  bottom: var(--card-inset-bottom);
  left: var(--card-inset-x);
  border-radius: 18px 18px 0 0;
  background: rgba(200, 200, 200, 0.55);
  box-sizing: border-box;
}

/* ── Content container: game chrome + board + tools (movable via --content-offset-*) ── */
.content,
.scene-slot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  transform: translate(var(--content-offset-x), var(--content-offset-y));
  box-sizing: border-box;
}

.scene {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--scene-gap);
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}

.chrome-top {
  flex: 0 0 var(--chrome-top-h);
  height: var(--chrome-top-h);
  display: grid;
  /*
   * back | (space) | score | (space) | pause
   * Mistakes / time center in the flexible gutters so they split
   * the gap between the edge controls and the score.
   */
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  column-gap: 6px;
  width: 100%;
  min-width: 0;
}

.chrome-top > * {
  min-width: 0;
}

.chrome-top .stat {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(8, 18, 24, 0.4);
  justify-self: center;
  width: max-content;
  max-width: 100%;
}

.chrome-score {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  text-align: center;
}

.chrome-score-value {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: clamp(24px, 7vw, 36px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #e8fff9;
  white-space: nowrap;
}

.chrome-top .back-btn {
  justify-self: start;
  width: 44px;
}

.chrome-top .chrome-icon-btn {
  justify-self: end;
  width: 44px;
}

.chrome-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 4px;
  border-radius: 8px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.chrome-btn:hover,
.chrome-btn:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.chrome-icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
}

.chrome-btn-icon {
  font-size: 18px;
  line-height: 1;
}

.chrome-btn-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.back-btn {
  align-items: flex-start;
  padding-left: 2px;
}

.back {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(243, 239, 230, 0.65);
  text-decoration: none;
  margin-bottom: 4px;
  transition: color 0.15s ease;
}

.back:hover,
.back:focus-visible {
  color: var(--accent-lit);
  outline: none;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1 1 0;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, 0.5);
}

.field-select,
.btn {
  appearance: none;
  border: 1px solid rgba(243, 239, 230, 0.18);
  background: rgba(8, 18, 24, 0.72);
  color: var(--paper);
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.field-select {
  width: 100%;
  background-image: linear-gradient(45deg, transparent 50%, rgba(243, 239, 230, 0.7) 50%),
    linear-gradient(135deg, rgba(243, 239, 230, 0.7) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

/* Custom select menu (keeps native <select> for logic) */
.menu {
  position: relative;
  width: 100%;
  min-width: 0;
}

.menu-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  pointer-events: none !important;
}

.menu-trigger {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid rgba(243, 239, 230, 0.18);
  background: rgba(8, 18, 24, 0.78);
  color: var(--paper);
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.menu-trigger-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-chevron {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: 0.75;
  transition: transform 0.15s ease;
}

.menu.is-open .menu-chevron {
  transform: rotate(225deg) translateY(-1px);
}

.menu-trigger:hover {
  border-color: rgba(20, 184, 164, 0.55);
}

.menu-trigger:focus-visible {
  outline: 2px solid var(--accent-lit);
  outline-offset: 2px;
}

.menu-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10080;
  list-style: none;
  margin: 0;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(243, 239, 230, 0.16);
  background: rgba(10, 22, 28, 0.96);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  display: none;
  max-height: min(240px, 50vh);
  overflow: auto;
}

.menu.is-open .menu-list,
.menu-list.is-open {
  display: grid;
  gap: 2px;
}

.menu-option {
  appearance: none;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.menu-option:hover,
.menu-option:focus-visible {
  background: rgba(20, 184, 164, 0.18);
  color: #e9fff9;
  outline: none;
}

.menu-option.is-selected {
  background: rgba(15, 138, 122, 0.28);
  color: #d7fff8;
}

.btn:hover,
.field-select:hover {
  border-color: rgba(20, 184, 164, 0.55);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.field-select:focus-visible {
  outline: 2px solid var(--accent-lit);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0b6e62);
  border-color: transparent;
  color: #f7fffd;
  width: 100%;
  margin-top: 8px;
}

.btn-tool {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  padding: 8px 6px;
  min-width: 0;
  position: relative;
}

.btn-tool[aria-pressed="true"] {
  background: rgba(15, 138, 122, 0.28);
  border-color: var(--accent-lit);
  color: #d7fff8;
}

.btn-tool:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-icon {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
}

.tool-icon-hint {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.tool-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.tool-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  font-weight: 700;
  opacity: 0.9;
  pointer-events: none;
}

.tool-badge.is-count,
.tool-badge-count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0;
  top: 2px;
  right: 2px;
}

.tool-badge[hidden] {
  display: none !important;
}

.stat {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: clamp(11px, 2.9vw, 13px);
  font-weight: 600;
  color: #e8fff9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chrome-top #mistakes.stat-value,
.chrome-top #timer.stat-value {
  font-size: clamp(14px, 3.8vw, 18px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.chrome-top .chrome-stat-time {
  min-width: 5.5em;
}

/* Board block: does not grow — width/aspect set size, tools follow below */
.stage {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
  width: 100%;
}

.stage-frame {
  display: flex;
  justify-content: center;
  width: 100%;
}

.board-slot {
  position: relative;
  display: flex;
  justify-content: center;
  width: min(var(--board-width-pct), var(--board-size));
  aspect-ratio: 1;
  flex: 0 0 auto;
  overflow: visible;
}

/* Glass / Zen wells enable these; single-layer blur lives there */
.board-frost {
  display: none;
}

.board {
  --n: 9;
  --br: 3;
  --bc: 3;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  background: var(--paper);
  color: var(--given);
  border: 3px solid var(--line-strong);
  border-radius: 6px;
  box-shadow:
    0 18px 40px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  overflow: hidden;
  user-select: none;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(11px, calc(var(--board-size) / var(--n) * 0.48), 36px);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s ease;
}

.cell:nth-child(var(--n)n) {
  border-right: none;
}

.cell.box-r {
  border-right: 2px solid var(--line-strong);
}

.cell.box-b {
  border-bottom: 2px solid var(--line-strong);
}

.cell.given {
  color: var(--given);
}

.cell.entry {
  color: var(--entry);
}

.cell.selected {
  background: var(--select);
  box-shadow: inset 0 0 0 2px rgba(15, 138, 122, 0.55);
}

.cell.peer {
  background: var(--peer);
}

/* Same digit as selection — tertiary highlight (wins over peer) */
.cell.same,
.cell.peer.same {
  background: var(--same);
  box-shadow: inset 0 0 0 2px var(--same-ring);
}

.cell.conflict .glyph,
.cell.conflict .notes {
  color: var(--conflict);
}

.cell.hint-flash {
  animation: hint-pulse 0.7s var(--ease);
}

/* Completed row/col/box — ripple outward from the finishing digit */
.cell.unit-pulse {
  z-index: 2;
  animation: unit-cell-pulse 0.62s var(--ease) both;
  animation-delay: var(--pulse-delay, 0ms);
}

.cell.unit-pulse .glyph {
  display: inline-block;
  animation: unit-glyph-pulse 0.62s var(--ease) both;
  animation-delay: var(--pulse-delay, 0ms);
}

.glyph {
  line-height: 1;
}

/* Floating score pops above the board */
.score-float {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.05;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: score-float-rise 1.7s ease-out forwards;
  text-shadow: 0 1px 2px rgba(4, 12, 18, 0.35);
}

.score-float-amt {
  font-size: clamp(13px, calc(var(--board-size) * 0.055), 22px);
}

.score-float-combo {
  font-size: clamp(9px, calc(var(--board-size) * 0.032), 13px);
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.score-float.is-pos {
  color: var(--accent-lit);
}

.score-float.is-neg {
  color: var(--conflict);
}

.score-float.is-combo {
  color: #d4a028;
}

.chrome-score-value.score-bump {
  animation: score-chrome-bump 0.35s var(--ease);
}

.notes {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(var(--note-cols, 3), 1fr);
  grid-template-rows: repeat(var(--note-rows, 3), 1fr);
  font-size: clamp(6px, calc(var(--board-size) / var(--n) * 0.22), 11px);
  font-weight: 500;
  color: #6b7280;
  pointer-events: none;
}

.notes span {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.notes span.on {
  opacity: 1;
  color: #4b5563;
}

.tools {
  flex: 0 0 var(--tools-h);
  height: var(--tools-h);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

.pad-wrap {
  flex: 0 0 auto;
  min-height: var(--pad-h);
  display: grid;
  width: 100%;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.num-btn {
  appearance: none;
  border: 1px solid rgba(243, 239, 230, 0.16);
  background: rgba(8, 18, 24, 0.78);
  color: var(--paper);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(14px, 4.2vw, 18px);
  aspect-ratio: 1;
  min-height: 0;
  width: 100%;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.num-btn:hover {
  border-color: rgba(20, 184, 164, 0.55);
  background: rgba(15, 138, 122, 0.2);
}

.num-btn:active {
  transform: scale(0.96);
}

.num-btn:focus-visible {
  outline: 2px solid var(--accent-lit);
  outline-offset: 2px;
}

.num-btn.exhausted {
  opacity: 0.35;
}

.help,
.foot {
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(243, 239, 230, 0.42);
}

.foot {
  margin-top: auto;
  padding-top: 8px;
}

/* Pause/settings stays above the board so live theme/size changes stay visible */
#pauseOverlay.overlay {
  z-index: 10060;
  align-items: flex-start;
  justify-content: center;
  padding-top: calc(var(--fg-ad-h) + 56px);
  background: rgba(6, 12, 16, 0.28);
  backdrop-filter: blur(1.5px);
}

.settings-card {
  width: min(380px, 100%);
  text-align: left;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.pause-card > p {
  margin-bottom: 0;
}

.pause-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 0;
}

.pause-meta .stat {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(8, 18, 24, 0.35);
  border: 1px solid rgba(243, 239, 230, 0.1);
  justify-items: center;
  text-align: center;
}

.pause-meta .stat-value {
  font-size: 15px;
}

.settings-fields {
  display: grid;
  gap: 12px;
  margin: 16px 0 18px;
}

.settings-actions {
  display: grid;
  gap: 8px;
}

.settings-actions .btn-primary {
  margin-top: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 12, 16, 0.72);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(360px, 100%);
  background: linear-gradient(160deg, #163041, #0c1a22);
  border: 1px solid rgba(20, 184, 164, 0.35);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
  animation: card-pop 0.35s var(--ease);
}

.overlay-card h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #e9fff9;
}

.overlay-card p {
  color: rgba(243, 239, 230, 0.72);
  font-size: 15px;
  line-height: 1.4;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 18px auto 0;
  border-radius: 50%;
  border: 3px solid rgba(243, 239, 230, 0.15);
  border-top-color: var(--accent-lit);
  animation: spin 0.7s linear infinite;
}

@keyframes brand-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes board-rise {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes card-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes hint-pulse {
  0%, 100% { background: transparent; }
  40% { background: rgba(20, 184, 164, 0.35); }
}

@keyframes unit-cell-pulse {
  0% { background-color: transparent; box-shadow: none; }
  28% {
    background-color: rgba(20, 184, 164, 0.4);
    box-shadow: inset 0 0 0 2px rgba(20, 184, 164, 0.55);
  }
  100% { background-color: transparent; box-shadow: none; }
}

@keyframes unit-glyph-pulse {
  0% { transform: scale(1); }
  28% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes score-float-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 0);
  }
  8% {
    opacity: 1;
    transform: translate(-50%, -20%);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, -340%);
  }
  68% {
    opacity: 1;
    transform: translate(-50%, -340%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -340%);
  }
}

@keyframes score-chrome-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .score-float,
  .cell.unit-pulse,
  .cell.unit-pulse .glyph,
  .chrome-score-value.score-bump {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ═══════════════════════════════════════════
   Ink board surfaces (data-ink-grid / ink-grid--*)
   paper = default · night · blueprint · graphite
   ═══════════════════════════════════════════ */

/* Kill frost plate except on Night glass (prevents white wash + invisible glyphs) */
html[data-theme="ink"] .board::before {
  content: none;
}

html[data-theme="ink"].ink-grid--paper .board,
html[data-theme="ink"][data-ink-grid="paper"] .board {
  position: relative;
  background-color: var(--paper);
  background-image: none;
  border: 3px solid var(--line-strong);
  border-radius: 6px;
  color: var(--given);
  gap: 0;
  padding: 0;
  overflow: hidden;
  box-shadow:
    0 18px 40px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

html[data-theme="ink"].ink-grid--paper .cell,
html[data-theme="ink"][data-ink-grid="paper"] .cell {
  background: transparent;
  color: var(--given);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="ink"].ink-grid--paper .cell.given,
html[data-theme="ink"][data-ink-grid="paper"] .cell.given {
  color: var(--given);
}

html[data-theme="ink"].ink-grid--paper .cell.entry,
html[data-theme="ink"][data-ink-grid="paper"] .cell.entry {
  color: var(--entry);
}

html[data-theme="ink"].ink-grid--paper .cell.selected,
html[data-theme="ink"][data-ink-grid="paper"] .cell.selected {
  background: var(--select);
  box-shadow: inset 0 0 0 2px rgba(15, 138, 122, 0.55);
}

/* Same digit: selected-style frame, orange */
html[data-theme="ink"].ink-grid--paper .cell.same,
html[data-theme="ink"].ink-grid--paper .cell.peer.same,
html[data-theme="ink"][data-ink-grid="paper"] .cell.same,
html[data-theme="ink"][data-ink-grid="paper"] .cell.peer.same {
  background: rgba(196, 92, 38, 0.16);
  box-shadow: inset 0 0 0 2px rgba(232, 140, 60, 0.75);
}

html[data-theme="ink"].ink-grid--night {
  --ink-glass: calc(0.12 + var(--slab-cream-opacity, 0.55) * 0.28);
  --ink-pane-blur: calc(10px + var(--slab-cream-opacity, 0.55) * 16px);
}

html[data-theme="ink"].ink-grid--night .board,
html[data-theme="ink"][data-ink-grid="night"] .board {
  position: relative;
  background-color: transparent;
  background-image: none;
  border: 1px solid rgba(20, 184, 164, 0.28);
  border-radius: 14px;
  box-shadow:
    0 18px 40px rgba(4, 12, 18, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  gap: 2px;
  padding: 3px;
  overflow: visible;
  color: #e8fff9;
}

html[data-theme="ink"].ink-grid--night .board::before,
html[data-theme="ink"][data-ink-grid="night"] .board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: rgba(8, 18, 24, 0.2);
  backdrop-filter: blur(var(--ink-pane-blur)) saturate(1.15);
  -webkit-backdrop-filter: blur(var(--ink-pane-blur)) saturate(1.15);
}

html[data-theme="ink"].ink-grid--night .cell,
html[data-theme="ink"][data-ink-grid="night"] .cell {
  z-index: 1;
  border-radius: 10%;
  border-right: none;
  border-bottom: none;
  background:
    radial-gradient(ellipse 100% 70% at 50% 20%, rgba(255, 255, 255, 0.1), transparent 50%),
    rgba(10, 24, 32, var(--ink-glass));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #e8fff9;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(20, 184, 164, 0.12);
}

html[data-theme="ink"].ink-grid--night .cell.box-r,
html[data-theme="ink"][data-ink-grid="night"] .cell.box-r {
  border-right: none;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(20, 184, 164, 0.12),
    2px 0 0 rgba(20, 184, 164, 0.35);
}

html[data-theme="ink"].ink-grid--night .cell.box-b,
html[data-theme="ink"][data-ink-grid="night"] .cell.box-b {
  border-bottom: none;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(20, 184, 164, 0.12),
    0 2px 0 rgba(20, 184, 164, 0.35);
}

html[data-theme="ink"].ink-grid--night .cell.box-r.box-b,
html[data-theme="ink"][data-ink-grid="night"] .cell.box-r.box-b {
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(20, 184, 164, 0.12),
    2px 0 0 rgba(20, 184, 164, 0.35),
    0 2px 0 rgba(20, 184, 164, 0.35);
}

html[data-theme="ink"].ink-grid--night .cell.given,
html[data-theme="ink"].ink-grid--night .cell.given .glyph,
html[data-theme="ink"][data-ink-grid="night"] .cell.given,
html[data-theme="ink"][data-ink-grid="night"] .cell.given .glyph {
  color: #f3efe6;
}

html[data-theme="ink"].ink-grid--night .cell.entry,
html[data-theme="ink"].ink-grid--night .cell.entry .glyph,
html[data-theme="ink"][data-ink-grid="night"] .cell.entry,
html[data-theme="ink"][data-ink-grid="night"] .cell.entry .glyph {
  color: #5eead4;
}

html[data-theme="ink"].ink-grid--night .cell.selected,
html[data-theme="ink"][data-ink-grid="night"] .cell.selected {
  background: rgba(20, 184, 164, 0.28);
  box-shadow: inset 0 0 0 2px rgba(94, 234, 212, 0.7);
}

html[data-theme="ink"].ink-grid--night .cell.peer,
html[data-theme="ink"][data-ink-grid="night"] .cell.peer {
  background: rgba(20, 184, 164, 0.12);
}

html[data-theme="ink"].ink-grid--night .cell.same,
html[data-theme="ink"].ink-grid--night .cell.peer.same,
html[data-theme="ink"][data-ink-grid="night"] .cell.same,
html[data-theme="ink"][data-ink-grid="night"] .cell.peer.same {
  background: rgba(196, 92, 38, 0.22);
  box-shadow: inset 0 0 0 2px rgba(232, 140, 60, 0.75);
}

html[data-theme="ink"].ink-grid--night .notes,
html[data-theme="ink"][data-ink-grid="night"] .notes {
  color: rgba(200, 220, 220, 0.35);
}

html[data-theme="ink"].ink-grid--night .notes span.on,
html[data-theme="ink"][data-ink-grid="night"] .notes span.on {
  color: rgba(200, 245, 235, 0.9);
}

/* Blueprint — drafting table */
html[data-theme="ink"].ink-grid--blueprint .board,
html[data-theme="ink"][data-ink-grid="blueprint"] .board {
  position: relative;
  background-color: #0f2a3d;
  background-image: linear-gradient(180deg, #163a52 0%, #0f2a3d 55%, #0c2232 100%);
  border: 2px solid rgba(94, 234, 212, 0.45);
  border-radius: 4px;
  box-shadow:
    0 18px 40px rgba(4, 12, 18, 0.55),
    inset 0 0 0 1px rgba(94, 234, 212, 0.12),
    inset 0 0 40px rgba(8, 40, 56, 0.5);
  color: #d7fff8;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

html[data-theme="ink"].ink-grid--blueprint .cell,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell {
  background: transparent;
  border-right: 1px solid rgba(94, 234, 212, 0.18);
  border-bottom: 1px solid rgba(94, 234, 212, 0.18);
  border-radius: 0;
  font-weight: 600;
  color: #d7fff8;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="ink"].ink-grid--blueprint .cell.box-r,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.box-r {
  border-right: 2px solid rgba(94, 234, 212, 0.55);
}

html[data-theme="ink"].ink-grid--blueprint .cell.box-b,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.box-b {
  border-bottom: 2px solid rgba(94, 234, 212, 0.55);
}

html[data-theme="ink"].ink-grid--blueprint .cell.given,
html[data-theme="ink"].ink-grid--blueprint .cell.given .glyph,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.given,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.given .glyph {
  color: #f3efe6;
}

html[data-theme="ink"].ink-grid--blueprint .cell.entry,
html[data-theme="ink"].ink-grid--blueprint .cell.entry .glyph,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.entry,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.entry .glyph {
  color: #5eead4;
}

html[data-theme="ink"].ink-grid--blueprint .cell.selected,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.selected {
  background: rgba(94, 234, 212, 0.16);
  box-shadow: inset 0 0 0 2px rgba(94, 234, 212, 0.65);
}

html[data-theme="ink"].ink-grid--blueprint .cell.peer,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.peer {
  background: rgba(94, 234, 212, 0.07);
}

html[data-theme="ink"].ink-grid--blueprint .cell.same,
html[data-theme="ink"].ink-grid--blueprint .cell.peer.same,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.same,
html[data-theme="ink"][data-ink-grid="blueprint"] .cell.peer.same {
  background: rgba(196, 92, 38, 0.2);
  box-shadow: inset 0 0 0 2px rgba(232, 140, 60, 0.75);
}

html[data-theme="ink"].ink-grid--blueprint .notes,
html[data-theme="ink"][data-ink-grid="blueprint"] .notes {
  color: rgba(120, 180, 180, 0.45);
}

html[data-theme="ink"].ink-grid--blueprint .notes span.on,
html[data-theme="ink"][data-ink-grid="blueprint"] .notes span.on {
  color: rgba(180, 240, 230, 0.85);
}

/* Graphite — dark soft slate */
html[data-theme="ink"].ink-grid--graphite .board,
html[data-theme="ink"][data-ink-grid="graphite"] .board {
  position: relative;
  background-color: #1a2228;
  background-image:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(255, 255, 255, 0.04), transparent 50%),
    linear-gradient(160deg, #2a3238 0%, #1a2228 50%, #141a1e 100%);
  border: 2px solid #3a454c;
  border-radius: 10px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: #e8ecef;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

html[data-theme="ink"].ink-grid--graphite .cell,
html[data-theme="ink"][data-ink-grid="graphite"] .cell {
  background: transparent;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  color: #e8ecef;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="ink"].ink-grid--graphite .cell.box-r,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.box-r {
  border-right: 2px solid rgba(20, 184, 164, 0.4);
}

html[data-theme="ink"].ink-grid--graphite .cell.box-b,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.box-b {
  border-bottom: 2px solid rgba(20, 184, 164, 0.4);
}

html[data-theme="ink"].ink-grid--graphite .cell.given,
html[data-theme="ink"].ink-grid--graphite .cell.given .glyph,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.given,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.given .glyph {
  color: #f3efe6;
}

html[data-theme="ink"].ink-grid--graphite .cell.entry,
html[data-theme="ink"].ink-grid--graphite .cell.entry .glyph,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.entry,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.entry .glyph {
  color: #5eead4;
}

html[data-theme="ink"].ink-grid--graphite .cell.selected,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.selected {
  background: rgba(20, 184, 164, 0.22);
  box-shadow: inset 0 0 0 2px rgba(94, 234, 212, 0.55);
}

html[data-theme="ink"].ink-grid--graphite .cell.peer,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.peer {
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="ink"].ink-grid--graphite .cell.same,
html[data-theme="ink"].ink-grid--graphite .cell.peer.same,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.same,
html[data-theme="ink"][data-ink-grid="graphite"] .cell.peer.same {
  background: rgba(196, 92, 38, 0.2);
  box-shadow: inset 0 0 0 2px rgba(232, 140, 60, 0.75);
}

html[data-theme="ink"].ink-grid--graphite .notes,
html[data-theme="ink"][data-ink-grid="graphite"] .notes {
  color: rgba(180, 190, 195, 0.35);
}

html[data-theme="ink"].ink-grid--graphite .notes span.on,
html[data-theme="ink"][data-ink-grid="graphite"] .notes span.on {
  color: rgba(220, 230, 235, 0.85);
}

/* Ink night Depth slider chrome */
html[data-theme="ink"][data-ink-grid="night"] .field-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 4px;
  border: 1px solid rgba(243, 239, 230, 0.18);
  border-radius: 10px;
  background: rgba(8, 18, 24, 0.78);
  cursor: pointer;
}

html[data-theme="ink"][data-ink-grid="night"] .field-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(20, 184, 164, 0.25);
}

html[data-theme="ink"][data-ink-grid="night"] .field-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid rgba(243, 239, 230, 0.85);
  background: var(--accent-lit);
}

html[data-theme="ink"][data-ink-grid="night"] .field-range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(20, 184, 164, 0.25);
}

html[data-theme="ink"][data-ink-grid="night"] .field-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(243, 239, 230, 0.85);
  background: var(--accent-lit);
}

@media (max-width: 420px) {
  .field {
    flex: 1 1 30%;
  }

  .chrome-top {
    gap: 4px;
  }

  .chrome-top .stat {
    padding: 3px 6px;
  }

  .chrome-top .stat-label {
    font-size: 8px;
  }

  .chrome-top .stat-value {
    font-size: 11px;
  }

  .chrome-top #mistakes.stat-value,
  .chrome-top #timer.stat-value {
    font-size: 14px;
  }
}

/* —— Tablet portrait: taller column, same stack, larger board —— */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  :root {
    --app-max-w: 720px;
    --board-max: 620px;
    --board-width-cap: min(96vw, calc(var(--app-max-w) - (var(--content-inset-x) * 2)));
  }
}

/*
 * Wide play: board + controls side-by-side.
 * Triggers on tablet landscape or any viewport ≥1024px.
 */
@media (min-width: 768px) and (orientation: landscape), (min-width: 1024px) {
  :root {
    --app-max-w: 1100px;
    --board-max: 720px;
    --controls-rail-w: 260px;
    --scene-gap: 12px;
    /* Tools/pad sit beside the board — drop them from leftover height */
    --board-size: min(
      var(--board-width-cap),
      calc(100dvh - var(--fg-ad-h) - var(--content-inset-top) - var(--content-inset-bottom) - var(--chrome-top-h) - (var(--scene-gap) * 2) - 16px),
      var(--board-max)
    );
    --board-width-cap: min(
      calc(100vw - (var(--content-inset-x) * 2) - var(--controls-rail-w) - var(--scene-gap) - 8px),
      calc(var(--app-max-w) - (var(--content-inset-x) * 2) - var(--controls-rail-w) - var(--scene-gap))
    );
  }

  .scene {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--controls-rail-w);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "stage rail";
    align-items: start;
    column-gap: var(--scene-gap);
    row-gap: var(--scene-gap);
    flex: 1 1 auto;
    min-height: 0;
  }

  .chrome-top {
    grid-area: top;
  }

  .stage {
    grid-area: stage;
    align-self: center;
    justify-self: center;
    width: 100%;
    max-width: var(--board-size);
  }

  .controls-rail {
    grid-area: rail;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: var(--scene-gap);
    width: var(--controls-rail-w);
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    align-self: center;
  }

  .controls-rail .tools {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .controls-rail .tools .btn-tool {
    min-height: 64px;
    aspect-ratio: auto;
  }

  .controls-rail .pad-wrap {
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
  }

  /* Compact pad in the rail — override inline 9-across from buildNumpad() */
  .controls-rail .numpad {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px;
    width: 100%;
  }

  .controls-rail .num-btn {
    font-size: clamp(16px, 2.2vw, 22px);
  }

  .chrome-score-value {
    font-size: clamp(32px, 4vw, 48px);
  }

  .stat-value {
    font-size: clamp(12px, 1.6vw, 15px);
  }

  /* Beat theme-specific fixed --tools-h (themes load after this file) */
  html .controls-rail .tools {
    height: auto !important;
    flex: 0 0 auto !important;
    max-height: none !important;
  }

  html .controls-rail .tools .btn-tool {
    max-height: none !important;
  }

  /* Compact pad columns by board size (data-board-n set in game.js) */
  html[data-board-n="4"] .controls-rail .numpad {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

}

/* Temporarily hide surface debug controls (logic kept for later) */
.field-grid-debug,
.field-slab {
  display: none !important;
}

/* —— Start splash —— */
html.is-splash .app,
html.is-splash #gameApp {
  display: none !important;
}

html.is-playing .splash {
  display: none !important;
}

.splash {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: min(420px, calc(100% - 28px));
  margin: 0 auto;
  min-height: calc(100dvh - var(--fg-ad-h));
  padding: calc(24px + var(--fg-ad-h)) 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 18px;
}

.splash-back {
  align-self: flex-start;
  margin-bottom: 4px;
}

.splash-title {
  font-family: var(--font-display);
  font-size: clamp(48px, 14vw, 72px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.95;
  margin: 0;
  background: linear-gradient(120deg, #f7f3ea 0%, #9ad9cf 55%, #14b8a4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brand-in 0.7s var(--ease) both;
}

.splash-sub {
  margin: -6px 0 4px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, 0.55);
}

.splash-fields {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.splash-fields .field {
  flex: none;
}

.splash-actions {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.splash-play {
  margin-top: 0;
  width: 100%;
  min-height: 52px;
  font-size: 18px;
  letter-spacing: 0.06em;
}

.splash-play.splash-secondary {
  background: transparent;
  color: inherit;
  box-shadow: none;
  border: 1px solid rgba(243, 239, 230, 0.28);
  opacity: 0.92;
}

html[data-theme="wireframe"] .splash-play.splash-secondary,
html[data-theme="minimal"] .splash-play.splash-secondary,
html[data-theme="ink"] .splash-play.splash-secondary,
html[data-theme="wood"] .splash-play.splash-secondary {
  border-color: rgba(40, 40, 40, 0.28);
  color: inherit;
}

html[data-theme="ink"] .splash-title {
  font-size: clamp(40px, 11.5vw, 58px);
  line-height: 1.05;
}

/* ═══════════════════════════════════════════
   Gray-box wireframe template (shared skeleton)
   Structural only — themes skin this later
   ═══════════════════════════════════════════ */

html[data-theme="wireframe"] {
  --ink: #2a2a2a;
  --ink-mid: #3a3a3a;
  --ink-lit: #4a4a4a;
  --paper: #d0d0d0;
  --paper-edge: #b8b8b8;
  --line: #9a9a9a;
  --line-strong: #555;
  --accent: #6a6a6a;
  --accent-lit: #8a8a8a;
  --warn: #777;
  --given: #222;
  --entry: #444;
  --conflict: #8a3030;
  --select: rgba(80, 80, 80, 0.28);
  --peer: rgba(80, 80, 80, 0.12);
  --shadow: rgba(0, 0, 0, 0.25);
  --wire-fill: #c4c4c4;
  --wire-fill-deep: #b0b0b0;
  --wire-stroke: #6e6e6e;
  --wire-label: #3d3d3d;
  --wire-bg: #ececec;
}

html[data-theme="wireframe"] {
  --content-inset-top: 6px;
  --card-inset-top: 0px;
  --card-inset-x: 0px;
  --card-inset-bottom: 0px;
  --content-offset-x: 0px;
  --content-offset-y: 0px;
}

html[data-theme="wireframe"] body {
  color: var(--wire-label);
  background: #6e6e6e;
}

html[data-theme="wireframe"] .atmosphere {
  background: #6e6e6e;
}

/* Gray-box shows a backdrop card; content sits on top and can move separately */
html[data-theme="wireframe"] .backdrop-card {
  display: block;
  background: #e4e4e4;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -2px 0 rgba(0, 0, 0, 0.06);
}

html[data-theme="wireframe"] .atmosphere::after {
  opacity: 0.04;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.35) 1px, transparent 1px);
  background-size: 24px 24px;
}

html[data-theme="wireframe"] .splash-title {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: #333;
}

html[data-theme="wireframe"] .splash-sub,
html[data-theme="wireframe"] .field-label,
html[data-theme="wireframe"] .back {
  color: rgba(40, 40, 40, 0.55);
}

html[data-theme="wireframe"] .field-select,
html[data-theme="wireframe"] .menu-trigger,
html[data-theme="wireframe"] .btn {
  background: var(--wire-fill);
  border: 2px solid var(--wire-stroke);
  color: var(--wire-label);
  border-radius: 6px;
  box-shadow: none;
}

html[data-theme="wireframe"] .btn-primary {
  background: var(--wire-fill-deep);
  border-color: var(--wire-stroke);
  color: var(--wire-label);
}

html[data-theme="wireframe"] .menu-list {
  background: #f0f0f0;
  border: 2px solid var(--wire-stroke);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

html[data-theme="wireframe"] .menu-option {
  color: var(--wire-label);
}

html[data-theme="wireframe"] .menu-option:hover,
html[data-theme="wireframe"] .menu-option:focus-visible,
html[data-theme="wireframe"] .menu-option.is-selected {
  background: rgba(0, 0, 0, 0.08);
  color: #222;
}

html[data-theme="wireframe"] .chrome-top,
html[data-theme="wireframe"] .tools {
  background: var(--wire-fill);
  border: 2px dashed var(--wire-stroke);
  border-radius: 8px;
  box-sizing: border-box;
}

html[data-theme="wireframe"] .chrome-top {
  padding: 0 6px;
}

html[data-theme="wireframe"] {
  --tools-h: 82rem;
}

html[data-theme="wireframe"] .tools {
  padding: 7rem;
  gap: 8rem;
  align-items: center;
  box-sizing: border-box;
}

/* Numpad sits free — no dashed frame; same outer width as the tools row */
html[data-theme="wireframe"] .pad-wrap {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
}

html[data-theme="wireframe"] .numpad {
  width: 100%;
  gap: 6rem;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

/* Chevron-only back + gear matched to Minimal sizing */
html[data-theme="wireframe"] .back-btn .chrome-btn-label {
  display: none;
}

html[data-theme="wireframe"] .chrome-top .back-btn,
html[data-theme="wireframe"] .chrome-top #btnPause {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--wire-fill-deep);
  border: 2px solid var(--wire-stroke);
  color: var(--wire-label);
  box-shadow: none;
}

html[data-theme="wireframe"] .chrome-top .back-btn .chrome-btn-icon,
html[data-theme="wireframe"] .chrome-top #btnPause .chrome-btn-icon {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--wire-label);
}

html[data-theme="wireframe"] .chrome-btn {
  background: var(--wire-fill-deep);
  border: 2px solid var(--wire-stroke);
  border-radius: 8px;
  color: var(--wire-label);
}

html[data-theme="wireframe"] .chrome-icon-btn {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

html[data-theme="wireframe"] .stat-label {
  color: rgba(40, 40, 40, 0.55);
}

html[data-theme="wireframe"] .stat-value,
html[data-theme="wireframe"] .chrome-score-value {
  color: var(--wire-label);
}

html[data-theme="wireframe"] .board-slot {
  border: 2px dashed var(--wire-stroke);
  border-radius: 8px;
  background: rgba(180, 180, 180, 0.35);
  padding: 4px;
  box-sizing: border-box;
}

html[data-theme="wireframe"] .board {
  background: #d8d8d8;
  border: 3px solid #555;
  border-radius: 4px;
  box-shadow: none;
  color: #222;
}

html[data-theme="wireframe"] .cell {
  border-right: 1px solid #9a9a9a;
  border-bottom: 1px solid #9a9a9a;
}

html[data-theme="wireframe"] .cell.box-r {
  border-right: 2px solid #444;
}

html[data-theme="wireframe"] .cell.box-b {
  border-bottom: 2px solid #444;
}

html[data-theme="wireframe"] .cell.selected {
  background: rgba(80, 80, 80, 0.22);
  box-shadow: inset 0 0 0 2px #555;
}

html[data-theme="wireframe"] .cell.peer {
  background: rgba(80, 80, 80, 0.1);
}

html[data-theme="wireframe"] .cell.same,
html[data-theme="wireframe"] .cell.peer.same {
  background: rgba(200, 160, 60, 0.28);
  box-shadow: inset 0 0 0 2px rgba(180, 140, 40, 0.55);
}

html[data-theme="wireframe"] .tools .btn-tool {
  background: var(--wire-fill-deep);
  border: 2px solid var(--wire-stroke);
  border-radius: 14rem;
  color: var(--wire-label);
  aspect-ratio: 1.35 / 1;
  align-self: center;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: calc(var(--tools-h) - 14rem);
  margin: 0;
}

html[data-theme="wireframe"] .tools .btn-tool[aria-pressed="true"] {
  background: #8a8a8a;
  border-color: #333;
  color: #111;
  box-shadow: inset 0 0 0 2px #555;
}

html[data-theme="wireframe"] .tools .btn-tool:disabled {
  opacity: 0.4;
  border-style: dashed;
}

html[data-theme="wireframe"] .tool-badge {
  top: 2px;
  right: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #555;
  color: #f0f0f0;
  font-size: 8px;
  opacity: 1;
}

html[data-theme="wireframe"] .tools .btn-tool[aria-pressed="true"] .tool-badge {
  background: #222;
  color: #fff;
}

html[data-theme="wireframe"] .tool-badge.is-count {
  background: #444;
  color: #fff;
  border: 1px solid #222;
}

html[data-theme="wireframe"] .tools .btn-tool.is-empty .tool-badge.is-count {
  opacity: 0.35;
}

html[data-theme="wireframe"] .settings-actions .btn-tool {
  width: 100%;
  aspect-ratio: auto;
  border-radius: 6px;
  flex-direction: row;
}

html[data-theme="wireframe"] .num-btn {
  background: var(--wire-fill-deep);
  border: 2px solid var(--wire-stroke);
  color: var(--wire-label);
  border-radius: 6rem;
  min-width: 0;
  width: 100%;
}

html[data-theme="wireframe"] .num-btn:hover {
  background: #9e9e9e;
  border-color: #444;
}

html[data-theme="wireframe"] .overlay {
  background: rgba(40, 40, 40, 0.45);
}

html[data-theme="wireframe"] .overlay-card {
  background: #e8e8e8;
  border: 2px solid var(--wire-stroke);
  color: var(--wire-label);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

html[data-theme="wireframe"] .overlay-card h2 {
  color: #222;
}

html[data-theme="wireframe"] .overlay-card p {
  color: rgba(40, 40, 40, 0.7);
}
