* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #000;
  color: #fff;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

#hud {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  font-size: 18px;
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.25s ease;
}

.hud-item {
  white-space: nowrap;
}

.hud-item span {
  font-weight: 700;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   HEALTH BAR
   ============================================ */

#health-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  z-index: 5;
}

#health-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.7);
}

#health-bar-bg {
  width: 120px;
  height: 12px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#health-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #44ff66, #66ff88);
  border-radius: 5px;
  transition: width 0.2s ease, background 0.3s ease;
  box-shadow: 0 0 8px rgba(68, 255, 102, 0.4);
}

#health-text {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

#controls-hint {
  position: fixed;
  left: 20px;
  bottom: 26px;
  padding: 10px 16px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  opacity: 0.9;
  transition: opacity 0.25s ease;
}

body:not(.state-playing) #hud,
body:not(.state-playing) #controls-hint {
  opacity: 0;
}

#powerup-banner {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  padding: 12px 20px;
  font-size: 17px;
  letter-spacing: 0.04em;
  background: rgba(12, 18, 48, 0.75);
  border: 1px solid rgba(140, 190, 255, 0.35);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5;
}

#powerup-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 3, 15, 0.82);
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 10;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen.visible {
  opacity: 1;
  visibility: visible;
}

.panel {
  max-width: 520px;
  padding: 32px;
  background: rgba(8, 12, 30, 0.75);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 100, 255, 0.2), inset 0 0 20px rgba(0, 50, 150, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.panel h1 {
  margin: 0 0 12px;
  font-size: 42px;
  letter-spacing: 0.04em;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 32px;
}

.description {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
}

.stat {
  margin: 8px 0;
  font-size: 18px;
}

.action-button {
  margin-top: 16px;
  padding: 12px 32px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0b0f2a;
  background: linear-gradient(135deg, #8ec5ff, #5fa8ff);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(95, 168, 255, 0.35);
}

.action-button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.action-button.secondary {
  background: linear-gradient(135deg, rgba(100, 120, 180, 0.3), rgba(80, 100, 160, 0.2));
  color: #fff;
  border: 1px solid rgba(140, 180, 255, 0.3);
}

.action-button.secondary:hover,
.action-button.secondary:focus-visible {
  box-shadow: 0 8px 24px rgba(100, 150, 255, 0.25);
}

/* ============================================
   PAUSE MENU
   ============================================ */

.pause-hint {
  margin-bottom: 20px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
}

.pause-buttons,
.gameover-buttons,
.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.pause-buttons .action-button,
.gameover-buttons .action-button,
.title-buttons .action-button {
  min-width: 180px;
  margin-top: 0;
  text-decoration: none;
  text-align: center;
}

.settings-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-group-title {
  margin: 0 0 12px;
  font-size: 16px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.15em;
  text-align: left;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  padding: 4px 0;
}

.setting-row span {
  margin-right: 20px;
}

.setting-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #5fa8ff;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.setting-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #5fa8ff;
  cursor: pointer;
}

/* ============================================
   CROSSHAIR — improved visibility
   ============================================ */

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.25s ease;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
  will-change: transform;
  transform: translate(-50%, -50%);
}

body.state-playing #crosshair {
  opacity: 0.95;
}

body.state-playing {
  cursor: none;
}

body.state-paused,
body.state-gameover,
body.state-title {
  cursor: default;
}

.crosshair-line {
  position: absolute;
  background: #fff;
  box-shadow:
    0 0 6px rgba(140, 200, 255, 0.8),
    0 0 12px rgba(140, 200, 255, 0.4);
}

.crosshair-top {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5px;
  height: 12px;
}

.crosshair-bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5px;
  height: 12px;
}

.crosshair-left {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 2.5px;
}

.crosshair-right {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 2.5px;
}

.crosshair-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ff6478;
  box-shadow:
    0 0 6px rgba(255, 100, 120, 0.9),
    0 0 14px rgba(255, 100, 120, 0.5);
}

/* ============================================
   COMBO DISPLAY
   ============================================ */

#combo-display {
  position: fixed;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  padding: 16px 28px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow:
    0 0 20px rgba(255, 200, 100, 0.8),
    0 0 40px rgba(255, 150, 50, 0.6);
  background: linear-gradient(135deg, rgba(255, 180, 50, 0.25), rgba(255, 100, 50, 0.15));
  border: 2px solid rgba(255, 180, 100, 0.5);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 6;
}

#combo-display.visible {
  opacity: 1;
}

#combo-display.combo-pop {
  animation: comboPop 0.25s ease-out;
}

@keyframes comboPop {
  0% {
    transform: translateY(-50%) scale(1.3);
  }

  50% {
    transform: translateY(-50%) scale(0.95);
  }

  100% {
    transform: translateY(-50%) scale(1);
  }
}

/* ============================================
   SHIELD TIMER
   ============================================ */

#shield-timer {
  position: fixed;
  top: 80px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(40, 180, 140, 0.2);
  border: 1px solid rgba(68, 255, 170, 0.4);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 5;
}

#shield-timer.visible {
  opacity: 1;
}

#shield-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #44ffaa;
  text-shadow: 0 0 12px rgba(68, 255, 170, 0.6);
}

#shield-bar-container {
  width: 120px;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

#shield-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #44ffaa, #66ffcc);
  border-radius: 4px;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px rgba(68, 255, 170, 0.5);
}

/* ============================================
   DASH INDICATOR
   ============================================ */

#dash-indicator {
  position: fixed;
  top: 140px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(40, 120, 180, 0.2);
  border: 1px solid rgba(68, 200, 255, 0.4);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 5;
}

#dash-indicator.visible {
  opacity: 1;
}

#dash-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #44ddff;
  text-shadow: 0 0 12px rgba(68, 220, 255, 0.6);
}

#dash-bar-container {
  width: 120px;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

#dash-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #44ddff, #88eeff);
  border-radius: 4px;
  transition: width 0.05s linear;
  box-shadow: 0 0 10px rgba(68, 220, 255, 0.5);
}

/* ============================================
   CONTROLS GUIDE (Title Screen)
   ============================================ */

.controls-guide {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.control-item {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.control-item kbd {
  display: inline-block;
  padding: 3px 8px;
  margin-right: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(100, 160, 255, 0.2);
  border: 1px solid rgba(100, 160, 255, 0.35);
  border-radius: 5px;
  text-transform: uppercase;
}

/* ============================================
   DIFFICULTY SELECTOR (Title Screen)
   ============================================ */

.difficulty-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
}

.diff-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.diff-buttons {
  display: flex;
  gap: 6px;
}

.diff-btn {
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.diff-btn.active {
  color: #0b0f2a;
  background: linear-gradient(135deg, #8ec5ff, #5fa8ff);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(95, 168, 255, 0.3);
}

/* ============================================
   HIGH SCORE DISPLAY
   ============================================ */

.high-score-display {
  margin: 16px 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: #ffd95c;
  text-shadow: 0 0 12px rgba(255, 200, 80, 0.5);
}

.high-score-display span,
.stat.high-score span {
  font-weight: 800;
}

.stat.high-score {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffd95c;
}

#new-high-score {
  margin-bottom: 16px;
  padding: 12px 20px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 200, 50, 0.3), rgba(255, 100, 150, 0.2));
  border: 2px solid rgba(255, 200, 100, 0.5);
  border-radius: 12px;
  animation: highScorePulse 1s ease-in-out infinite;
}

#new-high-score.visible {
  display: block;
}

#new-high-score.hidden {
  display: none;
}

@keyframes highScorePulse {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 200, 100, 0.4);
  }

  50% {
    transform: scale(1.03);
    box-shadow: 0 0 30px rgba(255, 200, 100, 0.6);
  }
}