/* brainGames/styles/main.css
   90s Nintendo-cartridge shell. Shared by index.html (the picker / cartridge
   deck) and play.html (the runner). No flat modern UI, no emojis.
   Palette:
     --purple : #3b1f5a
     --yellow : #f7d51d
     --pink   : #ff4aa0
     --green  : #6cff83
     --chrome : #c0c0c0
*/

:root {
  --c-purple: #3b1f5a;
  --c-purple-deep: #20103a;
  --c-yellow: #f7d51d;
  --c-pink:   #ff4aa0;
  --c-green:  #6cff83;
  --c-chrome: #c0c0c0;
  --c-ink:    #0a0614;
  --c-dim:    rgba(255, 255, 255, 0.35);

  --border-pixel: 4px;
  --status-bar-height: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--c-purple-deep);
  color: var(--c-chrome);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 20px;
  letter-spacing: 0.02em;
  image-rendering: pixelated;
}

body {
  background:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0.0) 0px,
      rgba(0,0,0,0.0) 3px,
      rgba(0,0,0,0.25) 4px),
    radial-gradient(ellipse at center, #3b1f5a 0%, #1a0a33 70%, #0a0614 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* CRT scanline overlay — pinned above content but not interactive. */
.crt-scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0.18) 0px,
      rgba(0,0,0,0.18) 1px,
      rgba(0,0,0,0.0) 2px,
      rgba(0,0,0,0.0) 4px);
  mix-blend-mode: multiply;
}

.crt-scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center,
      rgba(255,255,255,0.02) 0%,
      rgba(0,0,0,0.35) 100%);
}

/* ---------- Pixel frame ---------- */
.pixel-frame {
  position: relative;
  background: var(--c-purple);
  border: var(--border-pixel) solid var(--c-chrome);
  box-shadow:
    0 0 0 2px var(--c-ink),
    0 0 0 6px var(--c-chrome),
    0 0 0 8px var(--c-ink),
    0 8px 0 8px rgba(0,0,0,0.5);
  padding: 24px;
}

.pixel-frame.accent-yellow { border-color: var(--c-yellow); }
.pixel-frame.accent-pink   { border-color: var(--c-pink); }
.pixel-frame.accent-green  { border-color: var(--c-green); }

/* ---------- Typography ---------- */
h1, h2, h3, .display {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.3;
  margin: 0 0 12px 0;
}

h1 {
  font-size: 40px;
  color: var(--c-chrome);
  text-shadow:
    3px 0 0 var(--c-pink),
    -3px 0 0 var(--c-green),
    0 4px 0 var(--c-ink);
}

h2 { font-size: 18px; color: var(--c-yellow); text-shadow: 0 2px 0 var(--c-ink); }
h3 { font-size: 14px; color: var(--c-chrome); text-shadow: 0 2px 0 var(--c-ink); }

p, li { color: var(--c-chrome); }

.small { font-size: 14px; color: var(--c-dim); }

/* ---------- Top bar (pages share this) ---------- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  min-height: var(--status-bar-height);
  background: linear-gradient(180deg, #1e0f3a 0%, #120826 100%);
  border-bottom: 3px solid var(--c-chrome);
  box-shadow: 0 3px 0 0 var(--c-ink);
}

.top-bar .title-chrome {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: var(--c-chrome);
  text-shadow:
    2px 0 0 var(--c-pink),
    -2px 0 0 var(--c-green),
    0 3px 0 var(--c-ink);
}

.press-start {
  font-family: 'Press Start 2P', monospace;
  color: var(--c-yellow);
  font-size: 14px;
  animation: blink 1.1s steps(2, end) infinite;
}

@keyframes blink {
  50% { opacity: 0.05; }
}

.back-link {
  font-family: 'Press Start 2P', monospace;
  color: var(--c-yellow);
  text-decoration: none;
  font-size: 12px;
  padding: 8px 12px;
  border: 3px solid var(--c-yellow);
  background: transparent;
  letter-spacing: 0.1em;
}
.back-link:hover { background: var(--c-yellow); color: var(--c-purple-deep); }

.live-readout {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--c-green);
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border: 2px solid var(--c-green);
  background: rgba(0,0,0,0.4);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.hero-title {
  text-align: center;
  margin: 20px 0 8px;
}

.hero-sub {
  text-align: center;
  margin-bottom: 28px;
}

/* ---------- Buttons ---------- */
.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-ink);
  background: var(--c-yellow);
  border: 3px solid var(--c-ink);
  padding: 12px 18px;
  cursor: pointer;
  box-shadow:
    4px 4px 0 0 var(--c-ink),
    0 0 0 2px var(--c-chrome) inset;
  transition: transform 0.03s linear;
}
.pixel-btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 0 var(--c-ink), 0 0 0 2px var(--c-chrome) inset; }
.pixel-btn.accent-pink  { background: var(--c-pink); color: var(--c-ink); }
.pixel-btn.accent-green { background: var(--c-green); color: var(--c-ink); }
.pixel-btn.accent-chrome { background: var(--c-chrome); color: var(--c-ink); }
.pixel-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Connection gate ---------- */
.gate {
  margin: 0 auto 28px;
}

.gate-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 16px 0;
}

.gate-light {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  border: 3px solid var(--c-chrome);
  background: rgba(0,0,0,0.35);
  min-height: 130px;
}

.gate-light .dot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2a1a45;
  border: 3px solid var(--c-chrome);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
  position: relative;
}

.gate-light.on .dot {
  background: var(--c-green);
  border-color: var(--c-green);
  box-shadow:
    0 0 14px var(--c-green),
    inset 0 0 6px rgba(255,255,255,0.5);
  animation: gateGlow 1.6s ease-in-out infinite;
}

@keyframes gateGlow {
  0%, 100% { box-shadow: 0 0 12px var(--c-green), inset 0 0 6px rgba(255,255,255,0.4); }
  50%      { box-shadow: 0 0 24px var(--c-green), inset 0 0 10px rgba(255,255,255,0.7); }
}

.gate-light .label {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--c-chrome);
  text-align: center;
}

.gate-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.gate-status {
  text-align: center;
  margin-top: 10px;
  font-size: 16px;
  color: var(--c-dim);
}

/* ---------- Grid of cartridge slots ---------- */
.cartridge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .cartridge-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .cartridge-grid { grid-template-columns: repeat(2, 1fr); }
  .gate-row { grid-template-columns: 1fr; }
}

.cartridge {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(160deg, #4a2770 0%, #2a1048 100%);
  border: 4px solid var(--c-chrome);
  box-shadow:
    inset 0 0 0 2px var(--c-ink),
    4px 4px 0 0 var(--c-ink);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px;
  overflow: hidden;
}

.cartridge::before {
  /* Top "label" strip typical of NES cartridges. */
  content: "";
  display: block;
  height: 34%;
  background: repeating-linear-gradient(90deg,
    var(--c-yellow) 0 10px,
    var(--c-ink) 10px 12px);
  border: 2px solid var(--c-ink);
  margin-bottom: 8px;
}

.cartridge .slot-id {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--c-chrome);
  text-align: center;
  margin-bottom: 6px;
}

.cartridge .slot-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--c-dim);
  line-height: 1.6;
  padding: 6px;
}

.cartridge.empty { opacity: 0.65; }
.cartridge:hover:not(.empty) { transform: translate(-2px, -2px); box-shadow: inset 0 0 0 2px var(--c-ink), 6px 6px 0 0 var(--c-ink); cursor: pointer; }

/* ---------- Grid hidden state ---------- */
.deck-wrap.locked .cartridge-grid { display: none; }
.deck-wrap.locked .deck-locked-msg { display: block; }
.deck-wrap:not(.locked) .deck-locked-msg { display: none; }

.deck-locked-msg {
  text-align: center;
  padding: 30px 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--c-pink);
  letter-spacing: 0.1em;
  animation: blink 1.3s steps(2) infinite;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 48px;
  padding: 18px 0;
  text-align: center;
  font-size: 14px;
  color: var(--c-dim);
  border-top: 2px dashed var(--c-dim);
}

/* ---------- Play page specifics ---------- */

/* Tube resolution baked in the runner. Kept in sync here so the DOM that
   wraps the canvas renders at 1:1 pixels. */
:root {
  --tube-w: 800px;
  --tube-h: 600px;
  --tv-case: #2d2a26;          /* dark plastic body */
  --tv-case-hi: #3f3a33;       /* highlight */
  --tv-case-lo: #14110d;       /* shadow */
  --tv-bezel: #1a1815;         /* inner bezel */
  --tv-plate: #b8b2a4;         /* embossed brand plate */
  --tv-knob: #7a6f61;          /* knob silver/brass */
  --tv-knob-hi: #d8cfbd;
  --tv-led-off: #3a2d1a;
  --tv-led-on:  #ff6b3a;
}

.play-stage {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--status-bar-height);
  bottom: 0;
  overflow: auto;
  background:
    radial-gradient(ellipse at center, #1a0a33 0%, #0a0614 70%, #000 100%);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The TV set is authored at 1:1 pixel size and scaled down visually on
   smaller viewports via CSS transform (see @media below). */
.tv-set {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center center;
}

.tv-cabinet {
  position: relative;
  display: grid;
  grid-template-columns: auto 140px;
  gap: 18px;
  padding: 32px 28px 26px;
  background:
    linear-gradient(180deg, var(--tv-case-hi) 0%, var(--tv-case) 22%, var(--tv-case) 78%, var(--tv-case-lo) 100%);
  border-radius: 22px;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.08),
    inset 0 -4px 0 rgba(0, 0, 0, 0.55),
    0 18px 0 -6px rgba(0, 0, 0, 0.6),
    0 30px 60px rgba(0, 0, 0, 0.7);
}

/* Subtle plastic speckling on the case to sell the 90s injection-moulded
   look, via a CSS-only dotted noise layer. */
.tv-cabinet::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    radial-gradient(rgba(0,0,0,0.15)    1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 2px;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* ----- Screen block (brand plate + CRT + model plate) ----- */
.tv-screen-area {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.tv-brand {
  align-self: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--tv-plate);
  text-shadow:
    1px 1px 0 rgba(0,0,0,0.6),
    -1px -1px 0 rgba(255,255,255,0.12);
  padding: 2px 12px 0;
}

.tv-screen-bezel {
  padding: 14px;
  background:
    linear-gradient(180deg, #0c0a08 0%, #1a1814 100%);
  border-radius: 10px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.05),
    inset 0 -2px 0 rgba(0,0,0,0.7);
}

.tv-screen-inner {
  padding: 6px;
  background: var(--tv-bezel);
  border-radius: 16px;
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,0.9),
    inset 0 0 0 6px #26221c,
    inset 0 0 24px rgba(0,0,0,0.9);
}

/* The CRT surface is the actual rendering area. We round the corners
   slightly and add a radial vignette to mimic tube curvature. */
.tv-crt-surface {
  position: relative;
  width: var(--tube-w);
  height: var(--tube-h);
  background: #000;
  border-radius: 22px / 18px; /* slight CRT curvature */
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    inset 0 0 40px rgba(0,0,0,0.9);
}

#game-container {
  position: absolute;
  inset: 0;
  background: #000;
}

#game-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* CRT glare — soft diagonal highlight across the top-left. */
.tv-crt-glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(125deg,
      rgba(255,255,255,0.12) 0%,
      rgba(255,255,255,0.03) 18%,
      rgba(255,255,255,0) 42%);
  mix-blend-mode: screen;
}

/* CRT scanlines inside the tube only (distinct from the page-level scanlines). */
.tv-crt-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.22) 0px,
    rgba(0,0,0,0.22) 1px,
    rgba(0,0,0,0)    2px,
    rgba(0,0,0,0)    3px
  );
  mix-blend-mode: multiply;
  opacity: 0.9;
}

/* Edge vignette — darkens the tube corners for CRT depth. */
.tv-crt-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 60px 12px rgba(0,0,0,0.65);
  border-radius: inherit;
}

.tv-model-plate {
  align-self: center;
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: #6a6358;
  letter-spacing: 0.08em;
}

/* ----- Control panel on the right side ----- */
.tv-control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 10px;
  background:
    linear-gradient(180deg, #1f1d19 0%, #141210 100%);
  border-radius: 12px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.04),
    inset 0 -2px 0 rgba(0,0,0,0.7);
  align-self: stretch;
}

.tv-led-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.tv-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tv-led-off);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.2),
    inset 0 -1px 1px rgba(0,0,0,0.6);
}

.tv-led.power-led {
  background: var(--tv-led-on);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 0 8px var(--tv-led-on),
    0 0 2px #fff;
  animation: ledPulse 2.8s ease-in-out infinite;
}

@keyframes ledPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

.tv-led-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #8a7f6f;
  letter-spacing: 0.1em;
}

.tv-channel-readout {
  margin: 2px auto;
  width: 86px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #0a0704;
  text-align: center;
  box-shadow:
    inset 0 0 0 2px #2a251e,
    inset 0 4px 8px rgba(0,0,0,0.9);
}

.tv-channel-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #8a6a3a;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.tv-channel-num {
  font-family: 'VT323', monospace;
  font-size: 26px;
  color: #ff8a3a;
  text-shadow: 0 0 6px #ff6b2a, 0 0 1px #fff;
  line-height: 1;
}

.tv-channel-arrows {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}

.tv-ch-arrow {
  flex: 1;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  line-height: 1;
  padding: 4px 0 5px;
  background: linear-gradient(180deg, #3c342a 0%, #1f1a13 100%);
  color: var(--tv-plate);
  border: 1px solid #0a0604;
  border-radius: 3px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -1px 0 rgba(0,0,0,0.6);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.tv-ch-arrow:hover { color: var(--c-yellow); }

.tv-ch-arrow:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,0.6),
    inset 0 -1px 0 rgba(255,255,255,0.05);
}

.tv-knob-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tv-knob {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, var(--tv-knob-hi) 0%, var(--tv-knob) 55%, #3a332a 100%);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,0.25),
    inset 0 -3px 4px rgba(0,0,0,0.55),
    0 4px 0 #151310,
    0 6px 8px rgba(0,0,0,0.45);
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.tv-knob.is-clickable {
  cursor: pointer;
  outline: none;
}

.tv-knob.is-clickable:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,0.35),
    inset 0 -3px 4px rgba(0,0,0,0.55),
    0 5px 0 #151310,
    0 10px 12px rgba(0,0,0,0.5),
    0 0 0 2px rgba(247, 213, 29, 0.35);
}

.tv-knob.is-clickable:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,0.2),
    inset 0 -2px 3px rgba(0,0,0,0.6),
    0 2px 0 #151310,
    0 3px 4px rgba(0,0,0,0.6);
}

.tv-knob.is-clickable:focus-visible {
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,0.25),
    inset 0 -3px 4px rgba(0,0,0,0.55),
    0 4px 0 #151310,
    0 6px 8px rgba(0,0,0,0.45),
    0 0 0 3px var(--c-yellow);
}

.tv-knob-pointer {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 4px;
  height: 18px;
  background: #2a241c;
  border-radius: 2px;
  transform: translateX(-50%) rotate(-30deg);
  transform-origin: 50% 80%;
  box-shadow: 0 0 3px rgba(0,0,0,0.6);
}

.tv-knob-wrap:nth-of-type(odd) .tv-knob-pointer {
  transform: translateX(-50%) rotate(15deg);
}

.tv-knob-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #8a7f6f;
  letter-spacing: 0.1em;
}

.tv-speaker-grille {
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  background: #0a0704;
  border-radius: 6px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
}

.tv-speaker-grille span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #3a342b 0%, #0d0a07 80%);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.6);
}

/* TV stand — small trapezoid under the cabinet. */
.tv-stand {
  margin-top: -6px;
  width: 280px;
  height: 18px;
  background:
    linear-gradient(180deg, var(--tv-case-hi) 0%, var(--tv-case) 60%, var(--tv-case-lo) 100%);
  clip-path: polygon(18% 0%, 82% 0%, 92% 100%, 8% 100%);
  box-shadow: 0 6px 12px rgba(0,0,0,0.6);
}

/* Responsive scaling — keep the tube pixel-exact, shrink the whole set
   proportionally so a 1280-wide viewport can still show the full TV. */
@media (max-width: 1180px) {
  .tv-set { transform: scale(0.88); }
}
@media (max-width: 1050px) {
  .tv-set { transform: scale(0.78); }
}
@media (max-width: 940px) {
  .tv-set { transform: scale(0.68); }
}
@media (max-width: 820px) {
  .tv-set { transform: scale(0.56); }
}
@media (max-height: 760px) {
  .tv-set { transform: scale(0.86); }
}
@media (max-height: 680px) {
  .tv-set { transform: scale(0.74); }
}

/* ---------- Modal (connection gate on play page) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 20, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.modal-backdrop.hidden { display: none; }

.modal {
  max-width: 520px;
  width: 90%;
  padding: 28px;
  background: var(--c-purple);
  border: 4px solid var(--c-yellow);
  box-shadow: 0 0 0 2px var(--c-ink), 0 0 0 6px var(--c-chrome);
  text-align: center;
}

.modal h2 { color: var(--c-yellow); margin-bottom: 18px; }

.modal .actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ---------- Manifest-driven cartridge cards (I2) ---------- */
.cart-card {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(160deg, #4a2770 0%, #2a1048 100%);
  border: 4px solid var(--c-chrome);
  box-shadow:
    inset 0 0 0 2px var(--c-ink),
    4px 4px 0 0 var(--c-ink);
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
  overflow: hidden;
  transition: transform 0.08s linear, box-shadow 0.08s linear;
}

.cart-card::before {
  /* NES-style yellow/black striped label strip along the top. */
  content: "";
  display: block;
  height: 8px;
  background: repeating-linear-gradient(90deg,
    var(--c-yellow) 0 10px,
    var(--c-ink) 10px 12px);
  border: 2px solid var(--c-ink);
  margin: -4px -4px 4px -4px;
}

.cart-card:hover {
  transform: translate(-2px, -2px);
  box-shadow:
    inset 0 0 0 2px var(--c-ink),
    6px 6px 0 0 var(--c-ink);
}

.cart-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 2px;
  border-bottom: 2px dashed rgba(192, 192, 192, 0.35);
}

.cart-title {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 10px;
  color: var(--c-chrome);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  text-shadow: 0 2px 0 var(--c-ink);
}

.cart-cat {
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 13px;
  color: rgba(247, 213, 29, 0.7);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.cart-preview {
  display: block;
  width: 160px;
  height: 100px;
  max-width: 100%;
  margin: 2px auto 0;
  background: var(--c-ink);
  border: 2px solid var(--c-chrome);
  box-shadow: inset 0 0 0 2px var(--c-ink);
  image-rendering: pixelated;
}

.cart-mapping {
  margin: 2px 2px 0;
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 14px;
  color: rgba(192, 192, 192, 0.75);
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cart-play {
  margin-top: auto;
  align-self: center;
  font-size: 10px;
  padding: 8px 14px;
}

@keyframes cartShake {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(-4px, 0); }
  30%  { transform: translate(4px, 0); }
  45%  { transform: translate(-3px, 0); }
  60%  { transform: translate(3px, 0); }
  75%  { transform: translate(-2px, 0); }
  100% { transform: translate(0, 0); }
}

.cart-shake {
  animation: cartShake 0.4s ease-in-out 1;
  border-color: var(--c-pink);
}

