@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600&display=swap');

/* --- Reset --- */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
  background: #000;
  font-family: 'Exo 2', sans-serif;
  cursor: crosshair;
}

/* --- Background & Canvas --- */

#bg {
  display: none;
}

canvas#game {
  display: block;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- Player HUD --- */

.player-hud {
  position: fixed;
  top: 0;
  padding: 15px 21px;
  pointer-events: none;
  z-index: 10;
}

.player-hud.p1 {
  left: 0;
}

.player-hud.p2 {
  right: 0;
  text-align: right;
}

.p-label {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  letter-spacing: 3px;
  margin-bottom: 3px;
  opacity: 0.5;
}

.p-label.p1c { color: #60c0ff; }
.p-label.p2c { color: #ff6060; }

.stage-label {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 5px;
}

.stage-label.p1c { color: #a0e8ff; }
.stage-label.p2c { color: #ffa0a0; }

/* --- Bars --- */

.bar-ct {
  width: 240px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 3px;
}

.p2 .bar-ct {
  margin-left: auto;
}

.bar-mass {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
}

.bar-mass.p1c { background: linear-gradient(90deg, #4a9eff, #a0e8ff); }
.bar-mass.p2c { background: linear-gradient(90deg, #ff4a4a, #ffa0a0); }

.bar-hp {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
}

.bar-hp.p1c { background: linear-gradient(90deg, #22cc66, #66ff99); }
.bar-hp.p2c { background: linear-gradient(90deg, #cc6622, #ffaa66); }

/* --- HUD Text & Stats --- */

.hud-txt {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 1px;
  font-family: 'Orbitron', monospace;
  margin-bottom: 2px;
}

.stat-row {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.25);
  font-family: 'Orbitron', monospace;
  letter-spacing: 1px;
}

.stat-val {
  font-weight: 600;
}

.stat-val.p1c { color: rgba(160, 232, 255, 0.6); }
.stat-val.p2c { color: rgba(255, 160, 160, 0.6); }

/* --- Leaderboard --- */

.leaderboard {
  margin-top: 8px;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 1px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  color: rgba(255, 255, 255, 0.35);
}

.lb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-stage {
  opacity: 0.6;
  font-size: 9px;
}

/* --- Divider --- */

#divider {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.15);
  z-index: 5;
  pointer-events: none;
}

/* --- Upgrade Overlay --- */

.upgrade-ov {
  position: fixed;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  transition: opacity .3s;
}

.upgrade-ov.visible { display: flex; opacity: 1; }
.upgrade-ov.left    { left: 0; width: 50%; }
.upgrade-ov.right   { left: 50%; width: 50%; }
.upgrade-ov.full    { left: 0; width: 100%; }

.upgrade-panel {
  text-align: center;
  max-width: 90%;
  padding: 21px;
}

.upgrade-title {
  font-family: 'Orbitron', monospace;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  margin-bottom: 5px;
}

.upgrade-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 3px;
  margin-bottom: 21px;
  text-transform: uppercase;
}

.upgrade-who {
  font-size: 15px;
  letter-spacing: 3px;
  margin-bottom: 5px;
  font-family: 'Orbitron', monospace;
}

.upgrade-opts {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.upgrade-card {
  width: 165px;
  padding: 18px 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  pointer-events: auto;
}

.upgrade-card.selected {
  background: rgba(100, 180, 255, 0.15);
  border-color: rgba(100, 180, 255, 0.6);
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(100, 180, 255, 0.2);
}

.upgrade-card .icon {
  font-size: 30px;
  margin-bottom: 8px;
}

.upgrade-card .name {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 5px;
  text-transform: uppercase;
}

.upgrade-card .desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1.4;
}

/* --- Flashes --- */

#stage-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(160, 232, 255, 0.3), transparent);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity .3s;
}

#death-flash {
  position: fixed;
  inset: 0;
  background: rgba(180, 0, 0, 0.2);
  pointer-events: none;
  z-index: 45;
  opacity: 0;
  transition: opacity .5s;
}

/* --- Pause Corner Button --- */

.pause-corner-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  z-index: 20;
  transition: all .3s;
}

.pause-corner-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}

/* --- Minimap --- */

.minimap {
  position: fixed;
  bottom: 55px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 8, 0.7);
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
}

.minimap.p1m { left: 18px; }
.minimap.p2m { right: 18px; }
.minimap canvas { width: 100%; height: 100%; }

/* --- Win Overlay --- */

#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
  flex-direction: column;
}

#win-overlay.visible {
  display: flex;
}

#win-title {
  font-family: 'Orbitron', monospace;
  font-size: 39px;
  font-weight: 900;
  letter-spacing: 7px;
  color: #fff;
  margin-bottom: 9px;
  text-shadow: 0 0 30px rgba(100, 180, 255, 0.6);
}

#win-sub {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 4px;
  margin-bottom: 36px;
  text-transform: uppercase;
}

.stats-grid {
  display: flex;
  gap: 16px;
  margin-bottom: 36px;
  justify-content: center;
  flex-wrap: wrap;
}

.stats-card {
  text-align: center;
  min-width: 160px;
  max-width: 200px;
  padding: 16px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  border-top: 3px solid currentColor;
}

.stats-card h3 {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.stats-card .stats-stage {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  opacity: 0.5;
  margin-bottom: 12px;
}

.stats-card .srow {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 5px;
  font-family: 'Exo 2', sans-serif;
}

.stats-card .srow b {
  color: rgba(255, 255, 255, 0.8);
}

/* --- Menu Button --- */

.menu-btn {
  font-family: 'Orbitron', monospace;
  font-size: 16px;
  letter-spacing: 4px;
  color: #fff;
  background: rgba(100, 180, 255, 0.2);
  border: 2px solid rgba(100, 180, 255, 0.5);
  border-radius: 10px;
  padding: 14px 36px;
  cursor: pointer;
  transition: all .3s;
  margin: 6px;
}

.menu-btn:hover,
.menu-btn.gp-focus {
  background: rgba(100, 180, 255, 0.35);
  transform: scale(1.05);
}

/* --- Pause Overlay --- */

#pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 150;
}

#pause-overlay.visible {
  display: flex;
}

.pause-content {
  text-align: center;
}

.pause-title {
  font-family: 'Orbitron', monospace;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 36px;
}

.pause-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}

.pause-btns .menu-btn {
  font-size: 12px;
  letter-spacing: 3px;
  padding: 10px 30px;
  pointer-events: auto;
}

.pause-resume {
  font-size: 14px;
  letter-spacing: 4px;
  padding: 12px 36px;
  pointer-events: auto;
  background: rgba(100, 255, 150, 0.15);
  border-color: rgba(100, 255, 150, 0.4);
}

.pause-resume:hover {
  background: rgba(100, 255, 150, 0.3);
}

/* --- Start Menu --- */

#start-menu {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(8, 12, 30, 0.3), rgba(0, 0, 0, 0.5));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 300;
}

#start-menu.hidden {
  display: none;
}

#start-menu h1 {
  font-family: 'Orbitron', monospace;
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 12px;
  color: #fff;
  text-shadow: 0 0 40px rgba(100, 180, 255, 0.5), 0 0 80px rgba(100, 180, 255, 0.2);
  margin-bottom: 9px;
}

#start-menu .sub {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 6px;
  margin-bottom: 45px;
  text-transform: uppercase;
}

#start-menu .modes {
  display: flex;
  gap: 18px;
  margin-bottom: 30px;
}

/* --- Loading --- */

#loading {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 400;
}

#loading.hidden {
  display: none;
}

#loading h2 {
  font-family: 'Orbitron', monospace;
  font-size: 24px;
  letter-spacing: 6px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 21px;
}

.load-bar {
  width: 300px;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.load-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a9eff, #a0e8ff);
  transition: width .15s;
  border-radius: 3px;
}

/* --- Controls Hint --- */

#controls-hint {
  position: fixed;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.1);
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 10;
  transition: opacity 2s;
  text-align: center;
  line-height: 1.4;
}

/* --- Touch Controls --- */

.touch-zone {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  pointer-events: none;
  display: none;
}

.touch-zone.active { display: block; pointer-events: auto; }

.joystick-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
}

.joystick-ring.visible { display: block; }

.joystick-knob {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(100, 180, 255, 0.3);
  border: 2px solid rgba(100, 180, 255, 0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
}

.joystick-knob.visible { display: block; }

#touch-pause-btn {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  z-index: 20;
  display: none;
  pointer-events: auto;
}

/* --- Mobile / Small Screen --- */

@media (max-width: 768px) {

  /* HUD */
  .player-hud { padding: 8px 10px; }
  .p-label { font-size: 10px; letter-spacing: 2px; }
  .stage-label { font-size: 13px; letter-spacing: 2px; margin-bottom: 3px; }
  .bar-ct { width: 130px; height: 4px; margin-bottom: 2px; }
  .hud-txt { font-size: 9px; }
  .leaderboard { font-size: 8px; margin-top: 4px; }
  .lb-stage { font-size: 7px; }
  .lb-dot { width: 4px; height: 4px; }

  /* Minimap */
  .minimap { width: 90px; height: 90px; bottom: 12px; }
  .minimap.p1m { left: 8px; }
  .minimap.p2m { right: 8px; }

  /* Start menu */
  #start-menu h1 { font-size: 28px; letter-spacing: 6px; }
  #start-menu .sub { font-size: 12px; letter-spacing: 3px; margin-bottom: 28px; }
  #start-menu .modes { gap: 10px; flex-wrap: wrap; justify-content: center; }

  /* Menu buttons */
  .menu-btn { font-size: 12px; letter-spacing: 2px; padding: 10px 20px; }

  /* Pause */
  .pause-title { font-size: 22px; letter-spacing: 6px; margin-bottom: 20px; }
  .pause-btns .menu-btn { font-size: 10px; padding: 8px 18px; }
  .pause-resume { font-size: 12px; padding: 10px 24px; }
  .pause-btns { gap: 6px; margin-bottom: 18px; }

  /* Upgrade cards */
  .upgrade-title { font-size: 16px; letter-spacing: 2px; }
  .upgrade-sub { font-size: 10px; letter-spacing: 2px; margin-bottom: 12px; }
  .upgrade-who { font-size: 11px; letter-spacing: 2px; }
  .upgrade-opts { gap: 8px; }
  .upgrade-card { width: 110px; padding: 10px 6px; border-radius: 8px; }
  .upgrade-card .icon { font-size: 22px; margin-bottom: 5px; }
  .upgrade-card .name { font-size: 9px; }
  .upgrade-card .desc { font-size: 9px; line-height: 1.3; }
  .upgrade-panel { padding: 12px; }

  /* Win overlay */
  #win-title { font-size: 22px; letter-spacing: 4px; }
  #win-sub { font-size: 12px; letter-spacing: 2px; margin-bottom: 20px; }
  .stats-grid { gap: 8px; margin-bottom: 20px; }
  .stats-card { min-width: 120px; max-width: 150px; padding: 10px 8px; }
  .stats-card h3 { font-size: 10px; }
  .stats-card .stats-stage { font-size: 8px; }
  .stats-card .srow { font-size: 10px; }

  /* Pause button */
  .pause-corner-btn { top: 8px; right: 8px; font-size: 14px; padding: 3px 7px; }

  /* Controls hint */
  #controls-hint { font-size: 9px; bottom: 8px; letter-spacing: 1px; }

  /* Loading */
  .load-bar { width: 200px; }
  #loading h2 { font-size: 18px; letter-spacing: 4px; }
}

@media (max-width: 420px) {

  /* Extra small phones */
  #start-menu h1 { font-size: 22px; letter-spacing: 4px; }
  #start-menu .sub { font-size: 10px; margin-bottom: 20px; }
  .menu-btn { font-size: 11px; padding: 9px 16px; letter-spacing: 1px; }
  .bar-ct { width: 100px; }
  .minimap { width: 70px; height: 70px; }
  .upgrade-card { width: 90px; padding: 8px 4px; }
  .upgrade-card .icon { font-size: 18px; }
  .upgrade-card .name { font-size: 8px; }
  .upgrade-card .desc { font-size: 8px; }
  .upgrade-title { font-size: 14px; }
  .stats-card { min-width: 100px; }
  #win-title { font-size: 18px; }
}
