* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --shell-hi: #5b5ba5;
  --shell: #45457f;
  --shell-lo: #2e2e5c;
  --bezel: #26263a;
  --bezel-hi: #3a3a54;
  --btn: #2b2b40;
  --btn-hi: #3d3d58;
  --ab: #9a4a8f;
  --ab-lo: #7a3570;
  --label: #b8b8d8;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% 15%, #1c2340 0%, #131828 45%, #0b0e1a 100%);
  font-family: 'Courier New', monospace;
  overflow: hidden;
  padding: 16px;
}

#stage { display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------- handheld shell ---------- */
#gba-shell {
  position: relative;
  background: linear-gradient(155deg, var(--shell-hi) 0%, var(--shell) 45%, var(--shell-lo) 100%);
  border-radius: 18px 18px 18px 74px;
  padding: 0 26px 30px;
  box-shadow:
    0 22px 60px rgba(0,0,0,0.65),
    0 4px 0 rgba(255,255,255,0.08) inset,
    0 -6px 14px rgba(0,0,0,0.35) inset;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

/* shoulder bar */
.shoulder-bar {
  display: flex; align-items: flex-end; justify-content: space-between;
  height: 26px; margin: 0 -10px; padding: 0 8px;
}
.shoulder-btn {
  width: 96px; height: 20px; border: none; cursor: pointer;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn));
  color: var(--label); font-family: inherit; font-size: 10px; font-weight: bold;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -2px 0 rgba(255,255,255,0.10) inset, 0 3px 5px rgba(0,0,0,0.4);
  transition: transform 0.05s, box-shadow 0.05s;
}
.shoulder-btn span { display: block; transform: translateY(-2px); letter-spacing: 1px; }
.shoulder-btn:active, .shoulder-btn.pressed { transform: translateY(3px); box-shadow: 0 -1px 0 rgba(255,255,255,0.06) inset, 0 1px 2px rgba(0,0,0,0.4); }
.shoulder-mid { flex: 1; height: 10px; background: linear-gradient(180deg, var(--shell-lo), var(--shell)); border-radius: 6px 6px 0 0; margin: 0 6px; }

/* main row */
.shell-main { display: flex; align-items: center; gap: 22px; margin-top: 14px; }

/* D-pad */
.controls-left { flex: 0 0 118px; display: flex; justify-content: center; }
.dpad { position: relative; width: 112px; height: 112px; }
.dpad-btn {
  position: absolute; background: linear-gradient(180deg, var(--btn-hi), var(--btn));
  border: none; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.45), 0 -1px 0 rgba(255,255,255,0.08) inset;
  transition: transform 0.05s, background 0.05s;
}
.dpad-btn::after { content: ''; position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-50%,-50%); }
.dpad-up::after { border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 6px solid #1a1a28; top: 30%; }
.dpad-down::after { border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid #1a1a28; top: 62%; }
.dpad-left::after { border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 6px solid #1a1a28; left: 26%; }
.dpad-right::after { border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 6px solid #1a1a28; left: 60%; }
.dpad-btn:active, .dpad-btn.pressed { background: #1c1c2c; transform: scale(0.96); }
.dpad-up { width: 38px; height: 40px; left: 37px; top: 0; border-radius: 6px 6px 0 0; }
.dpad-down { width: 38px; height: 40px; left: 37px; bottom: 0; border-radius: 0 0 6px 6px; }
.dpad-left { width: 40px; height: 38px; left: 0; top: 37px; border-radius: 6px 0 0 6px; }
.dpad-right { width: 40px; height: 38px; right: 0; top: 37px; border-radius: 0 6px 6px 0; }
.dpad-center { position: absolute; width: 38px; height: 38px; left: 37px; top: 37px; background: var(--btn); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,0.3) inset; }
.dpad-center::after { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #3d3d58, #22223a); }

/* screen */
.screen-area { display: flex; flex-direction: column; align-items: center; }
.power-row { display: flex; align-items: center; gap: 6px; align-self: flex-start; margin: 0 0 5px 6px; }
.power-led { width: 9px; height: 9px; border-radius: 50%; background: #ff3030; box-shadow: 0 0 7px #ff3030, 0 0 14px rgba(255,40,40,0.6); animation: led-pulse 3s ease-in-out infinite; }
@keyframes led-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.65; } }
.power-label { font-size: 7px; color: var(--label); letter-spacing: 2px; }

.screen-bezel {
  background: linear-gradient(160deg, var(--bezel-hi), var(--bezel) 55%, #1c1c2c);
  border-radius: 10px; padding: 14px 18px 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5) inset, 0 1px 0 rgba(255,255,255,0.07);
}
.bezel-inner {
  position: relative; background: #000;
  border: 2px solid #14141f; border-radius: 5px;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset, 0 0 24px rgba(0,0,0,0.8) inset;
}
#game-screen { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.screen-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(140,220,255,0.04) 2px, rgba(140,220,255,0.04) 3px);
  box-shadow: inset 0 0 24px rgba(120,200,255,0.18);
}
.bezel-label { text-align: center; font-size: 6px; color: #8888aa; letter-spacing: 2px; margin-top: 7px; }

/* A/B cluster */
.controls-right { flex: 0 0 150px; display: flex; justify-content: center; }
.ab-cluster { position: relative; width: 150px; height: 112px; transform: rotate(-18deg); }
.action-btn {
  position: absolute; width: 50px; height: 50px; border-radius: 50%; border: none;
  background: radial-gradient(circle at 32% 28%, #c06ab2, var(--ab) 55%, var(--ab-lo));
  color: #f0ddf0; font-size: 15px; font-weight: bold; font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5), 0 -2px 0 rgba(255,255,255,0.15) inset;
  transition: transform 0.05s, box-shadow 0.05s;
}
.action-btn:active, .action-btn.pressed { transform: translateY(3px) scale(0.96); box-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 -1px 0 rgba(255,255,255,0.08) inset; }
.a-btn { right: 6px; top: 12px; }
.b-btn { left: 14px; top: 48px; }

/* bottom row */
.bottom-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding: 0 6px; }
.meta-cluster { display: flex; gap: 26px; transform: translateX(10px); }
.meta-btn {
  background: none; border: none; cursor: pointer; color: var(--label);
  font-family: inherit; font-size: 8px; letter-spacing: 1.5px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.meta-pill { display: block; width: 46px; height: 11px; border-radius: 6px; background: linear-gradient(180deg, var(--btn-hi), var(--btn)); box-shadow: 0 2px 4px rgba(0,0,0,0.45), 0 -1px 0 rgba(255,255,255,0.08) inset; transition: transform 0.05s, background 0.05s; }
.meta-btn:active .meta-pill, .meta-btn.pressed .meta-pill { transform: translateY(2px); background: #1c1c2c; }

.speaker-grille { display: flex; gap: 5px; transform: rotate(-18deg) translateX(-6px); }
.grille-col { display: flex; flex-direction: column; gap: 5px; }
.grille-col i { width: 5px; height: 5px; border-radius: 50%; background: #24243c; box-shadow: 0 1px 0 rgba(255,255,255,0.08), 0 -1px 2px rgba(0,0,0,0.6) inset; }
.grille-col:nth-child(2) { transform: translateY(4px); }
.grille-col:nth-child(3) { transform: translateY(8px); }
.grille-col:nth-child(4) { transform: translateY(12px); }
.grille-col:nth-child(5) { transform: translateY(16px); }
.grille-col:nth-child(6) { transform: translateY(20px); }

.shell-brand {
  position: absolute; left: 30px; bottom: 10px;
  font-size: 12px; font-weight: bold; color: var(--label); letter-spacing: 2px;
}
.shell-brand span { font-weight: normal; font-size: 9px; color: #9090b8; margin-left: 3px; }
.shell-brand em { font-style: normal; display: block; font-size: 7px; letter-spacing: 4px; color: #7878a0; }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; gap: 10px; }
.hud-btn {
  background: #2a2f4a; border: 1px solid #444a70; color: #a8b0d8;
  font-family: inherit; font-size: 11px; padding: 5px 14px; border-radius: 5px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hud-btn:hover { background: #363c60; }
.hud-btn.active { background: #3a5a44; border-color: #5a8a66; color: #c8f0d0; }
.key-hint { font-size: 9px; color: #5a6088; letter-spacing: 0.5px; }

@media (max-width: 900px) { #stage { transform: scale(0.8); transform-origin: top center; } }
@media (max-width: 700px) { #stage { transform: scale(0.62); transform-origin: top center; } .key-hint { display: none; } }
@media (max-width: 520px) { #stage { transform: scale(0.48); transform-origin: top center; } }
