:root {
  color-scheme: light dark;
  interpolate-size: allow-keywords;
  --bg-page: #e3e0d9;
  --bg-surface: #f3f1ec;
  --bg-subtle: #d8d4cb;
  --stage-bg: #f8f7f3;
  --ink-primary: #1c1e21;
  --ink-muted: #50545c;
  --border-soft: #c2beb3;
  --border-strong: #928e82;
  --key-lip: #b1aca0;
  --key-hi: rgba(255, 255, 255, 0.9);
  --hw-hole: color-mix(in oklab, var(--border-strong) 84%, var(--ink-primary) 16%);
  --hw-highlight: rgba(255, 255, 255, 0.78);
  --hw-etch: color-mix(in oklab, var(--border-strong) 62%, transparent);
  --hw-seam: color-mix(in oklab, var(--border-soft) 72%, transparent);
  --accent: #ff4f00;
  --accent-fg: #ffffff;
  --accent-lip: #b63700;
  --accent-tint: rgba(255, 79, 0, 0.12);
  --accent-hatch: rgba(255, 79, 0, 0.45);
  --accent-soft-text: #962b00;
  accent-color: var(--accent);
  --amber: #c97d00;
  --amber-text: #784400;
  --amber-bg: rgba(217, 140, 0, 0.14);
  --amber-bg-hover: rgba(217, 140, 0, 0.22);
  --amber-border: rgba(201, 125, 0, 0.45);
  --pro-locked-status-bg: rgba(243, 241, 236, 0.9);
  --success: #0e8a54;
  --success-text: #0b6e43;
  --success-bg: rgba(14, 138, 84, 0.12);
  --success-border: rgba(14, 138, 84, 0.42);
  --error-text: #a61616;
  --error-bg: rgba(220, 38, 38, 0.09);
  --error-border: rgba(220, 38, 38, 0.36);
  --lcd-bg: #181b19;
  --lcd-border: #0a0c0b;
  --lcd-ink: #eff2e8;
  --lcd-muted: #93a18e;
  --lcd-amber: #ffb84d;
  --lcd-green: #4ade80;
  --ink-0: #1d4ed8;
  --ink-0-bg: rgba(37, 99, 235, 0.12);
  --ink-0-border: rgba(37, 99, 235, 0.35);
  --ink-1: #b91c1c;
  --ink-1-bg: rgba(220, 38, 38, 0.11);
  --ink-1-border: rgba(220, 38, 38, 0.35);
  --ink-2: #047857;
  --ink-2-bg: rgba(5, 150, 105, 0.12);
  --ink-2-border: rgba(5, 150, 105, 0.36);
  --ink-3: #b45309;
  --ink-3-bg: rgba(217, 119, 6, 0.13);
  --ink-3-border: rgba(217, 119, 6, 0.36);
  --radius-xl: 14px;
  --radius-lg: 11px;
  --radius-md: 7px;
  --radius-sm: 5px;
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.82), 0 4px 12px rgba(28, 30, 33, 0.09);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --shadow-btn: 0 2.5px 0 var(--key-lip), inset 0 1px 0 var(--key-hi);
  --shadow-btn-active: 0 0.5px 0 var(--key-lip), inset 0 1px 0 var(--key-hi);
  --shadow-cta: 0 3.5px 0 var(--accent-lip), inset 0 1px 0 rgba(255, 255, 255, 0.32);
  --shadow-cta-active: 0 1px 0 var(--accent-lip), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  --dot-tex: radial-gradient(rgba(28, 30, 33, 0.075) 1px, transparent 1px);
  --modal-backdrop: rgba(12, 14, 16, 0.68);
  --results-backdrop: rgba(15, 20, 26, 0.28);
  --tour-scrim: rgba(10, 14, 24, 0.66);
  --tour-ring: #ff4f00;
  --tour-ring-glow: rgba(255, 79, 0, 0.45);
  --font-sans: "Helvetica Neue", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --bg-page: #151619;
    --bg-surface: #202227;
    --bg-subtle: #2a2d34;
    --stage-bg: #181a1e;
    --ink-primary: #ecebe6;
    --ink-muted: #a7acb8;
    --border-soft: #363a43;
    --border-strong: #4d5360;
    --key-lip: #090a0c;
    --key-hi: rgba(255, 255, 255, 0.09);
    --hw-hole: #090a0d;
    --hw-highlight: rgba(255, 255, 255, 0.14);
    --hw-etch: color-mix(in oklab, var(--border-strong) 58%, transparent);
    --hw-seam: rgba(9, 10, 12, 0.65);
    --accent: #ff5e1a;
    --accent-fg: #ffffff;
    --accent-lip: #9f3304;
    --accent-tint: rgba(255, 94, 26, 0.18);
    --accent-hatch: rgba(255, 94, 26, 0.48);
    --accent-soft-text: #ff9a6b;
    --amber: #f4b428;
    --amber-text: #fcd34d;
    --amber-bg: rgba(244, 180, 40, 0.16);
    --amber-bg-hover: rgba(244, 180, 40, 0.24);
    --amber-border: rgba(244, 180, 40, 0.44);
    --pro-locked-status-bg: rgba(32, 34, 39, 0.92);
    --success: #22b573;
    --success-text: #6ee7b7;
    --success-bg: rgba(34, 181, 115, 0.16);
    --success-border: rgba(34, 181, 115, 0.42);
    --error-text: #fca5a5;
    --error-bg: rgba(248, 113, 113, 0.16);
    --error-border: rgba(248, 113, 113, 0.42);
    --lcd-bg: #0a0b0d;
    --lcd-border: #050607;
    --lcd-ink: #e9ece2;
    --lcd-muted: #7f8c7c;
    --lcd-amber: #f4b428;
    --lcd-green: #34d399;
    --ink-0: #60a5fa;
    --ink-0-bg: rgba(59, 130, 246, 0.19);
    --ink-0-border: rgba(96, 165, 250, 0.42);
    --ink-1: #fca5a5;
    --ink-1-bg: rgba(239, 68, 68, 0.19);
    --ink-1-border: rgba(248, 113, 113, 0.42);
    --ink-2: #6ee7b7;
    --ink-2-bg: rgba(16, 185, 129, 0.19);
    --ink-2-border: rgba(52, 211, 153, 0.42);
    --ink-3: #fcd34d;
    --ink-3-bg: rgba(245, 158, 11, 0.19);
    --ink-3-border: rgba(251, 191, 36, 0.42);
    --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 22px rgba(0, 0, 0, 0.48);
    --shadow-modal: 0 22px 54px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --shadow-cta: 0 3.5px 0 var(--accent-lip), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    --dot-tex: radial-gradient(rgba(236, 235, 230, 0.065) 1px, transparent 1px);
    --modal-backdrop: rgba(5, 6, 8, 0.78);
    --results-backdrop: rgba(5, 8, 14, 0.4);
    --tour-scrim: rgba(3, 5, 10, 0.82);
    --tour-ring: #f4b428;
    --tour-ring-glow: rgba(244, 180, 40, 0.55);
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
  --bg-page: #151619;
  --bg-surface: #202227;
  --bg-subtle: #2a2d34;
  --stage-bg: #181a1e;
  --ink-primary: #ecebe6;
  --ink-muted: #a7acb8;
  --border-soft: #363a43;
  --border-strong: #4d5360;
  --key-lip: #090a0c;
  --key-hi: rgba(255, 255, 255, 0.09);
  --hw-hole: #090a0d;
  --hw-highlight: rgba(255, 255, 255, 0.14);
  --hw-etch: color-mix(in oklab, var(--border-strong) 58%, transparent);
  --hw-seam: rgba(9, 10, 12, 0.65);
  --accent: #ff5e1a;
  --accent-fg: #ffffff;
  --accent-lip: #9f3304;
  --accent-tint: rgba(255, 94, 26, 0.18);
  --accent-hatch: rgba(255, 94, 26, 0.48);
  --accent-soft-text: #ff9a6b;
  --amber: #f4b428;
  --amber-text: #fcd34d;
  --amber-bg: rgba(244, 180, 40, 0.16);
  --amber-bg-hover: rgba(244, 180, 40, 0.24);
  --amber-border: rgba(244, 180, 40, 0.44);
  --pro-locked-status-bg: rgba(32, 34, 39, 0.92);
  --success: #22b573;
  --success-text: #6ee7b7;
  --success-bg: rgba(34, 181, 115, 0.16);
  --success-border: rgba(34, 181, 115, 0.42);
  --error-text: #fca5a5;
  --error-bg: rgba(248, 113, 113, 0.16);
  --error-border: rgba(248, 113, 113, 0.42);
  --lcd-bg: #0a0b0d;
  --lcd-border: #050607;
  --lcd-ink: #e9ece2;
  --lcd-muted: #7f8c7c;
  --lcd-amber: #f4b428;
  --lcd-green: #34d399;
  --ink-0: #60a5fa;
  --ink-0-bg: rgba(59, 130, 246, 0.19);
  --ink-0-border: rgba(96, 165, 250, 0.42);
  --ink-1: #fca5a5;
  --ink-1-bg: rgba(239, 68, 68, 0.19);
  --ink-1-border: rgba(248, 113, 113, 0.42);
  --ink-2: #6ee7b7;
  --ink-2-bg: rgba(16, 185, 129, 0.19);
  --ink-2-border: rgba(52, 211, 153, 0.42);
  --ink-3: #fcd34d;
  --ink-3-bg: rgba(245, 158, 11, 0.19);
  --ink-3-border: rgba(251, 191, 36, 0.42);
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 22px rgba(0, 0, 0, 0.48);
  --shadow-modal: 0 22px 54px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-cta: 0 3.5px 0 var(--accent-lip), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  --dot-tex: radial-gradient(rgba(236, 235, 230, 0.065) 1px, transparent 1px);
  --modal-backdrop: rgba(5, 6, 8, 0.78);
  --results-backdrop: rgba(5, 8, 14, 0.4);
  --tour-scrim: rgba(3, 5, 10, 0.82);
  --tour-ring: #f4b428;
  --tour-ring-glow: rgba(244, 180, 40, 0.55);
}

:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-size: 1rem;
  line-height: 1.45;
  overflow-wrap: break-word;
}

input {
  user-select: text;
  -webkit-user-select: text;
}

:where(a:any-link, button, summary, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[tabindex="-1"]:focus:not(:focus-visible) {
  outline: none;
}

/* Sticky Mobile-Friendly Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 2px 6px 2px 2px;
  min-block-size: 38px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.brand-btn:hover {
  background: var(--bg-subtle);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: transparent;
  filter: drop-shadow(0 2px 5px rgba(15, 36, 102, 0.22));
  display: block;
}

.brand-mark-lg {
  width: 40px;
  height: 40px;
}

.brand-logo-img,
.landing-logo-img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.day-select {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  outline: none;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.day-select:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.day-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-block-size: 34px;
  white-space: nowrap;
  overflow: hidden;
}

.day-picker-btn:hover {
  border-color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.timer-pill {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 5px 11px;
  border-radius: var(--radius-md);
  background: var(--lcd-bg);
  border: 1px solid var(--lcd-border);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.48);
  color: var(--lcd-ink);
  display: inline-flex;
  align-items: center;
  min-block-size: 36px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.timer-pill.is-perfect-active,
.timer-pill.is-perfect-earned {
  background: var(--lcd-bg);
  border-color: var(--amber-border);
  color: var(--lcd-amber);
}

.score-pill {
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-btn);
  padding: 5px 11px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  min-block-size: 36px;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.score-pill:hover {
  border-color: var(--accent);
}

.score-pill:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.theme-toggle-btn {
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-btn);
  min-block-size: 36px;
  min-inline-size: 36px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
}

.theme-toggle-btn:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.theme-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-opt-to-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-opt-to-dark {
    display: none;
  }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-opt-to-light {
    display: inline-flex;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-opt-to-dark {
  display: none;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-opt-to-light {
  display: inline-flex;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-opt-to-dark {
  display: inline-flex;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-opt-to-light {
  display: none;
}

.hw-grille-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-block-size: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hw-seam);
  box-shadow: 0 1px 0 color-mix(in oklab, var(--hw-highlight) 55%, transparent);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.hw-grille-inset {
  width: calc(100% - 68px);
  margin-inline: auto;
  padding-bottom: 4px;
  border-bottom: none;
  box-shadow: none;
}

.hw-speaker-dots {
  width: 45px;
  height: 10px;
  flex-shrink: 0;
  background-image:
    radial-gradient(circle at 50% 44%, var(--hw-hole) 1.1px, transparent 1.55px),
    radial-gradient(circle at 50% 62%, var(--hw-highlight) 1.1px, transparent 1.65px);
  background-size: 5px 5px;
}

.hw-speaker-dots-sm {
  width: 35px;
}

.hw-chassis-ticks {
  width: 41px;
  height: 6px;
  flex-shrink: 0;
  background-image:
    linear-gradient(to right, transparent 20px, var(--hw-hole) 20px 21px, transparent 21px),
    repeating-linear-gradient(to right, var(--hw-etch) 0 1px, transparent 1px 5px);
  background-size: 41px 6px, 41px 4px;
  background-position: 0 0, 0 2px;
  background-repeat: no-repeat;
}

.hw-vent-slots {
  width: 22px;
  height: 7px;
  flex-shrink: 0;
  background-image:
    repeating-linear-gradient(to right, var(--hw-hole) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(to right, var(--hw-highlight) 0 2px, transparent 2px 5px);
  background-size: 22px 6px, 22px 6px;
  background-position: 0 0, 0 1px;
  background-repeat: no-repeat;
}

@media (forced-colors: active) {
  .hw-grille-bar {
    display: none;
  }
}

@media (min-width: 860px) {
  .topbar {
    padding: 6px 18px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.badge-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  color: var(--ink-muted);
}

.badge-accent {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
}

.badge-accent.is-perfect {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
}

.badge-perfect {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
  white-space: nowrap;
}

/* Responsive Workspace Grid: Borderless Full-Bleed Mobile -> Desktop 2-Col Cards */
.workspace {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0 calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* On mobile, order: 1) Brief, 2) Full-bleed Canvas, 3) Answer */
.brief-card { order: 1; }
.canvas-card { order: 2; }
.answer-card { order: 3; }

/* Mobile: borderless full-viewport layout with larger, legible typography */
@media (max-width: 859px) {
  html, body {
    background: var(--bg-surface);
  }
  html {
    scroll-padding-top: calc(54px + env(safe-area-inset-top, 0px));
  }
  body.view-game:not(.formula-focus) {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }
  body.view-game:not(.formula-focus) #appMain {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
  }
  body.view-game:not(.formula-focus) #gameWorkspace {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0 0 max(6px, env(safe-area-inset-bottom, 0px));
  }
  body.view-game:not(.formula-focus) .canvas-card {
    flex: 1 0 auto;
    justify-content: space-between;
  }
  body.view-game:not(.formula-focus) .stage-wrap {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .workspace {
    gap: 0;
  }
  .topbar {
    border-bottom: none;
    padding: max(6px, env(safe-area-inset-top, 0px)) 10px 6px;
    gap: 0;
  }
  .topbar-main {
    gap: 6px;
  }
  .topbar .brand {
    gap: 6px;
  }
  .topbar .brand-btn {
    min-block-size: 34px;
    padding: 2px 4px 2px 0;
    gap: 6px;
    border-radius: 8px;
  }
  .topbar .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }
  .topbar .brand-name {
    font-size: clamp(0.9375rem, 0.72rem + 0.8vw, 1.0625rem);
    line-height: 1.1;
  }
  .topbar .day-select,
  .topbar .day-picker-btn {
    min-block-size: 32px;
    font-size: clamp(0.75rem, 0.65rem + 0.45vw, 0.875rem);
    line-height: 1.15;
    padding: 4px 8px;
    gap: 4px;
  }
  .topbar-right {
    gap: 5px;
  }
  .topbar .timer-pill,
  .topbar .score-pill {
    min-block-size: 32px;
    font-size: clamp(0.75rem, 0.65rem + 0.45vw, 0.875rem);
    line-height: 1.15;
    padding: 4px 8px;
    gap: 5px;
  }
  .topbar .theme-toggle-btn {
    min-block-size: 32px;
    min-inline-size: 32px;
    padding: 4px 6px;
  }
  .badge-mono,
  .hud-pill {
    border-color: var(--border-soft);
  }
  .card {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .panel-body {
    padding: 6px 10px;
  }
  .brief-card.panel-body {
    padding: 4px 10px 3px;
    gap: 3px;
  }
  .brief-card .panel-header {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-block-size: 28px;
  }
  .brief-card .badge-mono {
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 2px 6px;
  }
  .brief-card .puzzle-title {
    font-size: clamp(1rem, 0.82rem + 0.9vw, 1.1875rem);
    line-height: 1.2;
    font-weight: 800;
    min-width: 0;
    overflow-wrap: break-word;
  }
  .brief-header-actions {
    gap: 5px;
    flex-shrink: 0;
  }
  .brief-card .badge-perfect,
  .brief-card .badge-accent {
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 2px 7px;
  }
  .brief-card .btn.brief-help-btn {
    min-inline-size: 28px;
    min-block-size: 28px;
    width: auto;
    height: auto;
    padding: 2px 8px;
    font-size: 0.8125rem;
    line-height: 1;
  }
  .brief-card .puzzle-prompt {
    font-size: clamp(0.875rem, 0.8rem + 0.45vw, 1rem);
    line-height: 1.34;
    color: color-mix(in srgb, var(--ink-primary) 88%, var(--ink-muted));
    margin: 0;
  }
  .brief-values-row {
    gap: 5px;
  }
  .brief-values-row .chip-row {
    gap: 5px;
  }
  .brief-values-row .badge-mono {
    font-size: 0.78125rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 2px 8px;
    color: var(--ink-primary);
  }
  #stageContainer .stage-hud {
    top: 4px;
    left: 6px;
    right: 6px;
    gap: 5px;
  }
  #stageContainer .hud-pill {
    font-size: 0.75rem;
    padding: 2px 7px;
  }
  #stageContainer .hud-action-btn {
    font-size: 0.78125rem;
    padding: 3px 9px;
  }
  .canvas-card .toolbar {
    background: transparent !important;
    border: none !important;
    padding: 4px 8px;
    gap: 4px;
  }
  .canvas-card .toolbar .toolbar-group {
    width: 100%;
    justify-content: space-between;
    gap: 3px;
  }
  .canvas-card .toolbar .tour-group {
    gap: 3px;
  }
  .canvas-card .toolbar .btn {
    font-size: clamp(0.75rem, 0.62rem + 0.55vw, 0.875rem);
    min-block-size: 34px;
    padding: 3px 7px;
    border-radius: 7px;
  }
  .canvas-card .ink-swatch {
    width: 22px;
    height: 22px;
  }
  #answerCard.panel-body {
    padding: 5px 10px 7px;
    gap: 5px;
  }
  #answerCard .answer-label {
    font-size: 0.8125rem;
  }
  #answerCard #liveEval {
    font-size: 0.78125rem;
    padding: 2px 8px;
  }
  #answerCard .answer-input-row {
    gap: 6px;
  }
  #answerCard .input-mono {
    font-size: 1rem;
    min-block-size: 40px;
    padding: 6px 10px;
  }
  #answerCard .answer-check-btn {
    font-size: 0.875rem;
    min-block-size: 40px;
    padding: 0 14px;
  }
  #answerCard .math-pad {
    gap: 4px;
  }
  #answerCard .pad-key {
    font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.125rem);
    font-weight: 700;
    min-block-size: 36px;
    padding: 3px 0;
  }
  #answerCard .feedback-box {
    font-size: 0.8125rem;
    line-height: 1.4;
    padding: 7px 9px;
  }
  #answerCard .action-grid {
    display: none;
  }
  .brief-title-group {
    width: auto;
    flex: 1 1 0;
    justify-content: flex-start;
    min-width: 0;
    gap: 4px 6px;
  }
  #gameWorkspace .selection-bar {
    padding: 4px 8px;
  }
  #gameWorkspace .sel-tag,
  #gameWorkspace .sel-btn {
    font-size: 0.78125rem;
    min-block-size: 32px;
    padding: 3px 8px;
  }
  #gameWorkspace .proof-timeline {
    background: transparent !important;
    border: none !important;
    padding: 5px 10px 6px;
    gap: 5px;
  }
  #gameWorkspace #proofToolBadge {
    display: none;
  }
  #gameWorkspace .timeline-ticks {
    font-size: 0.75rem;
  }
  #gameWorkspace .step-narration {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 1px 0 !important;
    gap: 3px;
  }
  #gameWorkspace .step-narration-title {
    font-size: 0.875rem;
    line-height: 1.35;
  }
  #gameWorkspace .step-narration-detail {
    font-size: 0.8125rem;
    line-height: 1.42;
  }
  #gameWorkspace .proof-math-bar {
    padding: 6px 9px;
    font-size: 0.84375rem;
    line-height: 1.45;
  }
  #gameWorkspace .hint-ts-chip {
    font-size: 0.7rem;
    padding: 1px 6px;
  }
  .feedback-box {
    border: none !important;
  }
  .legend-bar {
    display: none !important;
  }
}

@media (max-width: 859px) and (pointer: coarse) {
  .topbar .brand-btn,
  .topbar .day-picker-btn,
  .topbar .score-pill,
  .topbar .theme-toggle-btn,
  .brief-help-btn,
  #formulaHintDock .proof-action-btn {
    position: relative;
  }
  .topbar .brand-btn::after,
  .topbar .day-picker-btn::after,
  .topbar .score-pill::after,
  .topbar .theme-toggle-btn::after,
  .brief-help-btn::after,
  #formulaHintDock .proof-action-btn::after {
    content: "";
    position: absolute;
    inset: -6px -2px;
  }
}

@media (max-width: 405px) {
  .topbar {
    padding-inline: 8px;
  }
  .topbar-main {
    gap: 4px;
  }
  .topbar .brand {
    gap: 4px;
  }
  .topbar .brand-btn {
    gap: 4px;
    padding-inline-end: 2px;
  }
  .topbar .brand-mark {
    width: 24px;
    height: 24px;
    border-radius: 7px;
  }
  .topbar .brand-name {
    font-size: 0.875rem;
  }
  .topbar .day-select,
  .topbar .day-picker-btn,
  .topbar .timer-pill,
  .topbar .score-pill {
    padding: 4px 6px;
    font-size: 0.75rem;
    gap: 3px;
  }
  .topbar .theme-toggle-btn {
    min-inline-size: 30px;
    min-block-size: 30px;
    padding: 3px 5px;
  }
}

@media (max-width: 430px) {
  .topbar:has(#btnOpenShare:not(.hidden)) .brand-name {
    display: none;
  }
}

@media (max-width: 390px) {
  .topbar .brand-name {
    display: none;
  }
}

@media (max-width: 374px) {
  .canvas-card .toolbar {
    padding: 3px 5px;
    gap: 3px;
  }
  .canvas-card .toolbar .btn {
    padding: 3px 5px;
    font-size: 0.75rem;
    min-block-size: 32px;
  }
  .canvas-card .ink-swatch {
    width: 20px;
    height: 20px;
  }
}

@media (min-width: 860px) {
  .workspace {
    max-width: 1260px;
    padding: 10px 16px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(316px, 32vw, 376px);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px 12px;
    align-items: stretch;
  }
  .workspace .panel-body {
    padding: 10px 12px;
    gap: 7px;
  }
  .workspace .legend-bar {
    padding: 5px 12px;
  }
  .workspace .pad-key {
    min-block-size: 38px;
    padding: 4px 0;
  }
  .workspace .action-grid .btn-submit {
    min-block-size: 38px;
    padding: 8px 6px;
    font-size: 0.8125rem;
  }
  .canvas-card {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-width: 0;
    min-height: 0;
  }
  .brief-card {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    align-self: start;
  }
  .answer-card {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    align-self: start;
  }
  body.view-game.proof-open:not(.solve-mode):not(.formula-focus):not(.tutorial-open) .answer-card {
    grid-row: 1 / span 2;
  }
  body.view-game.solve-mode .workspace {
    grid-template-columns: minmax(0, 760px);
    grid-template-rows: minmax(0, 1fr);
    justify-content: center;
  }
  body.view-game.solve-mode .canvas-card {
    grid-column: 1;
    grid-row: 1;
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.canvas-card {
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Touch-Optimized Drafting Toolbar (2 visible thumb rows below SVG on mobile, top bar on desktop) */
.toolbar {
  padding: 8px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  order: 3;
}

.stage-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  background: var(--stage-bg);
  order: 1;
}

.proof-timeline {
  order: 4;
}

.legend-bar {
  order: 5;
}

@media (min-width: 860px) {
  .toolbar {
    order: 1;
    border-top: none;
    border-bottom: 1px solid var(--border-soft);
    padding: 6px 10px;
    gap: 5px;
  }
  .toolbar .btn {
    min-block-size: 32px;
    padding: 4px 8px;
    font-size: 0.8125rem;
  }
  .stage-wrap { order: 2; }
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 6px 10px;
  min-block-size: 38px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.08s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.active,
.tool-btn[aria-pressed="true"],
.btn-primary {
  background: var(--accent);
  border-color: var(--accent-lip);
  color: var(--accent-fg);
  box-shadow: var(--shadow-cta);
}

.btn.active:active:not(:disabled),
.tool-btn[aria-pressed="true"]:active:not(:disabled),
.btn-primary:active:not(:disabled) {
  box-shadow: var(--shadow-cta-active);
}

#btnGridSnap[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-surface));
  border-color: var(--accent);
  color: var(--accent-soft-text);
}

.ink-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.ink-swatch.active,
.ink-swatch[aria-pressed="true"] {
  transform: scale(1.2);
  border-color: var(--ink-primary);
}

#vectorStage {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  max-height: 68vh;
  max-height: 68dvh;
  display: block;
  margin: 0 auto;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

/* Keep #vectorStage itself as the permanent pointer target across innerHTML re-renders */
#vectorStage * {
  pointer-events: none;
}

/* Viewport-fit workspace: lock game screen inside 100dvh without page scrolling */
@media (min-width: 860px) and (min-height: 480px) {
  body.view-game {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game #gameHeader {
    flex: 0 0 auto;
  }
  body.view-game #appMain {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game #gameWorkspace {
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  body.view-game .canvas-card {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  body.view-game .stage-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  body.view-game #vectorStage {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }
  body.view-game .toolbar,
  body.view-game .selection-bar,
  body.view-game .legend-bar {
    flex: 0 0 auto;
  }
  body.view-game .proof-timeline {
    flex: 0 0 auto;
    max-height: 46%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.view-game.solve-mode .proof-timeline {
    max-height: 50%;
  }
  body.view-game .brief-card,
  body.view-game .answer-card {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (min-width: 860px) and (max-height: 660px) {
  .workspace {
    padding: 8px 14px 10px;
    gap: 8px 10px;
  }
  .workspace .panel-body {
    padding: 8px 10px;
    gap: 6px;
  }
  .brief-card .puzzle-prompt {
    font-size: 0.875rem;
    line-height: 1.38;
  }
  .workspace .pad-key {
    min-block-size: 34px;
  }
  .workspace .answer-check-btn {
    min-block-size: 38px;
  }
  .workspace .action-grid .btn-submit {
    min-block-size: 34px;
    padding: 6px 6px;
  }
}

@media (max-width: 859px) and (min-height: 520px) {
  body.view-game:not(.formula-focus) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) #gameHeader {
    flex: 0 0 auto;
  }
  body.view-game:not(.formula-focus) #appMain {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) #gameWorkspace {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 0 max(4px, env(safe-area-inset-bottom, 0px));
  }
  body.view-game:not(.formula-focus) .brief-card {
    flex: 0 0 auto;
  }
  body.view-game:not(.formula-focus) .canvas-card {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    justify-content: flex-start;
  }
  body.view-game:not(.formula-focus) .stage-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) #vectorStage {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }
  body.view-game:not(.formula-focus) .toolbar,
  body.view-game:not(.formula-focus) .selection-bar {
    flex: 0 0 auto;
  }
  body.view-game:not(.formula-focus) .proof-timeline {
    flex: 0 0 auto;
    max-height: 46%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.view-game.solve-mode .proof-timeline {
    max-height: 50%;
  }
  body.view-game:not(.formula-focus) #answerCard {
    flex: 0 0 auto;
    max-height: 48%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (min-width: 860px) and (max-height: 479px) {
  body.view-game {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game #gameHeader {
    flex: 0 0 auto;
    padding: 4px 14px;
  }
  body.view-game .topbar .brand-btn,
  body.view-game .topbar .day-picker-btn,
  body.view-game .topbar .timer-pill,
  body.view-game .topbar .score-pill,
  body.view-game .topbar .theme-toggle-btn {
    min-block-size: 30px;
  }
  body.view-game .topbar .brand-mark {
    width: 24px;
    height: 24px;
  }
  body.view-game #appMain {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game #gameWorkspace {
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 5px 10px;
    grid-template-columns: minmax(0, 1fr) clamp(248px, 28vw, 300px);
    gap: 5px 8px;
  }
  body.view-game .canvas-card {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  body.view-game .stage-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  body.view-game #vectorStage {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }
  body.view-game .toolbar,
  body.view-game .selection-bar {
    flex: 0 0 auto;
    padding: 4px 8px;
    gap: 4px;
  }
  body.view-game .toolbar-group {
    gap: 3px;
  }
  body.view-game .toolbar .btn {
    min-block-size: 28px;
    padding: 2px 6px;
    font-size: 0.75rem;
  }
  body.view-game .ink-swatch {
    width: 17px;
    height: 17px;
  }
  body.view-game .proof-timeline {
    flex: 0 0 auto;
    max-height: 48%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.view-game.formula-focus .proof-timeline {
    max-height: 60%;
    padding: 4px 8px;
    gap: 3px;
  }
  body.view-game.formula-focus #hintTimestampStrip,
  body.view-game.formula-focus .timeline-controls {
    display: none !important;
  }
  body.view-game.formula-focus .step-narration {
    gap: 2px;
  }
  body.view-game.formula-focus .step-narration-title {
    font-size: 0.8125rem;
    line-height: 1.25;
  }
  body.view-game.formula-focus .step-narration-detail {
    font-size: 0.78125rem;
    line-height: 1.3;
  }
  body.view-game.formula-focus .proof-math-bar {
    padding: 4px 8px;
    font-size: 0.8125rem;
    line-height: 1.35;
  }
  body.view-game.solve-mode .proof-timeline {
    max-height: 52%;
  }
  body.view-game .brief-card,
  body.view-game .answer-card {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.view-game .workspace .panel-body {
    padding: 6px 8px;
    gap: 4px;
  }
  body.view-game .brief-card .puzzle-title {
    font-size: 1rem;
  }
  body.view-game .brief-card .puzzle-prompt {
    font-size: 0.78125rem;
    line-height: 1.28;
  }
  body.view-game .brief-values-row .badge-mono {
    font-size: 0.72rem;
    padding: 1px 6px;
  }
  body.view-game .answer-card .input-mono,
  body.view-game .answer-card .answer-check-btn {
    min-block-size: 32px;
    font-size: 0.875rem;
  }
  body.view-game .workspace .pad-key {
    min-block-size: 28px;
    padding: 0;
    font-size: 0.875rem;
  }
  body.view-game .workspace .action-grid .btn-submit {
    min-block-size: 30px;
    padding: 4px 6px;
  }
  body.view-game .legend-bar {
    display: none !important;
  }
}

@media (max-width: 859px) and (max-height: 500px) and (min-width: 560px) {
  body.view-game:not(.formula-focus) {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) #gameHeader {
    flex: 0 0 auto;
    padding: 3px 10px;
  }
  body.view-game:not(.formula-focus) .topbar .brand-btn,
  body.view-game:not(.formula-focus) .topbar .day-picker-btn,
  body.view-game:not(.formula-focus) .topbar .timer-pill,
  body.view-game:not(.formula-focus) .topbar .score-pill,
  body.view-game:not(.formula-focus) .topbar .theme-toggle-btn {
    min-block-size: 28px;
  }
  body.view-game:not(.formula-focus) .topbar .brand-mark {
    width: 24px;
    height: 24px;
  }
  body.view-game:not(.formula-focus) #appMain {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) #gameWorkspace {
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    padding: 4px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(228px, 260px);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px 8px;
    align-items: stretch;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) .canvas-card {
    grid-column: 1;
    grid-row: 1 / span 2;
    order: 0;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    justify-content: flex-start;
  }
  body.view-game:not(.formula-focus) .stage-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  body.view-game:not(.formula-focus) #vectorStage {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }
  body.view-game:not(.formula-focus) .toolbar,
  body.view-game:not(.formula-focus) .selection-bar {
    flex: 0 0 auto;
    padding: 3px 6px;
    gap: 3px;
  }
  body.view-game:not(.formula-focus) .canvas-card .toolbar .btn {
    min-block-size: 28px;
    padding: 2px 6px;
    font-size: 0.75rem;
  }
  body.view-game:not(.formula-focus) .canvas-card .ink-swatch {
    width: 18px;
    height: 18px;
  }
  body.view-game:not(.formula-focus) .proof-timeline {
    flex: 0 0 auto;
    max-height: 48%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.view-game:not(.formula-focus) .brief-card {
    grid-column: 2;
    grid-row: 1;
    order: 0;
    min-width: 0;
    padding: 3px 6px;
    gap: 2px;
  }
  body.view-game:not(.formula-focus) .brief-card .puzzle-title {
    font-size: 0.9375rem;
  }
  body.view-game:not(.formula-focus) .brief-card .puzzle-prompt {
    font-size: 0.75rem;
    line-height: 1.25;
  }
  body.view-game:not(.formula-focus) .brief-values-row .badge-mono {
    font-size: 0.6875rem;
    padding: 1px 5px;
  }
  body.view-game:not(.formula-focus) #answerCard {
    grid-column: 2;
    grid-row: 2;
    order: 0;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 6px;
    gap: 4px;
  }
  body.view-game:not(.formula-focus) #answerCard .input-mono,
  body.view-game:not(.formula-focus) #answerCard .answer-check-btn {
    min-block-size: 32px;
    font-size: 0.875rem;
  }
  body.view-game:not(.formula-focus) #answerCard .pad-key {
    min-block-size: 28px;
    padding: 0;
    font-size: 0.875rem;
  }
  body.view-game:not(.formula-focus) .legend-bar {
    display: none !important;
  }
  body.view-game.proof-open:not(.solve-mode):not(.formula-focus):not(.tutorial-open) #answerCard {
    grid-row: 1 / span 2;
  }
  body.view-game.solve-mode:not(.formula-focus) #gameWorkspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  body.view-game.solve-mode:not(.formula-focus) .canvas-card {
    grid-column: 1;
    grid-row: 1;
  }
}

.stage-hud {
  pointer-events: none;
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.stage-hud-right {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

#snapReadout {
  min-width: 0;
  flex: 0 1 auto;
}

#lineCounter {
  max-width: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.ink-swatch[data-ink="0"] {
  background: #2563eb;
}

.ink-swatch[data-ink="1"] {
  background: #dc2626;
}

.ink-swatch[data-ink="2"] {
  background: #059669;
}

.ink-swatch[data-ink="3"] {
  background: #d97706;
}

.hud-pill {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
  border: 1px solid var(--border-soft);
  color: var(--ink-muted);
  max-width: 72%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-action-btn {
  pointer-events: auto;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
}

/* Dedicated Non-Overlapping Selection Strip Below Canvas */
.selection-bar {
  order: 2;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.selection-bar::-webkit-scrollbar {
  display: none;
}

@media (min-width: 860px) {
  .selection-bar {
    order: 3;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-subtle);
    padding: 7px 12px;
  }
}

.sel-tag {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--ink-muted);
  white-space: nowrap;
}

.sel-btn {
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 5px 10px;
  min-block-size: 34px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.14s ease;
}

.sel-btn:hover {
  border-color: var(--accent);
}

.sel-btn:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.sel-btn.danger {
  color: var(--error-text);
  border-color: var(--error-border);
  background: var(--error-bg);
}

/* Unified Hint & Solve Timeline */
.proof-timeline {
  border-top: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-header.proof-header {
  flex-wrap: nowrap;
  gap: 6px;
}

.proof-header-left {
  flex: 1 1 auto;
  min-width: 0;
  gap: 5px;
  flex-wrap: nowrap;
}

.proof-header-actions {
  flex-shrink: 0;
  gap: 6px;
  flex-wrap: nowrap;
}

.proof-action-btn {
  min-block-size: 30px;
  min-inline-size: 44px;
  padding: 3px 9px;
  font-size: 0.78rem;
}

.timeline-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.timeline-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.timeline-nav-btn {
  min-block-size: 34px;
  min-inline-size: 64px;
  padding: 4px 10px;
  font-size: 0.8125rem;
  gap: 5px;
  justify-content: center;
}

.timeline-play-btn {
  min-block-size: 34px;
  min-inline-size: 76px;
  padding: 4px 10px;
  font-size: 0.8125rem;
  gap: 5px;
  justify-content: center;
}

.slider-col {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.timeline-slider {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
  cursor: pointer;
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.tick-btn {
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  min-inline-size: 24px;
  min-block-size: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.tick-btn.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-tint);
}

@media (max-width: 520px) {
  .timeline-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .timeline-btn-group {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: 100%;
    gap: 6px;
  }
  .timeline-nav-btn,
  .timeline-play-btn {
    min-block-size: 38px;
  }
  .slider-col {
    flex: 1 1 auto;
    width: 100%;
  }
}

@media (pointer: coarse) {
  .timeline-nav-btn,
  .timeline-play-btn {
    min-block-size: 42px;
  }
  .proof-timeline .proof-action-btn {
    min-block-size: 32px;
    min-inline-size: 44px;
    position: relative;
  }
  .proof-timeline .proof-action-btn::after {
    content: "";
    position: absolute;
    inset: -6px -2px;
  }
}

.step-narration {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-narration-title {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.4;
}

.step-narration-detail {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

.proof-math-bar {
  margin-top: 2px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  background: var(--lcd-bg);
  border: 1px solid var(--lcd-border);
  border-left: 3.5px solid var(--accent);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.55;
  color: var(--lcd-ink);
}

.proof-solution-summary {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink-primary);
  white-space: pre-line;
}

.solve-countdown-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Color-Matched Inline Pills (matches SVG Blue / Red / Green / Amber inks) */
.ink-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.94em;
  font-weight: 700;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 5px;
  border: 1px solid transparent;
  vertical-align: baseline;
}

.ink-0 {
  color: var(--ink-0);
  background: var(--ink-0-bg);
  border-color: var(--ink-0-border);
}

.ink-1 {
  color: var(--ink-1);
  background: var(--ink-1-bg);
  border-color: var(--ink-1-border);
}

.ink-2 {
  color: var(--ink-2);
  background: var(--ink-2-bg);
  border-color: var(--ink-2-border);
}

.ink-3 {
  color: var(--ink-3);
  background: var(--ink-3-bg);
  border-color: var(--ink-3-border);
}

.proof-math-bar .ink-0 {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(96, 165, 250, 0.45);
}

.proof-math-bar .ink-1 {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(248, 113, 113, 0.45);
}

.proof-math-bar .ink-2 {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(52, 211, 153, 0.45);
}

.proof-math-bar .ink-3 {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(251, 191, 36, 0.45);
}

.legend-bar {
  padding: 8px 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot-vertex {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

.dot-inter {
  width: 7px;
  height: 7px;
  border: 2px solid var(--amber);
  transform: rotate(45deg);
}

.dot-grid {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-muted);
}

/* Panels */
.panel-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.puzzle-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.puzzle-prompt {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: color-mix(in srgb, var(--ink-primary) 88%, var(--ink-muted));
  text-wrap: pretty;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 16px+ font-size prevents iOS Safari from auto-zooming on tap */
.input-mono {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-page);
  color: var(--ink-primary);
  outline: none;
}

.input-mono:focus {
  border-color: var(--accent);
}

.answer-label {
  font-size: 0.875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.answer-input-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.answer-input-row .input-mono {
  flex: 1 1 auto;
  min-width: 0;
  width: 0;
  padding: 9px 11px;
  background: var(--lcd-bg);
  border-color: var(--lcd-border);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.48);
  color: var(--lcd-ink);
}

.answer-input-row .input-mono::placeholder {
  color: var(--lcd-muted);
}

#liveEval {
  background: var(--lcd-bg);
  border-color: var(--lcd-border);
  color: var(--lcd-green);
  box-shadow: inset 0 1.5px 4px rgba(0, 0, 0, 0.45);
  font-weight: 700;
}

.answer-check-btn {
  flex: 0 0 auto;
  justify-content: center;
  min-block-size: 42px;
  padding: 0 16px;
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.formula-pad-dock[hidden],
.formula-hint-dock[hidden] {
  display: none !important;
}

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

.pad-key {
  min-block-size: 42px;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.14s ease;
}

.pad-key[data-action="backspace"],
.pad-key[data-action="clear-input"] {
  background: var(--bg-subtle);
}

.pad-key:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.pad-key:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
  border-color: var(--accent);
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-submit {
  width: 100%;
  justify-content: center;
  padding: 11px 12px;
  min-block-size: 44px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.action-grid .btn-submit {
  min-block-size: 42px;
  font-size: 0.875rem;
}

.feedback-box {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-line;
}

.feedback-box.ok {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.feedback-box.err {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
}

.feedback-box.err .ink-tag {
  background: var(--bg-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.popover {
  position: fixed;
  z-index: 60;
  width: min(264px, calc(100vw - 20px));
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-height: 500px) {
  .popover {
    padding: 8px 10px;
    gap: 6px;
  }
}

.popover-head {
  gap: 6px;
}

.popover-eyebrow {
  font-size: 0.6875rem;
  padding: 2px 6px;
}

.popover-title {
  display: block;
  margin-top: 3px;
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1.2;
}

.popover-close-btn {
  padding: 3px 9px;
  min-block-size: 32px;
  min-inline-size: 32px;
  font-size: 0.8125rem;
}

.popover-lcd-input {
  padding: 8px 10px;
  background: var(--lcd-bg);
  border-color: var(--lcd-border);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.48);
  color: var(--lcd-ink);
}

.popover-lcd-input::placeholder {
  color: var(--lcd-muted);
}

.quick-tags {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.quick-tags .pad-key {
  padding: 4px 2px;
  min-block-size: 34px;
  font-size: 0.8125rem;
}

.popover-actions {
  padding-top: 2px;
}

/* Modals (Google Login Gate, Scoreboard, Calendar, Results, How-To & Pro Mode) */
.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.modal-title-spaced {
  margin-top: 4px;
}

.modal-subtitle {
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.modal-lead {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--ink-primary);
  line-height: 1.5;
  text-wrap: pretty;
}

.modal-header-top {
  align-items: flex-start;
  flex-wrap: nowrap;
}

.modal-heading-group {
  min-inline-size: 0;
  flex: 1 1 auto;
}

.modal-close-btn {
  padding: 4px 10px;
  min-block-size: 34px;
  min-inline-size: 34px;
  font-size: 0.875rem;
  align-self: flex-start;
  flex-shrink: 0;
}

.modal-section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.modal-section-label-spaced {
  margin-bottom: 6px;
}

.modal-meta {
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.modal-meta-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.privacy-note {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  line-height: 1.48;
  text-wrap: pretty;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background-color: var(--lcd-bg);
  background-image: radial-gradient(rgba(239, 242, 232, 0.05) 1px, transparent 1px);
  background-size: 6px 6px;
  border: 1px solid var(--lcd-border);
  border-radius: var(--radius-md);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  overflow: clip;
}

.stat-tile {
  padding: 10px 6px;
  text-align: center;
  border-inline-end: 1px solid color-mix(in oklab, var(--lcd-muted) 22%, var(--lcd-bg));
}

.stat-tile:last-child {
  border-inline-end: none;
}

@media (max-width: 340px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-tile:nth-child(2) {
    border-inline-end: none;
  }
  .stat-tile:nth-child(-n + 2) {
    border-block-end: 1px solid color-mix(in oklab, var(--lcd-muted) 22%, var(--lcd-bg));
  }
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.3125rem;
  line-height: 1.15;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--lcd-ink);
}

.stat-val.is-perfect {
  color: var(--lcd-amber);
}

#statSolvedCount.is-positive {
  color: var(--lcd-green);
}

#statCurStreak.is-positive,
#statMaxStreak.is-positive {
  color: var(--lcd-amber);
}

.stats-arcade-meter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}

.stats-meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stats-meter-label {
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.stats-meter-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink-primary);
}

.stats-meter-segments {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
}

.stats-meter-seg {
  height: 7px;
  border-radius: 3px;
  background: color-mix(in oklab, var(--border-strong) 45%, var(--bg-surface));
  border: 1px solid var(--border-soft);
  transition: background-color 160ms ease, border-color 160ms ease;
}

.stats-meter-seg.is-lit {
  background: var(--amber);
  border-color: var(--amber-border);
  box-shadow: 0 0 6px color-mix(in srgb, var(--amber) 45%, transparent);
}

.stats-meter-seg.is-lit.is-full {
  background: var(--success);
  border-color: var(--success-border);
  box-shadow: 0 0 6px color-mix(in srgb, var(--success) 45%, transparent);
}

.stat-lbl {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--lcd-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-rule-strip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

@media (max-width: 350px) {
  .stats-rule-strip {
    flex-wrap: wrap;
    gap: 4px 8px;
  }
}

.stats-rule-badge {
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.stats-rule-copy {
  min-inline-size: 0;
  font-size: 0.734375rem;
  line-height: 1.3;
}

.stats-rule-copy code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.stats-history-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.stats-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stats-history-count {
  padding: 1px 7px;
  font-size: 0.75rem;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-block-size: 196px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.history-empty {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px dashed var(--border-soft);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.875rem;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-btn);
}

.history-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-strong);
}

.history-led[data-tone="amber"] {
  background: var(--amber);
  box-shadow: 0 0 6px color-mix(in srgb, var(--amber) 60%, transparent);
}

.history-led[data-tone="success"] {
  background: var(--success);
  box-shadow: 0 0 6px color-mix(in srgb, var(--success) 55%, transparent);
}

.history-led[data-tone="muted"] {
  background: var(--border-strong);
  opacity: 0.55;
}

.history-row-main {
  min-inline-size: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-row-title {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-status-pill[data-tone="amber"] {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.history-status-pill[data-tone="success"] {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

[hidden],
.hidden {
  display: none !important;
}

/* Pre-Game Get-Ready Landing View */
.landing-view {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(clamp(8px, 1.4dvh, 14px) + env(safe-area-inset-top, 0px)) 16px calc(clamp(10px, 1.8dvh, 20px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: var(--bg-page);
  background-image:
    linear-gradient(90deg, var(--accent) 0 28%, var(--amber) 28% 58%, var(--success) 58% 100%),
    var(--dot-tex);
  background-size: 100% 3px, 14px 14px;
  background-repeat: no-repeat, repeat;
  background-position: 0 0, 0 0;
}

.landing-shell {
  width: 100%;
  max-width: 460px;
  min-inline-size: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.3dvh, 14px);
}

.landing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.landing-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.account-pill {
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-btn);
  padding: 5px 11px 5px 9px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-block-size: 36px;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 140ms ease, background-color 140ms ease;
}

.account-pill:hover {
  border-color: var(--accent);
}

.account-pill:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.account-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-soft-text);
}

.account-pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 132px;
}

@media (max-width: 420px) {
  .account-pill-label {
    max-width: 96px;
  }
}

@media (max-width: 360px) {
  .account-pill-label {
    max-width: 78px;
  }
}

.account-pill.is-synced {
  justify-content: center;
  gap: 0;
  padding: 4px;
  min-inline-size: 36px;
  min-block-size: 36px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

.account-pill.is-synced .account-pill-label {
  display: none;
}

.account-pill.is-synced:hover {
  border-color: var(--accent);
}

.account-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border-soft));
  color: var(--accent-soft-text);
  font-family: var(--font-sans);
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

.account-avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 0.6875rem;
}

.account-avatar-lg {
  width: 38px;
  height: 38px;
  font-size: 0.875rem;
}

.account-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.account-avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.account-avatar-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  border: 1.5px solid var(--bg-surface);
}

.pro-pill {
  border: 1px solid var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber-text);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-btn);
  padding: 5px 11px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  min-block-size: 36px;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 140ms ease, background-color 140ms ease;
}

.pro-pill:hover {
  border-color: var(--amber);
  background: var(--amber-bg-hover);
}

.pro-pill:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.pro-pill.is-active {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.pro-toast-banner {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: var(--shadow-card);
}

.pro-toast-banner.ok {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.pro-toast-banner.err {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.pro-toast-banner.info {
  background: var(--accent-tint);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-soft));
}

@media (max-width: 420px) {
  .landing-topbar {
    gap: 5px;
  }
  .landing-topbar-right {
    gap: 4px;
  }
  .landing-topbar .day-picker-btn,
  .landing-topbar .score-pill,
  .landing-topbar .pro-pill,
  .landing-topbar .account-pill {
    padding: 4px 8px;
    font-size: 0.75rem;
    gap: 4px;
  }
  .landing-topbar .theme-toggle-btn {
    min-block-size: 32px;
    min-inline-size: 32px;
    padding: 4px 6px;
  }
  .landing-topbar .account-pill.is-synced {
    min-block-size: 36px;
    min-inline-size: 36px;
    padding: 4px;
    gap: 0;
  }
}

.landing-card {
  width: 100%;
  min-inline-size: 0;
  background-color: var(--bg-surface);
  background-image: linear-gradient(90deg, var(--accent) 0 38%, var(--amber) 38% 72%, var(--success) 72% 100%);
  background-size: 100% 3px;
  background-repeat: no-repeat;
  background-position: 0 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: 0 5px 0 var(--key-lip), var(--shadow-card);
  padding: clamp(12px, 1.8dvh, 18px) 16px clamp(12px, 1.6dvh, 18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(7px, 1.1dvh, 11px);
  overflow: clip;
}

.landing-console-screen {
  width: 100%;
  min-inline-size: 0;
  border-radius: var(--radius-lg);
  background-color: var(--lcd-bg);
  background-image: radial-gradient(rgba(239, 242, 232, 0.055) 1px, transparent 1px);
  background-size: 6px 6px;
  border: 1.5px solid var(--lcd-border);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.58), 0 1px 0 var(--key-hi);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
}

.landing-console-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-inline-size: 0;
}

.arcade-led-cluster {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  pointer-events: none;
}

.arcade-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.arcade-led-orange {
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.arcade-led-amber {
  background: var(--lcd-amber);
  box-shadow: 0 0 6px color-mix(in srgb, var(--lcd-amber) 65%, transparent);
}

.arcade-led-green {
  background: var(--lcd-green);
  box-shadow: 0 0 6px color-mix(in srgb, var(--lcd-green) 65%, transparent);
}

.landing-console-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  min-inline-size: 0;
}

.landing-console-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-inline-size: 0;
  flex: 1 1 auto;
}

#landingEyebrow {
  max-inline-size: calc(100% - 44px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (prefers-reduced-motion: no-preference) {
  .landing-card {
    animation: landingCardEnter 0.28s ease-out both;
  }
  .arcade-led-orange {
    animation: arcadeBeacon 0.55s ease-in-out 0.08s 2 forwards;
  }
  .arcade-led-amber {
    animation: arcadeBeacon 0.55s ease-in-out 0.2s 2 forwards;
  }
  .arcade-led-green {
    animation: arcadeBeacon 0.55s ease-in-out 0.32s 2 forwards;
  }
}

@keyframes arcadeBeacon {
  0% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes landingCardEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.landing-logo-wrap {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  background: transparent;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.42));
}

@media (max-width: 360px) {
  .landing-logo-wrap {
    width: 48px;
    height: 48px;
  }
}

.landing-title {
  margin: 0;
  font-size: clamp(1.45rem, 1.2rem + 1.2vw, 1.875rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--lcd-ink);
}

.landing-tagline {
  margin: 0;
  max-width: none;
  font-size: 0.8125rem;
  color: var(--lcd-muted);
  line-height: 1.38;
  text-wrap: pretty;
}

/* Landing Day Selector Grid (Today, Yesterday, Calendar) & Archive Banner */
.archive-date-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.archive-today-btn {
  min-block-size: 32px;
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.day-carousel {
  width: 100%;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.carousel-arrow-btn {
  min-inline-size: 34px;
  min-block-size: 34px;
  padding: 4px 10px;
  font-size: 0.875rem;
  touch-action: manipulation;
  position: relative;
}

.day-carousel-track {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  width: 100%;
  padding: 2px 2px 4px;
}

.day-card-btn {
  width: 100%;
  min-inline-size: 0;
  min-block-size: 74px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.day-card-btn:not(:disabled):hover {
  border-color: var(--border-strong);
}

.day-card-btn:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.day-card-btn:disabled,
.day-card-btn.is-unavailable {
  opacity: 0.56;
  cursor: not-allowed;
  box-shadow: none;
}

.day-card-btn.active {
  border-width: 1.5px;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-surface));
  box-shadow: 0 0 0 1.5px var(--accent);
}

.day-card-btn.is-pro-locked {
  border-color: var(--amber-border);
  background: var(--amber-bg);
}

.day-card-btn.is-pro-locked:not(:disabled):hover {
  border-color: var(--amber);
  background: var(--amber-bg-hover);
}

.day-card-btn.is-pro-locked .day-card-num {
  color: var(--amber-text);
  font-weight: 700;
}

.day-card-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-inline-size: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--ink-primary);
}

.day-card-btn.active .day-card-top {
  color: var(--accent-soft-text);
}

.day-card-cal-svg {
  flex-shrink: 0;
  color: var(--accent-soft-text);
}

.day-card-btn.day-card-calendar.active .day-card-cal-svg {
  display: none;
}

.day-card-active-dot {
  display: none;
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.day-card-btn.active .day-card-active-dot {
  display: inline-block;
}

.day-card-date {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--ink-muted);
}

.day-card-btn.active .day-card-date {
  color: var(--ink-primary);
}

.day-card-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-block-size: 14px;
}

.day-card-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.25;
  white-space: nowrap;
  color: var(--ink-muted);
}

.day-pips {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.day-pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

.day-pip.filled {
  background: var(--amber);
}

.day-pip.filled.is-perfect {
  background: var(--amber);
  box-shadow: 0 0 5px color-mix(in srgb, var(--amber) 65%, transparent);
}

.day-pip.filled.is-solved {
  background: var(--success);
  box-shadow: 0 0 5px color-mix(in srgb, var(--success) 60%, transparent);
}

.day-pip.filled.is-proof {
  background: var(--ink-muted);
}

.day-card-btn.is-day-solved:not(.active) {
  border-color: var(--success-border);
  background: color-mix(in srgb, var(--success) 8%, var(--bg-surface));
}

.day-card-btn.is-day-perfect:not(.active) {
  border-color: var(--amber-border);
  background: color-mix(in srgb, var(--amber) 9%, var(--bg-surface));
}

.day-card-calendar:not(.active) {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-soft));
  background: color-mix(in srgb, var(--accent-tint) 45%, var(--bg-subtle));
}

/* Archive Calendar Date Picker Modal */
.calendar-modal-card {
  padding: 18px 16px;
  gap: 10px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.calendar-month-label {
  padding: 5px 12px;
  border-radius: var(--radius-md);
  background-color: var(--lcd-bg);
  background-image: radial-gradient(rgba(239, 242, 232, 0.05) 1px, transparent 1px);
  background-size: 6px 6px;
  border: 1px solid var(--lcd-border);
  color: var(--lcd-ink);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekdays {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-bottom: 2px;
}

.cal-spacer {
  min-block-size: 40px;
}

.cal-day {
  min-block-size: 42px;
  padding: 4px 2px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.14s ease;
}

.cal-day:hover:not(:disabled) {
  border-color: var(--accent);
}

.cal-day:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.cal-day.is-day-solved:not(.is-selected) {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.cal-day.is-day-perfect:not(.is-selected) {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.cal-day.is-today:not(.is-selected) {
  border-style: dashed;
  border-color: var(--amber);
}

.cal-day.is-selected {
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 800;
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.cal-day.is-selected .day-pip.filled {
  background: var(--accent-fg);
}

.cal-day.is-selected .day-pip.filled.is-perfect {
  background: var(--lcd-amber);
}

.cal-day:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.cal-day.cal-day-window-empty:disabled {
  opacity: 0.56;
  border-style: dashed;
  border-color: var(--border-strong);
}

.cal-day.is-pro-locked {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber-text);
  cursor: pointer;
}

.cal-day.is-pro-locked:hover {
  border-color: var(--amber);
  background: var(--amber-bg-hover);
}

.cal-day-lock {
  font-size: 0.6875rem;
  line-height: 1;
}

.calendar-pro-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
}

.calendar-pro-copy {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.35;
}

.calendar-pro-btn {
  min-block-size: 36px;
  padding: 5px 11px;
  font-size: 0.8125rem;
  font-weight: 800;
  flex-shrink: 0;
}

.cal-day-pips {
  display: inline-flex;
  gap: 2px;
}

.cal-day .day-pip {
  width: 4px;
  height: 4px;
}

.cal-day.is-selected .day-pip:not(.filled) {
  background: rgba(255, 255, 255, 0.45);
}

.landing-challenge-list {
  width: 100%;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.landing-challenge-btn {
  width: 100%;
  min-inline-size: 0;
  min-block-size: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.landing-challenge-btn:hover {
  border-color: var(--border-strong);
}

.landing-challenge-btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.landing-challenge-btn.active {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.challenge-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-strong);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.challenge-led[data-tone="amber"] {
  background: var(--amber);
  box-shadow: 0 0 6px color-mix(in srgb, var(--amber) 65%, transparent);
}

.challenge-led[data-tone="success"] {
  background: var(--success);
  box-shadow: 0 0 6px color-mix(in srgb, var(--success) 60%, transparent);
}

.challenge-led[data-tone="active"] {
  background: var(--accent);
  box-shadow: 0 0 7px color-mix(in srgb, var(--accent) 65%, transparent);
}

.challenge-led[data-tone="amber-locked"] {
  background: var(--amber);
  opacity: 0.72;
}

.challenge-led[data-tone="locked"],
.challenge-led[data-tone="muted"] {
  background: var(--border-strong);
  opacity: 0.55;
}

.landing-challenge-btn.is-locked,
.landing-challenge-btn[aria-disabled="true"],
.landing-challenge-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.landing-challenge-btn.is-locked:hover,
.landing-challenge-btn[aria-disabled="true"]:hover,
.landing-challenge-btn:disabled:hover {
  border-color: var(--border-soft);
}

.landing-challenge-btn.is-pro-locked {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  opacity: 1;
  cursor: pointer;
}

.landing-challenge-btn.is-pro-locked:hover {
  border-color: var(--amber);
  background: var(--amber-bg-hover);
}

.landing-challenge-btn.is-pro-locked .landing-challenge-status {
  border-color: var(--amber-border);
  color: var(--amber-text);
  background: var(--pro-locked-status-bg);
}

.modal-card .btn-submit,
.modal-dialog .btn-submit {
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  overflow-wrap: break-word;
}

.landing-challenge-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.landing-challenge-name {
  font-weight: 700;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.landing-challenge-status {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  color: var(--ink-muted);
  flex-shrink: 0;
}

.landing-challenge-btn.active .landing-challenge-status {
  border-color: var(--accent);
  color: var(--ink-primary);
}

.landing-play-btn {
  width: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 54px;
  block-size: 54px;
  padding-inline: 14px;
  font-size: clamp(0.9375rem, 0.85rem + 0.5vw, 1.0625rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  border-radius: var(--radius-lg);
  margin-top: 4px;
  gap: 8px;
  box-shadow: 0 4.5px 0 var(--accent-lip), inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.landing-play-btn::before {
  content: "▶";
  font-size: 0.82em;
  line-height: 1;
  flex-shrink: 0;
}

.landing-play-btn[data-cta-state="pro"]::before {
  content: "✦";
}

.landing-play-btn[data-cta-state="review"]::before {
  content: "↺";
  font-size: 0.95em;
}

.landing-play-label {
  display: block;
  min-inline-size: 0;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.landing-play-btn:active {
  box-shadow: var(--shadow-cta-active);
}

.landing-timer-note {
  margin: 0;
  width: 100%;
  min-inline-size: 0;
  line-height: 1.45;
  min-block-size: calc(2 * 1.45em);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  text-wrap: balance;
}

@media (max-width: 420px) {
  .landing-timer-note {
    font-size: 0.75rem;
  }
}

.landing-howto {
  width: 100%;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  margin-top: 0;
}

.landing-howto-trigger {
  width: 100%;
  min-block-size: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.landing-howto-trigger:hover {
  border-color: var(--border-strong);
}

.landing-howto-trigger:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.landing-howto-icon {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-height: 780px) {
  .landing-view {
    padding-block: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .landing-shell {
    gap: 7px;
  }
  .landing-card {
    padding: 10px 14px 10px;
    gap: 6px;
  }
  .landing-card .hw-grille-bar {
    padding-bottom: 5px;
  }
  .landing-console-screen {
    padding: 8px 11px;
    gap: 6px;
  }
  .landing-logo-wrap {
    width: 48px;
    height: 48px;
  }
  .landing-title {
    font-size: clamp(1.375rem, 1.15rem + 1vw, 1.65rem);
  }
  .landing-tagline {
    font-size: 0.78125rem;
    line-height: 1.32;
  }
  .day-card-btn {
    min-block-size: 62px;
    padding: 5px 6px;
    gap: 2px;
  }
  .landing-challenge-list {
    gap: 6px;
    margin-top: 2px;
  }
  .landing-challenge-btn {
    min-block-size: 42px;
    padding: 7px 12px;
  }
  .landing-howto {
    padding-top: 7px;
  }
  .landing-howto-trigger {
    min-block-size: 38px;
    padding: 6px 12px;
  }
}

@media (max-height: 680px) {
  .landing-view {
    padding-block: calc(6px + env(safe-area-inset-top, 0px)) calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .landing-shell {
    gap: 5px;
  }
  .landing-card {
    padding: 8px 14px 8px;
    gap: 4px;
  }
  .landing-console-screen {
    padding: 7px 10px;
    gap: 4px;
  }
  .landing-logo-wrap {
    width: 40px;
    height: 40px;
  }
  .landing-tagline {
    font-size: 0.75rem;
    line-height: 1.28;
  }
  .day-card-btn {
    min-block-size: 56px;
    padding: 4px 6px;
    gap: 1px;
  }
  .landing-challenge-btn {
    min-block-size: 38px;
    padding: 5px 12px;
  }
  .landing-howto {
    padding-top: 5px;
  }
  .landing-howto-trigger {
    min-block-size: 34px;
    padding: 4px 12px;
  }
}

/* Centered Top-Layer Native Modal Dialogs */
dialog.modal-dialog {
  width: min(calc(100vw - 32px), 440px);
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  inset: 0;
  margin: auto;
  padding: 0;
  overflow-y: auto;
  background: var(--bg-surface);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.modal-dialog:modal {
  overscroll-behavior: contain;
}

dialog.modal-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(10, 12, 16, 0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.modal-dialog[open]:where(:not([data-closing])) {
  opacity: 1;
}

@starting-style {
  dialog.modal-dialog[open]:where(:not([data-closing])) {
    opacity: 0;
  }
}

dialog.modal-dialog[open]:where(:not([data-closing]))::backdrop {
  background-color: var(--modal-backdrop);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

@starting-style {
  dialog.modal-dialog[open]:where(:not([data-closing]))::backdrop {
    background-color: rgba(10, 12, 16, 0);
    -webkit-backdrop-filter: blur(0px);
    backdrop-filter: blur(0px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  dialog.modal-dialog {
    transform: translateY(8px) scale(0.96);
  }

  dialog.modal-dialog[open]:where(:not([data-closing])) {
    transform: translateY(0) scale(1);
  }

  @starting-style {
    dialog.modal-dialog[open]:where(:not([data-closing])) {
      transform: translateY(8px) scale(0.96);
    }
  }
}

.modal-dialog-body,
.howto-dialog-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  background-color: var(--bg-surface);
  background-image: linear-gradient(90deg, var(--accent) 0 38%, var(--amber) 38% 72%, var(--success) 72% 100%);
  background-size: 100% 3px;
  background-repeat: no-repeat;
  background-position: 0 0;
}

dialog.modal-dialog .modal-header-top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-surface);
  padding-block: 8px;
  margin-block: -8px 0;
  border-bottom: 1px solid color-mix(in oklab, var(--border-soft) 50%, transparent);
}

@media (max-height: 500px) {
  dialog.modal-dialog {
    width: min(calc(100vw - 24px), 520px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 16px);
  }
  .modal-dialog-body,
  .howto-dialog-body,
  .results-sheet-body {
    padding: 12px 16px;
    gap: 8px;
  }
  dialog.pro-dialog .modal-dialog-body {
    padding: 10px 14px;
    gap: 7px;
  }
  .modal-title,
  .howto-dialog-title {
    font-size: 1.0625rem;
  }
  .pro-feature-list,
  .howto-modal-list {
    gap: 6px;
    font-size: 0.8125rem;
    line-height: 1.32;
  }
  .howto-modal-list li {
    padding: 7px 10px 7px 40px;
  }
  .howto-modal-list li::before {
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    left: 10px;
    top: 8px;
  }
  .pro-buy-btn,
  .howto-dialog-actions .landing-tutorial-btn {
    min-block-size: 38px;
  }
  .stats-sync-banner {
    padding: 7px 10px;
    gap: 8px;
  }
  .stat-tile {
    padding: 6px 4px;
  }
  .stats-arcade-meter {
    padding: 6px 10px;
    gap: 4px;
  }
  .stats-pro-row {
    padding: 7px 10px;
  }
  .results-arcade-screen {
    padding: 7px 10px 8px;
    gap: 6px;
  }
  .results-lcd-banner {
    padding: 5px 8px;
    gap: 8px;
  }
  .results-emblem {
    width: 30px;
    height: 30px;
  }
  .results-lcd-headline {
    font-size: 0.875rem;
  }
  .results-lcd-subline {
    font-size: 0.75rem;
  }
  .results-lcd-cell {
    padding: 6px 10px;
  }
  .results-hero-time {
    font-size: 1.1875rem;
  }
}

/* Tactile Instrument Sign-In, Stats & Calendar Dialogs */
dialog.auth-dialog,
dialog.stats-dialog,
dialog.calendar-dialog {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.auth-merge-pill {
  padding: 7px 11px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  font-weight: 700;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

/* Force light color-scheme on the GIS iframe container with explicit surface background
   so the cross-origin light-scheme Google iframe remains transparent in dark mode. */
.auth-google-frame {
  color-scheme: light;
  background: var(--bg-surface);
  color: var(--ink-primary);
  width: 100%;
  min-block-size: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-google-mount {
  color-scheme: light;
  width: 100%;
  min-block-size: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-google-frame iframe {
  color-scheme: light;
  background: transparent !important;
}

.auth-google-status {
  width: 100%;
}

.auth-google-skeleton {
  min-block-size: 44px;
  width: 100%;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--ink-muted);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.auth-skeleton-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-top-color: var(--accent);
  animation: authSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes authSpin {
  to {
    transform: rotate(360deg);
  }
}

.auth-google-unavailable {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--ink-muted);
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: center;
  text-wrap: pretty;
}

.auth-dev-btn {
  width: 100%;
  min-block-size: 44px;
  font-size: 0.875rem;
}

.auth-error {
  margin: 0;
  font-size: 0.875rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border-soft);
}

.auth-divider span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-guest-btn {
  width: 100%;
  min-block-size: 44px;
  font-size: 0.875rem;
}

.auth-trust-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-trust-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-btn);
}

.auth-trust-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border-soft));
  color: var(--accent-soft-text);
}

.auth-trust-icon-shield {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.auth-trust-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.8125rem;
  line-height: 1.42;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.auth-trust-copy strong {
  color: var(--ink-primary);
  font-size: 0.84375rem;
  font-weight: 700;
}

.auth-legal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.auth-legal-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-block-size: 32px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.auth-legal-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (pointer: coarse) {
  .auth-legal-footer a {
    min-block-size: 44px;
  }
}

.stats-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  border-inline-start: 3px solid var(--success);
}

.stats-account-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.stats-account-identity {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.stats-account-name {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--ink-primary);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-account-provider {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-synced-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.stats-synced-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.stats-sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  border-inline-start: 3px solid var(--accent);
}

.stats-sync-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stats-sync-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border-soft));
  color: var(--accent-soft-text);
}

.stats-sync-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.stats-sync-title {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--ink-primary);
  line-height: 1.25;
}

.stats-sync-copy {
  margin: 0;
  font-size: 0.78125rem;
  line-height: 1.38;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.stats-signin-btn {
  min-block-size: 36px;
  padding: 6px 13px;
  border-radius: var(--radius-md);
  font-size: 0.84375rem;
  font-weight: 800;
  flex-shrink: 0;
}

@media (max-width: 360px) {
  .day-carousel-track {
    gap: 6px;
  }

  .day-card-btn {
    min-block-size: 66px;
    padding: 6px 4px;
    gap: 2px;
  }

  .day-card-top {
    font-size: 0.71875rem;
    letter-spacing: -0.02em;
    gap: 3px;
  }

  .day-card-active-dot {
    width: 5px;
    height: 5px;
  }

  .day-card-cal-svg {
    width: 11px;
    height: 11px;
  }

  .day-card-date {
    font-size: 0.75rem;
  }

  .day-card-num {
    font-size: 0.6875rem;
  }

  .stats-account-card {
    gap: 8px;
    padding: 8px 10px;
  }

  .stats-account-lead {
    gap: 8px;
  }

  .account-avatar-lg {
    width: 32px;
    height: 32px;
  }

  .stats-sync-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .stats-signin-btn {
    width: 100%;
  }
}

.stats-sync-notice {
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--ink-primary);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}

.stats-footer {
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  gap: 8px;
}

.stats-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stats-footer-btn {
  min-block-size: 34px;
  padding: 5px 10px;
  font-size: 0.8125rem;
}

.btn-danger-subtle {
  color: var(--error-text);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.howto-dialog-title {
  margin: 5px 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.howto-close-btn {
  padding: 4px 10px;
  min-block-size: 34px;
  font-size: 0.875rem;
  align-self: flex-start;
}

.howto-modal-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  counter-reset: howto-step;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.90625rem;
  line-height: 1.46;
  color: var(--ink-primary);
  text-wrap: pretty;
}

.howto-modal-list li {
  counter-increment: howto-step;
  position: relative;
  padding: 10px 12px 10px 46px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-btn);
}

.howto-modal-list li::before {
  content: counter(howto-step);
  position: absolute;
  left: 11px;
  top: 10px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 800;
  background: var(--ink-0-bg);
  border: 1px solid var(--ink-0-border);
  color: var(--ink-0);
}

.howto-modal-list li:nth-child(2)::before {
  background: var(--accent-tint);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-soft));
  color: var(--accent-soft-text);
}

.howto-modal-list li:nth-child(3)::before {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.howto-modal-list code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}

.howto-dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.howto-dialog-actions .landing-tutorial-btn {
  margin-top: 0;
  min-block-size: 42px;
}

/* Pro Mode Modal, Stats Row & Accessible Form Controls */
.stats-pro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
}

.stats-pro-row.is-active {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.stats-pro-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stats-pro-btn {
  flex-shrink: 0;
  min-block-size: 38px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 800;
}

.pro-badge-accent {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
}

.pro-status-banner {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.pro-status-banner.ok {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.pro-status-banner.err {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.pro-status-banner.info {
  background: var(--accent-tint);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-soft));
}

.pro-active-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.pro-active-badge {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--success-text);
}

dialog.pro-dialog .modal-dialog-body {
  padding: 16px 18px;
  gap: 10px;
}

.pro-upgrade-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.pro-reason-banner {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  font-size: 0.84375rem;
  font-weight: 600;
  line-height: 1.38;
  color: var(--ink-primary);
}

.pro-feature-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.875rem;
  line-height: 1.42;
  color: var(--ink-primary);
}

.pro-buy-btn {
  min-block-size: 44px;
  font-size: 0.96875rem;
  font-weight: 800;
}

.pro-payment-methods {
  margin: -3px 0 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.pro-restore-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-btn);
}

.pro-restore-heading {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.pro-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pro-form .btn-submit {
  min-block-size: 44px;
}

.form-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}

.form-label {
  font-size: 0.84375rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.form-hint {
  display: block;
  font-size: 0.78125rem;
  line-height: 1.35;
  color: var(--ink-muted);
}

.pro-form .input-mono {
  font-size: max(1rem, 1em);
  min-block-size: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
}

.pro-form .input-mono:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.field-error-msg {
  display: none;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.38;
  color: var(--error-text);
  margin-top: 2px;
}

.pro-form input:is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--error-border);
  background: var(--error-bg);
}

.pro-form input:is(:user-invalid, .user-invalid-fallback) + .field-error-msg {
  display: block;
}

.pro-form input:is(:user-valid, .user-valid-fallback) {
  border-color: var(--success);
}

.pro-verify-email-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.pro-verify-email-row strong {
  color: var(--ink-primary);
  word-break: break-all;
}

.pro-form .pro-otp-input {
  letter-spacing: 0.16em;
  text-align: center;
  font-weight: 800;
  color-scheme: dark;
  background: var(--lcd-bg);
  border-color: var(--lcd-border);
  color: var(--lcd-green);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.pro-form .pro-otp-input::placeholder {
  color: var(--lcd-muted);
}

.pro-verify-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pro-text-link {
  border: 0;
  background: transparent;
  padding: 4px;
  min-block-size: 36px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent-soft-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

@media (pointer: coarse) {
  .landing-challenge-btn,
  .landing-howto-trigger,
  .brand-btn,
  #btnLandingCalendar,
  #btnLandingStats,
  #btnLandingPro,
  #btnLandingAccount,
  .stats-signin-btn,
  .cal-day {
    min-block-size: 44px;
  }
  #btnLandingAccount.is-synced {
    min-inline-size: 44px;
  }
  #btnLandingAccount.is-synced .account-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }
  #btnLandingTheme,
  #btnHeaderTheme {
    min-block-size: 40px;
    min-inline-size: 40px;
  }
  .howto-close-btn {
    min-block-size: 40px;
    min-inline-size: 40px;
  }
  .carousel-arrow-btn::after {
    content: "";
    position: absolute;
    inset: -4px;
  }
}

/* Same-Document View Transition between Landing Hero Logo and Game Header Mark */
body.view-landing #landingLogoWrap {
  view-transition-name: geo-brand-mark;
}

body.view-game #headerBrandMark {
  view-transition-name: geo-brand-mark;
}

::view-transition-old(geo-brand-mark),
::view-transition-new(geo-brand-mark) {
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  dialog.modal-dialog,
  dialog.modal-dialog::backdrop,
  dialog.results-sheet-dialog,
  dialog.results-sheet-dialog::backdrop {
    transition-duration: 0.08s;
  }
  .btn:active,
  .pad-key:active,
  .sel-btn:active,
  .day-card-btn:active,
  .cal-day:active,
  .results-daily-btn:active,
  .landing-challenge-btn:active,
  .landing-howto-trigger:active,
  .account-pill:active,
  .pro-pill:active,
  .theme-toggle-btn:active {
    transform: none;
  }
  .results-share-drawer {
    transition: none !important;
  }
  .auth-skeleton-spinner {
    animation: none !important;
  }
}

@keyframes pulseRing {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.25); opacity: 0.4; }
}

.pulse-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: pulseRing 1.4s ease-in-out infinite;
}

.hint-ts-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.hint-ts-chip {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber-text);
}

/* Centered Top-Layer Tactile Instrument Results Dialog */
dialog.results-sheet-dialog {
  width: min(calc(100vw - 32px), 440px);
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  inset: 0;
  margin: auto;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-surface);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.results-sheet-dialog:modal {
  overscroll-behavior: contain;
}

dialog.results-sheet-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(10, 12, 16, 0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.results-sheet-dialog[open]:where(:not([data-closing])) {
  opacity: 1;
}

@starting-style {
  dialog.results-sheet-dialog[open]:where(:not([data-closing])) {
    opacity: 0;
  }
}

dialog.results-sheet-dialog[open]:where(:not([data-closing]))::backdrop {
  background-color: var(--modal-backdrop);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

@starting-style {
  dialog.results-sheet-dialog[open]:where(:not([data-closing]))::backdrop {
    background-color: rgba(10, 12, 16, 0);
    -webkit-backdrop-filter: blur(0px);
    backdrop-filter: blur(0px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  dialog.results-sheet-dialog {
    transform: translateY(8px) scale(0.96);
  }

  dialog.results-sheet-dialog[open]:where(:not([data-closing])) {
    transform: translateY(0) scale(1);
  }

  @starting-style {
    dialog.results-sheet-dialog[open]:where(:not([data-closing])) {
      transform: translateY(8px) scale(0.96);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.results-sheet-dialog,
  dialog.results-sheet-dialog::backdrop {
    transition-duration: 0.08s;
  }
}

.results-sheet-body {
  position: relative;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  background-color: var(--bg-surface);
  background-image: linear-gradient(90deg, var(--accent) 0 38%, var(--amber) 38% 72%, var(--success) 72% 100%);
  background-size: 100% 3px;
  background-repeat: no-repeat;
  background-position: 0 0;
}

.results-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}

.arcade-shard {
  position: absolute;
  left: 50%;
  top: 106px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  margin-top: -4.5px;
  opacity: 0;
  pointer-events: none;
  background: var(--accent);
  border-radius: 2px;
}

.arcade-shard-0,
.arcade-shard-4,
.arcade-shard-8,
.arcade-shard-12 {
  background: var(--accent);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border-radius: 0;
}

.arcade-shard-1,
.arcade-shard-5,
.arcade-shard-9,
.arcade-shard-13 {
  background: var(--amber);
  border-radius: 2px;
}

.arcade-shard-2,
.arcade-shard-6,
.arcade-shard-10,
.arcade-shard-14 {
  background: var(--success);
  border-radius: 0 9px 0 0;
}

.arcade-shard-3,
.arcade-shard-7,
.arcade-shard-11,
.arcade-shard-15 {
  background: var(--ink-0);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  border-radius: 0;
}

.arcade-shard-0 { --tx: -124px; --ty: -82px; --rot: -135deg; }
.arcade-shard-1 { --tx: -92px; --ty: -102px; --rot: 110deg; }
.arcade-shard-2 { --tx: -50px; --ty: -110px; --rot: -80deg; }
.arcade-shard-3 { --tx: -14px; --ty: -118px; --rot: 145deg; }
.arcade-shard-4 { --tx: 24px; --ty: -115px; --rot: -120deg; }
.arcade-shard-5 { --tx: 64px; --ty: -104px; --rot: 95deg; }
.arcade-shard-6 { --tx: 104px; --ty: -86px; --rot: -155deg; }
.arcade-shard-7 { --tx: 132px; --ty: -46px; --rot: 130deg; }
.arcade-shard-8 { --tx: 122px; --ty: 18px; --rot: -95deg; }
.arcade-shard-9 { --tx: 84px; --ty: 54px; --rot: 140deg; }
.arcade-shard-10 { --tx: -130px; --ty: -32px; --rot: 115deg; }
.arcade-shard-11 { --tx: -116px; --ty: 28px; --rot: -145deg; }
.arcade-shard-12 { --tx: -74px; --ty: 56px; --rot: 85deg; }
.arcade-shard-13 { --tx: -32px; --ty: 68px; --rot: -110deg; }
.arcade-shard-14 { --tx: 38px; --ty: 66px; --rot: 125deg; }
.arcade-shard-15 { --tx: 110px; --ty: 48px; --rot: -130deg; }

@media (prefers-reduced-motion: no-preference) {
  @keyframes arcadeShardBurst {
    0% {
      opacity: 0;
      transform: translate(0, 0) scale(0.4) rotate(0deg);
    }
    18% {
      opacity: 1;
    }
    75% {
      opacity: 0.95;
    }
    100% {
      opacity: 0;
      transform: translate(var(--tx), var(--ty)) scale(1.05) rotate(var(--rot));
    }
  }

  .arcade-shard {
    animation: arcadeShardBurst 0.78s cubic-bezier(0.16, 0.88, 0.32, 1) forwards;
  }

  @keyframes arcadeLedChase {
    0%, 100% {
      opacity: 0.35;
      transform: scale(0.88);
    }
    50% {
      opacity: 1;
      transform: scale(1.18);
    }
  }

  .results-arcade-screen.is-celebrating:is([data-outcome="perfect"], [data-outcome="solved"]) .results-led {
    animation: arcadeLedChase 0.38s ease-in-out 2;
  }
  .results-arcade-screen.is-celebrating:is([data-outcome="perfect"], [data-outcome="solved"]) .results-led-2 {
    animation-delay: 0.06s;
  }
  .results-arcade-screen.is-celebrating:is([data-outcome="perfect"], [data-outcome="solved"]) .results-led-3 {
    animation-delay: 0.12s;
  }
  .results-arcade-screen.is-celebrating:is([data-outcome="perfect"], [data-outcome="solved"]) .results-led-4 {
    animation-delay: 0.18s;
  }
  .results-arcade-screen.is-celebrating:is([data-outcome="perfect"], [data-outcome="solved"]) .results-led-5 {
    animation-delay: 0.24s;
  }
}

.results-arcade-screen {
  background-color: var(--lcd-bg);
  background-image: radial-gradient(rgba(239, 242, 232, 0.05) 1px, transparent 1px);
  background-size: 6px 6px;
  border: 1.5px solid var(--lcd-border);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 1px 0 var(--key-hi);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.results-led-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.results-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lcd-muted);
  opacity: 0.55;
}

.results-arcade-screen[data-outcome="perfect"] .results-led {
  background: var(--lcd-amber);
  opacity: 1;
  box-shadow: 0 0 7px color-mix(in srgb, var(--lcd-amber) 72%, transparent);
}

.results-arcade-screen[data-outcome="perfect"] .results-led:nth-child(even) {
  background: var(--accent);
  box-shadow: 0 0 7px color-mix(in srgb, var(--accent) 72%, transparent);
}

.results-arcade-screen[data-outcome="solved"] .results-led {
  background: var(--lcd-green);
  opacity: 1;
  box-shadow: 0 0 7px color-mix(in srgb, var(--lcd-green) 68%, transparent);
}

.results-arcade-screen[data-outcome="solved"] .results-led:nth-child(even) {
  background: var(--accent);
  box-shadow: 0 0 7px color-mix(in srgb, var(--accent) 68%, transparent);
}

.results-arcade-screen[data-outcome="revealed"] .results-led-3 {
  background: var(--lcd-amber);
  opacity: 0.9;
  box-shadow: 0 0 6px color-mix(in srgb, var(--lcd-amber) 55%, transparent);
}

.results-lcd-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.results-emblem {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--lcd-ink);
}

.results-arcade-screen[data-outcome="perfect"] .results-emblem {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--lcd-amber);
}

.results-arcade-screen[data-outcome="solved"] .results-emblem {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--lcd-green);
}

.results-emblem-svg {
  display: none;
}

.results-arcade-screen[data-outcome="perfect"] .results-emblem-perfect {
  display: block;
}

.results-arcade-screen[data-outcome="solved"] .results-emblem-solved {
  display: block;
}

.results-arcade-screen[data-outcome="revealed"] .results-emblem-revealed {
  display: block;
}

.results-lcd-banner-copy {
  min-inline-size: 0;
  flex: 1 1 auto;
}

.results-lcd-headline {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--lcd-ink);
}

.results-arcade-screen[data-outcome="perfect"] .results-lcd-headline {
  color: var(--lcd-amber);
}

.results-arcade-screen[data-outcome="solved"] .results-lcd-headline {
  color: var(--lcd-green);
}

.results-lcd-subline {
  font-size: 0.78125rem;
  line-height: 1.35;
  color: var(--lcd-muted);
  margin-top: 1px;
  text-wrap: pretty;
}

.results-arcade-screen .results-hero-metric {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.results-arcade-screen .results-lcd-cell {
  border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
}

.results-eyebrow-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.results-status-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-muted);
  white-space: nowrap;
}

.results-status-pill[data-tone="amber"] {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.results-status-pill[data-tone="accent"] {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-soft-text);
}

.results-hero-metric {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-radius: var(--radius-md);
  background: var(--lcd-bg);
  border: 1px solid var(--lcd-border);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  overflow: clip;
}

.results-lcd-cell {
  padding: 10px 12px;
  text-align: center;
  min-width: 0;
  border-inline-end: 1px solid color-mix(in oklab, var(--lcd-muted) 22%, var(--lcd-bg));
}

.results-lcd-cell:last-child {
  border-inline-end: none;
}

.results-hero-time {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--lcd-ink);
}

.results-hero-time.is-perfect {
  color: var(--lcd-amber);
}

.results-hero-area {
  font-family: var(--font-mono);
  font-size: 0.96875rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--lcd-green);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--ink-muted);
}

.results-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.results-meta-hints {
  font-weight: 600;
  color: var(--ink-primary);
}

.results-meta-icon {
  flex-shrink: 0;
}

.results-meta-icon-amber {
  color: var(--amber);
}

.results-daily-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.results-daily-btn {
  min-block-size: 56px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  box-shadow: var(--shadow-btn);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font: inherit;
  text-align: center;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 140ms ease, background-color 140ms ease;
}

.results-daily-btn:hover:not(:disabled):not([aria-disabled="true"]):not(.is-locked) {
  border-color: var(--border-strong);
}

.results-daily-btn:active:not(:disabled):not([aria-disabled="true"]):not(.is-locked) {
  transform: translateY(2px);
  box-shadow: var(--shadow-btn-active);
}

.results-daily-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.results-daily-btn.is-next {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.results-daily-btn.is-locked,
.results-daily-btn[aria-disabled="true"],
.results-daily-btn:disabled {
  opacity: 0.54;
  cursor: not-allowed;
}

.results-daily-btn.is-pro-locked {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  opacity: 1;
  cursor: pointer;
}

.results-daily-btn.is-pro-locked:hover {
  border-color: var(--amber);
  background: var(--amber-bg-hover);
}

.results-daily-btn.is-pro-locked .results-daily-meta {
  color: var(--amber-text);
  font-weight: 700;
}

.results-daily-head {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
}

.results-daily-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 100%;
}

.results-daily-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.results-actions-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.results-actions-row.is-share-only {
  grid-template-columns: 1fr;
}

.results-share-btn,
.results-next-btn {
  min-block-size: 42px;
  padding: 8px 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.results-next-btn {
  min-width: 0;
}

#btnNextPuzzleLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-btn-icon {
  flex-shrink: 0;
}

.results-share-btn.is-copied {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.results-sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.results-sync-inline {
  display: inline-flex;
  align-items: center;
}

.results-sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-soft-text);
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border-soft));
}

.results-sync-btn:hover {
  border-color: var(--accent);
}

.results-share-drawer {
  block-size: 0;
  opacity: 0;
  overflow: hidden;
  transition: block-size 0.24s ease-out, opacity 0.18s ease-out;
}

.results-share-drawer.is-open {
  block-size: auto;
  opacity: 1;
}

.results-share-drawer-inner {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.results-share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.results-share-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.results-scope-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--bg-page);
  gap: 2px;
}

.results-scope-btn {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.results-scope-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.share-preview-box {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--lcd-border);
  background: var(--lcd-bg);
  color: var(--lcd-ink);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: all;
  -webkit-user-select: all;
}

/* Brief Help Button, Toolbar Tour Groups & Interactive Onboarding Tour Popover */
.brief-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brief-help-btn {
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-weight: 800;
}

.tour-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.landing-tutorial-btn {
  margin-top: 10px;
  width: 100%;
  min-block-size: 40px;
}

.tutorial-spotlight {
  scroll-margin-block: 110px;
}

@media (min-width: 860px) {
  @supports (position-area: block-end) {
    .tutorial-spotlight {
      anchor-name: --tutorial-target;
    }
  }
}

.tutorial-spotlight-frame {
  position: fixed;
  z-index: 65;
  pointer-events: none;
  border-radius: 12px;
  border: 3px solid var(--tour-ring);
  background: transparent;
  box-shadow:
    0 0 0 9999px var(--tour-scrim),
    0 0 0 1px rgba(255, 255, 255, 0.35),
    0 0 22px 2px var(--tour-ring-glow);
  opacity: 0;
}

.tutorial-spotlight-frame.is-active {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .tutorial-spotlight-frame {
    transition:
      top 0.24s cubic-bezier(0.22, 1, 0.36, 1),
      left 0.24s cubic-bezier(0.22, 1, 0.36, 1),
      width 0.24s cubic-bezier(0.22, 1, 0.36, 1),
      height 0.24s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.2s ease-out;
  }
}

#tutorialPopover {
  position: fixed;
  z-index: 75;
  inset: auto auto calc(12px + env(safe-area-inset-bottom, 0px)) 50%;
  translate: -50% 0;
  margin: 0;
  padding: 14px 16px 13px;
  width: min(calc(100vw - 24px), 356px);
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: 1.5px solid var(--tour-ring);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
  #tutorialPopover {
    transform: translateY(8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  #tutorialPopover {
    transition-duration: 0.08s;
  }
}

#tutorialPopover::backdrop {
  background: transparent;
  pointer-events: none;
}

#tutorialPopover:not(:popover-open):not(.is-open) {
  display: none;
}

#tutorialPopover:is(:popover-open, .is-open):where(:not([data-closing])) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 1;
}

@starting-style {
  #tutorialPopover:is(:popover-open, .is-open):where(:not([data-closing])) {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  #tutorialPopover:is(:popover-open, .is-open):where(:not([data-closing])) {
    transform: translateY(0) scale(1);
  }

  @starting-style {
    #tutorialPopover:is(:popover-open, .is-open):where(:not([data-closing])) {
      transform: translateY(8px) scale(0.98);
    }
  }
}

#tutorialPopover[data-dock="top"] {
  inset: calc(12px + env(safe-area-inset-top, 0px)) auto auto 50%;
  translate: -50% 0;
}

#tutorialPopover[data-dock="left"] {
  inset: 50% auto auto 10px;
  translate: 0 -50%;
}

#tutorialPopover[data-dock="right"] {
  inset: 50% 10px auto auto;
  translate: 0 -50%;
}

@media (max-height: 500px) {
  #tutorialPopover {
    max-height: calc(100dvh - 16px);
    padding: 10px 12px;
    gap: 4px;
  }
  #tutorialPopover .tutorial-title {
    font-size: 1rem;
  }
  #tutorialPopover .tutorial-body {
    font-size: 0.8125rem;
    line-height: 1.35;
  }
  #tutorialPopover .tutorial-nav-btn {
    min-block-size: 34px;
  }
}

@media (max-width: 859px) and (max-height: 500px) {
  #tutorialPopover {
    width: min(296px, 46vw);
  }
}

@media (min-width: 860px) {
  @supports (position-area: block-end) {
    #tutorialPopover[data-anchored="true"] {
      inset: auto;
      translate: none;
      margin: 10px;
      width: min(356px, calc(100% - 20px));
      max-width: calc(100% - 20px);
      max-height: calc(100dvh - 24px);
      position-anchor: --tutorial-target;
      position-area: block-end span-all;
      justify-self: center;
      justify-self: anchor-center;
      position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    }
    #tutorialPopover[data-anchored="true"][data-anchor-area="top"] {
      position-area: block-start span-all;
      justify-self: center;
      justify-self: anchor-center;
      position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    }
    #tutorialPopover[data-anchored="true"][data-anchor-area="right"] {
      position-area: inline-end span-all;
      align-self: safe center;
      justify-self: start;
      position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
    }
    #tutorialPopover[data-anchored="true"][data-anchor-area="left"] {
      position-area: inline-start span-all;
      align-self: safe center;
      justify-self: end;
      position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
    }
  }
}

.tutorial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tutorial-step-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tutorial-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tutorial-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

.tutorial-dot.active {
  width: 14px;
  border-radius: 3px;
  background: var(--accent);
}

.tutorial-skip-btn {
  min-block-size: 32px;
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.tutorial-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.tutorial-body {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.48;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.tutorial-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.tutorial-nav-btn {
  flex: 1;
  min-block-size: 40px;
}

@media (pointer: coarse) {
  .brief-help-btn {
    min-block-size: 36px;
    min-inline-size: 36px;
  }
  .tutorial-skip-btn,
  .tutorial-nav-btn,
  .landing-tutorial-btn {
    min-block-size: 44px;
  }
  .formula-exit-btn::after {
    content: "";
    position: absolute;
    inset: -6px;
  }
}

/* Formula Focus Mode: hide drafting chrome so full diagram + given values stay clear while typing */
.brief-values-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brief-values-row .chip-row {
  flex: 1 1 auto;
  min-width: 0;
}

.formula-exit-btn {
  display: none;
  flex-shrink: 0;
  min-block-size: 32px;
  padding: 4px 11px;
  font-size: 0.8125rem;
  border-radius: var(--radius-md);
  position: relative;
}

body.view-game.formula-focus .toolbar,
body.view-game.formula-focus #selectionBar,
body.view-game.formula-focus .stage-hud,
body.view-game.formula-focus .legend-bar,
body.view-game.formula-focus .answer-card .action-grid,
body.view-game.formula-focus .brief-card .puzzle-prompt {
  display: none !important;
}

body.view-game.formula-focus .formula-exit-btn {
  display: inline-flex;
}

@media (max-width: 859px) {
  body.view-game.formula-focus {
    overflow: hidden;
  }

  body.view-game.formula-focus #gameHeader {
    display: none !important;
  }

  body.view-game.formula-focus #appMain {
    position: fixed;
    top: var(--vv-top, 0px);
    left: 0;
    right: 0;
    height: var(--vv-height, 100dvh);
    overflow: hidden;
    background: var(--bg-surface);
  }

  body.view-game.formula-focus #gameWorkspace {
    height: 100%;
    padding: calc(4px + env(safe-area-inset-top, 0px)) 0 calc(4px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) 94px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brief brief"
      "stage pad"
      "answer answer";
    gap: 4px;
    overflow: hidden;
  }

  body.view-game.formula-focus.proof-open:not(.solve-mode) #gameWorkspace {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brief brief"
      "stage pad"
      "hint hint"
      "answer answer";
  }

  body.view-game.formula-focus.proof-open:not(.solve-mode) #formulaHintDock {
    grid-area: hint;
    min-inline-size: 0;
    min-block-size: 0;
    max-block-size: clamp(72px, calc(var(--vv-height, 100dvh) * 0.26), 164px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-subtle);
  }

  body.view-game.formula-focus #formulaHintDock #proofTimeline {
    max-height: none;
    overflow: visible;
    padding: 5px 10px 6px;
    gap: 4px;
  }

  body.view-game.formula-focus #formulaHintDock #hintTimestampStrip,
  body.view-game.formula-focus #formulaHintDock .timeline-controls {
    display: none !important;
  }

  body.view-game.formula-focus #formulaHintDock .proof-header-actions {
    gap: 8px;
  }

  body.view-game.formula-focus #formulaHintDock .proof-action-btn {
    min-block-size: 28px;
    padding: 2px 8px;
    font-size: 0.75rem;
    position: relative;
  }

  body.view-game.formula-focus #formulaHintDock .step-narration {
    gap: 2px;
  }

  body.view-game.formula-focus #formulaHintDock .step-narration-title {
    font-size: 0.8125rem;
    line-height: 1.3;
  }

  body.view-game.formula-focus #formulaHintDock .step-narration-detail {
    font-size: 0.78125rem;
    line-height: 1.35;
  }

  body.view-game.formula-focus #formulaHintDock .proof-math-bar {
    background: var(--bg-surface) !important;
    color: var(--ink-primary);
    border-top: 1px solid var(--border-soft) !important;
    border-right: 1px solid var(--border-soft) !important;
    border-bottom: 1px solid var(--border-soft) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: none;
    padding: 3px 8px !important;
    font-size: 0.8125rem;
    line-height: 1.35;
  }

  body.view-game.formula-focus #formulaHintDock .proof-math-bar .ink-0 {
    color: var(--ink-0);
    background: var(--ink-0-bg);
    border-color: var(--ink-0-border);
  }

  body.view-game.formula-focus #formulaHintDock .proof-math-bar .ink-1 {
    color: var(--ink-1);
    background: var(--ink-1-bg);
    border-color: var(--ink-1-border);
  }

  body.view-game.formula-focus #formulaHintDock .proof-math-bar .ink-2 {
    color: var(--ink-2);
    background: var(--ink-2-bg);
    border-color: var(--ink-2-border);
  }

  body.view-game.formula-focus #formulaHintDock .proof-math-bar .ink-3 {
    color: var(--ink-3);
    background: var(--ink-3-bg);
    border-color: var(--ink-3-border);
  }

  body.view-game.formula-focus .brief-card.panel-body {
    grid-area: brief;
    min-width: 0;
    padding: 4px 10px 2px;
    gap: 0;
  }

  body.view-game.formula-focus .brief-card .panel-header {
    display: none;
  }

  body.view-game.formula-focus .brief-values-row .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.view-game.formula-focus .brief-values-row .chip-row::-webkit-scrollbar {
    display: none;
  }

  body.view-game.formula-focus .brief-values-row .badge-mono {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 2px 7px;
  }

  body.view-game.formula-focus .canvas-card {
    grid-area: stage;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  body.view-game.formula-focus #stageContainer {
    flex: 1 1 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  body.view-game.formula-focus #vectorStage {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }

  body.view-game.formula-focus #formulaPadDock {
    grid-area: pad;
    display: flex;
    align-items: stretch;
    min-width: 0;
    min-height: 0;
    padding: 2px 6px 2px 0;
    overflow-y: auto;
  }

  body.view-game.formula-focus #formulaPadDock .math-pad {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(28px, 1fr));
    gap: 4px;
  }

  body.view-game.formula-focus #formulaPadDock .pad-key {
    min-height: 0;
    height: 100%;
    padding: 0;
    font-size: 0.9375rem;
  }

  body.view-game.formula-focus #answerCard.panel-body {
    grid-area: answer;
    min-width: 0;
    padding: 4px 10px 6px;
    gap: 4px;
    border-top: 1px solid var(--border-soft) !important;
  }

  body.view-game.formula-focus #answerCard .input-mono {
    padding: 6px 10px;
    min-block-size: 38px;
    font-size: 1rem;
  }

  body.view-game.formula-focus #answerCard .math-pad {
    gap: 4px;
  }

  body.view-game.formula-focus #answerCard .pad-key {
    min-block-size: 34px;
    padding: 4px 0;
  }

  body.view-game.formula-focus #answerCard .answer-check-btn {
    min-block-size: 38px;
    padding: 0 12px;
    font-size: 0.875rem;
  }

  body.view-game.formula-focus #answerCard .feedback-box {
    padding: 4px 8px;
    font-size: 0.8125rem;
    line-height: 1.3;
    max-block-size: 88px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 359px) {
  body.view-game.formula-focus #gameWorkspace {
    grid-template-columns: minmax(0, 1fr) 80px;
  }

  body.view-game.formula-focus #formulaPadDock .pad-key {
    font-size: 0.875rem;
  }
}

@media (min-width: 860px) {
  .formula-pad-dock,
  .formula-hint-dock {
    display: none !important;
  }

  body.view-game.formula-focus #vectorStage {
    max-height: min(100%, calc(100dvh - 120px));
  }
}

/* Collapse puzzle brief while Hint/Proof timeline is open (keep sticky topbar visible) */
body.view-game.proof-open:not(.formula-focus):not(.tutorial-open) .brief-card {
  display: none !important;
}

/* Solution Mode: show topbar, solution diagram, step controls, exit button, and solution text */
body.view-game.solve-mode .brief-card,
body.view-game.solve-mode .toolbar,
body.view-game.solve-mode #selectionBar,
body.view-game.solve-mode .stage-hud,
body.view-game.solve-mode .legend-bar,
body.view-game.solve-mode #answerCard,
body.view-game.solve-mode #formulaPadDock,
body.view-game.solve-mode #proofToolBadge,
body.view-game.solve-mode #btnNextHintInline,
body.view-game.solve-mode #hintTimestampStrip {
  display: none !important;
}

body.view-game.solve-mode #vectorStage {
  cursor: default;
}

body.view-game.solve-mode .panel-header.proof-header {
  align-items: center;
  gap: 6px 8px;
}

body.view-game.solve-mode .proof-header-left {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px 8px;
}

body.view-game.solve-mode .solve-countdown-note {
  margin-left: 0;
}

.privacy-note a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.landing-legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 4px 2px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.landing-legal-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-block-size: 36px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.landing-legal-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-height: 780px) {
  .landing-legal-footer {
    padding: 2px 4px 0;
  }
  .landing-legal-footer a {
    min-block-size: 28px;
  }
}

@media (pointer: coarse) {
  .landing-legal-footer a {
    min-block-size: 44px;
  }
}

@media (forced-colors: active) {
  .landing-view,
  .landing-card,
  .modal-dialog-body,
  .howto-dialog-body,
  .results-sheet-body {
    background-image: none;
  }
  .arcade-led-cluster,
  .results-led-strip,
  .results-confetti {
    display: none;
  }
}

