:root {
  color-scheme: dark;
  --bg: #08141b;
  --bg-2: #10222b;
  --surface: rgb(7 19 25 / 0.72);
  --surface-strong: rgb(10 28 36 / 0.88);
  --surface-soft: rgb(145 242 214 / 0.08);
  --line: rgb(148 240 210 / 0.18);
  --text: #eff7f4;
  --muted: #93aaa4;
  --accent: #79f2ce;
  --accent-strong: #3de2ff;
  --accent-warm: #ff9d57;
  --danger: #ff6f61;
  --shadow: 0 30px 90px rgb(0 0 0 / 0.32);
  --grid-glow: rgb(121 242 206 / 0.06);
  --font-display: "Avenir Next", "Segoe UI", "Hiragino Sans", sans-serif;
  --font-body: "Avenir Next", "Segoe UI", "Hiragino Sans", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", monospace;
}

:root[data-theme="afterglow"] {
  color-scheme: light;
  --bg: #fff6ea;
  --bg-2: #ffd6b0;
  --surface: rgb(255 250 243 / 0.8);
  --surface-strong: rgb(255 245 234 / 0.92);
  --surface-soft: rgb(255 124 77 / 0.08);
  --line: rgb(151 63 12 / 0.14);
  --text: #291711;
  --muted: #815a49;
  --accent: #ff7c4d;
  --accent-strong: #ee5e52;
  --accent-warm: #ffb11f;
  --danger: #be2f37;
  --shadow: 0 32px 80px rgb(114 55 24 / 0.14);
  --grid-glow: rgb(255 124 77 / 0.08);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 15% 20%, rgb(61 226 255 / 0.18), transparent 24%),
    radial-gradient(circle at 85% 14%, rgb(255 157 87 / 0.16), transparent 30%),
    linear-gradient(140deg, var(--bg), var(--bg-2) 60%, var(--bg));
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

button,
input,
output,
kbd {
  font: inherit;
}

button {
  border: 0;
}

.ambient {
  position: fixed;
  inset: auto;
  width: 42vw;
  height: 42vw;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.35;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}

.ambient-left {
  top: -12vw;
  left: -10vw;
  background: rgb(61 226 255 / 0.22);
}

.ambient-right {
  right: -10vw;
  bottom: -16vw;
  background: rgb(255 157 87 / 0.22);
  animation-duration: 18s;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  gap: 24px;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.05), rgb(255 255 255 / 0)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero {
  grid-column: 1 / -1;
  padding: 28px;
}

.eyebrow,
.section-label,
.note-label {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-copy {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: end;
  margin-top: 18px;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 8vw, 7.4rem);
  line-height: 0.88;
  letter-spacing: -0.06em;
}

.lede {
  width: min(56ch, 100%);
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  line-height: 1.8;
}

.hero-notes {
  display: grid;
  gap: 12px;
}

.note-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-soft);
}

.note-card p {
  margin: 12px 0 0;
  line-height: 1.7;
}

.stage {
  display: grid;
  gap: 18px;
  padding: 22px;
  min-height: 760px;
}

.stage-topbar,
.preset-heading,
.transport,
.toggle-row,
.legend,
.shortcut-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-value {
  margin: 8px 0 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.theme-switcher {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.04);
}

.theme-button {
  padding: 10px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.theme-button[aria-selected="true"] {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #041015;
}

.board-frame {
  position: relative;
  overflow: hidden;
  min-height: 580px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0)),
    rgb(3 10 15 / 0.58);
}

:root[data-theme="afterglow"] .board-frame {
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.5), rgb(255 255 255 / 0)),
    rgb(255 243 228 / 0.72);
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.board-hud {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: none;
}

.hud-chip,
.stat-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
}

.hud-chip strong,
.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.15rem;
}

.hud-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legend {
  justify-content: flex-start;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.legend-swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.legend-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.legend-secondary {
  background: rgb(255 255 255 / 0.12);
}

.legend-grid {
  background:
    linear-gradient(90deg, transparent 40%, var(--grid-glow) 50%, transparent 60%),
    linear-gradient(transparent 40%, var(--grid-glow) 50%, transparent 60%);
}

.controls {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 22px;
}

.transport {
  justify-content: flex-start;
}

.primary-action,
.ghost-action,
.preset-button {
  padding: 12px 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.primary-action {
  min-width: 108px;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #041015;
  box-shadow: 0 16px 40px rgb(61 226 255 / 0.22);
}

.ghost-action,
.preset-button {
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
  color: var(--text);
}

.primary-action:hover,
.ghost-action:hover,
.preset-button:hover,
.theme-button:hover {
  transform: translateY(-1px);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.control-stack {
  display: grid;
  gap: 16px;
}

.range-control {
  display: grid;
  gap: 10px;
}

.range-control span,
.range-control output {
  font-family: var(--font-mono);
}

.range-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.04);
  cursor: pointer;
}

.toggle-pill input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.preset-panel,
.shortcut-panel {
  display: grid;
  gap: 14px;
}

.preset-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.shortcut-list {
  justify-content: flex-start;
}

.shortcut-list span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgb(255 255 255 / 0.04);
}

kbd {
  min-width: 2rem;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font-family: var(--font-mono);
  text-align: center;
}

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

  .hero-copy {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: auto;
  }

  .board-frame {
    min-height: 58vh;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 100%);
    padding: 10px 0 20px;
  }

  .panel {
    border-radius: 22px;
  }

  .hero,
  .stage,
  .controls {
    padding: 18px;
  }

  .board-frame {
    min-height: 48vh;
  }

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

@media (max-width: 560px) {
  .stat-grid,
  .preset-list {
    grid-template-columns: 1fr;
  }

  .board-hud {
    right: 12px;
    left: 12px;
  }

  .hud-chip,
  .stat-card {
    width: 100%;
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }

  to {
    transform: translate3d(16px, 24px, 0) scale(1.12);
  }
}
