@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --bg-dark: rgba(12, 14, 22, 0.84);
  --border-pixel: rgba(255, 255, 255, 0.16);
  --gold: #ffd447;
  --emerald: #44e37d;
  --crimson: #ff5555;
  --cyan: #4de8ff;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d111a;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: #f4f7ff;
}

#game-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.hidden {
  display: none !important;
}

/* Crosshair */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  font-size: 22px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  pointer-events: none;
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

#top-left-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--bg-dark);
  border: 2px solid var(--border-pixel);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.stat-pill .label {
  font-size: 10px;
  letter-spacing: 1px;
  color: #9ba7c2;
  font-weight: 700;
}

.stat-pill span:last-child {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  margin-top: 3px;
  color: #fff;
}

.biome-pill {
  align-self: flex-start;
  border-color: rgba(255, 212, 71, 0.45);
}

.biome-pill span:last-child {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}

.mode-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 85, 85, 0.22);
  border: 1px solid rgba(255, 85, 85, 0.55);
  color: #ff9c9c;
}

.mode-badge.practice {
  background: rgba(68, 227, 125, 0.2);
  border-color: rgba(68, 227, 125, 0.5);
  color: #8cffb6;
}

#top-right-hud {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  background: var(--bg-dark);
  border: 2px solid var(--border-pixel);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}

.icon-btn:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

/* Vertical Tower Meter */
#tower-meter {
  position: absolute;
  right: 22px;
  top: 84px;
  bottom: 130px;
  width: 18px;
  background: rgba(10, 12, 20, 0.78);
  border: 2px solid var(--border-pixel);
  border-radius: 12px;
  overflow: visible;
}

#tower-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(to top, #44e37d, #4de8ff, #ffd447, #ff5555);
  border-radius: 10px;
  opacity: 0.75;
  transition: height 0.08s linear;
}

#tower-player-marker {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 0%;
  height: 6px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 10px #fff;
  transform: translateY(50%);
}

#tower-best-marker {
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 0%;
  height: 3px;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.tower-zone {
  position: absolute;
  right: 24px;
  font-size: 14px;
  transform: translateY(50%);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.tower-zone.z1 { bottom: 4%; }
.tower-zone.z2 { bottom: 24%; }
.tower-zone.z3 { bottom: 46%; }
.tower-zone.z4 { bottom: 68%; }
.tower-zone.z5 { bottom: 96%; }

/* Bottom Charge HUD */
#bottom-hud {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, 92vw);
}

#sneak-indicator {
  background: rgba(77, 232, 255, 0.22);
  border: 1.5px solid var(--cyan);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.8px;
}

#charge-container {
  width: 100%;
  background: var(--bg-dark);
  border: 2px solid var(--border-pixel);
  border-radius: 12px;
  padding: 10px 14px 8px;
  backdrop-filter: blur(8px);
}

#charge-bar-bg {
  position: relative;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#charge-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #44e37d 0%, #ffd447 65%, #ff4747 100%);
  transition: width 0.02s linear;
  box-shadow: 0 0 12px rgba(255, 212, 71, 0.6);
}

#charge-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-evenly;
  pointer-events: none;
}

#charge-ticks span {
  width: 2px;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
}

#charge-label {
  margin-top: 5px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #cbd5f0;
}

#controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 11px;
  color: rgba(235, 241, 255, 0.78);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

#controls-hint b {
  color: var(--gold);
}

/* Taunt & Zone Banners */
#taunt-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: rgba(24, 10, 14, 0.88);
  border: 2px solid var(--crimson);
  border-radius: 14px;
  padding: 12px 24px;
  box-shadow: 0 10px 30px rgba(255, 40, 40, 0.35);
  animation: popIn 0.25s ease-out;
}

#taunt-drop {
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  color: var(--crimson);
  margin-bottom: 6px;
}

#taunt-text {
  font-size: 15px;
  font-weight: 600;
  color: #ffe2e2;
}

#zone-banner {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: rgba(12, 16, 28, 0.85);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 10px 26px;
  animation: popIn 0.3s ease-out;
}

#zone-banner-sub {
  font-size: 10px;
  letter-spacing: 2px;
  color: #9ba7c2;
  font-weight: 700;
}

#zone-banner-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: var(--gold);
  margin-top: 4px;
}

@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -12px) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(16, 22, 38, 0.72), rgba(7, 9, 15, 0.92));
  backdrop-filter: blur(6px);
  padding: 20px;
}

.modal-card {
  width: min(560px, 95vw);
  background: rgba(18, 22, 34, 0.96);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 28px 28px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-card.compact {
  width: min(380px, 92vw);
}

.badge-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold);
  background: rgba(255, 212, 71, 0.14);
  border: 1px solid rgba(255, 212, 71, 0.4);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.modal-card h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(24px, 4vw, 34px);
  color: #fff;
  text-shadow: 0 4px 0 #3a4668;
  margin-bottom: 8px;
}

.modal-card h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  margin-bottom: 10px;
}

.subtitle {
  color: #a9b6d4;
  font-size: 15px;
  margin-bottom: 18px;
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
  margin-bottom: 18px;
}

.feature-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}

.fi-icon {
  font-size: 18px;
  line-height: 1.2;
}

.feature-item small {
  color: #9aa7c5;
  font-size: 12px;
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 12px;
  color: #e4ebff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.mode-btn span {
  font-size: 11px;
  color: #9aa7c5;
}

.mode-btn.active {
  border-color: var(--gold);
  background: rgba(255, 212, 71, 0.12);
}

.primary-btn, .secondary-btn, .danger-btn {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}

.primary-btn {
  background: linear-gradient(135deg, #44e37d, #27b863);
  color: #072211;
  box-shadow: 0 5px 0 #17783e;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 14px;
}

.danger-btn {
  background: rgba(255, 85, 85, 0.2);
  border: 1px solid rgba(255, 85, 85, 0.5);
  color: #ff9c9c;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 14px;
}

.primary-btn:hover, .secondary-btn:hover, .danger-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.tiny-note {
  margin-top: 12px;
  font-size: 12px;
  color: #7c89a6;
}

#pause-stats {
  color: #b4c0dc;
  margin-bottom: 10px;
}

.crown-emoji {
  font-size: 54px;
  margin-bottom: 8px;
  animation: floatCrown 2s ease-in-out infinite;
}

@keyframes floatCrown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.victory-stats > div {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.victory-stats span {
  font-size: 10px;
  color: #9ba7c2;
  letter-spacing: 1px;
}

.victory-stats strong {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  color: var(--gold);
}

/* Mobile Touch Controls */
#game-container,
#mobile-controls,
#touch-joystick,
#touch-jump-btn,
#touch-sneak-btn,
#touch-cp-btn {
  touch-action: none;
  -webkit-touch-callout: none;
}

#mobile-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

#touch-joystick {
  position: absolute;
  left: 22px;
  bottom: 24px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: rgba(14, 18, 30, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#touch-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #9fb4e8);
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transform: translate(0px, 0px);
  pointer-events: none;
}

#touch-actions {
  position: absolute;
  right: 22px;
  bottom: 24px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

#touch-jump-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.45);
  background: linear-gradient(135deg, rgba(68, 227, 125, 0.88), rgba(29, 168, 92, 0.9));
  color: #062110;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(39, 184, 99, 0.45);
  cursor: pointer;
}

#touch-jump-btn.charging {
  transform: scale(0.92);
  background: linear-gradient(135deg, #ffd447, #ff5555);
  border-color: #fff;
}

.touch-pill-btn {
  padding: 12px 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(14, 18, 30, 0.75);
  color: #e6eeff;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.touch-pill-btn.active {
  border-color: var(--cyan);
  background: rgba(77, 232, 255, 0.25);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(77, 232, 255, 0.4);
}

.icon-btn.active {
  border-color: var(--emerald);
  color: var(--emerald);
}

@media (max-width: 768px), (pointer: coarse) {
  #controls-hint {
    display: none;
  }

  #bottom-hud {
    bottom: 164px;
    width: min(320px, 60vw);
  }

  #tower-meter {
    top: 70px;
    bottom: 185px;
    right: 12px;
    width: 14px;
  }

  .stat-pill {
    padding: 4px 8px;
  }

  .stat-pill span:last-child {
    font-size: 11px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}
