:root {
  --ds-silver: #b8b8b8;
  --ds-silver-light: #d4d4d4;
  --ds-silver-dark: #8a8a8a;
  --ds-charcoal: #2a2a2a;
  --ds-blue: #5B9BD5;
  --ds-green: #00FF41;
  --ds-screen-bg: #1a1a2e;
  --ds-bezel: #0f0f0f;
  --ds-hinge: #6b6b6b;
}

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

body {
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a15 70%);
  background-attachment: fixed;
  min-height: 100vh;
  font-family: 'IBM Plex Mono', monospace;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.008) 2px, rgba(255,255,255,0.008) 4px);
  pointer-events: none;
  z-index: 0;
}

.pixel-font { font-family: 'Press Start 2P', monospace; }
.mono-font { font-family: 'IBM Plex Mono', monospace; }

/* DS Shell */
.ds-shell {
  position: relative;
  perspective: 1200px;
}

.ds-top-half {
  background: linear-gradient(180deg, #c8c8c8 0%, #a0a0a0 40%, #b0b0b0 60%, #959595 100%);
  border-radius: 16px 16px 0 0;
  padding: 14px;
  position: relative;
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 -2px 8px rgba(0,0,0,0.3);
}

.ds-top-half::before {
  content: '';
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #444 40%, #222 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
}

.ds-hinge {
  height: 10px;
  background: linear-gradient(180deg, #7a7a7a, #5a5a5a, #6a6a6a, #4a4a4a);
  position: relative;
  box-shadow: 
    inset 0 2px 3px rgba(0,0,0,0.4),
    inset 0 -1px 2px rgba(255,255,255,0.15);
}

.ds-hinge::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80%; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
}

.ds-bottom-half {
  background: linear-gradient(180deg, #a0a0a0 0%, #b0b0b0 20%, #c0c0c0 50%, #a8a8a8 100%);
  border-radius: 0 0 16px 16px;
  padding: 14px;
  padding-bottom: 20px;
  position: relative;
  box-shadow: 
    inset 0 -1px 0 rgba(255,255,255,0.3),
    0 4px 16px rgba(0,0,0,0.4);
}

/* Screens */
.ds-screen-bezel {
  background: #0a0a0a;
  border-radius: 4px;
  padding: 6px;
  box-shadow: 
    inset 0 2px 6px rgba(0,0,0,0.8),
    0 1px 0 rgba(255,255,255,0.15);
}

.ds-screen {
  width: 256px;
  height: 192px;
  background: var(--ds-screen-bg);
  position: relative;
  overflow: hidden;
  image-rendering: pixelated;
}

.ds-screen.off {
  background: #0a0a0a;
}

/* Screen scanlines */
.ds-screen::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.06) 1px,
    rgba(0,0,0,0.06) 2px
  );
  pointer-events: none;
  z-index: 10;
}

/* Power LED */
.power-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  position: absolute;
}

.power-led.on {
  background: #00ff41;
  box-shadow: 0 0 6px #00ff41, 0 0 12px #00ff4466;
  animation: led-pulse 2s ease-in-out infinite;
}

.power-led.off {
  background: #ff3333;
  box-shadow: 0 0 4px #ff333366;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* D-Pad */
.dpad {
  width: 60px;
  height: 60px;
  position: relative;
}

.dpad-btn {
  position: absolute;
  background: linear-gradient(180deg, #3a3a3a, #222);
  border: 1px solid #1a1a1a;
  cursor: pointer;
  transition: all 0.08s;
}

.dpad-btn:active {
  background: linear-gradient(180deg, #222, #1a1a1a);
  transform: scale(0.95);
}

.dpad-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  background: #2a2a2a;
  border-radius: 50%;
  z-index: 2;
}

.dpad-up, .dpad-down { width: 20px; height: 22px; left: 20px; border-radius: 3px; }
.dpad-up { top: 0; border-radius: 5px 5px 2px 2px; }
.dpad-down { bottom: 0; border-radius: 2px 2px 5px 5px; }
.dpad-left, .dpad-right { width: 22px; height: 20px; top: 20px; border-radius: 3px; }
.dpad-left { left: 0; border-radius: 5px 2px 2px 5px; }
.dpad-right { right: 0; border-radius: 2px 5px 5px 2px; }

/* Face buttons */
.face-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #1a1a1a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  color: #888;
  transition: all 0.08s;
  user-select: none;
}

.face-btn:active {
  transform: scale(0.9);
}

.face-btn-a { background: linear-gradient(180deg, #4a4a4a, #333); }
.face-btn-b { background: linear-gradient(180deg, #4a4a4a, #333); }
.face-btn-x { background: linear-gradient(180deg, #4a4a4a, #333); }
.face-btn-y { background: linear-gradient(180deg, #4a4a4a, #333); }

/* Start/Select */
.small-btn {
  width: 28px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(180deg, #5a5a5a, #3a3a3a);
  border: 1px solid #2a2a2a;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 5px;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all 0.08s;
}

.small-btn:active {
  transform: scale(0.92);
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
}

/* Shoulder buttons */
.shoulder-btn {
  height: 14px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #a0a0a0, #888);
  border: 1px solid #777;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all 0.08s;
}

.shoulder-btn:active {
  transform: scaleY(0.85);
  background: linear-gradient(180deg, #888, #777);
}

/* Boot animation */
@keyframes boot-glow {
  0% { opacity: 0; filter: brightness(0.3); }
  30% { opacity: 1; filter: brightness(1.5); }
  60% { opacity: 1; filter: brightness(1); }
  100% { opacity: 1; filter: brightness(1); }
}

@keyframes pixel-dissolve-in {
  0% { clip-path: inset(0 100% 0 0); }
  100% { clip-path: inset(0 0 0 0); }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.97; }
  75% { opacity: 0.99; }
}

.screen-flicker {
  animation: flicker 0.15s ease-in-out 3;
}

@keyframes scroll-hex {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

.hex-scroll {
  animation: scroll-hex 8s linear infinite;
}

/* Drop zone */
.drop-zone-active {
  animation: drop-pulse 0.8s ease-in-out infinite;
}

@keyframes drop-pulse {
  0%, 100% { box-shadow: inset 0 0 20px rgba(91,155,213,0.3); }
  50% { box-shadow: inset 0 0 30px rgba(91,155,213,0.6); }
}

/* Debug panel */
.debug-panel {
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

/* Register update flash */
@keyframes reg-flash {
  0% { color: #00ff41; }
  100% { color: #00aa2a; }
}

.reg-update {
  animation: reg-flash 0.3s ease-out;
}

/* Spinning cartridge */
@keyframes spin-cartridge {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

.spin-cart {
  animation: spin-cartridge 3s linear infinite;
}

/* Waveform */
@keyframes wave-move {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100px); }
}

/* Touch ripple */
@keyframes ripple-effect {
  0% { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}

.touch-ripple {
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(91, 155, 213, 0.4);
  animation: ripple-effect 0.5s ease-out forwards;
  pointer-events: none;
}

/* Memory bar */
.mem-bar {
  transition: width 0.5s ease;
}

/* Responsive */
@media (max-width: 360px) {
  .ds-screen {
    width: 224px;
    height: 168px;
  }
}

/* Footer */
.footer-link {
  color: #5B9BD5;
  text-decoration: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  transition: color 0.2s;
}
.footer-link:hover {
  color: #7db8e8;
}