/* ========== RESET & BASE ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #00ff41;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* ========== INTRO SCREEN ========== */
#intro-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 1s ease;
}

#intro-screen.fade-out {
  opacity: 0;
}

#terminal {
  max-width: 600px;
  width: 90%;
  font-size: clamp(16px, 3vw, 24px);
  line-height: 1.8;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41, 0 0 20px #00ff41;
}

#terminal-text {
  white-space: pre-wrap;
}

#cursor {
  animation: blink 0.7s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ========== GAME CANVAS ========== */
#game-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}

/* ========== MATRIX RAIN ========== */
#rain-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.12;
}

/* ========== CROSSHAIR ========== */
#crosshair {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
  display: none;
}

#crosshair .ch-h,
#crosshair .ch-v {
  position: absolute;
  background: #00ff41;
  box-shadow: 0 0 4px #00ff41;
}

#crosshair .ch-h {
  width: 20px; height: 2px;
  top: -1px; left: -10px;
}

#crosshair .ch-v {
  width: 2px; height: 20px;
  top: -10px; left: -1px;
}

/* ========== RABBIT DIRECTION INDICATOR ========== */
#rabbit-indicator {
  position: fixed;
  top: 50%; left: 50%;
  width: 200px; height: 200px;
  margin-top: -100px; margin-left: -100px;
  z-index: 9;
  pointer-events: none;
  display: none;
}

#rabbit-arrow {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0.9;
  transform-origin: center 120px;
  -webkit-backface-visibility: hidden;
}


/* ========== UPSIDE DOWN WARNING ========== */
#upside-down-warning {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  pointer-events: none;
  font-size: clamp(28px, 6vw, 56px);
  font-weight: bold;
  color: #ff2222;
  text-shadow: 0 0 20px #ff2222, 0 0 40px #ff0000;
  letter-spacing: 6px;
  white-space: nowrap;
  animation: upside-blink 0.5s infinite;
}

@keyframes upside-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ========== HUD ========== */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  z-index: 20;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

#hud-left {
  display: flex;
  gap: 24px;
  align-items: center;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  text-shadow: 0 0 6px #00ff41;
}

.hud-label {
  opacity: 0.6;
  font-size: 11px;
  letter-spacing: 2px;
}

.hud-unit {
  opacity: 0.6;
  font-size: 12px;
}

#speed-bar-container {
  width: 100px;
  height: 6px;
  background: rgba(0, 255, 65, 0.15);
  border: 1px solid rgba(0, 255, 65, 0.3);
  border-radius: 3px;
  overflow: hidden;
}

#speed-bar {
  width: 0%;
  height: 100%;
  background: #00ff41;
  box-shadow: 0 0 8px #00ff41;
  transition: width 0.1s linear;
}

#speed-value {
  min-width: 36px;
  text-align: right;
}

#distance-value {
  min-width: 48px;
  text-align: right;
}

#hud-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#boost-label {
  font-size: 18px;
  font-weight: bold;
  color: #00ff41;
  text-shadow: 0 0 15px #00ff41, 0 0 30px #00ff41;
  letter-spacing: 6px;
  animation: pulse 0.3s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

#hud-right {
  text-align: right;
}

/* ========== ATTITUDE HUD (PITCH / ALT) ========== */
#attitude-hud {
  position: fixed;
  right: 20px;
  top: 70px;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

#hud-timer {
  font-size: 16px;
  letter-spacing: 2px;
  text-shadow: 0 0 8px #00ff41;
}

#speed-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#status-text {
  font-size: 10px;
  text-shadow: 0 0 6px #00ff41;
  opacity: 0.8;
  min-height: 14px;
  letter-spacing: 1px;
}

/* ========== GIVE UP BUTTON ========== */
#give-up-btn {
  position: fixed;
  top: 68px;
  right: 12px;
  z-index: 30;
  background: transparent;
  border: 1px solid rgba(0, 255, 65, 0.4);
  color: #00ff41;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  text-shadow: 0 0 4px #00ff41;
  pointer-events: auto;
  opacity: 0.6;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#give-up-btn:hover {
  opacity: 1;
  border-color: #00ff41;
}

/* ========== MUTE BUTTON ========== */
#mute-btn {
  position: fixed;
  top: 68px;
  right: 100px;
  z-index: 30;
  background: transparent;
  border: 1px solid rgba(0, 255, 65, 0.4);
  color: #00ff41;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  text-shadow: 0 0 4px #00ff41;
  pointer-events: auto;
  opacity: 0.6;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#mute-btn:hover {
  opacity: 1;
  border-color: #00ff41;
}

@media (max-width: 768px) {
  #mute-btn {
    top: 132px;
    right: 12px;
    font-size: 11px;
    padding: 5px 10px;
  }
}

/* ========== MOBILE CONTROLS ========== */
#mobile-controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 220px;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 24px;
  pointer-events: none;
}

#joystick-area {
  width: 150px;
  height: 150px;
  pointer-events: auto;
  touch-action: none;
  position: relative;
}

#joystick-base {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(0, 255, 65, 0.06);
  border: 2px solid rgba(0, 255, 65, 0.3);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 20px rgba(0, 255, 65, 0.05);
}

#joystick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(0, 255, 65, 0.2);
  border: 2px solid rgba(0, 255, 65, 0.6);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
  transition: box-shadow 0.1s;
}

#joystick-knob.active {
  background: rgba(0, 255, 65, 0.35);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
}

#boost-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 255, 65, 0.1);
  border: 2px solid rgba(0, 255, 65, 0.4);
  color: #00ff41;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  margin-bottom: 10px;
  text-shadow: 0 0 10px #00ff41;
}

#boost-btn:active, #boost-btn.active {
  background: rgba(0, 255, 65, 0.3);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.5), inset 0 0 20px rgba(0, 255, 65, 0.2);
}

/* ========== OVERLAY SCREEN ========== */
#overlay-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
}

#overlay-rain {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

#overlay-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#overlay-title {
  font-size: clamp(24px, 6vw, 48px);
  font-weight: bold;
  text-shadow: 0 0 20px #00ff41, 0 0 40px #00ff41;
  letter-spacing: 4px;
  margin-bottom: 16px;
  text-align: center;
}

#overlay-subtitle {
  font-size: clamp(12px, 2.5vw, 18px);
  opacity: 0.6;
  margin-bottom: 12px;
  text-align: center;
  padding: 0 20px;
}

#overlay-time {
  font-size: clamp(16px, 3vw, 24px);
  color: #00ff41;
  text-shadow: 0 0 8px #00ff41;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

#overlay-rank-info {
  font-size: clamp(12px, 2vw, 16px);
  color: #ffff00;
  text-shadow: 0 0 6px #ffff00;
  letter-spacing: 1px;
  margin-bottom: 24px;
}

#overlay-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.overlay-btn {
  background: transparent;
  border: 2px solid #00ff41;
  color: #00ff41;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  padding: 10px 28px;
  cursor: pointer;
  letter-spacing: 3px;
  text-shadow: 0 0 8px #00ff41;
  text-decoration: none;
  transition: all 0.2s;
  display: inline-block;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 5;
}

.overlay-btn:hover {
  background: rgba(0, 255, 65, 0.15);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

/* ========== RANKING MODAL ========== */
#ranking-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ranking-modal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
}

#ranking-modal-title {
  font-size: 20px;
  letter-spacing: 4px;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41;
  margin-bottom: 8px;
}

#ranking-name-input {
  background: transparent;
  border: 2px solid #00ff41;
  color: #00ff41;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  padding: 10px 16px;
  width: 100%;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  text-shadow: 0 0 4px #00ff41;
  touch-action: manipulation;
}

#ranking-name-input::placeholder {
  color: rgba(0, 255, 65, 0.3);
}

#ranking-name-input:focus {
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
}

#ranking-list {
  width: 100%;
  font-size: 14px;
  line-height: 2;
  letter-spacing: 1px;
}

.rank-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 8px;
  opacity: 0.7;
}

.rank-row.is-you {
  color: #ffff00;
  text-shadow: 0 0 8px #ffff00;
  opacity: 1;
  font-weight: bold;
}

.rank-pos { min-width: 40px; }
.rank-name { flex: 1; text-align: left; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; }
.rank-time { min-width: 60px; text-align: right; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  #hud {
    padding: 6px 12px;
    height: 50px;
  }

  .hud-item {
    font-size: 12px;
    gap: 4px;
  }

  .hud-label {
    font-size: 9px;
  }

  #speed-bar-container {
    width: 60px;
  }

  #status-text {
    font-size: 8px;
    min-height: 11px;
  }

  #attitude-hud {
    right: 12px;
    top: 56px;
  }

  #give-up-btn {
    top: 100px;
    right: 12px;
    font-size: 11px;
    padding: 5px 10px;
  }

  #crosshair .ch-h {
    width: 14px;
    left: -7px;
  }

  #crosshair .ch-v {
    height: 14px;
    top: -7px;
  }
}

/* ========== SCANLINE EFFECT ========== */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 999;
}
