@tailwind base;

:root {
  --amber: #ffaa00;
  --orange: #ff6600;
  --crt-green: #33ff33;
  --dark-navy: #0d0d1a;
  --surface: #1a1a2e;
  --surface2: #2a2a3e;
}

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

body {
  font-family: 'Fira Code', monospace;
  background: var(--dark-navy);
  color: #e0e0e0;
  overflow-x: hidden;
}

.font-retro { font-family: 'Press Start 2P', cursive; }
.font-mono { font-family: 'Fira Code', monospace; }

/* Scanline overlay */
.scanlines {
  position: relative;
}
.scanlines::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
  z-index: 2;
}

/* CRT effect on canvas */
.crt-wrapper {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
}

.crt-wrapper.crt-enabled::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.12) 1px,
    rgba(0,0,0,0.12) 2px
  );
  pointer-events: none;
  z-index: 5;
}

.crt-wrapper.crt-enabled::after {
  content: '';
  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: 6;
}

.crt-wrapper.crt-enabled canvas {
  filter: brightness(1.1) contrast(1.1) saturate(1.2);
}

/* Wood grain TV bezel */
.tv-bezel {
  background:
    linear-gradient(135deg, #5a3a1a 0%, #8b6914 20%, #6b4a1e 40%, #9b7424 60%, #5a3a1a 80%, #8b6914 100%);
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.1),
    inset 0 -2px 4px rgba(0,0,0,0.3),
    0 8px 32px rgba(0,0,0,0.6),
    0 2px 8px rgba(0,0,0,0.4);
  position: relative;
}

.tv-bezel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 24px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    rgba(0,0,0,0.03) 1px,
    transparent 2px,
    transparent 6px
  );
  pointer-events: none;
}

/* Cartridge slot styling */
.cartridge-slot {
  background: linear-gradient(180deg, #0a0a15 0%, #15152a 50%, #0a0a15 100%);
  border: 3px solid #2a2a3e;
  box-shadow:
    inset 0 4px 12px rgba(0,0,0,0.8),
    inset 0 -2px 6px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.05);
  border-radius: 8px;
}

/* Pulsing glow */
@keyframes pulseGlow {
  0%, 100% { text-shadow: 0 0 8px rgba(255,170,0,0.4); }
  50% { text-shadow: 0 0 20px rgba(255,170,0,0.8), 0 0 40px rgba(255,102,0,0.4); }
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* LED indicators */
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.3);
}

.led-red {
  background: #cc0000;
  box-shadow: 0 0 4px #cc0000, inset 0 1px 2px rgba(255,255,255,0.3);
}

.led-green {
  background: #00cc00;
  box-shadow: 0 0 8px #00cc00, 0 0 16px rgba(0,204,0,0.3), inset 0 1px 2px rgba(255,255,255,0.3);
}

/* Physical button style */
.phys-btn {
  background: linear-gradient(180deg, #3a3a4e 0%, #2a2a3e 50%, #1a1a2e 100%);
  border: 1px solid #4a4a5e;
  border-radius: 6px;
  box-shadow:
    0 3px 0 #0a0a15,
    0 4px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.08s ease;
  cursor: pointer;
  user-select: none;
}

.phys-btn:active, .phys-btn.pressed {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #0a0a15,
    0 1px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Toggle switch */
.toggle-switch {
  width: 48px;
  height: 24px;
  background: #1a1a2e;
  border-radius: 12px;
  border: 2px solid #3a3a4e;
  cursor: pointer;
  position: relative;
  transition: background 0.3s;
}

.toggle-switch.on {
  background: #1a4a1a;
  border-color: #33ff33;
}

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

.toggle-switch.on .toggle-knob {
  left: 25px;
  background: linear-gradient(180deg, #55ff55 0%, #33cc33 100%);
}

/* Gradient accent line */
.accent-line {
  height: 3px;
  background: linear-gradient(90deg, #ff6600, #ffaa00, #ff6600);
}

/* Controller d-pad */
.dpad-btn {
  background: linear-gradient(180deg, #333 0%, #222 100%);
  border: 1px solid #444;
  color: #888;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.05s;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: linear-gradient(180deg, #444 0%, #333 100%);
  color: var(--amber);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
}

/* Keypad button */
.keypad-btn {
  background: linear-gradient(180deg, #2a2a3e 0%, #1a1a2e 100%);
  border: 1px solid #3a3a4e;
  border-radius: 4px;
  color: #aaa;
  font-family: 'Press Start 2P', cursive;
  font-size: 10px;
  cursor: pointer;
  user-select: none;
  transition: all 0.05s;
  box-shadow: 0 2px 0 #0a0a15;
}

.keypad-btn:active, .keypad-btn.pressed {
  transform: translateY(1px);
  box-shadow: 0 0 0 #0a0a15;
  background: linear-gradient(180deg, #3a3a4e 0%, #2a2a3e 100%);
  color: var(--amber);
}

/* Fire button */
.fire-btn {
  background: linear-gradient(180deg, #8b2020 0%, #6b1010 100%);
  border: 2px solid #aa3030;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  color: #ff6666;
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 3px 0 #3a0808, 0 4px 8px rgba(0,0,0,0.4);
  transition: all 0.05s;
}

.fire-btn:active, .fire-btn.pressed {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a0808;
}

/* CRT power on */
@keyframes crtPowerOn {
  0% { transform: scaleY(0.005) scaleX(0.5); filter: brightness(10); }
  30% { transform: scaleY(0.005) scaleX(1); filter: brightness(5); }
  50% { transform: scaleY(1) scaleX(1); filter: brightness(2); }
  100% { transform: scaleY(1) scaleX(1); filter: brightness(1); }
}

.crt-power-on {
  animation: crtPowerOn 0.5s ease-out forwards;
}

/* Debug panel */
.debug-panel {
  background: #0a0f0a;
  border: 1px solid #1a3a1a;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  color: #33ff33;
}

.debug-panel .register-changed {
  color: #ffaa00;
  font-weight: bold;
}

/* Scrollbar styling for debug */
.debug-panel::-webkit-scrollbar { width: 6px; }
.debug-panel::-webkit-scrollbar-track { background: #0a0f0a; }
.debug-panel::-webkit-scrollbar-thumb { background: #1a3a1a; border-radius: 3px; }

/* Collapsible section */
.collapse-header {
  cursor: pointer;
  user-select: none;
}

.collapse-header:hover {
  color: var(--amber);
}

/* Volume slider */
input[type="range"] {
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-track {
  height: 4px;
  background: #2a2a3e;
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--amber);
  border-radius: 50%;
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(255,170,0,0.4);
}

/* Mobile */
@media (max-width: 768px) {
  .tv-bezel { padding: 12px; border-radius: 16px; }
  .fire-btn { width: 48px; height: 48px; }
}