@font-face {
  font-family: "JetBrainsMonoNL Nerd Font Mono";
  src: url("../assets/fonts/JetBrainsMonoNLNerdFontMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrainsMonoNL Nerd Font Mono";
  src: url("../assets/fonts/JetBrainsMonoNLNerdFontMono-Bold.woff2") format("woff2");
  font-weight: 600 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #070d10;
  --deep: #04090b;
  --surface: #0f191e;
  --surface-2: #152228;
  --fg: #e8f0f2;
  --muted: #9aafb6;
  --faint: #6d838c;
  --chrome: #c5d5dc;
  --bright: #eaf3f6;
  --leaf: #6baa88;
  --leaf-dark: #3f6f58;
  --teal: #5aa8a0;
  --food: #d9955a;
  --line: rgba(232, 240, 242, 0.12);
  --line-strong: rgba(232, 240, 242, 0.22);
  --font: "JetBrainsMonoNL Nerd Font Mono", "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; background: var(--deep); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--fg);
  background:
    linear-gradient(rgba(90, 168, 160, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 168, 160, 0.035) 1px, transparent 1px),
    radial-gradient(ellipse at 50% -20%, #183038 0, #081014 42%, #050a0c 78%);
  background-size: 36px 36px, 36px 36px, auto;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid #9ee0d4; outline-offset: 3px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--bright);
  color: var(--deep);
}
.skip-link:focus { left: 1rem; top: 1rem; }

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

.arcade-max { width: min(100% - 2rem, 91rem); margin-inline: auto; }

.arcade-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 10, 12, 0.84);
  backdrop-filter: blur(18px);
}

.arcade-header-inner { display: flex; min-height: 4.25rem; align-items: center; justify-content: space-between; gap: 1rem; }
.arcade-brand { display: inline-flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.arcade-brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid rgba(107, 170, 136, 0.45);
  border-radius: 0.55rem;
  background: rgba(107, 170, 136, 0.1);
  color: var(--leaf);
  font-weight: 700;
}
.arcade-brand strong, .arcade-brand small { display: block; }
.arcade-brand strong { font-size: 0.84rem; }
.arcade-brand small { margin-top: 0.1rem; color: var(--faint); font-size: 0.56rem; letter-spacing: 0.08em; text-transform: uppercase; }
.arcade-header-actions { display: flex; align-items: center; gap: 0.65rem; }
.save-pill, .back-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.66rem;
  text-decoration: none;
}
.save-pill { gap: 0.5rem; padding: 0.4rem 0.75rem; }
.save-pill i { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0.75rem var(--leaf); }
.save-pill.unsaved i { background: var(--food); box-shadow: 0 0 0.75rem var(--food); }
.back-link { padding: 0.4rem 0.8rem; }
.back-link:hover { border-color: var(--line-strong); color: var(--fg); }

.arcade-main { padding-block: clamp(1.5rem, 4vw, 3.25rem); }
.arcade-intro { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.eyebrow, .panel-label, .control-heading span, .brain-heading span, .board-head span {
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.arcade-intro h1 { margin: 0.45rem 0 0; font-size: clamp(2.2rem, 6vw, 5.25rem); line-height: 0.95; letter-spacing: -0.075em; }
.arcade-intro p:not(.eyebrow) { max-width: 48rem; margin: 1rem 0 0; color: var(--muted); font-size: clamp(0.8rem, 1.7vw, 1rem); line-height: 1.65; }
.intro-proof { flex: 0 0 auto; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 0.8rem; background: rgba(15, 25, 30, 0.75); }
.intro-proof span, .intro-proof strong { display: block; }
.intro-proof span { color: var(--faint); font-size: 0.58rem; text-transform: uppercase; }
.intro-proof strong { margin-top: 0.35rem; color: var(--chrome); font-size: 0.68rem; font-weight: 500; }
.intro-proof i { display: inline-block; width: 0.38rem; height: 0.38rem; margin-right: 0.4rem; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0.65rem var(--leaf); }

.arcade-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.65fr) minmax(19rem, 0.75fr); }
.board-panel, .control-panel, .proof-strip { border: 1px solid var(--line); background: rgba(15, 25, 30, 0.8); backdrop-filter: blur(15px); }
.board-panel { min-width: 0; padding: clamp(0.8rem, 2vw, 1.35rem); border-radius: 1.25rem; }
.board-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 0.9rem; }
.board-head div > strong { display: block; margin-top: 0.35rem; font-size: clamp(1rem, 2vw, 1.35rem); }
.score-block { text-align: right; }
.score-block strong { color: var(--leaf); font-size: clamp(1.8rem, 4vw, 3.2rem) !important; line-height: 0.85; letter-spacing: -0.08em; }

.canvas-wrap { position: relative; aspect-ratio: 18 / 14; overflow: hidden; border: 1px solid var(--line); border-radius: 0.85rem; background: var(--deep); box-shadow: inset 0 0 3rem #000a; }
.arcade-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 1.25rem;
  background: rgba(4, 9, 11, 0.79);
  backdrop-filter: blur(9px);
  text-align: center;
}
.board-overlay[hidden] { display: none; }
.board-overlay > span { color: var(--leaf); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; }
.board-overlay > strong { margin-top: 0.45rem; font-size: clamp(1.8rem, 5vw, 4.2rem); letter-spacing: -0.06em; }
.board-overlay p { max-width: 28rem; margin: 0.6rem 0 1.1rem; color: var(--muted); font-size: 0.76rem; line-height: 1.55; }
.board-overlay button, .primary-action {
  border: 1px solid var(--leaf);
  border-radius: 999px;
  background: var(--leaf);
  color: var(--deep);
  font-weight: 700;
}
.board-overlay button { padding: 0.65rem 1rem; }

.board-progress { display: grid; align-items: center; gap: 0.7rem; grid-template-columns: auto auto 1fr auto; margin-top: 0.9rem; color: var(--faint); font-size: 0.64rem; }
.board-progress > strong { color: var(--chrome); font-weight: 500; }
.progress-track { height: 0.32rem; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.055); }
.progress-track i { display: block; width: 2%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--leaf-dark), var(--leaf), var(--teal)); box-shadow: 0 0 1rem rgba(107, 170, 136, 0.35); }

.control-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.control-panel { border-radius: 1rem; padding: 0.95rem; }
.control-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.control-heading strong, .brain-heading strong { display: block; margin-top: 0.28rem; font-size: 0.84rem; }
kbd { padding: 0.18rem 0.38rem; border: 1px solid var(--line); border-radius: 0.35rem; background: rgba(255, 255, 255, 0.04); color: var(--faint); font-family: var(--font); font-size: 0.55rem; font-weight: 400; }
.segmented, .speed-row { display: grid; gap: 0.28rem; margin-top: 0.75rem; padding: 0.25rem; border: 1px solid rgba(255, 255, 255, 0.04); border-radius: 0.7rem; background: rgba(0, 0, 0, 0.23); }
.segmented { grid-template-columns: 1fr 1fr; }
.speed-row { grid-template-columns: repeat(3, 1fr); }
.segmented button, .speed-row button { min-height: 2.75rem; border: 1px solid transparent; border-radius: 0.55rem; background: transparent; text-align: left; }
.speed-row button { text-align: center; }
.segmented button strong, .segmented button span, .speed-row button strong, .speed-row button span { display: block; }
.segmented button strong, .speed-row button strong { font-size: 0.68rem; }
.segmented button span, .speed-row button span { margin-top: 0.12rem; color: var(--faint); font-size: 0.55rem; }
.segmented button.active, .speed-row button.active { border-color: rgba(107, 170, 136, 0.24); background: rgba(107, 170, 136, 0.1); }
.segmented button.active strong, .speed-row button.active strong { color: #abd6bd; }

.brain-panel { background: radial-gradient(circle at 12% 10%, rgba(90, 168, 160, 0.09), transparent 36%), rgba(15, 25, 30, 0.88); }
.brain-heading { display: flex; align-items: center; gap: 0.75rem; }
.brain-heading p { margin: 0.25rem 0 0; color: var(--faint); font-size: 0.6rem; line-height: 1.4; }
.orbit { position: relative; display: grid; width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem; place-items: center; border: 1px solid rgba(90, 168, 160, 0.3); border-radius: 50%; }
.orbit::before { position: absolute; inset: 0.36rem; border: 1px solid rgba(107, 170, 136, 0.28); border-radius: 50%; border-left-color: transparent; content: ""; animation: orbit 2.2s linear infinite; }
.orbit i { width: 0.3rem; height: 0.3rem; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0.7rem var(--teal); }
.telemetry { display: grid; grid-template-columns: 1fr 1fr; margin: 0.85rem 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.telemetry div { min-width: 0; padding: 0.65rem 0; }
.telemetry div:nth-child(odd) { border-right: 1px solid var(--line); }
.telemetry div:nth-child(even) { padding-left: 0.65rem; }
.telemetry div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
.telemetry dt { color: var(--faint); font-size: 0.55rem; text-transform: uppercase; }
.telemetry dd { margin: 0.28rem 0 0; overflow: hidden; color: var(--chrome); font-size: 0.61rem; text-overflow: ellipsis; white-space: nowrap; }
.telemetry dd.safe { color: #abd6bd; }

.action-panel, .manual-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.action-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.action-row button { min-height: 2.5rem; padding: 0.5rem 0.72rem; }
.secondary-action { border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.035); }
.records { display: flex; gap: 0.8rem; margin: 0; text-align: right; }
.records dt { color: var(--faint); font-size: 0.52rem; text-transform: uppercase; }
.records dd { margin: 0.2rem 0 0; color: var(--chrome); font-size: 0.67rem; }
.manual-panel p { max-width: 13rem; margin: 0.3rem 0 0; color: var(--faint); font-size: 0.58rem; line-height: 1.45; }
.dpad { display: grid; flex: 0 0 auto; gap: 0.18rem; grid-template-columns: repeat(3, 2.75rem); grid-template-rows: repeat(3, 2.75rem); }
.dpad button { min-width: 2.75rem; min-height: 2.75rem; border: 1px solid var(--line); border-radius: 0.5rem; background: rgba(255, 255, 255, 0.04); }
.dpad button:hover { border-color: rgba(107, 170, 136, 0.35); background: rgba(107, 170, 136, 0.1); }
.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .center { grid-column: 2; grid-row: 2; color: var(--leaf); }
.dpad .right { grid-column: 3; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 3; }

.proof-strip { display: grid; align-items: center; gap: 2rem; grid-template-columns: 0.8fr 2.2fr; margin-top: 1rem; padding: 1.25rem; border-radius: 1rem; }
.proof-strip h2 { margin: 0.35rem 0 0; font-size: clamp(1.1rem, 2.5vw, 1.6rem); letter-spacing: -0.035em; }
.proof-strip ol { display: grid; gap: 0.75rem; grid-template-columns: repeat(3, 1fr); margin: 0; padding: 0; list-style: none; }
.proof-strip li { display: grid; gap: 0.65rem; grid-template-columns: auto 1fr; padding-left: 0.75rem; border-left: 1px solid var(--line); }
.proof-strip li > span { color: var(--leaf); font-size: 0.58rem; }
.proof-strip li strong { display: block; font-size: 0.66rem; }
.proof-strip li p { margin: 0.25rem 0 0; color: var(--faint); font-size: 0.56rem; line-height: 1.45; }
.arcade-footer { display: flex; justify-content: space-between; gap: 1rem; padding-block: 1rem 1.75rem; color: var(--faint); font-size: 0.58rem; text-transform: uppercase; }

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

@media (max-width: 980px) {
  .arcade-grid { grid-template-columns: 1fr; }
  .control-stack { display: grid; grid-template-columns: 1fr 1fr; }
  .brain-panel, .manual-panel { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .arcade-max { width: min(100% - 1rem, 91rem); }
  .save-pill { display: none; }
  .arcade-intro { display: block; }
  .intro-proof { display: inline-block; margin-top: 1rem; }
  .arcade-intro h1 { font-size: 2.6rem; }
  .control-stack { display: flex; }
  .board-progress { grid-template-columns: auto auto 1fr; }
  .board-progress > span:last-child { display: none; }
  .dpad { grid-template-columns: repeat(3, 2.75rem); grid-template-rows: repeat(3, 2.75rem); }
  .dpad button { min-width: 2.75rem; min-height: 2.75rem; }
  .proof-strip { grid-template-columns: 1fr; }
  .proof-strip ol { grid-template-columns: 1fr; }
  .proof-strip li { padding: 0.65rem 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .arcade-footer { display: block; line-height: 1.7; text-align: center; }
}

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

@media (forced-colors: active) {
  .board-panel, .control-panel, .proof-strip, .canvas-wrap { border: 1px solid CanvasText; }
}
