:root {
  --neon-cyan: #00f0ff;
  --neon-blue: #0088ff;
  --neon-magenta: #ff007f;
  --neon-purple: #a855f7;
  --neon-yellow: #ffd700;
  --neon-red: #ff3344;
  --dark-space: #030712;
  --hud-bg: rgba(6, 16, 32, 0.75);
  --hud-border: rgba(0, 240, 255, 0.4);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--dark-space);
  color: #e2e8f0;
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
}

.font-orbitron {
  font-family: 'Orbitron', monospace, sans-serif;
  letter-spacing: 1px;
}

.highlight-cyan {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.highlight-purple {
  color: #d946ef;
  text-shadow: 0 0 10px rgba(217, 70, 239, 0.6);
}

.highlight-red {
  color: var(--neon-red);
  text-shadow: 0 0 15px rgba(255, 51, 68, 0.8);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* EFEKTY PEŁNOEKRANOWE */
#screen-effects {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.flash-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

#damage-flash {
  background: radial-gradient(circle, rgba(255, 30, 50, 0.4) 0%, rgba(200, 0, 0, 0.8) 100%);
}

#boost-flash {
  background: radial-gradient(circle, rgba(0, 240, 255, 0.35) 0%, rgba(0, 100, 255, 0.6) 100%);
}

#crystal-flash {
  background: radial-gradient(circle, rgba(255, 230, 80, 0.25) 0%, rgba(217, 70, 239, 0.4) 100%);
}

#speed-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.8);
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

#warp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* HUD GŁÓWNY */
#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 24px;
  pointer-events: none;
}

#hud.hidden {
  display: none !important;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  padding: 10px 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.15), inset 0 0 15px rgba(0, 240, 255, 0.05);
  clip-path: polygon(0 0, 100% 0, 98% 100%, 2% 100%);
}

.hud-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  color: #7dd3fc;
  font-weight: 700;
  text-transform: uppercase;
}

.hud-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
}

.hud-stat-box small {
  font-size: 0.75rem;
  color: #94a3b8;
}

.crystal-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crystal-icon {
  font-size: 1.1rem;
  filter: drop-shadow(0 0 5px #d946ef);
}

.hud-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--neon-cyan);
  color: #ffffff;
  padding: 6px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-family: 'Rajdhani', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-btn:hover {
  background: rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 12px var(--neon-cyan);
  transform: translateY(-1px);
}

/* CELOWNIK (CROSSHAIR) */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.75;
  transition: transform 0.05s ease-out;
}

.crosshair-ring {
  position: absolute;
  inset: 6px;
  border: 1.5px solid rgba(0, 240, 255, 0.6);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.crosshair-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: var(--neon-cyan);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px var(--neon-cyan);
}

.crosshair-wings {
  position: absolute;
  inset: 0;
  border-top: 2px solid rgba(0, 240, 255, 0.8);
  border-bottom: 2px solid rgba(0, 240, 255, 0.8);
  clip-path: polygon(40% 0, 60% 0, 60% 100%, 40% 100%);
}

/* POWIADOMIENIA I OSTRZEŻENIA */
#hud-announcements {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  width: 90%;
  max-width: 600px;
}

.announcement-banner {
  padding: 10px 24px;
  border-radius: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  animation: pulseAlarm 0.4s infinite alternate ease-in-out;
}

.banner-warning {
  background: rgba(239, 68, 68, 0.25);
  border: 2px solid var(--neon-red);
  color: #ff5566;
  text-shadow: 0 0 10px rgba(255, 51, 68, 0.8);
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.5);
}

.banner-boost {
  background: rgba(0, 240, 255, 0.25);
  border: 2px solid var(--neon-cyan);
  color: #ffffff;
  text-shadow: 0 0 15px var(--neon-cyan);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.6);
  animation: pulseBoost 0.3s infinite alternate;
}

.announcement-floating {
  font-family: 'Orbitron', sans-serif;
  color: var(--neon-yellow);
  font-size: 1.4rem;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
  animation: floatUpFade 1.2s forwards ease-out;
}

@keyframes pulseAlarm {
  from { transform: scale(0.97); opacity: 0.85; }
  to { transform: scale(1.03); opacity: 1; }
}

@keyframes pulseBoost {
  from { transform: scale(0.98); }
  to { transform: scale(1.04); }
}

@keyframes floatUpFade {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-40px); opacity: 0; }
}

/* DOLNY PAS HUD */
.hud-bottom {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  align-items: flex-end;
  gap: 20px;
  pointer-events: none;
}

.hud-gauge-left, .hud-gauge-center, .hud-gauge-right {
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  padding: 12px 18px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.15);
}

.hud-gauge-center {
  clip-path: polygon(5% 0, 95% 0, 100% 100%, 0 100%);
  padding-bottom: 16px;
}

.speed-number-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

#speed-display {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
}

.speed-unit {
  font-size: 0.85rem;
  color: #38bdf8;
  font-weight: 700;
}

.bar-fill {
  height: 8px;
  border-radius: 4px;
  transition: width 0.1s linear;
}

.speed-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

#speed-bar-fill {
  width: 40%;
  background: linear-gradient(90deg, #0088ff, #00f0ff);
  box-shadow: 0 0 10px #00f0ff;
}

.boost-cluster {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.boost-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.boost-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--neon-cyan);
  letter-spacing: 1.5px;
}

.boost-status {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 700;
}

.boost-bar-container {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 4px;
  overflow: hidden;
  padding: 1px;
}

#boost-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #00f0ff, #d946ef);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.8);
  border-radius: 2px;
  transition: width 0.05s linear;
}

.shield-cluster {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shield-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shield-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 1.2px;
}

#shield-percent {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 1rem;
}

.shield-pips {
  display: flex;
  gap: 6px;
  height: 10px;
}

.shield-pip {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.shield-pip.active {
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
}

.shield-pip.warning {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
}

.shield-pip.danger {
  background: var(--neon-red);
  box-shadow: 0 0 10px var(--neon-red);
}

/* MODALE I EKRANY (START / GAMEOVER / PAUZA) */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-screen.hidden {
  display: none !important;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(3, 7, 18, 0.6) 0%, rgba(2, 4, 10, 0.95) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.menu-content {
  position: relative;
  z-index: 2;
  width: 90%;
  max-width: 680px;
  background: rgba(10, 20, 40, 0.85);
  border: 1px solid rgba(0, 240, 255, 0.5);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.25), inset 0 0 30px rgba(0, 240, 255, 0.05);
  text-align: center;
  animation: panelSlideIn 0.4s ease-out;
}

@keyframes panelSlideIn {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.logo-sub {
  font-size: 0.85rem;
  letter-spacing: 4px;
  color: #38bdf8;
  font-weight: 700;
  margin-bottom: 6px;
}

.logo-title {
  font-size: 3.6rem;
  line-height: 1;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 25px rgba(255, 255, 255, 0.4);
}

.logo-divider {
  width: 140px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  margin: 16px auto;
}

.mission-briefing {
  font-size: 1.15rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 24px;
}

.controls-guide {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 28px;
  text-align: left;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
}

.key-badge {
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--neon-cyan);
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.3);
}

.guide-desc {
  color: #94a3b8;
}

.menu-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
}

.epic-btn {
  position: relative;
  background: linear-gradient(135deg, #0284c7, #06b6d4, #3b82f6);
  border: 1px solid var(--neon-cyan);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 800;
  padding: 14px 44px;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.5);
  transition: all 0.2s ease;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%);
}

.epic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.8);
}

.epic-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: rotate(30deg);
  animation: btnSheen 3.5s infinite ease-in-out;
  pointer-events: none;
}

@keyframes btnSheen {
  0% { left: -60%; }
  25% { left: 140%; }
  100% { left: 140%; }
}

.epic-btn:active {
  transform: scale(0.98);
}

.pulse-glow {
  animation: btnPulse 1.8s infinite alternate ease-in-out;
}

@keyframes btnPulse {
  0% { box-shadow: 0 0 15px rgba(0, 240, 255, 0.4); }
  100% { box-shadow: 0 0 35px rgba(0, 240, 255, 0.9); }
}

.high-score-banner {
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: #64748b;
  font-weight: 700;
}

/* GAME OVER STYLES */
.gameover-title {
  font-size: 3.2rem;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 8px;
}

.gameover-sub {
  color: #94a3b8;
  font-size: 1.1rem;
  margin-bottom: 24px;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.summary-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 700;
}

.summary-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

/* TOUCH CONTROLS */
.touch-only {
  display: none;
  pointer-events: auto;
}

@media (pointer: coarse), (max-width: 900px) {
  .touch-only {
    display: block;
  }

  #touch-controls {
    position: absolute;
    bottom: 90px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 15;
  }

  #touch-joystick-zone {
    width: 120px;
    height: 120px;
    background: rgba(0, 240, 255, 0.1);
    border: 2px dashed rgba(0, 240, 255, 0.4);
    border-radius: 50%;
    position: relative;
    pointer-events: auto;
  }

  #joystick-knob {
    width: 50px;
    height: 50px;
    background: var(--neon-cyan);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px var(--neon-cyan);
  }

  .touch-action-btn {
    pointer-events: auto;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #d946ef);
    border: 2px solid #fff;
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    font-size: 0.85rem;
    box-shadow: 0 0 20px rgba(217, 70, 239, 0.8);
    cursor: pointer;
  }

  .hud-top {
    padding: 6px 12px;
    gap: 8px;
  }

  .hud-value {
    font-size: 1.1rem;
  }

  .hud-bottom {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .hud-gauge-right {
    display: none;
  }

  .stats-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
