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

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

body {
  background: #000;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  cursor: none;
  width: 100vw;
  height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#scene-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#scene-container canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

#crt-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.12) 0px,
    rgba(0,0,0,0.12) 1px,
    transparent 1px,
    transparent 2px
  );
}

#vignette-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 101;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}

/* === HUD TOP BAR === */
#hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 36px;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  z-index: 200;
  border-bottom: 2px solid #333;
  gap: 4px;
}

#hud-clock {
  color: #0f0;
  font-size: 10px;
  letter-spacing: 2px;
  text-shadow: 0 0 4px #0f0;
  flex-shrink: 0;
  min-width: 60px;
}

#hud-title {
  color: #ffd700;
  font-size: 9px;
  text-shadow: 1px 1px 0 #000, 0 0 8px rgba(255,215,0,0.3);
  animation: shimmer 3s ease-in-out infinite;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  flex: 1;
  min-width: 0;
}

@keyframes shimmer {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(5deg); }
}

#hud-icons {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.hud-btn {
  color: #ccc;
  font-size: 16px;
  cursor: none;
  padding: 4px 6px;
  background: none;
  border: 1px solid transparent;
  font-family: inherit;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.hud-btn:hover, .hud-btn:active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-color: #555;
}

/* === PERF COUNTER === */
#perf-counter {
  position: fixed;
  bottom: 40px;
  right: 8px;
  z-index: 200;
  color: #0f0;
  font-size: 7px;
  text-shadow: 0 0 3px #0f0;
  line-height: 1.5;
  text-align: right;
  pointer-events: none;
}

.hidden { display: none !important; }

/* === CONTROLS OVERLAY === */
#controls-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAADklEQVQIW2NkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==");
  background-size: 2px 2px;
}

.overlay-panel {
  background: #111;
  border: 2px solid #555;
  padding: 16px 20px;
  max-width: 400px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
}

.overlay-panel h2 {
  color: #ffd700;
  font-size: 11px;
  margin-bottom: 12px;
  text-align: center;
  border-bottom: 1px solid #444;
  padding-bottom: 8px;
}

.control-row {
  color: #aaa;
  font-size: 7px;
  margin: 5px 0;
  display: flex;
  gap: 8px;
  align-items: center;
}

.key {
  display: inline-block;
  background: #333;
  color: #fff;
  padding: 3px 6px;
  border: 1px solid #666;
  min-width: 60px;
  text-align: center;
  font-size: 6px;
  flex-shrink: 0;
}

/* === SETTINGS PANEL === */
#settings-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAADklEQVQIW2NkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==");
  background-size: 2px 2px;
}

.settings-inner {
  background: #111;
  border: 2px solid #555;
  padding: 16px 18px;
  width: 300px;
  max-width: 92vw;
}

.settings-inner h2 {
  color: #ffd700;
  font-size: 10px;
  margin-bottom: 12px;
  text-align: center;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  color: #ccc;
  font-size: 7px;
  gap: 8px;
}

.setting-row label {
  flex-shrink: 0;
}

.toggle-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  background: #333;
  color: #0f0;
  border: 2px solid #555;
  padding: 6px 12px;
  cursor: none;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}

.toggle-btn:hover, .toggle-btn:active { background: #444; }

.retro-slider {
  width: 80px;
  accent-color: #ffd700;
  cursor: none;
  min-height: 32px;
}

.retro-select {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  background: #222;
  color: #0f0;
  border: 2px solid #555;
  padding: 4px;
  cursor: none;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}

.retro-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  background: #333;
  color: #ffd700;
  border: 2px solid #666;
  padding: 8px 16px;
  margin-top: 12px;
  display: block;
  width: 100%;
  cursor: none;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}

.retro-btn:hover, .retro-btn:active { background: #444; }

/* === TERMINAL MODAL === */
#terminal-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.92);
}

.terminal-inner {
  width: 480px;
  max-width: 94vw;
  background: #001a00;
  border: 3px solid #0a3a0a;
  box-shadow: 0 0 30px rgba(0,255,0,0.15), inset 0 0 60px rgba(0,255,0,0.05);
  padding: 16px;
  max-height: 80vh;
  overflow-y: auto;
}

#terminal-screen {
  color: #0f0;
  font-size: 8px;
  line-height: 1.6;
  min-height: 160px;
  text-shadow: 0 0 5px rgba(0,255,0,0.5);
  word-break: break-all;
}

#terminal-text {
  margin: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  white-space: pre-wrap;
}

#terminal-cursor {
  animation: blink 0.6s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.terminal-footer {
  color: #0a0;
  font-size: 7px;
  text-align: center;
  margin-top: 12px;
  border-top: 1px solid #0a3a0a;
  padding-top: 8px;
}

/* === DEBUG OVERLAY === */
#debug-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  text-align: center;
  pointer-events: none;
}

#debug-text {
  color: #fff;
  font-size: 14px;
  animation: flashDebug 0.3s steps(1) infinite;
}

@keyframes flashDebug {
  50% { color: #f00; }
}

#debug-timer {
  color: #ff0;
  font-size: 9px;
  margin-top: 8px;
}

/* === REMIX FOOTER === */
#remix-footer {
  position: fixed;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
}

#remix-footer a {
  color: #444;
  font-size: 6px;
  font-family: 'Press Start 2P', monospace;
  text-decoration: none;
}

#remix-footer a:hover { color: #888; }

/* === CUSTOM CURSOR === */
#custom-cursor {
  position: fixed;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 9999;
  image-rendering: pixelated;
}

/* === MOBILE CONTROLS === */
#mobile-controls {
  display: none;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  body {
    cursor: auto;
  }
  
  #custom-cursor {
    display: none !important;
  }
  
  #hud-top {
    height: 32px;
    padding: 0 4px;
  }
  
  #hud-clock {
    font-size: 8px;
    min-width: 50px;
    letter-spacing: 1px;
  }
  
  #hud-title {
    font-size: 7px;
  }
  
  .hud-btn {
    font-size: 14px;
    min-width: 28px;
    min-height: 28px;
    padding: 2px 4px;
  }
  
  #perf-counter {
    bottom: 70px;
    right: 4px;
    font-size: 6px;
  }
  
  #mobile-controls {
    display: flex;
    position: fixed;
    bottom: 8px;
    left: 8px;
    right: 8px;
    z-index: 200;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
  }
  
  #mobile-dpad {
    position: relative;
    width: 110px;
    height: 110px;
    pointer-events: auto;
  }
  
  .dpad-btn {
    position: absolute;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  
  .dpad-btn:active {
    background: rgba(255,255,255,0.35);
  }
  
  .dpad-up { top: 0; left: 37px; }
  .dpad-down { bottom: 0; left: 37px; }
  .dpad-left { top: 37px; left: 0; }
  .dpad-right { top: 37px; right: 0; }
  
  #mobile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    pointer-events: auto;
  }
  
  .action-btn {
    width: 44px;
    height: 36px;
    background: rgba(255,215,0,0.15);
    border: 2px solid rgba(255,215,0,0.3);
    color: #ffd700;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  
  .action-btn:active {
    background: rgba(255,215,0,0.35);
  }
  
  .control-row {
    font-size: 6px;
  }
  
  .key {
    font-size: 5px;
    min-width: 50px;
    padding: 2px 4px;
  }
  
  #debug-text {
    font-size: 10px;
  }
}

@media (max-width: 400px) {
  #hud-title {
    font-size: 6px;
  }
  
  #hud-clock {
    font-size: 7px;
  }
}