:root {
  --bg: #141613;
  --bg-2: #1b1e1a;
  --panel: #1e211d;
  --line: #31352f;
  --ink: #ecebe4;
  --muted: #9c9e93;
  --accent: #b9cc63;
  --shell: #dcd8cf;
  --shell-2: #c9c4b9;
  --shell-edge: #a9a397;
  --bezel: #585c68;
  --bezel-2: #4b4e59;
  --berry: #9a2b5b;
  --berry-2: #7c2149;
  --navy: #2d3270;
  --lcd: #9bbc0f;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 30% -10%, #23281f 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #1d2119 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 24px 8px;
}

.wordmark {
  font: 700 22px/1 var(--mono);
  letter-spacing: -0.5px;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--accent); }

.tagline { margin: 0; color: var(--muted); flex: 1; }

.source {
  font-size: 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  text-decoration: none;
}
.source:hover { border-color: var(--accent); }

/* ---------- layout ---------- */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 400px) 320px;
  gap: 56px;
  justify-content: center;
  align-items: start;
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

@media (max-width: 820px) {
  .stage { grid-template-columns: minmax(0, 420px); gap: 28px; padding-top: 8px; }
  .tagline { display: none; }
}

/* ---------- the console ---------- */

.console {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 90 / 148;
  width: 100%;
  background: linear-gradient(160deg, var(--shell) 0%, var(--shell-2) 100%);
  border-radius: 3.5cqw 3.5cqw 16cqw 3.5cqw;
  box-shadow:
    inset 0 0 0 0.6cqw rgba(255, 255, 255, 0.35),
    inset -1.2cqw -1.6cqw 0 var(--shell-edge),
    0 30px 60px rgba(0, 0, 0, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.3);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.bezel {
  position: absolute;
  left: 7cqw;
  right: 7cqw;
  top: 7cqw;
  padding: 4cqw 9cqw 7cqw;
  background: linear-gradient(180deg, var(--bezel) 0%, var(--bezel-2) 100%);
  border-radius: 2.5cqw 2.5cqw 10cqw 2.5cqw;
  box-shadow: inset 0 0.5cqw 1.5cqw rgba(0, 0, 0, 0.35);
}

.bezel-label {
  display: flex;
  align-items: center;
  gap: 2.4cqw;
  margin: 0 -7cqw 2.6cqw;
  color: #b9bcc8;
  font: 600 2.3cqw/1 var(--mono);
  letter-spacing: 0.25cqw;
  text-transform: uppercase;
  white-space: nowrap;
}

.led {
  flex: none;
  width: 2.2cqw;
  height: 2.2cqw;
  border-radius: 50%;
  background: #3a1d21;
  box-shadow: inset 0 0 0.4cqw rgba(0, 0, 0, 0.6);
  transition: background 0.2s, box-shadow 0.2s;
}
.led.on {
  background: #ff3b4a;
  box-shadow: 0 0 1.6cqw #ff3b4a, inset 0 0 0.4cqw rgba(255, 255, 255, 0.5);
}

.screen {
  position: relative;
  aspect-ratio: 160 / 144;
  background: var(--lcd);
  box-shadow: inset 0 0 0 0.4cqw rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.screen.grid::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: calc(100% / 160) calc(100% / 144);
  mix-blend-mode: multiply;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5cqw;
  border: 0;
  background: rgba(15, 56, 15, 0.72);
  color: #e3f0b4;
  font: 600 4.2cqw/1.2 var(--mono);
  cursor: pointer;
  text-align: center;
  padding: 4cqw;
}
.screen-overlay span { font-weight: 400; font-size: 3cqw; opacity: 0.85; }
.screen-overlay[hidden] { display: none; }

.console-name {
  position: absolute;
  left: 9cqw;
  top: 87cqw;
  color: var(--navy);
  font: italic 800 7cqw/1 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.2cqw;
}
.console-name sup { font-size: 2.6cqw; font-style: normal; margin-left: 0.8cqw; letter-spacing: 0.3cqw; vertical-align: 3.2cqw; }

.pad {
  position: absolute;
  left: 7cqw;
  right: 7cqw;
  top: 104cqw;
  height: 32cqw;
}

.dpad {
  position: absolute;
  left: 2cqw;
  top: 4cqw;
  width: 27cqw;
  height: 27cqw;
  touch-action: none;
  cursor: pointer;
}
.dpad::before {
  content: "";
  position: absolute;
  inset: -3cqw;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.12), transparent);
}
.dpad-arm, .dpad-hub {
  position: absolute;
  background: #2c2c31;
  box-shadow: inset 0 -0.6cqw 0 rgba(0, 0, 0, 0.35), 0 0.5cqw 0.8cqw rgba(0, 0, 0, 0.25);
  transition: transform 0.05s, filter 0.05s;
}
.dpad-arm.up, .dpad-arm.down { left: 9cqw; width: 9cqw; height: 10cqw; }
.dpad-arm.left, .dpad-arm.right { top: 9cqw; width: 10cqw; height: 9cqw; }
.dpad-arm.up { top: 0; border-radius: 1cqw 1cqw 0 0; }
.dpad-arm.down { bottom: 0; border-radius: 0 0 1cqw 1cqw; }
.dpad-arm.left { left: 0; border-radius: 1cqw 0 0 1cqw; }
.dpad-arm.right { right: 0; border-radius: 0 1cqw 1cqw 0; }
.dpad-hub { left: 9cqw; top: 9cqw; width: 9cqw; height: 9cqw; box-shadow: none; }
.dpad-hub::after {
  content: "";
  position: absolute;
  inset: 2.4cqw;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3b3b42, #232327);
}
.dpad-arm.pressed { filter: brightness(0.75); transform: scale(0.96); }

.ab {
  position: absolute;
  right: 0;
  top: 2cqw;
  width: 42cqw;
  height: 26cqw;
  transform: rotate(-25deg);
}
.ab::before {
  content: "";
  position: absolute;
  inset: 1cqw -1cqw;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
}
.round {
  position: absolute;
  top: 3cqw;
  width: 16cqw;
  height: 16cqw;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #b43a6d, var(--berry) 55%, var(--berry-2));
  box-shadow: 0 0.9cqw 0 #5c1736, 0 1.6cqw 2cqw rgba(0, 0, 0, 0.3);
  color: transparent;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.05s, box-shadow 0.05s;
}
.round::after {
  position: absolute;
  bottom: -6.5cqw;
  left: 0;
  right: 0;
  color: var(--navy);
  font: 700 3.6cqw/1 var(--mono);
}
.round.b { left: 2cqw; }
.round.a { right: 2cqw; }
.round.b::after { content: "B"; }
.round.a::after { content: "A"; }

.menu-buttons {
  position: absolute;
  left: 24cqw;
  right: 32cqw;
  top: 139cqw;
  display: flex;
  justify-content: space-between;
}
.pill {
  position: relative;
  width: 15cqw;
  height: 3.6cqw;
  border: 0;
  border-radius: 999px;
  background: #8d8b93;
  box-shadow: inset 0 -0.6cqw 0 rgba(0, 0, 0, 0.25);
  transform: rotate(-25deg);
  color: transparent;
  font-size: 0;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.05s;
}
.pill::after {
  content: attr(data-button);
  position: absolute;
  top: 5cqw;
  left: -2cqw;
  right: -2cqw;
  color: var(--navy);
  font: 700 2.5cqw/1 var(--mono);
  letter-spacing: 0.3cqw;
  text-transform: uppercase;
}
.round.pressed { transform: translateY(0.7cqw); box-shadow: 0 0.2cqw 0 #5c1736, 0 0.6cqw 1cqw rgba(0, 0, 0, 0.3); }
.pill.pressed { transform: rotate(-25deg) translateY(0.4cqw); filter: brightness(0.85); }

.grille {
  position: absolute;
  right: 10cqw;
  bottom: 11.5cqw;
  display: flex;
  gap: 2.3cqw;
  transform: rotate(-28deg);
  pointer-events: none;
}
.grille i {
  width: 1.6cqw;
  height: 12.5cqw;
  border-radius: 999px;
  background: linear-gradient(90deg, #a49e92, #bdb7ab);
  box-shadow: inset 0.3cqw 0.4cqw 0.5cqw rgba(0, 0, 0, 0.3);
}

/* ---------- side panel ---------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cart { display: flex; flex-direction: column; gap: 12px; }
.cart-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 8px 8px 3px 3px;
  background: repeating-linear-gradient(0deg, #2a2e28 0 2px, #272b25 2px 4px);
  border: 1px solid var(--line);
}
.cart-kicker { color: var(--muted); font: 600 11px/1.4 var(--mono); letter-spacing: 1.5px; text-transform: uppercase; }
.cart-title { font: 700 18px/1.3 var(--mono); overflow-wrap: anywhere; }
.cart-meta { color: var(--muted); font-size: 13px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #262a24;
  color: var(--ink);
  font: 500 14px/1 system-ui, sans-serif;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: #4a5045; }
.btn:focus-visible, .round:focus-visible, .pill:focus-visible, .screen-overlay:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn[aria-pressed="true"] { background: #39421f; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1f0b; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); }
.transport .btn { flex: 1; }

.btn.icon { padding: 8px; width: 40px; height: 40px; display: grid; place-items: center; }
.btn.icon svg { width: 22px; height: 22px; }
#mute[aria-pressed="true"] .waves { display: none; }

.volume { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; flex: 1; }
.volume input { flex: 1; accent-color: var(--accent); }

.palettes { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.palettes legend { color: var(--muted); font-size: 13px; margin-bottom: 8px; padding: 0; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 12px/1 system-ui, sans-serif;
  cursor: pointer;
}
.swatch .chips { display: grid; grid-template-columns: repeat(4, 12px); height: 22px; border-radius: 4px; overflow: hidden; }
.swatch[aria-checked="true"] { border-color: var(--accent); color: var(--ink); }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.toggle input { accent-color: var(--accent); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}
.stats div { padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.stats dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.stats dd { margin: 2px 0 0; font: 600 15px/1.3 var(--mono); white-space: nowrap; }

.keys summary { cursor: pointer; color: var(--ink); }
.keys table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.keys td { padding: 4px 0; color: var(--muted); }
.keys td:last-child { text-align: right; }
.keys p { color: var(--muted); font-size: 13px; }
kbd {
  display: inline-block;
  min-width: 22px;
  margin-left: 4px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #262a24;
  color: var(--ink);
  font: 12px/1.4 var(--mono);
  text-align: center;
}

.fineprint { margin: 0; color: var(--muted); font-size: 13px; }

.footer {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 40px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.footer p { margin: 4px 0; }

/* ---------- overlays ---------- */

.drop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 10, 0.82);
  border: 3px dashed var(--accent);
  font: 600 22px/1.3 var(--mono);
}
.drop[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 11;
  transform: translateX(-50%);
  max-width: min(90vw, 520px);
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #2a2e27;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.error { border-color: #a5404a; }
