/* --- Reset & base --- */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: #0b0b0b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Title screen --- */
#titleScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  transition: opacity 0.6s ease;
}

#titleScreen.hidden {
  pointer-events: none;
  opacity: 0;
}

#siteTitle {
  margin: 0;
  font-size: clamp(48px, 10vw, 140px);
  letter-spacing: 0.12em;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.08);
  transition: transform 0.6s ease, opacity 0.6s ease, font-size 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
  #siteTitle {
    animation: none;
  }
  #titleScreen,
  #siteTitle,
  #gameScreen,
  #gameOverPanel {
    transition-duration: 0.15s;
  }
}

#titleScreen.minimized #siteTitle {
  transform: scale(0.4);
  opacity: 0.25;
  font-size: clamp(24px, 5vw, 60px);
}

#playButton {
  margin-top: 2rem;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 600;
  color: #0b0b0b;
  background: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

#playButton:hover {
  background: transparent;
  color: #fff;
}

#playButton:focus {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

#playButton:active {
  transform: scale(0.98);
}

/* --- Game screen --- */
#gameScreen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.6s ease;
  background: #0b0b0b;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
}

#gameScreen.visible {
  opacity: 1;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 100vh;
  background: #0b0b0b;
  outline: none;
  touch-action: none;
  -ms-touch-action: none;
}

#gameCanvas:focus {
  outline: 2px solid rgba(255, 255, 255, 0.3);
  outline-offset: 2px;
}

/* --- HUD --- */
#hud {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
}

#scoreLabel {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

#scoreDisplay {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* --- Message overlay --- */
#messageOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 1.2rem;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.9);
}

/* --- Game over panel --- */
#gameOverPanel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(11, 11, 11, 0.92);
  gap: 1rem;
}

#gameOverTitle {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 800;
}

#finalScoreText {
  margin: 0;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.9);
}

#leaderboardWrap.leaderboard-hidden {
  display: none;
}

#leaderboardList {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 12rem;
  overflow-y: auto;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  min-width: 12rem;
  text-align: center;
}

#leaderboardList li {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#initialsForm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

#initialsForm label {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.8);
}

#initialsInput {
  width: 4rem;
  padding: 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  text-align: center;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}

#initialsInput:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#viewHighScoresButton {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#viewHighScoresButton:hover {
  color: #fff;
  border-color: #fff;
}

#viewHighScoresButton:focus {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

#submitScoreButton,
#restartButton,
#backButton {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: #0b0b0b;
  background: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

#submitScoreButton:hover,
#restartButton:hover,
#backButton:hover {
  background: transparent;
  color: #fff;
}

#submitScoreButton:focus,
#restartButton:focus,
#backButton:focus {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

#backButton {
  margin-top: 0.5rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}

#backButton:hover {
  color: #fff;
  border-color: #fff;
}

.subtle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

/* Utility */
[hidden] {
  display: none !important;
}
