:root {
  --bg-base: #f6e7c0;
  --bg-grid-a: #ead5a3;
  --bg-grid-b: #e2c88f;
  --surface: #fff4d7;
  --surface-soft: #f5e4bc;
  --surface-deep: #27304d;
  --ink: #1d2540;
  --ink-muted: #4b5778;
  --ink-inverse: #f8f6eb;
  --line: #1d2540;
  --line-soft: #756891;
  --brand: #2e5b7a;
  --brand-strong: #1f415e;
  --accent: #c45332;
  --accent-strong: #9a3d24;
  --ok: #1f6e4a;
  --warn: #8a5b21;
  --bad: #8d2d2d;
  --shadow-hard: 4px 4px 0 #1d2540;
  --shadow-hard-lg: 6px 6px 0 #1d2540;
  --radius-lg: 0;
  --radius-md: 0;
  --radius-sm: 0;
  --font-display: "Press Start 2P", "Courier New", monospace;
  --font-body: "VT323", "Courier New", monospace;
  --font-script: "Noto Sans Mongolian", "Mongolian Baiti", serif;
}

body.theme-arcade-dark {
  --bg-base: #0b1020;
  --bg-grid-a: #121938;
  --bg-grid-b: #1a2046;
  --surface: #171e3d;
  --surface-soft: #1f2750;
  --surface-deep: #060a1a;
  --ink: #eaf2ff;
  --ink-muted: #a8bde8;
  --ink-inverse: #eef5ff;
  --line: #6ed4ff;
  --line-soft: #3a6ba2;
  --brand: #2e8bc5;
  --brand-strong: #1d6fa2;
  --accent: #ff4f87;
  --accent-strong: #d43b6e;
  --ok: #5ad89a;
  --warn: #ffbd5c;
  --bad: #ff6f6f;
  --shadow-hard: 4px 4px 0 #060b18;
  --shadow-hard-lg: 6px 6px 0 #060b18;
}

body.theme-gameboy-light {
  --bg-base: #c3d66f;
  --bg-grid-a: #b7ca62;
  --bg-grid-b: #a7ba4b;
  --surface: #d5e48a;
  --surface-soft: #c7d777;
  --surface-deep: #5f7332;
  --ink: #223116;
  --ink-muted: #3a4d27;
  --ink-inverse: #e8f5c8;
  --line: #273a1b;
  --line-soft: #3a5527;
  --brand: #46612d;
  --brand-strong: #384f25;
  --accent: #2f4b1e;
  --accent-strong: #203615;
  --ok: #2f5f1f;
  --warn: #5e651f;
  --bad: #65312b;
  --shadow-hard: 4px 4px 0 #42532c;
  --shadow-hard-lg: 6px 6px 0 #42532c;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  background:
    linear-gradient(90deg, rgba(29, 37, 64, 0.04) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(180deg, rgba(29, 37, 64, 0.04) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(circle at 12% 8%, rgba(196, 83, 50, 0.16), transparent 33%),
    radial-gradient(circle at 88% 12%, rgba(46, 91, 122, 0.14), transparent 30%),
    linear-gradient(180deg, var(--bg-base) 0%, var(--bg-grid-a) 56%, var(--bg-grid-b) 100%);
}

body.theme-arcade-dark {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(circle at 16% 8%, rgba(255, 79, 135, 0.16), transparent 34%),
    radial-gradient(circle at 90% 12%, rgba(91, 197, 255, 0.16), transparent 33%),
    linear-gradient(180deg, #070c19 0%, #0f1733 52%, #151f45 100%);
}

body.theme-gameboy-light {
  background:
    linear-gradient(90deg, rgba(20, 32, 12, 0.09) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(180deg, rgba(20, 32, 12, 0.09) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(180deg, var(--bg-base) 0%, var(--bg-grid-a) 56%, var(--bg-grid-b) 100%);
}

a {
  color: inherit;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 35;
  background: color-mix(in srgb, var(--bg-base) 84%, white 16%);
  border-bottom: 3px solid var(--line);
  box-shadow: 0 3px 0 rgba(29, 37, 64, 0.35);
}

.top-nav-inner {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 7px;
  background: #d4c0a7;
  box-shadow: 2px 2px 0 var(--line);
}

.brand-mark-icon {
  width: 30px;
  height: 30px;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 0.76rem;
  line-height: 1.3;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 rgba(29, 37, 64, 0.2);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-link {
  text-decoration: none;
  padding: 8px 11px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 120ms steps(2), box-shadow 120ms steps(2), background-color 120ms steps(2);
}

.nav-link:hover,
.nav-link:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.nav-link.active {
  background: var(--accent);
  color: var(--ink-inverse);
}

.app-shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 24px 16px 64px;
  position: relative;
}


.hero {
  border: 3px solid var(--line);
  padding: 24px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 2px, rgba(255, 255, 255, 0) 2px 10px),
    linear-gradient(140deg, var(--surface-deep) 0%, #2f3b5f 52%, #364976 100%);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-hard-lg);
  position: relative;
  overflow: hidden;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2px solid var(--ink-inverse);
}

.hero::before {
  top: 10px;
  right: 10px;
}

.hero::after {
  bottom: 10px;
  left: 10px;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  font-size: 0.52rem;
  text-transform: uppercase;
  opacity: 0.95;
}

.hero h1 {
  font-family: var(--font-display);
  margin: 12px 0 0;
  font-size: clamp(1.05rem, 2.35vw, 1.58rem);
  line-height: 1.5;
  max-width: 860px;
  text-wrap: balance;
}

.hero p {
  margin: 13px 0 0;
  line-height: 1.45;
  max-width: 840px;
  color: color-mix(in srgb, var(--ink-inverse) 92%, #9ec2ff 8%);
}

.hero-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 2px solid var(--line);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.52rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 120ms steps(2), box-shadow 120ms steps(2);
}

.btn:hover,
.btn:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.btn.primary {
  background: var(--accent);
  color: var(--ink-inverse);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.14);
  color: var(--ink-inverse);
  border-color: rgba(255, 255, 255, 0.55);
}

.grid {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  border: 3px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-hard);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(46, 91, 122, 0.035) 0 1px, transparent 1px 4px);
}

.panel h2,
.panel h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.55;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-wrap: balance;
}

.panel h2 {
  font-size: clamp(0.84rem, 1.5vw, 0.98rem);
}

.panel h3 {
  font-size: clamp(0.73rem, 1.3vw, 0.84rem);
}

.subtext {
  margin: 8px 0 0;
  color: var(--ink-muted);
  line-height: 1.42;
}

.stat-grid {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  border: 2px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(159, 206, 255, 0.16);
  padding: 10px;
}

.stat span {
  display: block;
  font-family: var(--font-display);
  font-size: 0.48rem;
  opacity: 0.9;
  line-height: 1.45;
  text-transform: uppercase;
}

.stat strong {
  margin-top: 7px;
  display: block;
  font-size: 1.42rem;
  line-height: 1;
}

.surface-muted {
  background: var(--surface-soft);
}

.kicker {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--line);
  background: color-mix(in srgb, var(--surface-soft) 80%, white 20%);
  padding: 5px 9px;
  font-family: var(--font-display);
  font-size: 0.46rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.feature-list,
.bullet-list,
.number-list {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.4;
}

.feature-list li,
.bullet-list li,
.number-list li {
  margin-bottom: 7px;
}

.compact-list {
  margin-top: 6px;
  margin-bottom: 0;
}

.compact-list li {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.metric-row {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  border-bottom: 2px dashed color-mix(in srgb, var(--line) 34%, white 66%);
  padding-bottom: 5px;
}

.metric-item span {
  color: var(--ink-muted);
}

.tabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  border: 2px solid var(--line);
  background: var(--surface);
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 100ms steps(2), box-shadow 100ms steps(2);
}

.tab-btn:hover,
.tab-btn:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.tab-btn.active {
  background: var(--brand);
  color: var(--ink-inverse);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

label {
  display: block;
  margin-bottom: 5px;
  font-family: var(--font-display);
  font-size: 0.5rem;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 2px solid var(--line);
  padding: 10px;
  background: #fff9eb;
  font: inherit;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #dbc79b;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.input-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.inline-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-row button,
.inline-row a {
  text-decoration: none;
}

.action-btn {
  border: 2px solid var(--line);
  padding: 10px 12px;
  font-family: var(--font-display);
  font-size: 0.48rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--brand);
  color: var(--ink-inverse);
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 100ms steps(2), box-shadow 100ms steps(2);
}

.action-btn:hover,
.action-btn:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.action-btn.alt {
  background: #f7ecd1;
  color: var(--ink);
}

.action-btn.warn {
  background: #f7be79;
  color: #542b00;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 1px 1px 0 var(--line);
}

.feedback {
  margin-top: 10px;
  min-height: 22px;
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.warn {
  color: var(--warn);
}

.feedback.bad {
  color: var(--bad);
}

.glyph-focus {
  min-height: 168px;
  border: 2px dashed color-mix(in srgb, var(--brand) 72%, white 28%);
  display: grid;
  place-items: center;
  font-family: var(--font-script);
  font-size: clamp(2.8rem, 8vw, 5rem);
  width: 100%;
  text-align: center;
  background:
    linear-gradient(90deg, rgba(29, 37, 64, 0.03) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, rgba(29, 37, 64, 0.03) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, #fffdf6, #fef5de);
}

.glyph-vertical {
  display: inline-block;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  line-height: 1;
  margin: 0 auto;
}

.script-line {
  display: inline-block;
  margin-top: 7px;
  padding: 8px 10px;
  border: 2px solid color-mix(in srgb, var(--line) 48%, white 52%);
  background: color-mix(in srgb, var(--surface) 86%, white 14%);
  font-family: var(--font-script);
  font-size: 1.55rem;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  line-height: 1;
  max-height: 110px;
}

.challenge-options {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mc-options {
  margin-top: 4px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mc-option {
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 42px;
  padding: 8px 10px;
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 100ms steps(2), box-shadow 100ms steps(2), background-color 100ms steps(2), color 100ms steps(2);
}

.mc-option:hover,
.mc-option:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.mc-option.correct {
  background: var(--ok);
  color: var(--ink-inverse);
}

.mc-option.wrong {
  background: var(--bad);
  color: var(--ink-inverse);
}

.mc-option:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.challenge-option {
  border: 2px solid var(--line);
  background: var(--surface);
  padding: 10px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 100ms steps(2), box-shadow 100ms steps(2);
}

.challenge-option:hover,
.challenge-option:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.challenge-option .glyph-focus {
  min-height: 90px;
  border: 2px solid color-mix(in srgb, var(--line) 30%, white 70%);
  background: #fff8e5;
  font-size: 2.5rem;
}

.table-wrap {
  overflow-x: auto;
  border: 2px solid color-mix(in srgb, var(--line) 36%, white 64%);
  box-shadow: inset 0 0 0 1px #d9c18b;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
  background: #fff8e6;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #ddcfae;
  padding: 8px 6px;
  vertical-align: top;
}

th {
  font-family: var(--font-display);
  font-size: 0.45rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #efe0bc;
  position: sticky;
  top: 0;
}

.sheet-name {
  display: block;
  font-family: var(--font-display);
  font-size: 0.47rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sheet-sub {
  display: block;
  color: var(--ink-muted);
  font-size: 0.96rem;
  margin-top: 2px;
}

.sheet-glyph-cell {
  text-align: center;
  min-width: 74px;
}

.sheet-glyph {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 84px;
  border: 2px solid #d6c29a;
  background: #fffbef;
  padding: 6px 4px;
  font-family: var(--font-script);
  font-size: 1.55rem;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  line-height: 1;
}

td.glyph,
.glyph-cell {
  font-family: var(--font-script);
  font-size: 1.45rem;
}

.status-chip {
  display: inline-block;
  border: 2px solid currentColor;
  font-family: var(--font-display);
  font-size: 0.45rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 4px 8px;
}

.status-chip.ok {
  background: #e2f7e8;
  color: #1f6e4a;
}

.status-chip.bad {
  background: #ffe4dd;
  color: #8d2d2d;
}

.lesson-stack {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.lesson-card {
  border: 2px solid color-mix(in srgb, var(--line) 48%, white 52%);
  background: color-mix(in srgb, var(--surface-soft) 78%, white 22%);
  padding: 10px;
}

.progress-track {
  margin-top: 6px;
  height: 10px;
  border: 2px solid var(--line);
  background: #f0dfb8;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--brand) 0 8px,
    #4f83ab 8px 12px
  );
}

.rule-chip-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.rule-chip {
  border: 2px solid color-mix(in srgb, var(--line) 48%, white 52%);
  background: #f7ebcf;
  padding: 6px 10px;
  font-family: var(--font-display);
  font-size: 0.45rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pad-area {
  border: 2px solid color-mix(in srgb, var(--line) 38%, white 62%);
  background: #fff8e8;
  padding: 10px;
}

canvas {
  width: 100%;
  border: 2px solid #d2bf99;
  background:
    linear-gradient(90deg, rgba(29, 37, 64, 0.03) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, rgba(29, 37, 64, 0.03) 1px, transparent 1px) 0 0 / 18px 18px,
    #fffbef;
  touch-action: none;
  display: block;
}

.mode-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-pill {
  border: 2px solid var(--line);
  padding: 8px 11px;
  background: #fbf0d3;
  font-family: var(--font-display);
  font-size: 0.48rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 100ms steps(2), box-shadow 100ms steps(2);
}

.mode-pill:hover,
.mode-pill:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.mode-pill.active {
  background: var(--accent);
  color: var(--ink-inverse);
}

.footer-note {
  margin-top: 14px;
  padding: 10px 12px;
  border: 2px solid color-mix(in srgb, var(--line) 38%, white 62%);
  background: color-mix(in srgb, var(--surface-soft) 82%, white 18%);
  font-family: var(--font-display);
  font-size: 0.45rem;
  line-height: 1.5;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hide {
  display: none !important;
}

.theme-switcher {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: stretch;
  margin-left: -4px;
}

.theme-trigger {
  border: 2px solid var(--line);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 6px, rgba(255, 255, 255, 0) 6px 12px),
    linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: 2px 2px 0 var(--line);
  color: var(--ink-inverse);
  min-height: 0;
  padding: 8px 11px;
  font-family: var(--font-display);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: transform 100ms steps(2), box-shadow 100ms steps(2), background-color 100ms steps(2);
}

.theme-trigger:hover,
.theme-trigger:focus-visible,
.theme-switcher.open .theme-trigger {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.theme-trigger-label {
  white-space: nowrap;
}

.theme-current {
  border: 1px solid rgba(255, 255, 255, 0.9);
  padding: 1px 4px;
  font-size: 0.42rem;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.14);
  color: var(--ink-inverse);
}

.theme-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 46;
  min-width: 230px;
  border: 2px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, white 10%);
  box-shadow: 3px 3px 0 var(--line);
  padding: 4px;
  display: none;
}

.theme-dropdown[hidden] {
  display: none !important;
}

.theme-switcher.open .theme-dropdown {
  display: grid;
  gap: 4px;
}

.theme-dropdown-header {
  margin: 0;
  padding: 5px 7px 6px;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.theme-switcher-grid {
  display: grid;
  gap: 4px;
  border: 2px solid var(--line);
  background: color-mix(in srgb, var(--surface-soft) 84%, white 16%);
  padding: 2px;
}

.theme-option {
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.36rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 7px 8px;
  min-height: 32px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 100ms steps(2), box-shadow 100ms steps(2), background-color 100ms steps(2), color 100ms steps(2);
}

.theme-option:hover,
.theme-option:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}

.theme-option.active {
  background: var(--accent);
  color: var(--ink-inverse);
}

.theme-code {
  display: inline-block;
  min-width: 24px;
  padding-right: 2px;
}

.theme-name {
  color: color-mix(in srgb, currentColor 86%, white 14%);
  white-space: nowrap;
}

.theme-swatch {
  width: 10px;
  height: 10px;
  border: 1px solid var(--line);
  box-shadow: 1px 1px 0 var(--line);
  flex: 0 0 auto;
}

.theme-option[data-theme="theme-default"] .theme-swatch {
  background: linear-gradient(135deg, #2e5b7a 0%, #c45332 100%);
}

.theme-option[data-theme="theme-arcade-dark"] .theme-swatch {
  background: linear-gradient(135deg, #2e8bc5 0%, #ff4f87 100%);
}

.theme-option[data-theme="theme-gameboy-light"] .theme-swatch {
  background: linear-gradient(135deg, #0f380f 0%, #9bbc0f 100%);
}

.hero,
.panel,
.nav-link,
.tab-btn,
.mode-pill,
.action-btn,
.btn {
  image-rendering: pixelated;
}

.hero,
.panel {
  animation: pixel-pop 260ms steps(5) both;
}

.grid > .panel:nth-child(2) {
  animation-delay: 80ms;
}

.grid > .panel:nth-child(3) {
  animation-delay: 130ms;
}

@keyframes pixel-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .grid.three {
    grid-template-columns: 1fr 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .brand-name {
    font-size: 0.62rem;
  }

  .nav-link {
    font-size: 0.5rem;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 1.25rem;
  }

  .app-shell {
    padding: 16px 12px 44px;
  }

  .top-nav-inner {
    padding: 8px 12px;
  }

  .hero {
    padding: 18px;
  }

  .grid.two,
  .grid.three,
  .input-row,
  .challenge-options,
  .mc-options {
    grid-template-columns: 1fr;
  }

  .nav-links {
    order: 2;
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .nav-link,
  .tab-btn,
  .mode-pill,
  .action-btn,
  .btn {
    min-height: 40px;
  }

  .hero h1 {
    font-size: 0.97rem;
    line-height: 1.6;
  }

  .stat strong {
    font-size: 1.2rem;
  }

  .theme-switcher {
    order: 3;
    margin-left: 0;
    margin-top: 4px;
    width: auto;
  }

  .theme-dropdown {
    right: 0;
    min-width: min(260px, calc(100vw - 22px));
  }

  .theme-trigger {
    min-height: 40px;
  }

  .theme-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

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