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

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

body {
  background: #050000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  touch-action: none;
  user-select: none;
}

/* iOS Safari: ensure buttons respond to touch despite body touch-action: none */
button, input, .start-overlay {
  touch-action: manipulation;
}

.cabinet {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 480px;
  max-height: 100vh;
  background: #0a0000;
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* === HUD === */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.hud-score {
  color: #FFD700;
  font-size: 14px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.hud-best {
  color: #888;
  font-size: 10px;
}

.hud-world {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  color: #FF6600;
  font-size: 8px;
  opacity: 0;
  letter-spacing: 2px;
  transition: opacity 1.5s, font-size 1.5s;
}

/* === START OVERLAY === */
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 0, 0, 0.92);
  z-index: 30;
  cursor: pointer;
}

.start-overlay .logo {
  color: #FF4400;
  font-size: 22px;
  text-shadow:
    0 0 20px rgba(255, 68, 0, 0.8),
    0 0 40px rgba(255, 68, 0, 0.4),
    0 0 80px rgba(255, 68, 0, 0.2);
  margin-bottom: 4px;
  letter-spacing: 4px;
  animation: fire-pulse 2s ease-in-out infinite;
}

.start-overlay .sub {
  color: #FFD700;
  font-size: 10px;
  margin-bottom: 40px;
  letter-spacing: 3px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.start-overlay .world-preview {
  color: #FF6600;
  font-size: 8px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.start-overlay .prompt {
  color: #CC3333;
  font-size: 8px;
  animation: blink 1.2s ease-in-out infinite;
  letter-spacing: 2px;
  margin-top: 30px;
}

.start-overlay .credits {
  position: absolute;
  bottom: 20px;
  color: #331111;
  font-size: 6px;
}

#start-btn {
  background: linear-gradient(180deg, #FF4400, #AA2200);
  border: 2px solid #FF6600;
  color: #FFD700;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  padding: 12px 30px;
  cursor: pointer;
  border-radius: 4px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  transition: all 0.2s;
  margin-top: 20px;
}

#start-btn:hover {
  background: linear-gradient(180deg, #FF6600, #CC3300);
  transform: scale(1.05);
}

/* === DEATH OVERLAY === */
.death-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 0, 0, 0.88);
  z-index: 30;
  overflow-y: auto;
  padding: 20px 0;
}

.death-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.death-leaderboard {
  width: 90%;
  max-width: 360px;
}

.death-title {
  color: #FF0000;
  font-size: 28px;
  text-shadow: 0 0 30px rgba(255, 0, 0, 0.7);
  margin-bottom: 20px;
  animation: fire-pulse 1s ease-in-out infinite;
}

.death-score {
  color: #FFD700;
  font-size: 14px;
  margin-bottom: 8px;
}

.death-best {
  color: #888;
  font-size: 10px;
  margin-bottom: 8px;
}

.death-world {
  color: #FF6600;
  font-size: 8px;
  margin-bottom: 30px;
  opacity: 0.6;
}

.death-btn {
  background: linear-gradient(180deg, #FF4400, #AA2200);
  border: 2px solid #FF6600;
  color: #FFD700;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 10px 24px;
  cursor: pointer;
  border-radius: 4px;
}

/* === AUDIO PANEL === */
.audio-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.audio-toggle {
  background: rgba(0,0,0,0.6);
  border: 1px solid #444;
  color: #FF6600;
  font-size: 14px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s;
}
.audio-toggle:hover,
.audio-toggle:active {
  border-color: #FF6600;
  color: #FFD700;
}

.audio-sliders {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: rgba(0,0,0,0.8);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 130px;
}
.audio-sliders.open {
  display: flex;
}

.audio-sliders label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #888;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  letter-spacing: 1px;
}
.audio-sliders label span {
  width: 24px;
  text-align: right;
  color: #FF6600;
}

/* Range slider — metal style */
.audio-sliders input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 6px;
  background: #222;
  border-radius: 3px;
  outline: none;
  border: 1px solid #333;
}
.audio-sliders input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: linear-gradient(180deg, #FF6600, #AA2200);
  border: 2px solid #FFD700;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(255,102,0,0.5);
}

/* === PAUSE BUTTON === */
.pause-btn {
  position: absolute;
  top: 12px;
  right: 50px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #444;
  color: #FF6600;
  font-size: 12px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
  letter-spacing: -2px;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.pause-btn:hover,
.pause-btn:active {
  border-color: #FF6600;
  color: #FFD700;
  background: rgba(0, 0, 0, 0.7);
}

/* === PAUSE OVERLAY === */
.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 50;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.overlay-content h2 {
  color: #FF4400;
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  letter-spacing: 4px;
  text-shadow:
    0 0 20px rgba(255, 68, 0, 0.8),
    0 0 40px rgba(255, 68, 0, 0.4);
  margin-bottom: 10px;
  animation: fire-pulse 2s ease-in-out infinite;
}

.metal-btn {
  background: linear-gradient(180deg, #FF4400, #AA2200);
  border: 2px solid #FF6600;
  color: #FFD700;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 10px 28px;
  cursor: pointer;
  border-radius: 4px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  transition: all 0.2s;
  min-width: 200px;
}
.metal-btn:hover {
  background: linear-gradient(180deg, #FF6600, #CC3300);
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(255, 102, 0, 0.5);
}

.pause-volume {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 14px 18px;
  min-width: 200px;
}

.pause-volume label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #FF6600;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  letter-spacing: 1px;
}

.pause-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 6px;
  background: #222;
  border-radius: 3px;
  outline: none;
  border: 1px solid #333;
}
.pause-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: linear-gradient(180deg, #FF6600, #AA2200);
  border: 2px solid #FFD700;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(255, 102, 0, 0.5);
}

/* === NAME INPUT (DEATH SCREEN) === */
.name-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.name-input-group label {
  color: #FF6600;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  letter-spacing: 2px;
}

.name-input-group input[type="text"] {
  background: rgba(10, 0, 0, 0.8);
  border: 2px solid #FF6600;
  border-radius: 4px;
  color: #FFD700;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  padding: 8px 14px;
  text-align: center;
  max-width: 200px;
  width: 100%;
  outline: none;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.name-input-group input[type="text"]::placeholder {
  color: #553300;
  opacity: 1;
}
.name-input-group input[type="text"]:focus {
  border-color: #FFD700;
  box-shadow: 0 0 12px rgba(255, 102, 0, 0.5), 0 0 24px rgba(255, 68, 0, 0.2);
}

/* === ANIMATIONS === */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

@keyframes fire-pulse {
  0%, 100% {
    text-shadow: 0 0 20px rgba(255,68,0,0.8), 0 0 40px rgba(255,68,0,0.4);
  }
  50% {
    text-shadow: 0 0 30px rgba(255,100,0,1), 0 0 60px rgba(255,68,0,0.6);
  }
}

.hidden { display: none !important; }

/* === MOBILE === */
@media (min-width: 500px) {
  .cabinet {
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
      0 0 40px rgba(255, 68, 0, 0.2),
      0 0 80px rgba(255, 68, 0, 0.1);
    max-height: 90vh;
  }
}
