* {
  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: #060911;
  color: #f8fafc;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

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

#hud-root {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-interactive {
  pointer-events: auto;
}

/* Simpler, Zero-Glitch Top Bar (No backdrop-filter GPU flicker, fixed height, no wrapping) */
.hud-topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: linear-gradient(180deg, rgba(6, 9, 17, 0.92) 0%, rgba(6, 9, 17, 0.65) 78%, transparent 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  contain: layout style;
  will-change: transform;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brand-orb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 12px #22d3ee, 0 0 22px #a855f7;
  flex-shrink: 0;
}

.brand-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
  white-space: nowrap;
}

.sector-stepper {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  height: 32px;
  overflow: hidden;
}

.step-btn {
  background: transparent;
  border: none;
  color: #e2e8f0;
  width: 28px;
  height: 100%;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-btn:hover:not(:disabled) {
  background: rgba(251, 191, 36, 0.22);
  color: #fde047;
}

.step-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.step-label {
  background: transparent;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #fde047;
  padding: 0 12px;
  height: 100%;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-label:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Unified Center Swarm Progress Pill (Zero layout shift) */
.hud-center-progress {
  flex: 1;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.progress-title {
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.66rem;
}

.progress-numbers {
  color: #f8fafc;
  min-width: 95px;
  text-align: right;
}

.gauge-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #a855f7);
  transition: width 0.1s linear;
}

/* Clean Right Action Bar */
.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lumen-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.32);
  height: 34px;
  padding: 0 12px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fde047;
  min-width: 78px;
  justify-content: center;
}

.lumen-icon {
  color: #fbbf24;
  font-size: 0.9rem;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
}

.amber-btn {
  background: #fbbf24;
  color: #090d16;
  box-shadow: 0 2px 12px rgba(251, 191, 36, 0.25);
}

.amber-btn:hover:not(:disabled) {
  background: #fcd34d;
}

.glass-btn {
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.14);
}

.glass-btn:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(251, 191, 36, 0.45);
}

.danger-hover-btn:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.65);
  color: #fecdd3;
}

.hud-btn.disabled, .hud-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.icon-btn {
  width: 34px;
  padding: 0;
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(255, 255, 255, 0.14);
}

.badge-pill {
  background: rgba(34, 211, 238, 0.18);
  color: #67e8f9;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 0.68rem;
}

.amber-badge {
  background: rgba(251, 191, 36, 0.18);
  color: #fde047;
  padding: 4px 10px;
  font-size: 0.74rem;
}

/* Minimal, Pass-Through Ability Icon Badges (Bottom-Right Corner, Zero Text Clutter!) */
.hud-bottombar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 24px 22px;
  pointer-events: none;
}

.ability-icon-dock {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.ability-orb-icon {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(8, 12, 24, 0.78);
  border: 1.5px solid rgba(34, 211, 238, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.22);
  transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.ability-orb-icon svg {
  width: 22px;
  height: 22px;
  stroke: #67e8f9;
  fill: none;
  stroke-width: 1.8;
}

.ability-orb-icon.anchor-orb {
  border-color: rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.2);
}

.ability-orb-icon.anchor-orb svg {
  stroke: #fde047;
}

.ability-orb-icon.active-pulse {
  transform: scale(1.16);
  border-color: #ffffff;
  background: rgba(34, 211, 238, 0.28);
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.75);
}

.ability-orb-icon.on-cooldown {
  opacity: 0.32;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.ability-key-dot {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #cbd5e1;
  font-size: 0.58rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast Notification */
.hud-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(10, 15, 28, 0.92);
  border: 1px solid rgba(34, 211, 238, 0.45);
  color: #e2e8f0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: opacity 0.22s ease;
  pointer-events: none;
  z-index: 25;
}

.hud-toast.danger {
  border-color: rgba(244, 63, 94, 0.65);
  color: #fecdd3;
}

.hidden {
  display: none !important;
}

/* Level Completion Overlay */
.completion-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(6, 9, 17, 0.35) 0%, rgba(6, 9, 17, 0.82) 100%);
  z-index: 30;
  animation: fadeIn 0.4s ease-out;
}

.completion-card {
  width: min(500px, 92vw);
  background: rgba(10, 15, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75);
}

.comp-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.14);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.32);
  margin-bottom: 12px;
}

.comp-badge.gold-badge {
  background: rgba(251, 191, 36, 0.18);
  color: #fde047;
  border-color: rgba(251, 191, 36, 0.45);
}

.comp-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 6px;
}

.comp-subtitle {
  font-size: 0.9rem;
  color: #cbd5e1;
  margin-bottom: 14px;
}

.comp-lore {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.07);
  border-left: 3px solid #fbbf24;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
  text-align: left;
}

.comp-rewards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 22px;
}

.reward-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.reward-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.reward-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fbbf24;
}

.comp-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.lg-btn {
  padding: 0 20px;
  height: 38px;
  font-size: 0.86rem;
}

/* Modal Drawers */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-panel {
  width: min(760px, 94vw);
  max-height: 84vh;
  background: #0b101d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 75px rgba(0, 0, 0, 0.85);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #22d3ee;
  font-weight: 700;
}

.modal-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.35rem;
  color: #f8fafc;
  margin-top: 2px;
}

.modal-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 24px;
  background: rgba(0, 0, 0, 0.22);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.tab-btn.active {
  background: rgba(34, 211, 238, 0.14);
  color: #67e8f9;
  border-color: rgba(34, 211, 238, 0.35);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.palette-controls-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 16px;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.shop-item-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shop-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.28);
  color: #22d3ee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  flex-shrink: 0;
}

.palette-swatch {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.shop-item-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #f8fafc;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 3px;
}

.tier-pill {
  font-size: 0.68rem;
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  padding: 2px 8px;
  border-radius: 99px;
}

.stat-pill {
  font-size: 0.68rem;
  background: rgba(34, 211, 238, 0.16);
  color: #67e8f9;
  padding: 2px 8px;
  border-radius: 99px;
}

.shop-item-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.4;
}

/* Star Atlas Codex Grid */
.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.codex-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.codex-card.discovered {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.04);
}

.codex-svg {
  width: 92px;
  height: 92px;
  background: rgba(8, 11, 18, 0.75);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.codex-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 0.98rem;
  color: #f8fafc;
}

.codex-sub {
  font-size: 0.7rem;
  color: #fbbf24;
  margin-top: 2px;
}

.codex-lore {
  font-size: 0.73rem;
  color: #94a3b8;
  line-height: 1.4;
  margin-top: 5px;
}

/* Sector Navigation Map Grid */
.sectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.sector-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #f8fafc;
  font-family: inherit;
}

.sector-card:hover:not(.locked) {
  background: rgba(34, 211, 238, 0.09);
  border-color: rgba(34, 211, 238, 0.45);
}

.sector-card.active {
  background: rgba(34, 211, 238, 0.15);
  border-color: #22d3ee;
}

.sector-card.completed:not(.active) {
  border-color: rgba(52, 211, 153, 0.3);
}

.sector-card.flawless:not(.active) {
  border-color: rgba(251, 191, 36, 0.38);
  background: rgba(251, 191, 36, 0.04);
}

.sector-card.locked {
  opacity: 0.38;
  cursor: not-allowed;
  background: rgba(15, 23, 42, 0.4);
}

.sector-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sector-num {
  font-weight: 800;
  font-size: 0.9rem;
  color: #f8fafc;
}

.sector-star {
  font-size: 0.78rem;
  color: #fbbf24;
}

.sector-arch {
  font-size: 0.74rem;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sector-const-tag {
  font-size: 0.66rem;
  font-weight: 700;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 99px;
  padding: 2px 7px;
  align-self: flex-start;
  margin-top: 2px;
}

/* Astral Founder's Pass Banner & Trial Action Group */
.founders-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 24px 0 24px;
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.12), rgba(168, 85, 247, 0.12));
  border: 1px solid rgba(251, 191, 36, 0.42);
  border-radius: 14px;
}

.founders-banner.founders-active {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.35);
}

.founders-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.founders-crown {
  font-size: 1.45rem;
}

.founders-title {
  font-weight: 800;
  font-size: 0.88rem;
  color: #fef08a;
}

.founders-desc {
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.shop-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Ambient Zen / Screensaver Floating Restore Pill */
.zen-floating-pill {
  position: fixed;
  bottom: 18px;
  right: 22px;
  z-index: 35;
  background: rgba(8, 12, 22, 0.72);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #a5f3fc;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.zen-floating-pill:hover {
  opacity: 1;
  border-color: #22d3ee;
}

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

@media (max-width: 720px) {
  .brand-title {
    display: none;
  }
  .hud-left {
    min-width: auto;
  }
  .founders-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .shop-item-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

