:root {
  --shell-bg: #0a0a0f;
  --body-bg: #12121a;
  --body-gradient: linear-gradient(145deg, #1a1a28 0%, #0f0f18 40%, #0a0a12 100%);
  --body-border: #2a2a3a;
  --screen-bg: #05070a;
  --screen-border: #1a1a2a;
  --pixel-color: #00ff88;
  --pixel-dim: #004422;
  --pixel-highlight: #66ffbb;
  --btn-primary: #3a3a4e;
  --btn-primary-hover: #4a4a5e;
  --btn-accent: #00ff88;
  --btn-accent-hover: #33ffaa;
  --text-primary: #e0e0f0;
  --text-secondary: #8888aa;
  --text-muted: #555570;
  --led-green: #00ff88;
  --led-red: #ff4455;
  --glow-color: rgba(0, 255, 136, 0.15);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --dpad-btn-size: 42px;
  --dpad-cluster-size: 132px;
  --action-btn-size: 46px;
  --action-cluster-w: 104px;
  --action-cluster-h: 92px;
  --sys-btn-h: 30px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--shell-bg); font-family: 'Courier New', 'Segoe UI', monospace, system-ui, sans-serif; color: var(--text-primary); overscroll-behavior: none; -webkit-overflow-scrolling: auto; }
html { touch-action: none; }
body { position: fixed; inset: 0; min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
button { font-family: inherit; color: inherit; cursor: pointer; border: none; background: none; outline: none; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
button:focus-visible { outline: 2px solid var(--btn-accent); outline-offset: 2px; }

/* ─── Prevent touch scroll, zoom, selection ─── */
html, body, .console-shell {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ─── Hide scrollbar for all elements ─── */
*::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ─── CONSOLE SHELL ─── */
.console-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100svh;
  height: 100dvh;
  max-height: 860px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--shell-bg);
}
.console-shell.fullscreen {
  width: 100vw;
  max-width: none;
  max-height: none;
  height: 100svh;
  height: 100dvh;
}
.console-shell.fullscreen .console-body,
#consoleShell:fullscreen .console-body,
#consoleShell:-webkit-full-screen .console-body {
  border-radius: 0;
  border: none;
  max-height: none;
  padding-top: max(6px, var(--safe-top));
  padding-right: max(6px, var(--safe-right));
  padding-bottom: max(6px, var(--safe-bottom));
  padding-left: max(6px, var(--safe-left));
}
html.pocket-arcade-fullscreen,
body.pocket-arcade-fullscreen {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.console-body {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px max(10px, var(--safe-right)) max(8px, var(--safe-bottom)) max(10px, var(--safe-left));
  background: var(--body-gradient);
  border: 1px solid var(--body-border);
  border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 20px 60px rgba(0,0,0,0.8),
    0 0 30px rgba(0,255,136,0.04),
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -1px 0 rgba(0,0,0,0.3);
  overflow: hidden;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* Neon skin variants */
.console-body.skin-neon {
  background: linear-gradient(145deg, #1a0a2e 0%, #0f0518 40%, #0a0212 100%);
  box-shadow: 0 0 0 1px rgba(255,0,255,0.1), 0 20px 60px rgba(0,0,0,0.8), 0 0 30px rgba(255,0,255,0.06);
}
.console-body.skin-neon { --pixel-color: #ff44ff; --pixel-dim: #440044; --pixel-highlight: #ff88ff; --btn-accent: #ff44ff; }
.console-body.skin-gold { background: linear-gradient(145deg, #2a1f08 0%, #1a1204 40%, #0f0a02 100%); }
.console-body.skin-gold { --pixel-color: #ffd700; --pixel-dim: #443300; --pixel-highlight: #ffed88; --btn-accent: #ffd700; }
.console-body.skin-purple { background: linear-gradient(145deg, #1a0a2e 0%, #0f0518 40%, #0a0212 100%); }
.console-body.skin-purple { --pixel-color: #a855f7; --pixel-dim: #3b0a5e; --pixel-highlight: #c084fc; --btn-accent: #a855f7; }

/* ─── TOP SECTION ─── */
.console-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  flex-shrink: 0;
}

.speaker-row {
  display: flex;
  align-items: center;
  flex: 1;
}
.speaker-holes {
  display: flex;
  gap: 3px;
}
.speaker-holes span {
  width: 4px;
  height: 10px;
  border-radius: 2px;
  background: rgba(255,255,255,0.06);
}
.speaker-holes span:nth-child(odd) { background: rgba(255,255,255,0.04); }

.console-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.brand-text {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--text-secondary);
}
.brand-model {
  font-size: 0.45rem;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  font-weight: 600;
}

.status-leds {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

/* Fullscreen toggle button in top bar */
.fs-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  transition: all 0.15s;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  margin-left: 4px;
}
.fs-toggle-btn:hover, .fs-toggle-btn:active {
  background: var(--btn-primary);
  color: var(--text-secondary);
}
.fs-toggle-btn.active-fs {
  color: var(--btn-accent);
  border-color: rgba(0,255,136,0.3);
}
.led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: block;
}
.led-power {
  background: var(--led-green);
  box-shadow: 0 0 6px rgba(0,255,136,0.6);
}
.led-sound {
  background: var(--text-muted);
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
  transition: all 0.2s;
}
.led-sound.on {
  background: var(--led-green);
  box-shadow: 0 0 6px rgba(0,255,136,0.5);
}

/* ─── LCD SCREEN ─── */
/* screen-region is the flexible area; the frame inside is ALWAYS a 1:1 square
   whose exact size is computed in JS (layoutScreen) and centered here. */
.screen-region {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lcd-frame {
  position: relative;
  /* Size is set inline by JS as a true square. Fallbacks keep it square-ish
     before the first layout pass runs. */
  width: var(--screen-size, min(92vw, 92vmin));
  height: var(--screen-size, min(92vw, 92vmin));
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  margin: 4px auto;
  border-radius: 12px;
  background: var(--screen-bg);
  border: 2px solid var(--screen-border);
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.6),
    inset 0 0 4px rgba(0,255,136,0.05),
    0 0 8px rgba(0,0,0,0.4);
  overflow: hidden;
}

.lcd-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.lcd-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
}

.screen-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(220,255,228,0.02), transparent 72%);
  pointer-events: none;
  transition: opacity 0.3s;
}
.screen-glow.active {
  opacity: 0.6;
}

.screen-bezel {
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 3;
}

/* ─── BUTTON PANEL ─── */
.button-panel {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 6px;
  flex-shrink: 0;
  gap: 8px;
  touch-action: none;
  /* Handheld feel: controls sit in the lower half, screen near the top. */
  margin-top: auto;
}

/* D-Pad */
.dpad-cluster {
  position: relative;
  width: var(--dpad-cluster-size);
  height: var(--dpad-cluster-size);
  flex-shrink: 0;
}

.dpad-btn {
  position: absolute;
  width: var(--dpad-btn-size);
  height: var(--dpad-btn-size);
  border-radius: 8px;
  background: var(--btn-primary);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.08s;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}
.dpad-btn:active, .dpad-btn.active {
  transform: scale(0.92);
  background: var(--btn-primary-hover);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), inset 0 0 0 2px var(--btn-accent);
  color: var(--btn-accent);
}
.dpad-up { top: 0; left: 50%; transform: translateX(-50%); }
.dpad-up:active, .dpad-up.active { transform: translateX(-50%) scale(0.92); }
.dpad-down { bottom: 0; left: 50%; transform: translateX(-50%); }
.dpad-down:active, .dpad-down.active { transform: translateX(-50%) scale(0.92); }
.dpad-left { left: 0; top: 50%; transform: translateY(-50%); }
.dpad-left:active, .dpad-left.active { transform: translateY(-50%) scale(0.92); }
.dpad-right { right: 0; top: 50%; transform: translateY(-50%); }
.dpad-right:active, .dpad-right.active { transform: translateY(-50%) scale(0.92); }

.dpad-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--body-bg);
  border: 1px solid rgba(255,255,255,0.05);
  pointer-events: none;
}

/* Action Buttons */
.action-cluster {
  position: relative;
  width: var(--action-cluster-w);
  height: var(--action-cluster-h);
  flex-shrink: 0;
}

.action-btn {
  position: absolute;
  width: var(--action-btn-size);
  height: var(--action-btn-size);
  border-radius: 50%;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.05em;
  border: 2px solid rgba(255,255,255,0.1);
  transition: all 0.08s;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}
.btn-a {
  top: 0;
  right: 0;
  background: linear-gradient(145deg, #2a8a4a, #1a5a30);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  color: #88ffbb;
}
.btn-a:active, .btn-a.active {
  transform: scale(0.88);
  box-shadow: 0 1px 3px rgba(0,0,0,0.6), inset 0 0 0 2px var(--btn-accent);
}
.btn-b {
  bottom: 0;
  left: 0;
  background: linear-gradient(145deg, #8a2a2a, #5a1a1a);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  color: #ff8888;
}
.btn-b:active, .btn-b.active {
  transform: scale(0.88);
  box-shadow: 0 1px 3px rgba(0,0,0,0.6), inset 0 0 0 2px #ff4455;
}

/* System Buttons */
.system-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 5px;
  width: 100px;
  flex-shrink: 0;
}

.sys-btn {
  height: var(--sys-btn-h);
  border-radius: 15px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--btn-primary);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.1s;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sys-btn:active, .sys-btn.active {
  transform: scale(0.94);
  background: var(--btn-primary-hover);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.sys-btn.sys-menu { color: var(--text-secondary); }
.sys-btn.sys-start { color: var(--btn-accent); }
.sys-btn.sys-sound {
  color: var(--text-secondary);
  background: var(--btn-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sys-btn.sys-sound.muted {
  color: var(--text-muted);
  background: rgba(60,60,80,0.3);
}
.sys-btn.sys-reset { color: var(--led-red); }
.sys-btn.sys-fullscreen {
  color: var(--text-secondary);
  font-size: 0.5rem;
}
.sys-btn.sys-fullscreen.active-fs {
  color: var(--btn-accent);
}

/* ─── BOTTOM SECTION ─── */
.console-bottom {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 16px 4px;
  flex-shrink: 0;
}
.cartridge-slot {
  width: 60px;
  height: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-label {
  font-size: 0.35rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.serial-info {
  font-size: 0.4rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.serial-info .region {
  color: var(--text-secondary);
  letter-spacing: 0.08em;
}

/* ─── BOOT SCREEN ─── */
.boot-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--shell-bg);
  border-radius: 28px;
}
.boot-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.boot-content {
  text-align: center;
}
.boot-logo {
  margin-bottom: 16px;
  animation: bootPulse 1.6s ease-in-out infinite;
}
@keyframes bootPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.boot-title {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--btn-accent);
  text-shadow: 0 0 20px rgba(0,255,136,0.5);
  margin-bottom: 4px;
}
.boot-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}
.boot-bar {
  width: 180px;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  margin: 0 auto 8px;
  overflow: hidden;
}
.boot-progress {
  height: 100%;
  width: 0%;
  background: var(--btn-accent);
  border-radius: 2px;
  transition: width 0.3s;
  box-shadow: 0 0 8px rgba(0,255,136,0.4);
}
.boot-hint {
  font-size: 0.55rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 480px) {
  .console-shell {
    max-width: 100%;
    height: 100svh;
    height: 100dvh;
    max-height: none;
  }
  .console-body {
    max-height: none;
    border-radius: 0;
    border: none;
    padding: max(6px, var(--safe-top)) max(4px, var(--safe-right)) max(6px, var(--safe-bottom)) max(4px, var(--safe-left));
  }
  .boot-screen { border-radius: 0; }
  .button-panel {
    gap: 4px;
    padding: 6px 4px 4px;
  }
  :root {
    --dpad-btn-size: 44px;
    --dpad-cluster-size: 132px;
    --action-btn-size: 50px;
    --action-cluster-w: 110px;
    --action-cluster-h: 92px;
    --sys-btn-h: 44px;
  }
  .system-buttons { width: 96px; }
  .sys-btn { font-size: 0.5rem; }
  .btn-a, .btn-b { font-size: 0.95rem; }
  .fs-toggle-btn { width: 44px; height: 44px; }
}

@media (max-width: 380px) {
  .button-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "dpad action"
      "system system";
    justify-items: center;
    align-items: center;
    gap: 4px 10px;
  }
  .dpad-cluster { grid-area: dpad; }
  .action-cluster { grid-area: action; }
  .system-buttons {
    grid-area: system;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: 1fr;
    width: min(100%, 320px);
    gap: 6px;
  }
  .sys-btn {
    min-height: 44px;
    border-radius: 12px;
  }
}

@media (min-width: 768px) {
  .console-body {
    padding: 12px 16px max(12px, var(--safe-bottom)) 16px;
  }
  :root {
    --dpad-btn-size: 46px;
    --dpad-cluster-size: 144px;
    --action-btn-size: 50px;
    --action-cluster-w: 112px;
    --action-cluster-h: 100px;
    --sys-btn-h: 32px;
  }
  .system-buttons { width: 110px; gap: 6px; }
  .sys-btn { font-size: 0.6rem; }
  .btn-a, .btn-b { font-size: 1.1rem; }
}

/* Landscape mode on phones */
@media (max-height: 500px) {
  .console-shell { max-height: none; height: 100svh; height: 100dvh; }
  .console-body {
    flex-direction: row;
    flex-wrap: wrap;
    padding: max(4px, var(--safe-top)) max(4px, var(--safe-right)) max(4px, var(--safe-bottom)) max(4px, var(--safe-left));
  }
  .console-top { width: auto; flex-direction: column; padding: 4px; }
  .speaker-row, .console-bottom { display: none; }
  .status-leds { justify-content: center; }
  .lcd-frame { flex: 1; min-width: 200px; height: 100%; margin: 4px; }
  .button-panel { flex-direction: column; width: auto; padding: 4px; }
  :root {
    --dpad-btn-size: 42px;
    --dpad-cluster-size: 126px;
    --action-btn-size: 48px;
    --action-cluster-w: 104px;
    --action-cluster-h: 86px;
    --sys-btn-h: 40px;
  }
  .system-buttons { width: 92px; }
  .sys-btn { height: 40px; font-size: 0.48rem; }
}

/* ═══════════════════════════════════════════════════════════════════════
   GAME LIBRARY — unified selector (all games at once, tap or D-pad + A)
   Lives inside the square LCD frame, so it inherits the 1:1 screen.
   ═══════════════════════════════════════════════════════════════════════ */
.game-library {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0,255,136,0.05), transparent 60%),
    #070c09;
  overflow: hidden;
}
.game-library[hidden] { display: none; }

.lib-header {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(0,255,136,0.1);
}
.lib-title {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--pixel-color);
  text-shadow: 0 0 8px rgba(0,255,136,0.3);
}
.lib-total {
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  color: rgba(0,255,136,0.4);
}

.lib-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  grid-auto-rows: min-content;
  gap: 8px;
  align-content: start;
  padding: 10px;
  outline: none;
}

.lib-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 13px 5px 9px;
  min-height: 98px;
  border-radius: 10px;
  background: rgba(0,255,136,0.03);
  border: 1px solid rgba(0,255,136,0.12);
  color: #d6efe4;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s, background 0.12s, border-color 0.12s, box-shadow 0.12s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.lib-card:active { transform: scale(0.95); }
.lib-card .lib-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.48rem;
  font-weight: 700;
  color: rgba(0,255,136,0.4);
}
.lib-card .lib-icon {
  font-size: 1.7rem;
  line-height: 1;
  color: var(--pixel-color);
  filter: drop-shadow(0 0 4px rgba(0,255,136,0.25));
}
.lib-card .lib-name {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  color: #eafff5;
}
.lib-card .lib-genre {
  font-size: 0.48rem;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.32);
  text-transform: uppercase;
}
.lib-card .lib-best {
  font-size: 0.5rem;
  letter-spacing: 0.02em;
  color: rgba(255,215,0,0.7);
}
.lib-card .lib-badge {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 0.46rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255,215,0,0.15);
  color: #ffd76a;
}
.lib-card.selected {
  border-color: var(--pixel-color);
  background: rgba(0,255,136,0.12);
  box-shadow: 0 0 0 1px var(--pixel-color), 0 0 14px rgba(0,255,136,0.25);
}
@media (hover: hover) {
  .lib-card:hover { border-color: rgba(0,255,136,0.4); background: rgba(0,255,136,0.08); }
}

.lib-hint {
  flex-shrink: 0;
  text-align: center;
  padding: 5px 6px;
  font-size: 0.46rem;
  letter-spacing: 0.06em;
  color: rgba(0,255,136,0.35);
  border-top: 1px solid rgba(0,255,136,0.08);
}

/* ═══════════════════════════════════════════════════════════════════════
   DESKTOP / LAPTOP — "web arcade cabinet": large square screen is the hero,
   controls move to a side column, keyboard is first-class.
   ═══════════════════════════════════════════════════════════════════════ */
@media (min-width: 860px) {
  body { padding: 0; }
  .console-shell {
    max-width: min(96vw, 1180px);
    width: min(96vw, 1180px);
    height: min(94vh, 820px);
    max-height: 820px;
  }
  .console-body {
    max-height: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "screen top"
      "screen panel"
      "screen bottom";
    column-gap: 18px;
    padding: 16px 22px;
    border-radius: 24px;
  }
  .screen-region {
    grid-area: screen;
    height: 100%;
  }
  .console-top {
    grid-area: top;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
  }
  .console-top .speaker-row { display: none; }
  .console-top .console-brand { align-items: center; }
  .console-top .brand-text { font-size: 0.72rem; }
  .console-top .brand-model { font-size: 0.52rem; }
  .console-top .status-leds { flex: 0; justify-content: center; }

  .button-panel {
    grid-area: panel;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 22px;
    margin-top: 0;
    padding: 8px;
  }
  .console-bottom {
    grid-area: bottom;
    justify-content: center;
    gap: 12px;
    padding: 6px 8px;
  }

  /* Bigger, comfortable controls in the side column */
  :root {
    --dpad-btn-size: 50px;
    --dpad-cluster-size: 156px;
    --action-btn-size: 58px;
    --action-cluster-w: 130px;
    --action-cluster-h: 116px;
    --sys-btn-h: 40px;
  }
  .system-buttons { width: 150px; gap: 8px; }
  .sys-btn { font-size: 0.6rem; border-radius: 12px; }
  .btn-a, .btn-b { font-size: 1.2rem; }
  .lib-header { padding: 16px 20px 12px; }
  .lib-title { font-size: 1.05rem; letter-spacing: 0.26em; }
  .lib-total { font-size: 0.8rem; }
  .lib-grid {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 16px;
    padding: 20px;
  }
  .lib-card {
    min-height: 132px;
    padding: 20px 10px 14px;
    border-radius: 14px;
    gap: 5px;
  }
  .lib-card .lib-num { font-size: 0.62rem; top: 7px; left: 10px; }
  .lib-card .lib-icon { font-size: 2.6rem; }
  .lib-card .lib-name { font-size: 0.86rem; }
  .lib-card .lib-genre { font-size: 0.62rem; }
  .lib-card .lib-best { font-size: 0.64rem; }
  .lib-card .lib-badge { font-size: 0.56rem; top: 7px; right: 9px; padding: 2px 5px; }
  .lib-hint { font-size: 0.72rem; padding: 12px; }
}

/* Wider desktops: keep the square from getting absurdly large but fill nicely */
@media (min-width: 1280px) {
  .console-shell { height: min(92vh, 860px); max-height: 900px; }
}
