:root {
  --bg-deep: #030308;
  --cyan: #00f3ff;
  --magenta: #ff007f;
  --gold: #ffcc00;
  --emerald: #00ff88;
  --violet: #b565ff;
  --danger: #ff2a55;
  --text-main: #eef6ff;
  --text-dim: #7a8ba8;
}

* {
  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(--bg-deep);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text-main);
  overscroll-behavior: none; /* no pull-to-refresh or bounce on phones */
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* mobile browsers: the visible area, not the one behind the address bar */
  overflow: hidden;
  cursor: crosshair;
}

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

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 22px;
  /* Phones in landscape: keep the HUD clear of the notch and rounded corners. */
  padding: max(14px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 14px max(22px, env(safe-area-inset-left));
  z-index: 10;
}

.hud-top {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  align-items: start;
  gap: 20px;
}

.hud-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
  font-weight: 700;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 14px rgba(0, 243, 255, 0.8), 0 0 28px rgba(0, 243, 255, 0.4);
  line-height: 1.05;
}

.left-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 5px;
}

.left-badges > div {
  white-space: nowrap;
}

.multiplier-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(255, 204, 0, 0.12);
  border: 1px solid rgba(255, 204, 0, 0.5);
  border-radius: 99px;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.8);
}

.cores-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--violet);
  background: rgba(181, 101, 255, 0.14);
  border: 1px solid rgba(181, 101, 255, 0.55);
  border-radius: 99px;
  text-shadow: 0 0 10px rgba(181, 101, 255, 0.85);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.wave-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2.5px;
  margin-bottom: 6px;
  text-shadow: 0 0 10px rgba(255, 0, 127, 0.7);
}

#wave-display {
  color: var(--magenta);
}

.separator {
  color: var(--text-dim);
}

#timer-display {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.xp-bar-container {
  position: relative;
  width: 100%;
  height: 16px;
  background: rgba(10, 18, 36, 0.75);
  border: 1px solid rgba(0, 255, 136, 0.45);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.18), inset 0 0 8px rgba(0, 0, 0, 0.8);
}

#xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00b8ff, #00ff88);
  box-shadow: 0 0 14px #00ff88;
  transition: width 0.12s ease-out;
}

#level-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
  text-shadow: 0 1px 3px #000, 0 0 8px #000;
}

.weapons-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 7px;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.bars-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

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

.bar-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--cyan);
}

.hp-bar-outer {
  width: 150px;
  height: 12px;
  background: rgba(15, 20, 35, 0.8);
  border: 1px solid rgba(0, 243, 255, 0.5);
  border-radius: 6px;
  overflow: hidden;
}

#hp-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #00f3ff, #00ffaa);
  box-shadow: 0 0 10px #00f3ff;
  transition: width 0.15s ease-out, background 0.2s;
}

#hp-text {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 58px;
  text-align: right;
}

.ability-group {
  display: flex;
  gap: 8px;
}

.ability-pill {
  position: relative;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(12, 18, 36, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

.key-hint {
  color: var(--cyan);
  font-weight: 900;
  margin-right: 4px;
}

.cooldown-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

.quick-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(10, 15, 30, 0.8);
  border: 1px solid rgba(122, 139, 168, 0.4);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  border-color: var(--cyan);
  color: #fff;
}

.hud-btn.active {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(0, 255, 136, 0.12);
}

/* Center Banner */
.center-banner {
  align-self: center;
  margin-bottom: auto;
  margin-top: 68px;
  padding: 8px 24px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(90deg, transparent, rgba(255, 0, 127, 0.25), transparent);
  border-top: 1px solid rgba(255, 0, 127, 0.6);
  border-bottom: 1px solid rgba(255, 0, 127, 0.6);
  text-shadow: 0 0 14px var(--magenta);
  animation: bannerPulse 0.4s ease-out;
}

@keyframes bannerPulse {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Boss Encounter HUD: spans the full top row under the three HUD columns */
.boss-hud {
  grid-column: 1 / -1;
  justify-self: center;
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: -8px;
  position: relative;
}

.boss-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  background: repeating-linear-gradient(-45deg, rgba(255, 42, 85, 0.34) 0 12px, rgba(255, 204, 0, 0.1) 12px 24px);
  background-size: 33.94px 33.94px;
  border: 1px solid var(--danger);
  border-radius: 4px;
  box-shadow: 0 0 18px rgba(255, 42, 85, 0.55), inset 0 0 14px rgba(255, 42, 85, 0.35);
  text-shadow: 0 0 10px var(--danger), 0 1px 2px #000;
  animation: hazardScroll 0.8s linear infinite, bossWarnFlash 0.25s ease-in-out infinite alternate;
}

.boss-warning-icon {
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold), 0 1px 2px #000;
}

.boss-warning-eta {
  min-width: 64px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  background: rgba(3, 4, 11, 0.7);
  border-radius: 3px;
}

@keyframes hazardScroll {
  from { background-position: 0 0; }
  to { background-position: 33.94px 0; }
}

@keyframes bossWarnFlash {
  from { border-color: var(--danger); }
  to { border-color: var(--gold); box-shadow: 0 0 26px rgba(255, 204, 0, 0.6), inset 0 0 18px rgba(255, 42, 85, 0.5); }
}

.boss-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.boss-bar-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.boss-bar-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 1px 2px #000;
}

.boss-bar-name {
  font-size: 13px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.8), 0 1px 2px #000;
}

.boss-bar-epithet {
  font-size: 10px;
  color: #ff77b7;
}

.boss-bar-hp {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.boss-bar-track {
  height: 12px;
  background: rgba(10, 14, 30, 0.85);
  border: 1px solid rgba(255, 204, 0, 0.65);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(255, 204, 0, 0.25);
}

.boss-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff2a55, #ffcc00);
  box-shadow: 0 0 12px #ffcc00;
  transition: width 0.12s ease-out;
}

/* Extra bosses stack as compact rows under the first. */
.boss-bar-row + .boss-bar-row .boss-bar-track { height: 6px; }
.boss-bar-row + .boss-bar-row .boss-bar-name { font-size: 11px; }

.boss-bar-more {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  color: var(--text-dim);
}

/* Boss arrival / defeat title card */
.boss-card {
  position: absolute;
  top: calc(100% + 22px);
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 94vw);
  padding: 12px 24px 14px;
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(255, 42, 85, 0.24) 18%, rgba(255, 42, 85, 0.24) 82%, transparent);
  border-top: 2px solid var(--danger);
  border-bottom: 2px solid var(--danger);
  animation: bossCardIn 0.6s cubic-bezier(0.2, 1.3, 0.4, 1);
  transition: opacity 0.4s ease-in;
}

.boss-card-kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--danger);
  text-shadow: 0 0 10px var(--danger);
}

.boss-card-name {
  font-size: clamp(24px, 5vw, 42px);
  font-weight: 900;
  letter-spacing: 6px;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 0 18px var(--gold), 0 0 38px rgba(255, 204, 0, 0.6);
}

.boss-card-epithet {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 5px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
}

.boss-card-detail {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: #d6e6ff;
}

.boss-card-defeat {
  background: linear-gradient(90deg, transparent, rgba(255, 204, 0, 0.22) 18%, rgba(255, 204, 0, 0.22) 82%, transparent);
  border-color: var(--gold);
}

.boss-card-defeat .boss-card-kicker {
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold);
}

.boss-card-defeat .boss-card-name {
  text-shadow: 0 0 18px var(--cyan), 0 0 38px rgba(0, 243, 255, 0.6);
}

.boss-card-out {
  opacity: 0;
}

@keyframes bossCardIn {
  0% { opacity: 0; transform: translateX(-50%) scale(1.5); }
  55% { opacity: 1; }
  100% { transform: translateX(-50%) scale(1); }
}

/* Lieutenant / new-hostile card: the boss title card at a smaller scale, silver instead of red-gold.
   It sits low on screen so it never covers the ship, the boss bars or the boss title card. */
.lt-card {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 92vw);
  padding: 7px 18px 9px;
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(190, 200, 255, 0.16) 18%, rgba(190, 200, 255, 0.16) 82%, transparent);
  border-top: 1px solid rgba(225, 232, 255, 0.8);
  border-bottom: 1px solid rgba(225, 232, 255, 0.8);
  animation: ltCardIn 0.45s cubic-bezier(0.2, 1.3, 0.4, 1);
  transition: opacity 0.35s ease-in;
}

.lt-card-kicker {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 5px;
  color: #dfe6ff;
  text-shadow: 0 0 8px rgba(200, 210, 255, 0.9);
}

.lt-card-name {
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 900;
  letter-spacing: 5px;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 0 14px rgba(190, 200, 255, 0.95), 0 0 28px rgba(150, 120, 255, 0.55);
}

.lt-card-epithet {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #c8b8ff;
}

.lt-card-epithet:empty { display: none; }

.lt-card-detail {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: #d6e6ff;
}

.lt-card-defeat {
  background: linear-gradient(90deg, transparent, rgba(255, 204, 0, 0.16) 18%, rgba(255, 204, 0, 0.16) 82%, transparent);
  border-color: rgba(255, 204, 0, 0.8);
}

.lt-card-defeat .lt-card-kicker { color: var(--gold); text-shadow: 0 0 8px var(--gold); }

.lt-card-intel {
  background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.12) 18%, rgba(0, 243, 255, 0.12) 82%, transparent);
  border-color: rgba(0, 243, 255, 0.7);
}

.lt-card-intel .lt-card-kicker { color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.lt-card-intel .lt-card-name { text-shadow: 0 0 14px rgba(0, 243, 255, 0.85); }

.lt-card-out { opacity: 0; }

@keyframes ltCardIn {
  0% { opacity: 0; transform: translateX(-50%) scale(1.3); }
  60% { opacity: 1; }
  100% { transform: translateX(-50%) scale(1); }
}

/* Modals */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(6, 10, 24, 0.82), rgba(2, 3, 8, 0.94));
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.modal-card {
  background: rgba(8, 12, 26, 0.94);
  border: 1px solid rgba(0, 243, 255, 0.4);
  box-shadow: 0 0 40px rgba(0, 243, 255, 0.18), inset 0 0 30px rgba(0, 243, 255, 0.05);
  border-radius: 16px;
  padding: 26px 32px;
  max-width: 1040px;
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  text-align: center;
  cursor: default;
}

.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.18);
}

.wallet-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(181, 101, 255, 0.12);
  border: 1px solid rgba(181, 101, 255, 0.55);
  box-shadow: 0 0 20px rgba(181, 101, 255, 0.22);
  padding: 8px 18px;
  border-radius: 12px;
}

.wallet-icon {
  font-size: 26px;
  color: var(--violet);
  text-shadow: 0 0 12px var(--violet);
}

.wallet-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #d6b4ff;
}

.wallet-value {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px var(--violet);
}

.glitch-subtitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: clamp(1px, 0.6vw, 4px);
  color: var(--cyan);
  margin-bottom: 4px;
  text-shadow: 0 0 10px var(--cyan);
}

.danger-text {
  color: var(--danger);
  text-shadow: 0 0 10px var(--danger);
}

.neon-title {
  font-size: clamp(22px, 6.5vw, 40px);
  font-weight: 900;
  letter-spacing: clamp(2px, 0.8vw, 5px);
  color: #ffffff;
  text-shadow: 0 0 18px var(--cyan), 0 0 36px rgba(0, 243, 255, 0.45);
}

.neon-title span {
  color: var(--magenta);
  text-shadow: 0 0 18px var(--magenta);
  margin: 0 4px;
}

.danger-glow {
  text-shadow: 0 0 18px var(--danger), 0 0 36px rgba(255, 42, 85, 0.55);
}

/* Two-Column Hub Layout (Armory + Leaderboard) */
.hub-columns {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
  text-align: left;
}

.hub-panel {
  background: rgba(12, 18, 36, 0.72);
  border: 1px solid rgba(0, 243, 255, 0.22);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--cyan);
}

.panel-sub {
  font-size: 11px;
  color: var(--text-dim);
}

/* Armory Grid */
.armory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
  max-height: 404px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

/* Category tabs + completion, and the one-time reset notice, span the whole grid row. */
.armory-tabs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 4px;
  background: rgba(8, 13, 30, 0.96);
}
.armory-tab {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(16, 24, 48, 0.85);
  color: #a9bcd8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}
.armory-tab.active { border-color: var(--cyan); color: #fff; background: rgba(0, 243, 255, 0.16); }
.armory-progress { margin-left: auto; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--emerald); }
.armory-notice {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 204, 0, 0.6);
  background: rgba(255, 204, 0, 0.1);
  font-size: 11px;
  color: #ffe9a8;
  line-height: 1.35;
}
.armory-notice b { color: #ffcc00; letter-spacing: 1px; }
.armory-notice-ok {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 204, 0, 0.7);
  background: rgba(255, 204, 0, 0.18);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}
.armory-value { font-size: 11px; color: #a9bcd8; margin-bottom: 5px; }
.armory-value b { color: #fff; }
.armory-bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); margin-bottom: 6px; overflow: hidden; }
.armory-bar i { display: block; height: 100%; background: var(--upg, var(--cyan)); }
.armory-card .armory-name { color: var(--upg, #fff); }
.armory-card.maxed { border-color: rgba(0, 255, 136, 0.45); }

.armory-card {
  background: rgba(16, 24, 48, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.armory-card.affordable {
  border-color: rgba(181, 101, 255, 0.55);
  cursor: pointer;
}

.armory-card.affordable:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 4px 18px rgba(0, 243, 255, 0.25);
}

.armory-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.armory-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.armory-rank {
  font-size: 10px;
  font-weight: 800;
  color: var(--emerald);
  letter-spacing: 1px;
}

.armory-desc {
  font-size: 11px;
  color: #a9bcd8;
  line-height: 1.35;
  margin-bottom: 3px;
}

.armory-buy-btn {
  width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  border: 1px solid rgba(181, 101, 255, 0.5);
  background: rgba(181, 101, 255, 0.18);
  color: #fff;
  cursor: pointer;
  transition: all 0.12s;
}

.armory-buy-btn:hover:not(:disabled) {
  background: rgba(0, 243, 255, 0.28);
  border-color: var(--cyan);
}

.armory-buy-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

/* Highscore List */
.highscore-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hs-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(16, 24, 46, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
}

.hs-row.hs-current {
  border-color: var(--gold);
  background: rgba(255, 204, 0, 0.14);
  box-shadow: 0 0 14px rgba(255, 204, 0, 0.25);
}

.hs-rank {
  font-weight: 900;
  color: var(--cyan);
}

.hs-row:nth-child(1) .hs-rank { color: var(--gold); }
.hs-row:nth-child(2) .hs-rank { color: #e0e8ff; }
.hs-row:nth-child(3) .hs-rank { color: #ff9955; }

.hs-name {
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hs-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.hs-score {
  font-weight: 900;
  color: var(--emerald);
  font-variant-numeric: tabular-nums;
}

/* Global / My Runs board tabs (focusable buttons, so the controller MenuNavigator reaches them) */
.board-header {
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.board-tabs {
  display: flex;
  gap: 6px;
}

.board-tab {
  background: rgba(8, 12, 26, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.3);
  color: var(--text-dim);
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.board-tab:hover {
  color: #fff;
  border-color: var(--cyan);
}

.board-tab.active {
  color: var(--bg-deep);
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.55);
}

.board-status {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.board-note {
  display: block;
  min-height: 14px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.board-note.offline {
  color: #ff9955;
  text-shadow: 0 0 8px rgba(255, 153, 85, 0.45);
}

.highscore-list {
  position: relative; /* rows' offsetTop is relative to the list, for scrolling the new run into view */
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 243, 255, 0.4) transparent;
  padding-right: 2px;
}

/* The title board shares its panel with the controls cheat-sheet: ~5 rows, the rest scrolls. */
#highscore-list {
  max-height: 190px;
}

/* A long board makes the right panel taller: keep the armory cards at the top of theirs, and let the title
   armory grid fill the panel down to its bottom edge (it scrolls inside; never shorter than ~2.5 card rows). */
.hub-panel:has(> .armory-grid) {
  justify-content: flex-start;
}

#armory-grid {
  flex: 1 1 0;
  min-height: 360px;
  max-height: none;
}

.hs-row.hs-mine {
  border-color: rgba(181, 101, 255, 0.75);
  background: rgba(181, 101, 255, 0.14);
}

.hs-row.hs-mine .hs-name {
  color: #e2c6ff;
}

.hs-row.hs-current.hs-mine {
  border-color: var(--gold);
  background: rgba(255, 204, 0, 0.14);
}

.hs-empty {
  padding: 14px 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-dim);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 7px;
}

/* Game-over global rank line ("GLOBAL RANK #12") */
.go-global-rank {
  min-height: 22px;
  margin: -6px 0 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text-dim);
}

.go-global-rank:empty {
  display: none;
}

.go-global-rank.tone-gold {
  font-size: 20px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 204, 0, 0.7), 0 0 30px rgba(255, 204, 0, 0.35);
}

.go-global-rank.tone-cyan {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.55);
}

.go-global-rank.tone-danger {
  color: var(--danger);
  text-shadow: 0 0 10px rgba(255, 42, 85, 0.45);
}

.controls-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: #b4c6e0;
}

.controls-mini b {
  color: var(--cyan);
}

.neon-btn {
  display: inline-block;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  padding: 13px 36px;
  border-radius: 99px;
  border: 2px solid var(--cyan);
  background: linear-gradient(90deg, rgba(0, 243, 255, 0.2), rgba(255, 0, 127, 0.2));
  color: #ffffff;
  cursor: pointer;
  text-shadow: 0 0 10px var(--cyan);
  box-shadow: 0 0 24px rgba(0, 243, 255, 0.35);
  transition: all 0.18s ease;
}

.neon-btn:hover {
  transform: translateY(-2px) scale(1.02);
  background: linear-gradient(90deg, rgba(0, 243, 255, 0.38), rgba(255, 0, 127, 0.38));
  box-shadow: 0 0 36px rgba(0, 243, 255, 0.65), 0 0 16px rgba(255, 0, 127, 0.45);
}

/* Upgrade Choices */
.upgrade-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 16px var(--emerald);
  margin-bottom: 6px;
}

.upgrade-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 22px;
}

.upgrade-hint span {
  color: var(--gold);
  font-weight: 800;
}

.upgrade-choices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Four-card level-up hands: one more column, and a wider modal to hold it. */
.upgrade-choices-grid.cards-4 {
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.modal-card:has(.cards-4) {
  max-width: 1280px;
}
@media (max-width: 1100px) {
  .upgrade-choices-grid.cards-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Rarity palette: common white/gray, uncommon green, rare blue, epic purple, legendary gold.
   Rarity owns the card border, name and badge color; lucky +2/+3 level rolls get a separate ribbon. */
.rarity-common { --rarity: #c9d4e4; --rarity-soft: rgba(201, 212, 228, 0.3); --rarity-bg: rgba(30, 36, 52, 0.94); }
.rarity-uncommon { --rarity: #00ff88; --rarity-soft: rgba(0, 255, 136, 0.32); --rarity-bg: rgba(6, 40, 30, 0.94); }
.rarity-rare { --rarity: #3d9bff; --rarity-soft: rgba(61, 155, 255, 0.36); --rarity-bg: rgba(10, 26, 60, 0.94); }
.rarity-epic { --rarity: #b565ff; --rarity-soft: rgba(181, 101, 255, 0.38); --rarity-bg: rgba(36, 14, 60, 0.94); }
.rarity-legendary { --rarity: #ffcc00; --rarity-soft: rgba(255, 204, 0, 0.4); --rarity-bg: rgba(48, 36, 8, 0.94); }
.rarity-evolution { --rarity: #ff4fd8; --rarity-soft: rgba(255, 79, 216, 0.4); --rarity-bg: rgba(48, 8, 40, 0.94); }
.rarity-transform { --rarity: #38f2d0; --rarity-soft: rgba(56, 242, 208, 0.4); --rarity-bg: rgba(6, 40, 36, 0.94); }
.rarity-boost { --rarity: #ffb347; --rarity-soft: rgba(255, 179, 71, 0.4); --rarity-bg: rgba(46, 30, 8, 0.94); }
/* Breakthrough picks: two big cards with a slow pulse so the R&D moment reads as special. */
.upgrade-option.breakthrough-card { animation: breakthrough-pulse 1.8s ease-in-out infinite; }
@keyframes breakthrough-pulse {
  0%, 100% { box-shadow: 0 0 14px var(--rarity-soft); }
  50% { box-shadow: 0 0 32px var(--rarity-soft), 0 0 4px var(--rarity) inset; }
}
@media (prefers-reduced-motion: reduce) { .upgrade-option.breakthrough-card { animation: none; } }

.upgrade-option {
  position: relative;
  background: linear-gradient(180deg, var(--rarity-bg), rgba(8, 12, 26, 0.97) 55%);
  border: 2px solid var(--rarity);
  border-radius: 12px;
  padding: 18px 16px 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 0 18px var(--rarity-soft);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.upgrade-option:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px var(--rarity-soft), 0 0 22px var(--rarity-soft);
}

/* Cache rewards are already installed: informational, not clickable. */
.upgrade-option.installed {
  cursor: default;
}

.upgrade-option.installed:hover {
  transform: none;
}

/* Multi-level roll: the ribbon wears the card's rarity color, since rarity is the jump size. */
.upg-jump-ribbon {
  position: absolute;
  top: -11px;
  right: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--rarity);
  color: #05060f;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: 0 0 14px var(--rarity-soft);
}

.jump-4 .upg-jump-ribbon,
.jump-5 .upg-jump-ribbon {
  outline: 1px solid #fff;
  animation: jump-ribbon-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes jump-ribbon-pulse {
  from { box-shadow: 0 0 10px var(--rarity-soft); }
  to { box-shadow: 0 0 26px var(--rarity); }
}

.upg-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.upg-key {
  font-size: 12px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(0, 243, 255, 0.15);
  border: 1px solid rgba(0, 243, 255, 0.5);
  color: var(--cyan);
  white-space: nowrap;
}

.upg-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  color: var(--rarity);
  border: 1px solid var(--rarity-soft);
  background: rgba(0, 0, 0, 0.3);
  text-align: right;
}

.upg-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--rarity);
  margin-bottom: 4px;
}

/* Weapon tags / damage types: small outlined chips in each tag's own neon (TAG_INFO in weapon-scaling.js). */
.upg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 6px;
}

.upg-tag {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 3px;
  color: var(--tag);
  border: 1px solid var(--tag);
  background: rgba(0, 0, 0, 0.35);
  opacity: 0.92;
}

.upg-headline {
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 0 12px var(--rarity-soft);
  margin-bottom: 6px;
}

.upg-summary {
  font-size: 12.5px;
  color: #b8c7e0;
  line-height: 1.4;
  margin-bottom: 10px;
}

.upg-stats {
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.upg-stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.upg-stat-label {
  color: #9fb0cc;
}

.upg-stat-val {
  color: #8494b2;
  white-space: nowrap;
}

.upg-stat-val b {
  color: #fff;
  font-weight: 800;
}

.upg-stat-more {
  color: #7a8ba8;
  font-style: italic;
}

.upg-level {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #dbe6f5;
}

.upg-max {
  color: var(--text-dim);
}

.upgrade-option[class*="jump-"] .upg-level {
  color: var(--rarity);
}

/* Cache rewards: center however many cards the jackpot installed. */
#chest-rewards-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 300px));
  justify-content: center;
}

/* 5x jackpots wrap to two rows: trim each card so the whole cache and its Claim button fit 720px. */
#chest-rewards-grid.compact {
  gap: 14px 16px;
}

#chest-rewards-grid.compact .upgrade-option {
  padding: 12px 14px 10px;
}

#chest-rewards-grid.compact .upg-top {
  margin-bottom: 6px;
}

#chest-rewards-grid.compact .upg-name {
  margin-bottom: 2px;
}

#chest-rewards-grid.compact .upg-tags {
  margin: 0 0 4px;
}

#chest-rewards-grid.compact .upg-headline {
  font-size: 18px;
  margin-bottom: 6px;
}

#chest-rewards-grid.compact .upg-summary {
  display: none;
}

#chest-rewards-grid.compact .upg-stats {
  margin-bottom: 8px;
}

#chest-rewards-grid.compact .upg-stat {
  padding: 2px 0;
}

@media (max-width: 760px) {
  .upgrade-card {
    padding: 18px 14px;
  }

  .upgrade-title {
    font-size: 26px;
  }

  .upgrade-hint {
    margin-bottom: 16px;
  }

  .upgrade-choices-grid,
  .upgrade-choices-grid.cards-4,
  #chest-rewards-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .upg-headline {
    font-size: 19px;
  }
}

/* Game Over Stats Row */
.gameover-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.go-stat-box {
  background: rgba(16, 22, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  padding: 10px 12px;
}

.go-stat-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.go-stat-val {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
}


/* Pilot Name Input Bar */
.name-entry-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(8, 12, 26, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
}

.name-label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--cyan);
  white-space: nowrap;
}

.name-input {
  flex: 1;
  background: rgba(16, 26, 52, 0.9);
  border: 1px solid rgba(0, 243, 255, 0.45);
  border-radius: 5px;
  padding: 5px 9px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.name-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.4);
}

.save-name-btn {
  background: rgba(0, 255, 136, 0.2);
  border: 1px solid var(--emerald);
  color: var(--emerald);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.save-name-btn:hover {
  background: rgba(0, 255, 136, 0.38);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}


/* Luck Badge & Multi-Level / Chest Jackpot Cards */
.luck-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--emerald);
  background: rgba(0, 255, 136, 0.12);
  border: 1px solid rgba(0, 255, 136, 0.55);
  border-radius: 99px;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.8);
}

.jump-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  margin-top: 6px;
}


/* In-Game Slide-Over Live Tuner & Sandbox Drawer */
.tuner-drawer {
  position: fixed;
  top: 72px;
  right: 16px;
  bottom: 182px;
  width: 390px;
  max-width: calc(100vw - 32px);
  background: rgba(6, 10, 24, 0.94);
  border: 1px solid rgba(0, 243, 255, 0.45);
  border-radius: 12px;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.8), 0 0 18px rgba(0, 243, 255, 0.18);
  backdrop-filter: blur(12px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
}
.tuner-drawer.hidden {
  display: none !important;
}
.tuner-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.2);
  background: rgba(0, 243, 255, 0.06);
}
.tuner-drawer-actions,
.tuner-sandbox-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.tuner-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 16px;
}
.drawer-group-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 1.2px;
  margin: 10px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.2);
}
.drawer-row {
  display: grid;
  grid-template-columns: 1fr 110px 58px;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 11px;
}
.drawer-row input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
  cursor: pointer;
}
.drawer-row input[type="color"] {
  width: 100%;
  height: 22px;
  border: 1px solid rgba(0, 243, 255, 0.35);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.drawer-val {
  font-family: Consolas, monospace;
  font-size: 10px;
  color: var(--emerald);
  text-align: right;
}


/* HUD & Pause Menu Volume Sliders */
.hud-vol-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(6, 12, 28, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
}
.hud-vol-pill input[type="range"] {
  width: 68px;
  accent-color: var(--cyan);
  cursor: pointer;
}
#hud-volume-label {
  min-width: 34px;
  text-align: right;
  font-family: Consolas, monospace;
  color: var(--emerald);
}
.pause-audio-box {
  background: rgba(5, 10, 24, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 12px;
  text-align: left;
}
.pause-slider-row {
  display: grid;
  grid-template-columns: 125px 1fr 48px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 700;
  color: #d6e8ff;
}
.pause-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
  cursor: pointer;
}

/* Pause-menu on/off toggles (e.g. floating damage numbers): dim when OFF, cyan when ON. */
.pause-toggle-btn {
  padding: 12px 18px;
  font-size: 13px;
  border-color: rgba(139, 163, 199, 0.55);
  color: #8ba3c7;
  background: rgba(5, 10, 24, 0.6);
}

.pause-toggle-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Controller focus highlight (menus navigated with d-pad / left stick) */
.gp-focus {
  outline: 2px solid var(--gold) !important;
  outline-offset: 3px;
  box-shadow: 0 0 18px rgba(255, 204, 0, 0.55) !important;
}

.upgrade-option.gp-focus {
  transform: translateY(-5px);
}

/* Short screens (up to 1366x768 laptops): a slimmer boss title card so it stays clear of the ship at
   screen centre even under a warning strip and stacked boss bars. */
@media (max-height: 820px) {
  .boss-card { top: calc(100% + 10px); padding: 6px 16px 8px; }
  .boss-card-name { font-size: clamp(20px, 4vw, 30px); letter-spacing: 4px; }
  .boss-card-epithet { font-size: 12px; }
  .boss-card-detail { margin-top: 2px; }
}

/* Narrow screens: stack the core wallet under the title so the logo keeps its width. */
@media (max-width: 600px) {
  .hub-header { flex-wrap: wrap; gap: 12px; }
}

/* Phones: armory and highscore board stack instead of sitting side by side in a card wider than the
   screen (which scrolled sideways and squeezed the board's callsigns). */
@media (max-width: 760px) {
  .hub-columns { grid-template-columns: minmax(0, 1fr); }
}

/* Phone-width boards: the callsign input shrinks to fit, and rows drop their wave/level/time line
   (keeping the version tag on ALL-TIME) so callsigns aren't cut to a few letters. */
@media (max-width: 480px) {
  .modal-card.hub-card { padding: 20px 14px; }
  .gameover-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .go-global-rank.tone-gold { font-size: 16px; letter-spacing: 1.5px; }
  .name-input { min-width: 0; width: 100%; }
  .hs-row { grid-template-columns: 28px minmax(0, 1fr) auto auto; gap: 6px; padding: 7px 8px; }
  .hs-meta { font-size: 0; }
  .hs-meta .hs-ver { font-size: 9.5px; margin-right: 0; }
}

/* Levels granted by an evolution on top of a weapon's own level (e.g. "+1 STORM") */
.lv-bonus {
  color: #ffd84d;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(255, 216, 77, 0.55);
}

/* ---- Weapon loadout ------------------------------------------------------------------------ */
/* Loadout cards (NEW WEAPON and the weapon picks it opens) are not level rolls: their own armory-orange tier. */
.rarity-weapon { --rarity: #ff8a3d; --rarity-soft: rgba(255, 138, 61, 0.4); --rarity-bg: rgba(44, 20, 8, 0.94); }

.upgrade-option.new-weapon-card {
  background:
    repeating-linear-gradient(135deg, rgba(255, 138, 61, 0.08) 0 10px, transparent 10px 20px),
    linear-gradient(180deg, var(--rarity-bg), rgba(8, 12, 26, 0.97) 60%);
  border-style: dashed;
  animation: new-weapon-pulse 1.1s ease-in-out infinite alternate;
}

.upgrade-option.new-weapon-card .upg-headline {
  font-size: 23px;
  color: var(--rarity);
}

/* The NEW WEAPON pick (1 of 3 weapons): the whole window turns armory orange, and each card leads with
   the weapon's name in its tier colour instead of a white "+N" stat headline. */
#upgrade-modal.phase-weapon .modal-card {
  border-color: rgba(255, 138, 61, 0.6);
  box-shadow: 0 0 46px rgba(255, 138, 61, 0.22), inset 0 0 40px rgba(255, 138, 61, 0.07);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 138, 61, 0.12), transparent 60%),
    rgba(14, 10, 18, 0.95);
}
#upgrade-modal.phase-weapon .glitch-subtitle { color: #ffb37a; text-shadow: 0 0 10px #ff8a3d; }
#upgrade-modal.phase-weapon .upgrade-title { text-shadow: 0 0 18px #ff8a3d; }
#upgrade-modal.phase-weapon .upgrade-hint span { color: #ffb37a; }
.upgrade-option.weapon-pick-card .upg-name { display: none; }
.upgrade-option.weapon-pick-card .upg-headline {
  color: var(--rarity);
  text-shadow: 0 0 14px var(--rarity-soft);
  margin-top: 4px;
}

@keyframes new-weapon-pulse {
  from { box-shadow: 0 0 12px var(--rarity-soft); }
  to { box-shadow: 0 0 30px var(--rarity), inset 0 0 18px rgba(255, 138, 61, 0.12); }
}

/* HUD strip: one chip per weapon slot, then the other installed upgrades on the next row. */
.weapon-slot-chip {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(10, 16, 32, 0.85);
  border: 1px solid var(--wc, var(--cyan));
  border-left-width: 3px;
  color: #eef6ff;
  white-space: nowrap;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

.weapon-slot-chip.empty {
  border: 1px dashed rgba(122, 139, 168, 0.55);
  color: var(--text-dim);
  background: rgba(10, 16, 32, 0.5);
  min-width: 22px;
  text-align: center;
}

/* Pause menu (js/run-overview.js): ship, run summary and actions on the left; LOADOUT / STATS / UPGRADES /
   SETTINGS tabs on the right, scrolling inside themselves so the ship stays in view. Stacked (one page
   scroll) on narrow screens. */
.modal-card.pause-card {
  max-width: 1240px;
  padding: 16px 22px 18px;
  text-align: center;
}

.pause-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px 20px;
  flex-wrap: wrap;
  text-align: left;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.18);
}

.pause-head .upgrade-title {
  font-size: 28px;
  margin-bottom: 0;
}

.pause-head .pause-hint {
  margin-bottom: 2px;
  font-size: 12px;
}

.pause-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: start;
  text-align: left;
}

.pause-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.pause-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.pause-tabs {
  flex-wrap: wrap;
}

.pause-tabs .board-tab {
  font-size: 11px;
  padding: 7px 12px;
}

.pause-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Desktop: the tab body scrolls on its own below the tabs. */
@media (min-width: 861px) {
  .pause-pane {
    max-height: calc(94vh - 150px);
    overflow-y: auto;
    padding-right: 4px;
  }
}

/* SETTINGS: one column, so the d-pad walks straight down from the sliders through every toggle. */
.pause-pane .pause-audio-box,
.pause-toggles {
  width: 100%;
  max-width: 560px;
}

.pause-pane .pause-audio-box {
  margin-top: 0;
}

.pause-toggles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.pause-toggles .neon-btn {
  letter-spacing: 1.5px;
}

/* The big ship (title screen and pause menu): its own canvas on a dark launch pad. */
.ship-stage {
  position: relative;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 45%, rgba(0, 243, 255, 0.08), rgba(3, 4, 11, 0.9) 70%);
  border: 1px solid rgba(0, 243, 255, 0.22);
  overflow: hidden;
}

.ship-preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pause-ship-stage {
  height: clamp(170px, 34vh, 330px);
}

.ship-stage-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: rgba(214, 232, 255, 0.7);
  pointer-events: none;
}

.title-ship-stage {
  flex: 0 1 260px;
  height: 140px;
  margin: 0 16px;
  min-width: 150px;
  border-color: rgba(0, 243, 255, 0.14);
}

.run-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.ro-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(16, 22, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ro-info-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.ro-info-value {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ro-info-detail {
  font-size: 9.5px;
  color: #8ba3c7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pause-actions .neon-btn {
  padding: 10px 14px;
  font-size: 12px;
  letter-spacing: 2px;
}

.pause-actions .primary-btn {
  font-size: 14px;
  padding: 12px 14px;
}

.pause-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pause-action-row .neon-btn {
  padding: 9px 8px;
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}

.neon-btn.pause-danger-btn {
  border-color: var(--magenta);
  color: #ff77b7;
  background: rgba(40, 6, 24, 0.55);
  box-shadow: 0 0 14px rgba(255, 0, 127, 0.2);
  text-shadow: none;
}

.quit-confirm {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 42, 85, 0.75);
  background: rgba(40, 6, 18, 0.85);
  box-shadow: 0 0 22px rgba(255, 42, 85, 0.3);
}

.quit-confirm-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 2.5px;
  color: #ff7a93;
  text-shadow: 0 0 10px rgba(255, 42, 85, 0.7);
}

.quit-confirm-text {
  margin: 6px 0 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #ffd0da;
}

.quit-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quit-confirm-actions .neon-btn.loadout-btn {
  padding: 9px 8px;
  font-size: 12px;
}

/* Weapon readout under each loadout slot: potential DPS and damage dealt this run. */
.loadout-readout {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 8px;
  font-size: 10px;
  color: #8ba3c7;
}

.loadout-readout b {
  color: #fff;
}

.pause-damage .pause-loadout-head {
  margin-bottom: 6px;
}

.ro-dmg-row {
  display: grid;
  grid-template-columns: minmax(80px, 0.9fr) minmax(40px, 1.4fr) auto;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-size: 11px;
}

.ro-dmg-name {
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ro-dmg-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.ro-dmg-bar span {
  display: block;
  height: 100%;
  background: var(--wc, var(--cyan));
  box-shadow: 0 0 6px var(--wc, var(--cyan));
}

.ro-dmg-num {
  color: #c9d4e4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ro-empty {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  padding: 4px 2px;
}

/* STATS tab: BASE / PERMANENT / THIS RUN / TOTAL per stat. */
.ro-stats {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ro-stats th,
.ro-stats td {
  padding: 4px 6px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow-wrap: anywhere;
}

.ro-stats thead th {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

.ro-stats th[scope="row"],
.ro-stats thead th:first-child {
  text-align: left;
  width: 34%;
  font-weight: 700;
  color: #d6e8ff;
}

.ro-stats tr.ro-group th {
  padding-top: 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--cyan);
  border-bottom-color: rgba(0, 243, 255, 0.25);
}

.ro-stats td.ro-none { color: rgba(122, 139, 168, 0.6); }
.ro-stats td.ro-up { color: var(--emerald); }
.ro-stats td.ro-down { color: #ff7a93; }
.ro-stats td.ro-total { color: #fff; font-weight: 900; }

.ro-note {
  margin-top: 8px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-dim);
}

.ro-note b { color: #c9d4e4; }

/* UPGRADES tab */
.ro-section + .ro-section {
  margin-top: 10px;
}

.ro-section-title {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--cyan);
}

.ro-upgrades {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
}

.ro-upgrade {
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(14, 20, 38, 0.92);
  border: 1px solid rgba(201, 212, 228, 0.18);
}

.ro-upgrade.evo {
  border-color: rgba(255, 79, 216, 0.55);
  background: rgba(40, 8, 36, 0.6);
}

.ro-upgrade-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ro-upgrade-name {
  font-size: 12.5px;
  font-weight: 900;
  color: #fff;
}

.ro-upgrade.evo .ro-upgrade-name { color: #ff9be9; }

.ro-upgrade-lv {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--gold);
  white-space: nowrap;
}

.ro-upgrade-text {
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1.38;
  color: #9fb4d8;
}

/* Level-up screen: the build so far under the cards (weapon slots, then picked upgrades). Small, and it
   scrolls inside itself rather than pushing the cards off a short screen. */
.loadout-strip {
  margin-top: 12px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(5, 10, 24, 0.7);
  border: 1px solid rgba(0, 243, 255, 0.18);
  max-height: 84px;
  overflow-y: auto;
  text-align: left;
}

.strip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 5px;
}

.strip-row + .strip-row {
  margin-top: 5px;
}

.strip-label {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  min-width: 64px;
}

.strip-row .weapon-slot-chip {
  font-size: 10px;
  padding: 1px 7px;
}

.strip-upgrade {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(15, 22, 42, 0.8);
  border: 1px solid var(--wc, rgba(0, 243, 255, 0.35));
  color: #c9f6ff;
  white-space: nowrap;
}

.strip-upgrade.evo {
  border-color: rgba(255, 79, 216, 0.6);
  color: #ff9be9;
  background: rgba(255, 79, 216, 0.12);
}

.strip-none {
  font-size: 10px;
  color: var(--text-dim);
}

/* [H] hides the HUD: every overlay goes, leaving the game view (and a faint way back). */
.hud-hidden #hud { display: none; }

.hud-hidden-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 12;
  padding: 5px 12px;
  border-radius: 99px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--cyan);
  background: rgba(5, 10, 24, 0.7);
  border: 1px solid rgba(0, 243, 255, 0.45);
  cursor: pointer;
  opacity: 1;
  transition: opacity 1.2s ease;
}

.hud-hidden-hint.settled { opacity: 0.3; }
.hud-hidden-hint:hover,
.hud-hidden-hint:focus-visible { opacity: 1; }

.neon-btn.go-menu-btn {
  border-color: var(--magenta);
  background: rgba(40, 6, 24, 0.55);
  text-shadow: 0 0 10px var(--magenta);
}

.pause-loadout-box {
  background: rgba(5, 10, 24, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 10px;
  padding: 10px 12px 12px;
}

.pause-loadout-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.pause-loadout-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2.5px;
  color: var(--cyan);
}

.pause-loadout-count {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.pause-loadout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Slots stay rarity-neutral: a weapon's own colour marks the edge, nothing implies a roll tier. */
.loadout-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 118px;
  padding: 8px 10px 9px;
  border-radius: 8px;
  background: rgba(14, 20, 38, 0.92);
  border: 1px solid rgba(201, 212, 228, 0.22);
  border-left: 3px solid var(--wc, var(--cyan));
}

.loadout-slot.empty {
  border: 1px dashed rgba(122, 139, 168, 0.45);
  background: rgba(10, 14, 28, 0.6);
  justify-content: flex-start;
}

.loadout-slot.loadout-passive {
  grid-column: 1 / -1;
  min-height: 0;
}

.loadout-slot.confirming {
  border-color: rgba(255, 42, 85, 0.75);
  box-shadow: 0 0 16px rgba(255, 42, 85, 0.3);
}

.loadout-slot-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.loadout-slot-num {
  color: var(--text-dim);
}

.loadout-lv {
  color: #eef6ff;
  font-size: 11px;
}

.loadout-name {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 6px var(--wc, var(--cyan));
}

.loadout-slot .upg-tags {
  margin: 1px 0 2px;
}

.loadout-empty-text {
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-dim);
  margin-top: 6px;
}

.loadout-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.loadout-line {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  color: #c9d4e4;
  background: rgba(255, 255, 255, 0.06);
}

.loadout-line.evo {
  color: #ff4fd8;
  background: rgba(255, 79, 216, 0.12);
}

.loadout-line.bt {
  color: #38f2d0;
  background: rgba(56, 242, 208, 0.12);
}

.loadout-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

.neon-btn.loadout-btn {
  padding: 4px 10px;
  font-size: 10px;
  letter-spacing: 1.5px;
  border-width: 1px;
  border-color: rgba(139, 163, 199, 0.55);
  color: #c9d4e4;
  background: rgba(5, 10, 24, 0.6);
  box-shadow: none;
  text-shadow: none;
}

.neon-btn.loadout-btn.danger {
  border-color: var(--danger);
  color: #ff7a93;
}

.neon-btn.loadout-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.loadout-confirm {
  font-size: 10.5px;
  line-height: 1.35;
  color: #ffb3c2;
}

@media (max-width: 860px) {
  .pause-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .pause-ship-stage {
    height: 200px;
  }
}

/* Phones: a slimmer pause card, two-column run summary, smaller stat table. */
@media (max-width: 520px) {
  .modal-card.pause-card { padding: 14px 12px 16px; }
  .pause-head .upgrade-title { font-size: 22px; letter-spacing: 2px; }
  .run-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pause-action-row { grid-template-columns: minmax(0, 1fr); }
  .pause-tabs .board-tab { padding: 6px 8px; font-size: 10px; letter-spacing: 1px; }
  .ro-stats { font-size: 10.5px; }
  .ro-stats th, .ro-stats td { padding: 4px 3px; }
  .ro-stats thead th { font-size: 8px; letter-spacing: 0.5px; }
  .ro-stats th[scope="row"], .ro-stats thead th:first-child { width: 31%; }
  .pause-slider-row { grid-template-columns: 96px minmax(0, 1fr) 44px; }
  .ro-upgrades { grid-template-columns: minmax(0, 1fr); }
  .strip-label { min-width: 0; width: 100%; }
  .loadout-strip { max-height: none; } /* the card already scrolls on phones */
}

/* Title hub on narrow screens: the ship gets its own row under the logo. */
@media (max-width: 600px) {
  .title-ship-stage { order: 3; flex: 1 1 100%; margin: 0; height: 150px; }
}

@media (max-width: 520px) {
  .pause-loadout-grid {
    grid-template-columns: 1fr;
  }

  .loadout-slot {
    min-height: 0;
  }
}

/* The HUD shows only the weapon slots; every other upgrade is listed in the pause menu. */
.weapons-bar {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 600px) {
  .weapon-slot-chip {
    font-size: 9.5px;
    padding: 1px 6px;
  }
}

/* ---------------------------------------------------------------------------------------------
   Field Guide (js/field-guide-ui.js): hostiles with live previews, mechanics and weapons.
   --------------------------------------------------------------------------------------------- */
.guide-overlay { z-index: 40; }

.guide-card {
  max-width: 1180px;
  height: min(94vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 24px 10px;
  text-align: left;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.18);
}

.guide-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 16px rgba(0, 243, 255, 0.8);
  line-height: 1.15;
}

.guide-progress {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.guide-close-btn {
  flex-shrink: 0;
  padding: 10px 20px;
  font-size: 12px;
  letter-spacing: 2px;
}

.guide-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 10px;
}

.guide-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 243, 255, 0.28);
  background: rgba(0, 243, 255, 0.05);
  color: #9fd8f5;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.guide-tab:hover { background: rgba(0, 243, 255, 0.12); }

.guide-tab.active {
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--cyan);
  color: #fff;
  text-shadow: 0 0 10px var(--cyan);
}

.guide-tab-new {
  margin-left: 4px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.7);
}

.guide-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 8px 12px 2px;
  scroll-padding: 16px;
  outline: none;
}

.guide-section { margin-bottom: 16px; }

.guide-section-title {
  margin: 4px 0 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--cyan);
  opacity: 0.85;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.guide-entry {
  --entry-hue: 190;
  position: relative;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(120, 160, 255, 0.18);
  background: rgba(10, 16, 34, 0.85);
  outline: none;
}

.guide-entry:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.guide-entry.fresh { box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255, 204, 0, 0.22); }

.guide-grid-wide { grid-template-columns: minmax(0, 1fr); }

.guide-hostile {
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  gap: 16px;
  border-color: hsla(var(--entry-hue), 100%, 60%, 0.32);
}

.guide-preview {
  position: relative;
  align-self: start;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid hsla(var(--entry-hue), 100%, 60%, 0.35);
  background: #04060f;
}

.guide-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.guide-unknown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 6px;
  color: rgba(170, 190, 230, 0.6);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
}

.guide-new {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--gold);
  color: #1a1200;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.7);
}

.guide-entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.guide-entry-head h3 {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  color: hsl(var(--entry-hue), 100%, 72%);
  text-shadow: 0 0 10px hsla(var(--entry-hue), 100%, 55%, 0.45);
}

.guide-group {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.guide-entry p {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #c9d6ea;
}

.guide-hint { color: var(--text-dim) !important; font-style: italic; }

.guide-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 7px;
}

.guide-stat {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  font-size: 10.5px;
  font-weight: 700;
  color: #e8f0ff;
  font-variant-numeric: tabular-nums;
}

.guide-stat b {
  margin-right: 3px;
  font-weight: 900;
  letter-spacing: 1px;
  color: hsl(var(--entry-hue), 100%, 72%);
}

.guide-tip,
.guide-recipe {
  padding-left: 8px;
  border-left: 2px solid hsl(var(--entry-hue), 100%, 60%);
}

.guide-tip b,
.guide-recipe b {
  display: block;
  font-size: 9.5px;
  letter-spacing: 2px;
  color: var(--gold);
}

.guide-mods {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 7px;
}

.guide-mods li {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid hsla(var(--mod-hue), 100%, 62%, 0.6);
  font-size: 10px;
  color: #dfe8fa;
}

.guide-mods b { color: hsl(var(--mod-hue), 100%, 70%); letter-spacing: 1px; }

.guide-entry.locked { border-style: dashed; border-color: rgba(120, 140, 180, 0.3); }
.guide-entry.locked h3 { color: #8a98b5; text-shadow: none; }

.guide-mechanic h3 { color: #e6f7ff; }
.guide-icon { font-size: 17px; color: var(--cyan); text-shadow: 0 0 10px var(--cyan); margin-right: 2px; }
.guide-mechanic .guide-entry-head { justify-content: flex-start; }

.guide-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 7px;
}

.guide-weapon { --entry-hue: 186; }
.guide-weapon.kit { --entry-hue: 160; border-color: rgba(0, 255, 170, 0.35); }
.guide-weapon.evolution { --entry-hue: 312; border-color: rgba(255, 79, 216, 0.4); }
.guide-weapon.owned { box-shadow: inset 3px 0 0 var(--emerald); }
.guide-grid-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.guide-weapon-meta {
  margin: -2px 0 6px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.guide-weapon-meta b { color: var(--emerald); }

.guide-legend-text { font-size: 12px; color: #b4c6e0; margin-bottom: 6px; }

.guide-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10.5px;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.guide-foot b { color: var(--gold); }

.guide-open-btn {
  padding: 12px 18px;
  font-size: 12px;
  letter-spacing: 2px;
  border-color: var(--emerald);
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.7);
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.25);
}

/* Title hub: the Field Guide button sits stacked above the core wallet so the logo keeps its width. */
.hub-header-side {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.guide-hub-btn {
  padding: 7px 14px;
  font-size: 11px;
  letter-spacing: 1.5px;
}

.guide-btn-badge { color: var(--gold); text-shadow: 0 0 8px rgba(255, 204, 0, 0.8); }

/* Intel card link + in-run toast */
.lt-card-link {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--cyan);
}

.lt-card-link:empty { display: none; }

.guide-toast {
  position: absolute;
  left: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, 70vw);
  padding: 8px 14px 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 136, 0.7);
  background: rgba(4, 16, 18, 0.88);
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.3);
  animation: guideToastIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
  transition: opacity 0.35s ease-in;
}

.guide-toast-icon { font-size: 20px; }

.guide-toast-body b {
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--emerald);
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.7);
}

.guide-toast-text {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #e6fff3;
}

.guide-toast-out { opacity: 0; }

@keyframes guideToastIn {
  0% { opacity: 0; transform: translateX(-24px); }
  100% { opacity: 1; transform: translateX(0); }
}

@media (max-width: 920px) {
  .guide-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-hostile { grid-template-columns: 260px minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .guide-card { padding: 14px 12px 8px; height: 96vh; }
  .guide-title { font-size: 20px; letter-spacing: 2px; }
  .guide-close-btn { padding: 8px 12px; font-size: 11px; letter-spacing: 1px; }
  .guide-tab { padding: 8px 4px; font-size: 11px; letter-spacing: 1px; }
  .guide-tab-new { display: block; margin: 2px 0 0; font-size: 9px; }
  .hub-header-side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .guide-hostile { grid-template-columns: minmax(0, 1fr); }
  .guide-foot { display: none; }
}

/* ---------------------------------------------------------------------------------------------
   Game version tag, PATCH NOTES (js/patch-notes.js) and the leaderboard VERSION selector.
   --------------------------------------------------------------------------------------------- */
.title-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 5px;
}

.version-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid rgba(0, 243, 255, 0.45);
  background: rgba(0, 243, 255, 0.08);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.15);
  white-space: nowrap;
}

.version-tag:empty { display: none; }

/* Game over: the tag sits beside SIGNAL LOST instead of adding a row. */
.go-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.version-tag-inline,
.upgrade-hint .version-tag-inline {
  color: var(--cyan);
  font-weight: 900;
  margin-left: 8px;
  font-size: 10px;
  padding: 2px 7px;
  vertical-align: 1px;
}

.notes-open-btn {
  padding: 12px 18px;
  font-size: 12px;
  letter-spacing: 2px;
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(255, 204, 0, 0.16), rgba(255, 0, 127, 0.16));
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
  box-shadow: 0 0 18px rgba(255, 204, 0, 0.22);
  white-space: nowrap;
}

.notes-open-btn:hover {
  background: linear-gradient(90deg, rgba(255, 204, 0, 0.3), rgba(255, 0, 127, 0.3));
  box-shadow: 0 0 30px rgba(255, 204, 0, 0.5), 0 0 14px rgba(255, 0, 127, 0.35);
}

/* Title hub: compact, next to the version tag under the logo (well clear of LAUNCH). */
.notes-hub-btn {
  padding: 6px 14px;
  font-size: 11px;
  letter-spacing: 1.5px;
}

.notes-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gold);
  color: #1a1200;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 1.5px;
  line-height: 1.5;
  text-shadow: none;
  vertical-align: 1px;
  animation: notes-badge-glow 1.1s ease-in-out infinite alternate;
}

@keyframes notes-badge-glow {
  from { box-shadow: 0 0 4px rgba(255, 204, 0, 0.55); }
  to { box-shadow: 0 0 14px rgba(255, 204, 0, 1), 0 0 26px rgba(255, 0, 127, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
  .notes-badge { animation: none; box-shadow: 0 0 10px rgba(255, 204, 0, 0.9); }
}

/* Patch notes modal: shares the Field Guide's card, header and scroll body. */
.notes-card { max-width: 880px; }

.notes-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; }
.notes-sub .version-tag { font-size: 10px; padding: 1px 7px; }

.notes-body { padding-top: 8px; }

.notes-entry {
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid rgba(120, 160, 255, 0.18);
  background: rgba(10, 16, 34, 0.85);
}

.notes-entry.latest {
  border-color: rgba(0, 243, 255, 0.55);
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.14), inset 0 0 22px rgba(0, 243, 255, 0.05);
}

.notes-entry.fresh { box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255, 204, 0, 0.22); }

.notes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.notes-head:hover { background: rgba(0, 243, 255, 0.06); }
.notes-head:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

.notes-ver {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.6);
  font-variant-numeric: tabular-nums;
}

.notes-name {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
}

.notes-flags { display: inline-flex; gap: 6px; }
.notes-flags:empty { display: none; }

.notes-current,
.notes-new-badge {
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.notes-current { border: 1px solid var(--emerald); color: var(--emerald); text-shadow: 0 0 6px rgba(0, 255, 136, 0.6); }
.notes-new-badge { background: var(--gold); color: #1a1200; box-shadow: 0 0 12px rgba(255, 204, 0, 0.7); }

.notes-date,
.notes-count {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.notes-entry.open .notes-count { display: none; }

.notes-caret {
  color: var(--cyan);
  font-size: 12px;
  transition: transform 0.15s ease;
}

.notes-entry:not(.open) .notes-caret { transform: rotate(-90deg); }

.notes-sections {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.notes-sections[hidden] { display: none; }

.notes-sec {
  --sec: var(--emerald);
  padding: 8px 12px 9px;
  border-radius: 8px;
  border-left: 3px solid var(--sec);
  background: rgba(4, 8, 20, 0.7);
  outline: none;
}

.notes-sec:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.notes-sec-balance { --sec: var(--gold); }
.notes-sec-fix { --sec: var(--violet); }

.notes-sec-title {
  margin-bottom: 4px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--sec);
}

.notes-sec ul { margin: 0; padding-left: 18px; }

.notes-sec li {
  font-size: 13px;
  line-height: 1.45;
  color: #d6e6ff;
}

.notes-sec li + li { margin-top: 3px; }
.notes-sec li::marker { color: var(--sec); }

/* Leaderboard VERSION selector (GLOBAL tab only): small pill buttons, controller focus stops. */
.board-versions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
}

/* Title board: the note and the selector share one row (wrapping when the note is long). */
.board-filter {
  align-items: center;
  margin-bottom: 6px;
  row-gap: 4px;
}

.board-filter .board-note,
.board-filter .board-versions { margin-bottom: 0; }

.board-ver-label {
  margin-right: 2px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.board-ver {
  background: rgba(8, 12, 26, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.28);
  color: var(--text-dim);
  font: inherit;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 1.2px;
  padding: 3px 9px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s;
  font-variant-numeric: tabular-nums;
}

.board-ver:hover { color: #fff; border-color: var(--cyan); }
.board-ver.current::before { content: '● '; color: var(--emerald); }

.board-ver.active {
  color: #fff;
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
  text-shadow: 0 0 6px rgba(0, 243, 255, 0.8);
}

.board-ver.all-time.active {
  background: rgba(181, 101, 255, 0.22);
  border-color: var(--violet);
  box-shadow: 0 0 10px rgba(181, 101, 255, 0.45);
  text-shadow: 0 0 6px rgba(181, 101, 255, 0.9);
}

/* ALL-TIME rows: the version each run was flown on, in front of its stats. */
.hs-ver {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 3px;
  border: 1px solid rgba(0, 243, 255, 0.4);
  color: var(--cyan);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  vertical-align: 1px;
}

.hs-ver.legacy {
  border-color: rgba(255, 153, 85, 0.45);
  color: #ffb27d;
}

@media (max-width: 560px) {
  .notes-head { padding: 10px 10px; gap: 2px 8px; }
  .notes-name { flex-basis: 100%; order: 5; font-size: 13px; }
  .notes-sections { padding: 0 10px 12px; }
  .notes-sec li { font-size: 12.5px; }
}

/* ---- Gold (per-run currency from gold veins): HUD chip, level-up REROLL / LOCK ----------------- */
.gold-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(255, 204, 0, 0.1);
  border: 1px solid rgba(255, 204, 0, 0.55);
  border-radius: 99px;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.8);
}

.gold-flash-gain { animation: gold-flash-gain 0.55s ease-out; }
.gold-flash-spend { animation: gold-flash-spend 0.6s ease-out; }
.gold-flash-short { animation: gold-flash-short 0.45s ease-out; }

@keyframes gold-flash-gain {
  0% { transform: scale(1.18); background: rgba(255, 204, 0, 0.55); color: #fff; box-shadow: 0 0 22px var(--gold); }
  100% { transform: scale(1); }
}

@keyframes gold-flash-spend {
  0% { transform: scale(0.9); background: rgba(255, 0, 127, 0.35); box-shadow: 0 0 22px rgba(255, 0, 127, 0.8); }
  100% { transform: scale(1); }
}

@keyframes gold-flash-short {
  0%, 50% { transform: translateX(-4px); border-color: #ff2a55; color: #ff7a90; }
  25%, 75% { transform: translateX(4px); }
  100% { transform: none; }
}

.hand-goldbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  margin-top: 18px;
}

.hand-goldbar.hidden { display: none; }

.hand-gold-count {
  padding: 6px 14px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--gold);
  background: rgba(255, 204, 0, 0.1);
  border: 1px solid rgba(255, 204, 0, 0.6);
  border-radius: 99px;
  text-shadow: 0 0 12px rgba(255, 204, 0, 0.85);
}

.neon-btn.hand-reroll-btn {
  padding: 9px 20px;
  font-size: 14px;
  border-color: var(--gold);
  color: #fff6cc;
  background: linear-gradient(90deg, rgba(255, 204, 0, 0.22), rgba(255, 0, 127, 0.16));
  text-shadow: 0 0 10px var(--gold);
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.35);
}

.neon-btn.hand-reroll-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(0.6);
  transform: none;
  box-shadow: none;
}

.hand-key {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.75;
}

.hand-lock-note {
  flex-basis: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.hand-lock-note.dropped { color: #ff77b7; }

/* Per-card LOCK toggle and LOCKED state: additions around the card, the card design is unchanged. */
.card-lock-toggle {
  align-self: flex-end;
  margin-top: 10px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--gold);
  border: 1px solid rgba(255, 204, 0, 0.6);
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  user-select: none;
}

.card-lock-toggle:hover { background: rgba(255, 204, 0, 0.2); }
.card-lock-toggle.on { background: var(--gold); color: #05060f; }
.card-lock-toggle.unaffordable { opacity: 0.4; cursor: not-allowed; }

.upgrade-option.card-locked {
  outline: 2px dashed var(--gold);
  outline-offset: 4px;
}

.card-lock-badge {
  position: absolute;
  top: -11px;
  left: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--gold);
  color: #05060f;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 0 14px rgba(255, 204, 0, 0.7);
}

/* RUN REPORT (game over, left panel tab; js/run-report.js): headline numbers, damage by weapon as bars
   with % share and DPS, and the enemies that hurt the ship most. Rows are [data-gp-nav] so the
   controller can walk and scroll them. */
.go-left-panel { justify-content: flex-start; }
.go-left-panel .panel-header { align-items: center; }
.run-report {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 243, 255, 0.4) transparent;
  padding-right: 2px;
}
.rr-headline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.rr-head {
  background: rgba(16, 22, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  padding: 6px 8px;
  min-width: 0;
}
.rr-head-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}
.rr-head-val {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.rr-section-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--cyan);
}
.rr-section-title span {
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.rr-bars, .rr-killers { display: flex; flex-direction: column; gap: 5px; }
.rr-bar-row {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  outline: none;
}
.rr-bar-row:hover, .rr-bar-row.gp-focus, .rr-killer:hover, .rr-killer.gp-focus {
  border-color: rgba(0, 243, 255, 0.55);
  background: rgba(0, 243, 255, 0.06);
}
.rr-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 3px;
}
.rr-name {
  font-weight: 800;
  color: #fff;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rr-lv {
  margin-left: 6px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.rr-nums {
  flex-shrink: 0;
  color: #b4c6e0;
  font-variant-numeric: tabular-nums;
}
.rr-nums b { color: #fff; }
.rr-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.rr-fill {
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--rc, var(--cyan));
  box-shadow: 0 0 10px var(--rc, var(--cyan));
}
.rr-killer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(16, 24, 46, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.07);
  outline: none;
}
.rr-killer.fatal { border-color: rgba(255, 42, 85, 0.6); background: rgba(255, 42, 85, 0.1); }
.rr-killer-name { font-weight: 800; color: #fff; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-killer.fatal .rr-killer-name { color: #ff8aa3; }
.rr-killer-val { flex-shrink: 0; color: #b4c6e0; font-variant-numeric: tabular-nums; }
.rr-empty { font-size: 11px; color: var(--text-dim); padding: 4px 6px; }
.rr-upload {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}
@media (max-width: 480px) {
  .rr-headline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rr-section-title span { display: none; }
  .go-left-panel .panel-header { flex-wrap: wrap; }
}

/* Title-screen consent checkboxes (both start checked): GLOBAL posting and anonymous stats */
.consent-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: -4px 0 10px;
  padding: 0 4px;
}
.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(214, 230, 255, 0.78);
  cursor: pointer;
}
.consent-check b { color: var(--cyan); font-weight: 800; }
.consent-check i { color: rgba(214, 230, 255, 0.5); font-style: normal; }
.consent-check input {
  flex: none;
  width: 14px;
  height: 14px;
  margin: 1px 0 0;
  accent-color: var(--cyan);
  cursor: pointer;
}
.consent-check input.gp-focus,
.consent-check input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* BANISH toggle (level-up cards): opposite corner to the LOCK toggle; red, and lit when armed. */
.card-banish-toggle {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 70, 100, 0.65);
  background: rgba(255, 70, 100, 0.1);
  color: #ff8fa3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  z-index: 2;
}
.card-banish-toggle:hover { background: rgba(255, 70, 100, 0.25); }
.card-banish-toggle.armed { background: #ff4664; color: #fff; border-color: #ff4664; }
.card-banish-toggle.unaffordable { opacity: 0.45; }
.card-banish-toggle.hidden { display: none; }

/* ---- Weapon Range (js/weapon-range-ui.js) ------------------------------------------------------ */
/* Title-screen entry: a secondary button beside LAUNCH, in the range's amber. */
.neon-btn.range-open-btn {
  border-color: #ffb347;
  background: linear-gradient(90deg, rgba(255, 179, 71, 0.16), rgba(0, 243, 255, 0.12));
  text-shadow: 0 0 10px rgba(255, 179, 71, 0.8);
  box-shadow: 0 0 20px rgba(255, 179, 71, 0.28);
}

/* Pause menu: EXIT only in the range; no restart, stats toggle or loadout discards there. */
#btn-pause-exit-range { display: none; border-color: #ffb347; color: #ffd39a; }
.range-mode #btn-pause-exit-range { display: block; }
/* MAIN MENU is EXIT there, and the range panel owns the loadout, so no LOADOUT tab or run summary. */
.range-mode #btn-pause-restart,
.range-mode #btn-pause-menu,
.range-mode #btn-pause-stats,
.range-mode #pause-run-info,
.range-mode [data-pause-tab="loadout"] { display: none; }

/* The run HUD's score, multipliers, XP and wave mean nothing in the range: the panel takes that corner. */
.range-mode .hud-left,
.range-mode .wave-row,
.range-mode .xp-bar-container { visibility: hidden; }

.range-panel {
  position: absolute;
  top: 14px;
  left: 16px;
  width: 344px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  background: rgba(6, 10, 24, 0.9);
  border: 1px solid rgba(255, 179, 71, 0.5);
  border-radius: 12px;
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.7), 0 0 16px rgba(255, 179, 71, 0.16);
  backdrop-filter: blur(10px);
  z-index: 20;
  pointer-events: auto;
  cursor: default;
  font-size: 11px;
  color: var(--text-main);
  overflow: hidden;
}
.range-panel.pad-edit { border-color: var(--gold); box-shadow: 0 0 28px rgba(0, 0, 0, 0.7), 0 0 22px rgba(255, 204, 0, 0.4); }

.rg-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 179, 71, 0.25);
  background: rgba(255, 179, 71, 0.06);
}
.rg-head-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rg-kicker { font-size: 9px; font-weight: 800; letter-spacing: 1.5px; color: #c9a36a; }
.rg-title { font-size: 14px; font-weight: 900; letter-spacing: 2px; color: #ffd39a; text-shadow: 0 0 10px rgba(255, 179, 71, 0.6); white-space: nowrap; }

.rg-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.rg-foot { padding: 5px 10px; font-size: 9.5px; color: var(--text-dim); border-top: 1px solid rgba(255, 255, 255, 0.06); }
.rg-foot b { color: #c9d4e4; }

.rg-btn {
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #c9d4e4;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(122, 139, 168, 0.45);
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.rg-btn:hover { border-color: var(--cyan); color: #fff; }
.rg-btn.is-on { border-color: var(--emerald); color: var(--emerald); background: rgba(0, 255, 136, 0.12); }
.rg-btn.is-off { opacity: 0.4; cursor: not-allowed; }
.rg-btn.rg-mini { padding: 3px 7px; }
.rg-btn.rg-exit { border-color: rgba(255, 179, 71, 0.7); color: #ffd39a; }
.rg-btn.rg-x { color: #ff8fa3; border-color: rgba(255, 70, 100, 0.5); }

.rg-readout-head, .rg-sec, .rg-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1.3px;
  color: var(--cyan);
}
.rg-readout-head { padding: 7px 10px 0; }
.rg-readout { padding: 2px 10px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.rg-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; }
.rg-total-val { font-size: 24px; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 0 12px rgba(0, 243, 255, 0.7); }
.rg-total-unit { font-size: 11px; font-weight: 800; color: var(--cyan); }
.rg-total-meta { font-size: 10px; color: var(--text-dim); }
.rg-sub { margin: 6px 0 3px; color: #8ba3c7; }
.rg-sub span { letter-spacing: 0.5px; }

.rg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wc); box-shadow: 0 0 6px var(--wc); flex: none; }
.rg-cmp, .rg-src {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  padding: 1px 0;
}
.rg-cmp-name, .rg-src-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-cmp-name i { font-style: normal; color: var(--text-dim); }
.rg-cmp-num, .rg-src-num { font-variant-numeric: tabular-nums; color: var(--text-dim); text-align: right; }
.rg-cmp-num b, .rg-src-num b { color: #fff; }
.rg-src-num i { font-style: normal; display: inline-block; min-width: 42px; margin-left: 6px; }
.rg-bar { grid-column: 2 / 4; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.rg-bar span { display: block; height: 100%; background: var(--wc); }

.rg-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px 10px 0; }
.rg-pane { padding: 4px 10px 10px; }
.rg-sec { margin: 10px 0 5px; padding-bottom: 3px; border-bottom: 1px solid rgba(0, 243, 255, 0.18); }
.rg-sec span { color: var(--text-dim); letter-spacing: 0.5px; }

.rg-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 0; }
.rg-row.rg-wrap { flex-wrap: wrap; }
.rg-label { font-weight: 700; color: #b4c6e0; min-width: 0; }
.rg-label i { display: block; font-style: normal; font-weight: 600; font-size: 9.5px; color: #c9a36a; }
.rg-mod.is-needs .rg-label { color: var(--text-dim); }
.rg-dim { color: var(--text-dim); font-size: 10px; }
.rg-empty { color: var(--text-dim); padding: 4px 0; }
.rg-note, .rg-live { margin-top: 4px; }

.rg-stepper { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.rg-stepper .rg-btn { min-width: 24px; padding: 3px 5px; text-align: center; }
.rg-val { display: inline-block; min-width: 44px; text-align: center; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.rg-seg { display: inline-flex; flex-wrap: wrap; gap: 3px; }

.rg-weapon {
  margin-bottom: 7px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--wc) 45%, transparent);
  border-left: 3px solid var(--wc);
  border-radius: 7px;
  background: rgba(5, 10, 24, 0.7);
}
.rg-w-head { display: flex; align-items: center; gap: 6px; }
.rg-w-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 900; color: var(--wc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-lv { color: #fff; }
.rg-chips { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0; }
.rg-chip { font-size: 9.5px; padding: 1px 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); color: #b4c6e0; }
.rg-chip.is-new { background: color-mix(in srgb, var(--wc, #00f3ff) 28%, transparent); color: #fff; }
.rg-auto-note { flex-basis: 100%; font-size: 9.5px; }
.rg-ranks { margin: 2px 0; }
.rg-bts { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.rg-btn.rg-bt { text-align: left; white-space: normal; }
.rg-btn.rg-bt b { color: #fff; margin-right: 3px; }
.rg-btn.rg-bt.is-transform { border-color: rgba(56, 242, 208, 0.6); color: #38f2d0; }
.rg-btn.rg-bt.is-boost { border-color: rgba(255, 179, 71, 0.7); color: #ffb347; }
.rg-addlist { display: flex; flex-wrap: wrap; gap: 4px; }
.rg-actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 8px; }
.rg-btn.rg-go { padding: 7px 10px; font-size: 11px; border-color: var(--emerald); color: var(--emerald); background: rgba(0, 255, 136, 0.1); }
.rg-btn.rg-clear { padding: 7px 10px; font-size: 11px; color: #ff8fa3; border-color: rgba(255, 70, 100, 0.6); }

/* Phones and narrow windows: the panel docks along the bottom edge and scrolls inside itself. */
@media (max-width: 760px) {
  .range-panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    max-height: 56vh;
  }
}

/* ---- Game modes (js/modes.js): title selector, HUD / game-over badge, board switch -------------- */
.mode-select {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(0, 243, 255, 0.28);
  background: rgba(8, 12, 26, 0.85);
}

.mode-opt {
  --mc: var(--cyan);
  --mc-rgb: 0, 243, 255;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-opt.mode-hardcore { --mc: var(--danger); --mc-rgb: 255, 42, 85; }
.mode-opt.mode-blitz { --mc: var(--gold); --mc-rgb: 255, 204, 0; }

.mode-opt-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
}

.mode-opt-sub {
  margin-top: 1px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 1px;
  white-space: nowrap;
  opacity: 0.8;
}

.mode-opt:hover,
.mode-opt:focus-visible,
.mode-opt.gp-focus { color: #fff; border-color: rgba(var(--mc-rgb), 0.6); outline: none; }

.mode-opt.active {
  color: #fff;
  border-color: var(--mc);
  background: rgba(var(--mc-rgb), 0.18);
  box-shadow: 0 0 14px rgba(var(--mc-rgb), 0.45), inset 0 0 10px rgba(var(--mc-rgb), 0.15);
  text-shadow: 0 0 8px rgba(var(--mc-rgb), 0.9);
}

.mode-opt.active .mode-opt-name { color: var(--mc); }

.mode-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--cyan);
  background: rgba(0, 243, 255, 0.1);
  border: 1px solid rgba(0, 243, 255, 0.5);
  border-radius: 99px;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.7);
  white-space: nowrap;
}

.mode-badge.mode-hardcore {
  color: #ff7d97;
  background: rgba(255, 42, 85, 0.14);
  border-color: rgba(255, 42, 85, 0.65);
  text-shadow: 0 0 10px rgba(255, 42, 85, 0.85);
}

.mode-badge.mode-blitz {
  color: var(--gold);
  background: rgba(255, 204, 0, 0.12);
  border-color: rgba(255, 204, 0, 0.6);
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.8);
}

.mode-badge.hidden { display: none; }

/* Board switch: same pills as the version selector, coloured per mode when active. */
.board-ver.board-mode.mode-hardcore.active {
  background: rgba(255, 42, 85, 0.2);
  border-color: var(--danger);
  box-shadow: 0 0 10px rgba(255, 42, 85, 0.45);
  text-shadow: 0 0 6px rgba(255, 42, 85, 0.9);
}

.board-ver.board-mode.mode-blitz.active {
  background: rgba(255, 204, 0, 0.18);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255, 204, 0, 0.45);
  text-shadow: 0 0 6px rgba(255, 204, 0, 0.9);
}

@media (max-width: 560px) {
  .mode-select { width: 100%; }
  .mode-opt { flex: 1; min-width: 0; padding: 5px 4px; }
  .mode-opt-name { font-size: 11.5px; letter-spacing: 1px; }
  .mode-opt-sub { font-size: 7.5px; letter-spacing: 0.4px; }
}

/* Touch controls (js/touch-controls.js): a full-screen layer under the HUD. A thumb on the left half
   drops a move stick where it lands, one on the right half an aim stick; DASH / NOVA sit by the radar. */
.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-stick {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 2px solid rgba(0, 243, 255, 0.35);
  background: radial-gradient(circle, rgba(0, 243, 255, 0.08), rgba(0, 243, 255, 0.02) 70%);
  pointer-events: none;
  display: none;
}
.touch-stick[data-stick="aim"] {
  border-color: rgba(255, 0, 170, 0.4);
  background: radial-gradient(circle, rgba(255, 0, 170, 0.08), rgba(255, 0, 170, 0.02) 70%);
}
.touch-stick.active { display: block; }
.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(0, 243, 255, 0.35);
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.6);
}
.touch-stick[data-stick="aim"] .touch-knob {
  background: rgba(255, 0, 170, 0.35);
  box-shadow: 0 0 14px rgba(255, 0, 170, 0.6);
}
.touch-btn {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 68px;
  height: 68px;
  border-radius: 50%;
  font: 700 12px/1 Consolas, monospace;
  letter-spacing: 1px;
  color: #fff;
  background: rgba(5, 10, 24, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  touch-action: none;
  opacity: 0.55;
}
.touch-btn.ready { opacity: 1; }
.touch-dash {
  right: max(16px, env(safe-area-inset-right));
  border-color: rgba(0, 243, 255, 0.8);
  /* The ring fills as the dash recharges. */
  background:
    radial-gradient(circle, rgba(5, 10, 24, 0.85) 58%, transparent 60%),
    conic-gradient(rgba(0, 243, 255, 0.75) calc(var(--ready, 1) * 360deg), rgba(0, 243, 255, 0.12) 0);
}
.touch-nova {
  right: calc(max(16px, env(safe-area-inset-right)) + 84px);
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 34px);
  border-color: rgba(255, 170, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.touch-nova-count { font-size: 15px; color: #ffcc00; }
.touch-btn:active { transform: scale(0.94); }

/* Touch play: no keyboard hints on the ability pills. */
body.touch-mode .key-hint { display: none; }

/* ===== Touch play (body.touch-mode): a phone-sized HUD, compact level-up cards and menus whose
   sections open as their own windows (Game.bindMobileMenus). Desktop never sees any of this. ===== */
.m-menu, .card-more-btn { display: none; }

/* HUD: score, wave + XP, shield and a small pause button. Everything else steps aside. */
body.touch-mode #hud { padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); }
body.touch-mode .hud-top { gap: 10px; grid-template-columns: 1fr 1.6fr 1fr; }
body.touch-mode .left-badges,
body.touch-mode #active-weapons-bar,
body.touch-mode .ability-group,
body.touch-mode .quick-toggles > :not(#btn-pause):not(#btn-fullscreen),
body.touch-mode #lt-card,
body.touch-mode #guide-toast,
body.touch-mode #center-banner,
body.touch-mode #boss-card,
body.touch-mode #hud-hidden-hint { display: none !important; }
body.touch-mode .stat-label { font-size: 9px; letter-spacing: 2px; }
body.touch-mode .stat-value { font-size: 20px; }
body.touch-mode .wave-row { font-size: 12px; margin: 3px 0 0; }
/* XP bar on top, level with the shield bar; the wave and timer sit under it. */
body.touch-mode .xp-bar-container { order: -1; margin-top: 2px; }
body.touch-mode .xp-bar-container { height: 9px; }
body.touch-mode #level-display { font-size: 8px; }
body.touch-mode .bars-wrapper { gap: 4px; }
body.touch-mode .bar-group { gap: 6px; }
body.touch-mode .bar-label { font-size: 9px; letter-spacing: 1px; }
body.touch-mode .hp-bar-outer { height: 9px; width: 120px; }
body.touch-mode #hp-text { font-size: 10px; }
body.touch-mode .quick-toggles { margin-top: 6px; justify-content: flex-end; }
body.touch-mode :is(#btn-pause, #btn-fullscreen) { font-size: 11px; padding: 6px 12px; pointer-events: auto; }

/* Boss: one thin bar under the wave, no title card. */
/* Hugs the XP bar: pinned under the centre column instead of in a row below the tall right column. */
body.touch-mode .hud-top { position: relative; }
body.touch-mode .boss-hud { position: absolute; top: 31px; left: 50%; transform: translateX(-50%); width: min(240px, 36vw); margin-top: 0; }
body.touch-mode .boss-warning { font-size: 10px; padding: 3px 8px; gap: 6px; }
body.touch-mode .boss-warning-text { display: none; }
body.touch-mode .boss-bars { gap: 3px; padding: 0; background: none; border: 0; box-shadow: none; }
body.touch-mode .boss-bar-head { margin-bottom: 1px; }
body.touch-mode .boss-bar-name,
body.touch-mode .boss-bar-row + .boss-bar-row .boss-bar-name { font-size: 8px; letter-spacing: 1px; }
body.touch-mode .boss-bar-epithet,
body.touch-mode .boss-bar-hp,
body.touch-mode .boss-bar-more { display: none; }
body.touch-mode .boss-bar-track,
body.touch-mode .boss-bar-row + .boss-bar-row .boss-bar-track { height: 4px; }

/* Menus: the home view is a few big buttons; [data-m-section] parts only show as an open window. */
body.touch-mode .m-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  width: 100%;
}
body.touch-mode .m-btn { margin: 0; padding: 11px 6px; font-size: 12px; letter-spacing: 1px; position: relative; }
body.touch-mode .m-fullscreen {
  grid-column: 1 / -1;
  padding: 13px;
  font-size: 15px;
  color: #05060f;
  background: linear-gradient(90deg, #ffcc00, #ff9d00);
  border-color: #ffd84d;
  box-shadow: 0 0 22px rgba(255, 204, 0, 0.55);
  animation: m-fs-pulse 2.2s ease-in-out infinite;
}
body.touch-mode .m-fullscreen.active { animation: none; background: rgba(255, 204, 0, 0.12); color: var(--gold); box-shadow: none; }
@keyframes m-fs-pulse { 50% { box-shadow: 0 0 34px rgba(255, 204, 0, 0.9); } }
@media (prefers-reduced-motion: reduce) { body.touch-mode .m-fullscreen { animation: none; } }
.m-fs-tip { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.4; color: var(--text-dim); }
body.touch-mode .m-btn .notes-badge { position: absolute; top: -7px; right: -4px; }
body.touch-mode [data-m-section]:not(.m-window) { display: none !important; }
body.touch-mode .m-window {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: block !important;
  max-height: none !important;
  overflow-y: auto;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 16px max(14px, env(safe-area-inset-left)) !important;
  background: rgba(4, 7, 18, 0.98) !important;
  text-align: left;
}
body.touch-mode .m-back { position: sticky; top: 0; z-index: 2; margin: 0 0 10px; padding: 9px 16px; font-size: 13px; }
body.touch-mode .modal-overlay { padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
body.touch-mode .modal-card { max-height: 100%; padding: 14px 18px; border-radius: 12px; }
body.touch-mode .controls-mini,
body.touch-mode .upgrade-hint,
body.touch-mode .pause-hint,
body.touch-mode .hand-key { display: none !important; }

/* Title home: logo, mode, LAUNCH and the button grid. */
body.touch-mode .hub-card { max-width: 720px; display: flex; flex-direction: column; gap: 10px; }
body.touch-mode #title-modal .hub-header { display: block; margin: 0; padding: 0; border: 0; text-align: center; }
body.touch-mode #title-modal .glitch-subtitle,
body.touch-mode .title-ship-stage,
body.touch-mode .hub-header-side,
body.touch-mode #btn-title-notes,
body.touch-mode #btn-weapon-range,
body.touch-mode #gameover-modal .wallet-pill,
body.touch-mode #btn-go-guide { display: none !important; }
body.touch-mode .neon-title { font-size: 30px; margin: 0; }
body.touch-mode .title-meta { justify-content: center; margin-top: 2px; }
body.touch-mode .hub-columns { display: block; margin: 0; }
body.touch-mode .title-actions { margin: 0 !important; gap: 8px !important; }
body.touch-mode #btn-start-game,
body.touch-mode #btn-restart-game { width: 100%; padding: 13px; font-size: 16px; }

/* Pause home: RESUME, the button grid, RESTART / MAIN MENU. */
body.touch-mode .pause-card { max-width: 640px; }
body.touch-mode .pause-head { margin-bottom: 8px; justify-content: center; }
body.touch-mode .pause-head .glitch-subtitle { display: none; }
body.touch-mode .pause-head .upgrade-title { font-size: 22px; margin: 0; }
body.touch-mode .pause-layout { display: block; }
body.touch-mode .pause-side { width: 100%; gap: 8px; }
body.touch-mode .pause-ship-stage,
body.touch-mode #pause-run-info,
body.touch-mode #btn-pause-notes { display: none !important; }
body.touch-mode .pause-actions { gap: 8px; }
body.touch-mode .pause-actions > .neon-btn,
body.touch-mode .pause-action-row .neon-btn { padding: 11px 8px; font-size: 13px; margin: 0; }
body.touch-mode #btn-resume-game { padding: 13px; font-size: 16px; }

/* Game over home: title, run numbers, RELAUNCH / MAIN MENU and the button grid. */
body.touch-mode #gameover-modal .hub-header { margin: 0; padding: 0; border: 0; justify-content: center; }
body.touch-mode #gameover-modal .neon-title { font-size: 26px !important; }
body.touch-mode #gameover-modal .glitch-subtitle { font-size: 10px; }

/* Level-up: compact cards (rarity, name, headline, level) in one row; MORE opens the full card. */
body.touch-mode .upgrade-card { padding: 10px 12px; max-width: 980px; }
body.touch-mode .upgrade-header .glitch-subtitle { font-size: 9px; margin: 0; }
body.touch-mode .upgrade-title { font-size: 19px; margin: 2px 0 8px; }
body.touch-mode .upgrade-choices-grid,
body.touch-mode .upgrade-choices-grid.cards-4,
body.touch-mode #chest-rewards-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
body.touch-mode .upgrade-option:not(.card-detail-card) { padding: 10px 10px 8px; }
body.touch-mode .upgrade-option:not(.card-detail-card):hover { transform: none; }
body.touch-mode .upgrade-option:not(.card-detail-card) :is(.upg-key, .upg-tags, .upg-stats) { display: none; }
/* What the card actually does, in brief: the full text and stats are behind MORE. */
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.3;
}
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-top { margin-bottom: 4px; justify-content: flex-start; }
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-badge { font-size: 8.5px; padding: 2px 6px; letter-spacing: 0.5px; }
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-name { font-size: 14px; margin-bottom: 4px; }
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-headline { font-size: 13px; line-height: 1.2; margin: 0; }
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-level { font-size: 10px; margin-top: 6px; padding-top: 5px; }
body.touch-mode .upgrade-option:not(.card-detail-card) .upg-jump-ribbon { font-size: 9px; padding: 2px 8px; }
body.touch-mode .card-lock-toggle,
body.touch-mode .card-banish-toggle { font-size: 10px; padding: 3px 8px; margin-top: 6px; }
body.touch-mode .card-more-btn {
  display: block;
  margin-top: 6px;
  padding: 6px 0;
  border-radius: 8px;
  border: 1px solid var(--rarity);
  color: var(--rarity);
  font: 800 11px/1 Consolas, monospace;
  letter-spacing: 2px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
}
body.touch-mode .hand-goldbar { margin-top: 8px; gap: 8px; padding: 6px 10px; }
body.touch-mode .hand-lock-note { font-size: 10px; }
body.touch-mode #upgrade-loadout-strip { display: none; }
body.touch-mode .card-detail {
  position: fixed;
  inset: 0;
  z-index: 46;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  background: rgba(2, 3, 8, 0.9);
}
body.touch-mode .card-detail-card { width: min(560px, 100%); max-height: calc(100% - 64px); overflow-y: auto; cursor: default; }
body.touch-mode .card-detail-card .upg-key,
body.touch-mode .card-detail-card .card-more-btn { display: none; }
body.touch-mode .card-detail-actions { display: flex; gap: 10px; }
body.touch-mode .card-detail-actions .neon-btn { margin: 0; padding: 11px 26px; font-size: 14px; }
body.touch-mode .m-btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch-mode .loadout-slot { min-height: 0; }
body.touch-mode .gameover-stats { gap: 6px; margin-bottom: 4px; }
body.touch-mode .go-stat-box { padding: 5px 8px; }
body.touch-mode .go-stat-label { font-size: 8px; letter-spacing: 1px; }
body.touch-mode .go-stat-val { font-size: 15px; }
body.touch-mode .go-global-rank { min-height: 0; margin: 0 0 2px; font-size: 11px; letter-spacing: 1.5px; }
body.touch-mode #gameover-modal .title-actions { display: flex; flex-direction: row; flex-wrap: nowrap; }
body.touch-mode #gameover-modal .title-actions .neon-btn { flex: 1; margin: 0; padding: 12px 8px; font-size: 14px; }
body.touch-mode #btn-restart-game { flex: 2 !important; }
body.touch-mode .card-detail-card .upg-jump-ribbon { position: static; transform: none; align-self: flex-start; margin-bottom: 8px; }
@media (max-height: 400px) {
  body.touch-mode .hub-card { gap: 7px; padding-top: 10px; padding-bottom: 10px; }
  body.touch-mode .neon-title { font-size: 24px; }
  body.touch-mode .upgrade-header .glitch-subtitle,
  body.touch-mode .hand-lock-note { display: none; }
  body.touch-mode .upgrade-option:not(.card-detail-card) .upg-summary { -webkit-line-clamp: 2; }
  body.touch-mode .upgrade-option:not(.card-detail-card) .upg-headline { font-size: 12px; }
  body.touch-mode .card-more-btn { padding: 5px 0; }
}
@media (orientation: portrait) {
  body.touch-mode .hud-top { grid-template-columns: auto 1fr auto; gap: 8px; }
  body.touch-mode .wave-row { white-space: nowrap; font-size: 11px; }
  body.touch-mode .bar-label { display: none; }
  body.touch-mode .hp-bar-outer { width: 64px; }
}

/* Landscape phones: the front camera sits in a top corner, so the score (top left) and the shield / pause
   column (top right) keep clear of both corners, whichever way the phone is turned. */
@media (orientation: landscape) {
  body.touch-mode #hud {
    padding-left: max(64px, calc(env(safe-area-inset-left) + 16px));
    padding-right: max(64px, calc(env(safe-area-inset-right) + 16px));
  }
}
