:root {
  --bg: #090c18;
  --bg-deep: #05060e;
  --panel: rgba(15, 20, 40, 0.82);
  --panel-border: rgba(255, 255, 255, 0.08);
  --player: #ff3d81;
  --player-glow: rgba(255, 61, 129, 0.55);
  --energy: #ffb020;
  --hazard: #4dd8ff;
  --hazard-2: #7c5cff;
  --text: #eef1fa;
  --text-dim: #8b93b0;
  --font-display: 'Chakra Petch', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: block;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(8, 11, 24, 0.94);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 58px 0 12px;
  z-index: 20;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  font-family: var(--font-display);
}

.top-actions {
  position: fixed;
  top: 8px;
  right: 0px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 30;
  pointer-events: auto;
}

.top-action-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.top-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--energy);
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 0 14px rgba(255, 176, 32, 0.35);
}

.top-action-btn:active {
  transform: translateY(1px) scale(0.96);
}

.top-action-btn.muted {
  border-color: rgba(255, 61, 129, 0.4);
  background: rgba(255, 61, 129, 0.12);
  box-shadow: 0 0 12px rgba(255, 61, 129, 0.25);
}

.top-action-btn.muted:hover {
  border-color: var(--player);
  box-shadow: 0 0 16px var(--player-glow);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

#hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hud-stats-stack {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hud-chip {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 36px;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.hud-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-value {
  font-weight: 700;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  text-align: center;
}

#escape-obj-val {
  min-width: 52px;
  text-align: center;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

#hv-score {
  min-width: 42px;
  text-align: center;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   ZONE TEXT & SECTOR BADGE HUD STYLING (Mode Tags & Zone Text)
   ========================================================================== */
#hud-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 1;
  min-width: 0;
}

.mode-tag,
#escape-zone-tag {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
  line-height: 1.12;
  max-width: 120px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

.mode-tag.escape,
#escape-zone-tag {
  color: var(--hazard);
  border-color: rgba(77, 216, 255, 0.3);
  background: rgba(15, 20, 40, 0.88);
}

.mode-tag.assault {
  color: var(--energy);
  border-color: rgba(255, 176, 32, 0.3);
  background: rgba(15, 20, 40, 0.88);
}

/* Upgrades HUD Bar */
.upgrade-bar {
  display: flex;
  gap: 6px;
  pointer-events: auto;
  flex-shrink: 0;
}

.upgrade-chip {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 38px;
  font-family: var(--font-display);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  color: var(--text-dim);
}

.upgrade-chip.affordable {
  color: #ffffff;
  background: rgba(255, 176, 32, 0.12);
  border-color: var(--energy);
  box-shadow: 0 0 12px rgba(255, 176, 32, 0.4);
}

.upgrade-chip.affordable:hover {
  transform: translateY(-1px);
  background: rgba(255, 176, 32, 0.28);
  box-shadow: 0 0 16px rgba(255, 176, 32, 0.6);
}

.upgrade-chip.affordable:active {
  transform: translateY(1px);
}

.upgrade-chip.maxed {
  opacity: 0.5;
  border-color: rgba(255, 255, 255, 0.05);
  cursor: default;
}

.hotkey-badge {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 1px;
}

.upgrade-chip.affordable .hotkey-badge {
  background: rgba(255, 176, 32, 0.3);
  color: #fff;
}

.pulse-turret-chip {
  border-color: rgba(0, 242, 254, 0.4);
  background: rgba(0, 242, 254, 0.08);
}

.pulse-turret-chip.affordable {
  background: rgba(0, 242, 254, 0.2);
  border-color: #00f2fe;
  box-shadow: 0 0 14px rgba(0, 242, 254, 0.5);
}

.pulse-turret-chip.affordable:hover {
  background: rgba(0, 242, 254, 0.35);
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.8);
}

.pulse-turret-chip.affordable .hotkey-badge {
  background: rgba(0, 242, 254, 0.35);
  color: #ffffff;
}

/* Boss Health Bar & Phase UI */
#boss-hud {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  font-family: var(--font-display);
  transition: all 0.3s ease;
}

.boss-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.boss-name {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #eef1fa;
  font-weight: 700;
  text-transform: uppercase;
}

.boss-phase-tag {
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid var(--panel-border);
  transition: all 0.3s ease;
}

#boss-hud.boss-phase-1 .boss-phase-tag {
  color: var(--energy);
  border-color: var(--energy);
  background: rgba(255, 176, 32, 0.15);
  box-shadow: 0 0 10px rgba(255, 176, 32, 0.3);
}

#boss-hud.boss-phase-2 .boss-phase-tag {
  color: #ff1744;
  border-color: #ff1744;
  background: rgba(255, 23, 68, 0.2);
  box-shadow: 0 0 12px rgba(255, 23, 68, 0.45);
}

#boss-hud.boss-phase-3 .boss-phase-tag {
  color: #e040fb;
  border-color: #e040fb;
  background: rgba(224, 64, 251, 0.25);
  box-shadow: 0 0 16px rgba(224, 64, 251, 0.6);
  animation: phaseGlitch 0.6s infinite alternate;
}

@keyframes phaseGlitch {
  from {
    opacity: 0.8;
    transform: scale(0.98);
  }

  to {
    opacity: 1;
    transform: scale(1.03);
  }
}

#bossbar-wrap {
  width: min(340px, 80vw);
  height: 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 23, 68, 0.5);
  overflow: hidden;
  box-shadow: 0 0 16px rgba(255, 23, 68, 0.4);
}

#bossbar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff1744, #e040fb);
  transition: width 0.15s ease;
}

.boss-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #ff5252;
  text-transform: uppercase;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 23, 68, 0.8);
}

/* ==========================================================================
   HEALTH & LIVES HUD STYLING (Hearts, Healthbar, Critical Vignette)
   ========================================================================== */
#hud-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 25;
}

#hud-center .hud-chip {
  pointer-events: auto;
}

#hearts {
  display: flex;
  gap: 4px;
  align-items: center;
}

.heart {
  width: 14px;
  height: 14px;
  position: relative;
  transition: transform 0.2s ease;
}

.heart.on {
  filter: drop-shadow(0 0 4px var(--player));
}

.heart svg {
  width: 100%;
  height: 100%;
}

#healthbar-wrap {
  width: 140px;
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

#healthbar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--energy), #ff7a3d);
  transition: width 0.2s ease;
}

.hud-chip.critical-health {
  animation: criticalHudPulse 0.9s infinite alternate !important;
}

.hud-chip.critical-health .heart.on {
  animation: criticalHeartFlash 0.9s infinite alternate !important;
}

@keyframes criticalHudPulse {
  0% {
    box-shadow: 0 0 6px rgba(255, 23, 68, 0.35);
    border-color: rgba(255, 23, 68, 0.5);
    background: rgba(255, 23, 68, 0.1);
  }

  100% {
    box-shadow: 0 0 12px rgba(255, 23, 68, 0.65);
    border-color: rgba(255, 23, 68, 0.85);
    background: rgba(255, 23, 68, 0.22);
  }
}

@keyframes criticalHeartFlash {
  0% {
    filter: drop-shadow(0 0 2px #ff1744);
    opacity: 0.8;
  }

  100% {
    filter: drop-shadow(0 0 6px #ff1744);
    opacity: 1;
  }
}

#danger-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 18;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: inset 0 0 35px rgba(255, 23, 68, 0.35);
  border: 2px solid rgba(255, 23, 68, 0.4);
}

#danger-vignette.active {
  opacity: 1;
  animation: vignetteDangerPulse 1.2s infinite alternate;
}

@keyframes vignetteDangerPulse {
  0% {
    box-shadow: inset 0 0 25px rgba(255, 23, 68, 0.3);
    border-color: rgba(255, 23, 68, 0.35);
  }

  100% {
    box-shadow: inset 0 0 50px rgba(255, 23, 68, 0.6);
    border-color: rgba(255, 23, 68, 0.7);
  }
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 20, 60, 0.55), rgba(4, 5, 12, 0.92));
  backdrop-filter: blur(3px);
  padding: 24px;
  text-align: center;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#overlay.hidden {
  display: none;
}

.panel {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: auto;
}

.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 8vw, 52px);
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, var(--player), var(--hazard-2) 60%, var(--hazard));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
  line-height: 1;
}

/* Victory Title with animated color wave */
.title.victory-title {
  background: linear-gradient(90deg,
      #ff3d81 0%,
      #ffb020 25%,
      #4dd8ff 50%,
      #7c5cff 75%,
      #ff3d81 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: victoryColorWave 3s linear infinite;
  filter: drop-shadow(0 0 18px rgba(255, 176, 32, 0.45));
}

@keyframes victoryColorWave {
  0% {
    background-position: 0% center;
  }

  100% {
    background-position: 200% center;
  }
}

/* Loss Title with red color and pulsing neon glitch effect */
.title.loss-title {
  background: linear-gradient(90deg,
      #ff1744 0%,
      #ff5252 35%,
      #ff1744 70%,
      #d50000 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: lossRedPulse 1.8s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 16px rgba(255, 23, 68, 0.75));
}

@keyframes lossRedPulse {
  0% {
    background-position: 0% center;
    filter: drop-shadow(0 0 12px rgba(255, 23, 68, 0.6));
    transform: scale(1);
  }

  50% {
    background-position: 100% center;
    filter: drop-shadow(0 0 24px rgba(255, 23, 68, 0.95)) drop-shadow(0 0 36px rgba(255, 82, 82, 0.5));
    transform: scale(1.02);
  }

  100% {
    background-position: 200% center;
    filter: drop-shadow(0 0 14px rgba(255, 23, 68, 0.7));
    transform: scale(0.99);
  }
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
  letter-spacing: 0.02em;
}

/* Signature element: the orientation gate */
#gate {
  width: 120px;
  height: 120px;
  position: relative;
  margin: 6px 0;
}

#gate svg {
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(.4, 1.4, .4, 1);
}

#gate .ring {
  transform-origin: 50% 50%;
  animation: spin 12s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

#gate .core {
  transform-origin: 50% 50%;
}

.mode-heading {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

.mode-heading.escape {
  color: var(--hazard);
}

.mode-heading.assault {
  color: var(--energy);
}

.desc {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0;
  max-width: 360px;
}

.desc b {
  color: var(--text);
  font-weight: 600;
}

.rotate-hint {
  font-size: 12.5px;
  /* color: var(--text-dim); */
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px dashed var(--panel-border);
  animation: pulse 2s ease-in-out infinite alternate;
}


@keyframes pulse {
  0% {
    transform: scale(1);
    /* background-color: rgba(255, 255, 255, 0.116); */
  }

  50% {
    transform: scale(1.03);
    /* background-color: rgb(0, 131, 238); */
  }

  100% {
    transform: scale(1);
    /* background-color: rgba(255, 255, 255, 0.116); */
  }
}

button {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 13px 34px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: linear-gradient(90deg, var(--player), var(--hazard-2));
  color: white;
  font-weight: 700;
  box-shadow: 0 0 24px var(--player-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 32px var(--player-glow);
}

button:active {
  transform: translateY(1px) scale(0.98);
}

button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.btn-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

button.btn-secondary {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: none;
  color: var(--text-dim);
  padding: 13px 22px;
}

button.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.2);
}

/* Escape Settings Row & Cog Button */
.start-btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 380px;
}

.btn-settings-cog {
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(77, 216, 255, 0.12);
  border: 1px solid var(--hazard);
  border-radius: 10px;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(77, 216, 255, 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  line-height: 1;
}

.btn-settings-cog:hover {
  background: rgba(77, 216, 255, 0.28);
  box-shadow: 0 0 24px rgba(77, 216, 255, 0.5);
  transform: translateY(-1px) rotate(30deg);
}

.btn-settings-cog:active {
  transform: translateY(1px) scale(0.95);
}

/* Unified Game & Escape Settings Modal Popup */
#game-settings-modal,
#escape-settings-modal,
.game-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 16, 0.82);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}

#game-settings-modal.active,
#escape-settings-modal.active,
.game-settings-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel,
.escape-settings-panel {
  position: relative;
  z-index: 11001;
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(10, 14, 30, 0.96);
  border: 1px solid var(--hazard);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 30px rgba(77, 216, 255, 0.25);
  font-family: var(--font-display);
  color: #eef1fa;
  display: flex;
  flex-direction: column;
  gap: 16px;
  user-select: none;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#game-settings-modal.active .settings-panel,
#escape-settings-modal.active .escape-settings-panel,
.game-settings-modal.active .settings-panel {
  transform: scale(1);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 12px;
}

.settings-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--hazard);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
}

.settings-close-btn:hover {
  background: rgba(255, 61, 129, 0.25);
  border-color: var(--player);
  color: #ffffff;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 14px 16px;
}

.settings-slider-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-label-wrap {
  display: flex;
  flex-direction: column;
}

.settings-label {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.settings-sublabel {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-body);
  margin-top: 2px;
}

.settings-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.settings-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.settings-slider:hover {
  background: rgba(255, 255, 255, 0.25);
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--hazard);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(77, 216, 255, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 0 16px rgba(77, 216, 255, 0.9);
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--hazard);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px rgba(77, 216, 255, 0.6);
}

.slider-val-badge {
  min-width: 44px;
  text-align: right;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--hazard);
}

.toggle-btn-group {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.toggle-opt-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.15s ease;
}

.toggle-opt-btn.active {
  background: var(--hazard);
  color: #05060e;
  box-shadow: 0 0 12px rgba(77, 216, 255, 0.5);
}

.reset-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.btn-reset-score {
  flex: 1;
  min-width: 100px;
  background: rgba(255, 61, 129, 0.12);
  border: 1px solid rgba(255, 61, 129, 0.4);
  color: #ff85ad;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.btn-reset-score:hover {
  background: rgba(255, 61, 129, 0.28);
  border-color: var(--player);
  color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 61, 129, 0.4);
  transform: translateY(-1px);
}

.btn-reset-score:active {
  transform: translateY(1px);
}

.btn-reset-score.reset-done {
  background: rgba(0, 242, 254, 0.25) !important;
  border-color: #00f2fe !important;
  color: #ffffff !important;
}

/* ==========================================================================
   PAUSE MODAL & PAUSE MENU CONTROLS
   ========================================================================== */
#pause-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 16, 0.85);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
}

#pause-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.pause-panel {
  width: min(500px, 92vw);
  background: rgba(10, 14, 30, 0.96);
  border: 1px solid var(--energy);
  border-radius: 16px;
  padding: 26px 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85), 0 0 32px rgba(255, 176, 32, 0.25);
  font-family: var(--font-display);
  color: #eef1fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  user-select: none;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#pause-modal.active .pause-panel {
  transform: scale(1);
}

.pause-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--energy);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.pause-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--font-body);
  letter-spacing: 0.05em;
  margin-top: -6px;
  text-align: center;
}

.pause-btn-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.pause-btn {
  width: 100%;
  /* padding: 12px 18px;#btn-fullscreen */
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.15s ease;
  padding-bottom: 5px;
}

@media (min-width: 700px) {
  .top-actions {
    margin-right: 10px !important;
  }
}

.pause-btn.primary {
  background: linear-gradient(135deg, rgba(255, 61, 129, 0.9), rgba(124, 92, 255, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(255, 61, 129, 0.4);
}

.pause-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(255, 61, 129, 0.6);
}

.pause-btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #eef1fa;
}

.pause-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--hazard);
  color: #ffffff;
  transform: translateY(-1px);
}

.pause-btn.secondary.muted {
  border-color: rgba(255, 61, 129, 0.4);
  background: rgba(255, 61, 129, 0.12);
  color: #ff85ad;
}

.pause-btn.secondary.muted:hover {
  border-color: var(--player);
  color: #ffffff;
}

.pause-btn-row-dual {
  display: flex;
  gap: 10px;
  width: 100%;
}

@media (max-width:525px) {
  .pause-btn-row-dual {
    flex-direction: column;
  }
}

.pause-btn-row-dual .pause-btn {
  flex: 1;
}

.stat-row {
  display: flex;
  gap: 22px;
  margin-top: 2px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat .num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.stat .lbl {
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#controls-hint {
  position: fixed;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
  z-index: 15;
  pointer-events: none;
  letter-spacing: 0.03em;
  font-family: var(--font-body);
}

.fullscreen-btn {
  position: fixed;
  top: 13px;
  right: 8px;
  width: 38px;
  height: 38px;
  padding: 0;
  z-index: 45;
  background: rgba(12, 16, 36, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.fullscreen-btn:active {
  transform: translateY(1px);
}

@media (max-height: 540px) {
  #overlay {
    align-items: flex-start;
    padding-top: 12px;
    padding-bottom: 24px;
  }

  .panel {
    gap: 8px;
  }

  .title {
    font-size: clamp(24px, 5.5vw, 36px);
  }

  .subtitle {
    font-size: 12px;
  }

  #gate {
    width: 60px;
    height: 60px;
    margin: 2px 0;
  }

  .mode-heading {
    font-size: 15px;
  }

  .desc {
    font-size: 12.5px;
    line-height: 1.35;
    max-width: 400px;
  }

  .rotate-hint {
    font-size: 11px;
    padding: 4px 10px;
  }

  button {
    padding: 9px 26px;
    font-size: 14px;
  }

  .stat-row {
    gap: 16px;
  }

  .stat .num {
    font-size: 20px;
  }

  #boss-hud {
    top: 58px;
    gap: 3px;
  }

  .boss-header {
    gap: 8px;
  }

  .boss-name {
    font-size: 10px;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }

  .boss-phase-tag {
    font-size: 8.5px;
    padding: 1.5px 6px;
    letter-spacing: 0.05em;
    line-height: 1.1;
  }

  #bossbar-wrap {
    width: min(260px, 60vw);
    height: 8px;
    border-radius: 4px;
  }

  .upgrade-bar {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 3px 6px;
    align-items: center;
  }

  .upgrade-chip {
    padding: 3px 8px;
    min-height: unset;
    height: 25px;
    font-size: 11.5px;
    border-radius: 6px;
    gap: 5px;
    box-sizing: border-box;
  }

  .upgrade-chip .hotkey-badge {
    font-size: 9.5px;
    padding: 1px 4px;
  }

  .upgrade-chip .upg-icon {
    font-size: 12px;
  }

  .upgrade-chip .upg-name {
    font-size: 11px;
    font-weight: 600;
  }

  .upgrade-chip .upg-lvl {
    font-size: 11px;
  }

  .upgrade-chip .upg-cost {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #gate .ring {
    animation: none;
  }

  button {
    transition: none;
  }
}

/* Responsive HUD Sizing for Small Width Screens */
@media (max-width: 1080px) {
  #hud {
    height: 56px;
    padding: 0 48px 0 10px;
  }

  .fullscreen-btn {
    top: 11px;
    right: 6px;
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .hud-chip {
    padding: 5px 8px;
    min-height: 34px;
    font-size: 12px;
  }

  .hud-label {
    font-size: 10px;
  }

  .hud-value {
    font-size: 13px;
  }

  #healthbar-wrap {
    width: 90px;
    height: 8px;
  }

  .upgrade-chip {
    padding: 5px 8px;
    min-height: 34px;
    font-size: 11px;
  }

  .upg-lvl-word {
    display: none;
  }
}

@media (max-width: 860px) {

  .mode-tag,
  #escape-zone-tag {
    font-size: 10px;
    padding: 3px 8px;
    max-width: 120px;
    line-height: 1.1;
  }

  #hud-left {
    gap: 6px;
  }

  .hud-stats-stack {
    gap: 6px;
  }

  .hud-chip {
    padding: 4px 7px;
    min-height: 32px;
    font-size: 11px;
  }

  .upgrade-bar {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 4px 8px;
    align-items: center;
  }

  .upgrade-chip {
    padding: 2px 9px;
    min-height: unset;
    height: 25px;
    font-size: 11.5px;
    border-radius: 6px;
    gap: 5px;
    box-sizing: border-box;
  }

  .upgrade-chip .hotkey-badge {
    font-size: 9.5px;
    padding: 1px 4px;
  }

  .upgrade-chip .upg-icon {
    font-size: 12px;
  }

  .upgrade-chip .upg-name {
    font-size: 11px;
    font-weight: 600;
  }

  .upgrade-chip .upg-lvl {
    font-size: 11px;
  }

  .upgrade-chip .upg-cost {
    font-size: 10px;
  }

  #healthbar-wrap {
    width: 100px;
  }

  #boss-hud {
    top: 62px;
    gap: 4px;
  }

  .boss-header {
    gap: 8px;
  }

  .boss-name {
    font-size: 11px;
    letter-spacing: 0.08em;
  }

  .boss-phase-tag {
    font-size: 9px;
    padding: 1.5px 7px;
    letter-spacing: 0.06em;
  }

  #bossbar-wrap {
    width: min(280px, 75vw);
    height: 9px;
    border-radius: 5px;
  }
}

@media (max-width: 680px) {
  #hud {
    padding: 0 42px 0 8px;
  }

  .fullscreen-btn {
    top: 11px;
    right: 5px;
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .mode-tag,
  #escape-zone-tag {
    /* font-size: 9px; */
    padding: 3px 6px;
    max-width: 115px;
    line-height: 1.08;
    letter-spacing: 0.03em;
  }

  #escape-obj-val {
    min-width: 48px;
  }

  #hv-score {
    min-width: 38px;
  }

  .upgrade-bar {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 3px 6px;
    align-items: center;
  }

  .upgrade-chip {
    padding: 2px 8px;
    min-height: unset;
    height: 24px;
    font-size: 11px;
    border-radius: 5px;
    gap: 4px;
    box-sizing: border-box;
  }

  .upgrade-chip .hotkey-badge {
    font-size: 9px;
    padding: 1px 3px;
  }

  .upgrade-chip .upg-icon {
    font-size: 11.5px;
  }

  .upgrade-chip .upg-name {
    font-size: 10.5px;
    font-weight: 600;
    display: inline;
  }

  .upgrade-chip .upg-lvl {
    font-size: 10.5px;
  }

  .upgrade-chip .upg-cost {
    font-size: 9.5px;
  }

  .hud-label {
    display: none;
  }

  #healthbar-wrap {
    width: 55px;
  }

  #boss-hud {
    top: 58px;
    gap: 3px;
  }

  .boss-header {
    gap: 6px;
  }

  .boss-name {
    font-size: 9.5px;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .boss-phase-tag {
    font-size: 8px;
    padding: 1px 6px;
    letter-spacing: 0.04em;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.1;
  }

  #bossbar-wrap {
    width: min(220px, 70vw);
    height: 7px;
    border-radius: 4px;
  }
}

/* Responsive HUD for Low Screen Height (< 400px) */
@media (max-height: 400px) {
  #hud {
    height: 58px;
  }

  .hud-stats-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    align-items: stretch;
    flex-shrink: 0;
  }

  .hud-stats-stack .hud-chip {
    min-height: unset;
    height: 23px;
    padding: 1px 7px;
    font-size: 11.5px;
    border-radius: 5px;
    gap: 5px;
    line-height: 1;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .hud-stats-stack .hud-chip .hud-label {
    display: inline-block;
    font-size: 9.5px;
    letter-spacing: 0.04em;
    line-height: 1;
  }

  .hud-stats-stack .hud-chip .hud-value {
    font-size: 11px;
    line-height: 1;
  }

  .upgrade-bar {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 3px 6px;
    align-items: center;
  }

  .upgrade-chip {
    min-height: unset;
    height: 23px;
    padding: 1px 8px;
    font-size: 10.5px;
    border-radius: 5px;
    gap: 4px;
    line-height: 1;
    box-sizing: border-box;
  }

  .upgrade-chip .hotkey-badge {
    font-size: 9px;
    padding: 1px 3px;
  }

  .upgrade-chip .upg-icon {
    font-size: 11px;
  }

  .upgrade-chip .upg-name {
    font-size: 10px;
    font-weight: 600;
    display: inline;
  }

  .upgrade-chip .upg-lvl {
    font-size: 10px;
  }

  .upgrade-chip .upg-cost {
    font-size: 9.5px;
  }

  #hud-left>.hud-chip {
    min-height: unset;
    height: 49px;
    padding: 2px 7px;
  }

  #boss-hud {
    top: 54px;
    gap: 2px;
  }

  .boss-header {
    gap: 6px;
  }

  .boss-name {
    font-size: 9px;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .boss-phase-tag {
    font-size: 7.5px;
    padding: 1px 5px;
    letter-spacing: 0.04em;
    line-height: 1;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #bossbar-wrap {
    width: min(210px, 48vw);
    height: 6px;
    border-radius: 3px;
  }
}

/* Wave Announcement Overlay Banner */
#wave-announcement {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  pointer-events: none;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 48px;
  background: rgba(8, 12, 26, 0.96);
  border-top: 2px solid var(--energy);
  border-bottom: 2px solid var(--energy);
  box-shadow: 0 0 45px rgba(255, 176, 32, 0.55), inset 0 0 25px rgba(255, 176, 32, 0.22);
  backdrop-filter: blur(16px);
  font-family: var(--font-display);
  color: #ffffff;
  text-align: center;
  letter-spacing: 0.12em;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#wave-announcement.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#wave-announcement.boss-wave {
  border-color: #ff1744;
  box-shadow: 0 0 50px rgba(255, 23, 68, 0.6), inset 0 0 30px rgba(255, 23, 68, 0.25);
  animation: bossBannerPulse 0.75s infinite alternate ease-in-out;
}

@keyframes bossBannerPulse {
  from {
    box-shadow: 0 0 35px rgba(255, 23, 68, 0.45);
  }

  to {
    box-shadow: 0 0 65px rgba(255, 23, 68, 0.85);
  }
}

.wave-title {
  font-size: 28px;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255, 176, 32, 0.85);
  color: var(--energy);
  margin: 0;
  line-height: 1.2;
}

#wave-announcement.boss-wave .wave-title {
  color: #ff1744;
  text-shadow: 0 0 22px rgba(255, 23, 68, 0.95);
}

.wave-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 6px;
  letter-spacing: 0.2em;
}

#wave-announcement.boss-wave .wave-subtitle {
  color: #ffa4b6;
}

@media (max-width: 680px),
(max-height: 480px) {
  #wave-announcement {
    padding: 10px 20px;
    width: min(90vw, 320px);
  }

  .wave-title {
    font-size: 18px;
  }

  .wave-subtitle {
    font-size: 10px;
    margin-top: 3px;
    letter-spacing: 0.12em;
  }
}

/* Difficulty Selector UI */
.diff-selector {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px 0;
  justify-content: center;
  flex-wrap: wrap;
}

.diff-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.diff-btn.active {
  border-color: var(--energy);
  color: #ffffff;
  background: rgba(255, 176, 32, 0.18);
  box-shadow: 0 0 14px rgba(255, 176, 32, 0.3);
}

.diff-btn.locked {
  opacity: 0.55;
  border-color: rgba(255, 255, 255, 0.06);
}

.diff-btn:hover:not(.locked) {
  border-color: var(--energy);
  transform: translateY(-1px);
}

.unlock-banner {
  background: rgba(77, 255, 136, 0.15);
  border: 1px solid #4dff88;
  color: #4dff88;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 10px 0;
  text-shadow: 0 0 10px rgba(77, 255, 136, 0.6);
  box-shadow: 0 0 16px rgba(77, 255, 136, 0.25);
  animation: unlockPulse 1.2s infinite alternate ease-in-out;
}

@keyframes unlockPulse {
  from {
    transform: scale(0.98);
    opacity: 0.85;
  }

  to {
    transform: scale(1.02);
    opacity: 1;
  }
}