@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  background: #0a0a0a;
  font-family: "Orbitron", monospace;
  color: #00ff00;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: -webkit-fill-available;
  /* Safari mobile fix */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#gameContainer {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#gameCanvas {
  background: linear-gradient(
    to bottom,
    #4a2818 0%,
    #6a3825 20%,
    #8a4832 40%,
    #aa5840 60%,
    #ca6850 80%,
    #ea7860 100%
  );
  border: 2px solid #ff6600;
  box-shadow: 0 0 20px #ff6600;
  flex: 1;
  width: 100%;
  image-rendering: pixelated;
}

#ui {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border: 1px solid #00ff00;
  border-radius: 5px;
  width: 180px;
  font-size: 12px;
}

#highScores {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border: 1px solid #ff6600;
  border-radius: 5px;
  width: 200px;
  font-size: 11px;
}

#highScores h3 {
  color: #ff6600;
  margin-bottom: 8px;
  text-align: center;
  font-size: 14px;
}

.score-entry {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  padding: 2px;
}

.score-rank {
  color: #ffaa00;
  width: 20px;
}

.score-name {
  color: #00ff00;
  flex: 1;
  margin: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-points {
  color: #ffffff;
}

.warning {
  color: #ff0000 !important;
  animation: blink 0.5s infinite alternate;
}

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

  100% {
    opacity: 0.7;
  }
}

#controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  margin-bottom: 20px;
  /* Extra space for Safari UI */
}

.control-btn {
  width: 80px;
  height: 80px;
  background: linear-gradient(
    45deg,
    rgba(51, 51, 51, 0.7),
    rgba(85, 85, 85, 0.7)
  );
  border: 3px solid rgba(0, 255, 0, 0.7);
  border-radius: 50%;
  color: rgba(0, 255, 0, 0.7);
  font-family: "Orbitron", monospace;
  font-weight: bold;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
  transition: all 0.1s;
  opacity: 0.5;
}

.control-btn:active {
  background: linear-gradient(45deg, #555, #777);
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.6);
  transform: scale(0.95);
}

#thrustBtn {
  background: linear-gradient(45deg, #660000, #880000);
  border-color: #ff0000;
  color: #ff0000;
  width: 100px;
  height: 100px;
}

#thrustBtn:active {
  background: linear-gradient(45deg, #880000, #aa0000);
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

#gameOver {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  border: 3px solid #ff6600;
  border-radius: 10px;
  padding: 30px;
  text-align: center;
  z-index: 20;
  display: none;
  box-shadow: 0 0 30px rgba(255, 102, 0, 0.5);
  max-width: 400px;
}

#nameInput {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #00ff00;
  color: #00ff00;
  font-family: "Orbitron", monospace;
  padding: 10px;
  margin: 15px 0;
  border-radius: 5px;
  text-align: center;
  width: 100%;
  font-size: 16px;
}

#nameInput::placeholder {
  color: #008800;
}

.btn {
  background: linear-gradient(45deg, #ff6600, #ff8800);
  border: 2px solid #ffaa00;
  color: #000;
  padding: 15px 30px;
  font-family: "Orbitron", monospace;
  font-weight: bold;
  border-radius: 5px;
  margin: 10px 5px;
  cursor: pointer;
  touch-action: manipulation;
  font-size: 14px;
}

.btn:hover {
  background: linear-gradient(45deg, #ff8800, #ffaa00);
}

.btn:disabled {
  background: #444;
  color: #888;
  border-color: #666;
  cursor: not-allowed;
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 0, 0.03) 2px,
    rgba(0, 255, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 5;
}

/* Mobile Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  body {
    height: -webkit-fill-available;
  }

  #controls {
    bottom: 30px;
    margin-bottom: 30px;
  }
}

/* iPhone specific adjustments */
@media only screen and (max-device-width: 896px) and (-webkit-device-pixel-ratio: 2) {
  #controls {
    bottom: 40px;
    margin-bottom: 40px;
  }

  #highScores {
    display: none;
    /* Hide on very small screens */
  }
}

.loading {
  color: #ffaa00;
  font-style: italic;
}

.error {
  color: #ff4444;
  font-size: 10px;
}
