@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  font-family: 'Press Start 2P', monospace;
  background: #0d0d1a;
  color: #f0f0e8;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Wood grain background */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(139, 90, 43, 0.03) 2px,
      rgba(139, 90, 43, 0.03) 4px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 20px,
      rgba(139, 90, 43, 0.02) 20px,
      rgba(139, 90, 43, 0.02) 22px
    ),
    radial-gradient(ellipse at 50% 0%, #1a1a2e 0%, #0d0d1a 70%);
  z-index: -1;
}

/* CRT Monitor Bezel */
.crt-bezel {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border-radius: 20px;
  padding: 20px;
  position: relative;
  box-shadow: 
    0 0 0 3px #333,
    0 0 0 6px #1a1a1a,
    inset 0 0 30px rgba(0,0,0,0.5),
    0 20px 60px rgba(0,0,0,0.8);
}

.crt-bezel::before {
  content: '';
  position: absolute;
  top: 8px; left: 8px;
  width: 8px; height: 8px;
  background: radial-gradient(circle, #555 30%, #333 70%);
  border-radius: 50%;
  box-shadow: 
    calc(100% - 16px) 0 0 0 #444,
    0 calc(100% - 16px) 0 0 #444,
    calc(100% - 16px) calc(100% - 16px) 0 0 #444;
}

/* CRT Screen Effect */
.crt-screen {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  width: 100%;
  min-height: 100px;
}

.crt-screen canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  height: auto;
  aspect-ratio: 256 / 240;
}

/* Scanlines overlay */
.crt-scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 2;
}

/* RGB pixel grid */
.crt-rgb-grid {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03) 0px,
    rgba(0, 255, 0, 0.03) 1px,
    rgba(0, 0, 255, 0.03) 2px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 2;
}

/* Vignette */
.crt-vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
  pointer-events: none;
  z-index: 3;
}

/* Screen curvature */
.crt-curve {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.3);
  pointer-events: none;
  z-index: 4;
}

/* CRT reflection */
.crt-reflection {
  position: absolute;
  top: 5%; left: 10%;
  width: 80%; height: 30%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 100%
  );
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

/* Power LED */
.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  transition: all 0.3s;
}

.power-led.on {
  background: #e23636;
  box-shadow: 0 0 6px #e23636, 0 0 12px rgba(226, 54, 54, 0.5);
  animation: led-pulse 2s ease-in-out infinite;
}

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

/* NES Controller */
.nes-controller {
  background: linear-gradient(180deg, #d4d0c8, #bbb8b0);
  border-radius: 8px;
  padding: 16px;
  position: relative;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.1);
  border: 2px solid #2a2a2a;
}

.nes-controller::before {
  content: '';
  position: absolute;
  top: 0; left: 30%; right: 30%;
  height: 3px;
  background: #1a1a2e;
  border-radius: 0 0 4px 4px;
}

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

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

.dpad-btn {
  position: absolute;
  background: linear-gradient(145deg, #3a3a3a, #252525);
  border: none;
  cursor: pointer;
  transition: all 0.05s;
  z-index: 2;
}

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

.dpad-up {
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 32px;
  border-radius: 4px 4px 0 0;
}

.dpad-down {
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 32px;
  border-radius: 0 0 4px 4px;
}

.dpad-left {
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 28px;
  border-radius: 4px 0 0 4px;
}

.dpad-right {
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 28px;
  border-radius: 0 4px 4px 0;
}

/* Action buttons */
.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e84040, #c02828);
  border: 2px solid #8a1a1a;
  color: #f0f0e8;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 
    0 3px 0 #8a1a1a,
    0 4px 8px rgba(0,0,0,0.3);
  transition: all 0.05s;
}

.action-btn:active, .action-btn.pressed {
  box-shadow: 0 1px 0 #8a1a1a;
  transform: translateY(2px);
}

/* Select/Start buttons */
.system-btn {
  width: 48px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, #555, #3a3a3a);
  border: 1px solid #222;
  cursor: pointer;
  box-shadow: 0 2px 0 #222;
  transition: all 0.05s;
}

.system-btn:active, .system-btn.pressed {
  box-shadow: 0 0 0 #222;
  transform: translateY(2px);
}

/* Control bar buttons */
.ctrl-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 8px 12px;
  border: 2px solid #444;
  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
  color: #f0f0e8;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 0 #111;
  transition: all 0.1s;
  white-space: nowrap;
}

.ctrl-btn:hover {
  background: linear-gradient(180deg, #4a4a4a, #3a3a3a);
  border-color: #d4a039;
}

.ctrl-btn:active {
  box-shadow: 0 1px 0 #111;
  transform: translateY(2px);
}

.ctrl-btn.primary {
  border-color: #e23636;
  background: linear-gradient(180deg, #c02828, #a02020);
}

.ctrl-btn.primary:hover {
  background: linear-gradient(180deg, #e23636, #c02828);
}

/* Power switch */
.power-switch {
  width: 48px;
  height: 24px;
  background: #222;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  border: 2px solid #444;
}

.power-switch-knob {
  width: 20px;
  height: 18px;
  background: linear-gradient(180deg, #888, #666);
  border-radius: 2px;
  position: absolute;
  top: 1px;
  left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.power-switch.on .power-switch-knob {
  left: 24px;
}

/* CRT power on animation */
@keyframes crt-power-on {
  0% { transform: scaleY(0.005) scaleX(0.8); opacity: 0.5; }
  20% { transform: scaleY(0.005) scaleX(1); opacity: 1; }
  50% { transform: scaleY(1) scaleX(1); opacity: 1; }
  100% { transform: scaleY(1) scaleX(1); opacity: 1; }
}

.crt-powering-on {
  animation: crt-power-on 0.6s ease-out forwards;
}

/* Static / Snow animation */
@keyframes static-flicker {
  0% { opacity: 0.8; }
  50% { opacity: 0.5; }
  100% { opacity: 0.8; }
}

/* Blink animation */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.blink {
  animation: blink 1s step-end infinite;
}

/* Title shimmer */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.shimmer-text {
  background: linear-gradient(
    90deg,
    #f0f0e8 0%,
    #f0f0e8 40%,
    #d4a039 50%,
    #f0f0e8 60%,
    #f0f0e8 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s linear infinite;
}

/* Settings drawer */
.settings-drawer {
  position: fixed;
  top: 0; right: -360px;
  width: 340px;
  height: 100%;
  background: #1a1a2e;
  border-left: 3px solid #d4a039;
  z-index: 100;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 20px;
}

.settings-drawer.open {
  right: 0;
}

.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* Cartridge mini card */
.cart-card {
  background: linear-gradient(180deg, #555, #3a3a3a);
  border-radius: 4px 4px 0 0;
  padding: 8px;
  width: 80px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s;
  border: 1px solid #666;
}

.cart-card:hover {
  transform: translateY(-4px);
  border-color: #d4a039;
}

.cart-card::before {
  content: '';
  display: block;
  width: 30px;
  height: 6px;
  background: #222;
  margin: 0 auto 6px;
  border-radius: 2px;
}

/* Volume knob */
.volume-knob {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  outline: none;
}

.volume-knob::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, #d4a039, #a07828);
  cursor: pointer;
  border: 2px solid #705020;
}

/* Speed selector */
.speed-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 4px 6px;
  border: 1px solid #444;
  background: #2a2a2a;
  color: #8d8d8d;
  cursor: pointer;
  border-radius: 2px;
}

.speed-btn.active {
  background: #d4a039;
  color: #1a1a2e;
  border-color: #d4a039;
}

/* Guru meditation error */
@keyframes guru-flash {
  0%, 100% { border-color: #e23636; }
  50% { border-color: #000; }
}

.guru-meditation {
  border: 4px solid #e23636;
  animation: guru-flash 1s infinite;
  padding: 20px;
  text-align: center;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #d4a039; }

/* Tooltip */
.key-tooltip {
  font-size: 6px;
  background: rgba(0,0,0,0.8);
  padding: 2px 4px;
  border-radius: 2px;
  color: #d4a039;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .crt-bezel { padding: 10px; border-radius: 12px; }
  .nes-controller { padding: 10px; }
  .dpad { width: 76px; height: 76px; }
  .dpad-up, .dpad-down { width: 24px; height: 28px; }
  .dpad-left, .dpad-right { width: 28px; height: 24px; }
  .dpad-center { width: 24px; height: 24px; }
  .action-btn { width: 40px; height: 40px; font-size: 8px; }
}