/* ==========================================================================
   MEME GALAXY — DESIGN SYSTEM & RESPONSIVE LAYOUT
   Colors: Deep Navy (#050B1B), Dark Blue (#08162D), Cyan (#00C8FF),
           Purple (#9A35FF), Green (#44FF75), Gold (#FFBE38), White (#F5FAFF)
   ========================================================================== */

:root {
  --bg-deep: #050b1b;
  --bg-dark: #08162d;
  --bg-panel: rgba(8, 22, 45, 0.78);
  --bg-panel-solid: #0d1e3a;
  --cyan: #00c8ff;
  --purple: #9a35ff;
  --green: #44ff75;
  --gold: #ffbe38;
  --white: #f5faff;
  --red: #ff3366;
  --border-neon: rgba(0, 200, 255, 0.28);
  --border-purple: rgba(154, 53, 255, 0.3);
  --font-display: 'Space Mono', monospace;
  --font-mono: 'Space Mono', monospace;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 14px;
}

/* 5-Area Desktop Layout Grid */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr 310px;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "top top top"
    "left center right";
  width: 100vw;
  height: 100vh;
  position: relative;
  background: radial-gradient(circle at 50% 20%, #0e244d 0%, var(--bg-deep) 85%);
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-neon);
  border-radius: 8px;
}

/* Typography & Colors */
.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-green { color: var(--green); }
.text-gold { color: var(--gold); }
.text-danger { color: var(--red); }

/* B. TOP NAVIGATION */
.top-nav {
  grid-area: top;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: rgba(5, 11, 27, 0.9);
  border-bottom: 1px solid var(--border-neon);
  z-index: 20;
}

.brand-zone {
  display: flex;
  flex-direction: column;
}

.game-tag {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--cyan);
  font-weight: 700;
}

.logo-title {
  font-size: 22px;
  letter-spacing: 3px;
  font-weight: 900;
  background: linear-gradient(90deg, #fff 0%, var(--cyan) 50%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.resources-zone {
  display: flex;
  align-items: center;
  gap: 20px;
}

.resource-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(8, 22, 45, 0.6);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0, 200, 255, 0.2);
}

.pill-icon {
  font-size: 16px;
}
.shard-icon { color: var(--gold); }
.level-icon { color: var(--cyan); }

.pill-data {
  display: flex;
  flex-direction: column;
}

.pill-label {
  font-size: 8px;
  letter-spacing: 1px;
  color: #8da4c4;
}

.pill-value {
  font-size: 14px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.pill-bar {
  width: 50px;
  height: 6px;
  background: #050b1b;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(0, 200, 255, 0.3);
}

.pill-bar-fill {
  width: 35%;
  height: 100%;
  background: var(--cyan);
}

/* A. LEFT SIDEBAR */
.sidebar-left {
  grid-area: left;
  display: flex;
  flex-direction: column;
  background: rgba(5, 11, 27, 0.85);
  border-right: 1px solid var(--border-neon);
  padding: 16px;
  gap: 16px;
  z-index: 10;
  overflow-y: auto;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px;
  background: rgba(8, 22, 45, 0.7);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 8px;
}

.avatar-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
}

.avatar-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px dashed var(--cyan);
  animation: spin 16s linear infinite;
}

.pilot-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  background: #08162d;
  border: 2px solid var(--purple);
}

.pilot-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 1.5px;
}

.pilot-status {
  font-size: 10px;
  color: #8da4c4;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.pilot-xp-section {
  width: 100%;
  margin-top: 10px;
}

.xp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #8da4c4;
  margin-bottom: 4px;
}

.custom-progress-bg {
  width: 100%;
  height: 6px;
  background: #050b1b;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(0, 200, 255, 0.2);
}

.custom-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--cyan);
  transition: width 0.3s ease;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: #a4b8d4;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-item:hover {
  background: rgba(0, 200, 255, 0.08);
  color: var(--white);
  border-color: rgba(0, 200, 255, 0.3);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(0, 200, 255, 0.25) 0%, transparent 100%);
  border-left: 3px solid var(--cyan);
  color: var(--white);
}

.nav-item.action-battle {
  background: rgba(68, 255, 117, 0.12);
  border-color: rgba(68, 255, 117, 0.4);
  color: var(--green);
}

.nav-item.action-battle:hover {
  background: rgba(68, 255, 117, 0.25);
  box-shadow: 0 0 14px rgba(68, 255, 117, 0.3);
}

.season-panel {
  margin-top: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.season-badge {
  font-size: 9px;
  background: var(--purple);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
}

.season-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-left: 4px;
}

.season-timer {
  font-size: 10px;
  color: #8da4c4;
  font-family: var(--font-mono);
}

/* C. CENTER BATTLEFIELD */
.battlefield-center {
  grid-area: center;
  position: relative;
  overflow: hidden;
  background: #03091d;
}

#webgl-container {
  width: 100%;
  height: 100%;
  background: url("./assets/environment/background.jpg") center / cover no-repeat;
}

/* Boss Warning & HP Bar */
.boss-warning-overlay {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  animation: pulse-warn 0.6s infinite alternate;
  z-index: 15;
}

.warning-glitch {
  font-size: 32px;
  font-weight: 900;
  color: var(--red);
  letter-spacing: 4px;
  text-shadow: 0 0 15px var(--red);
}

.boss-subtext {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--gold);
}

.boss-health-box {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  background: rgba(5, 11, 27, 0.85);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--red);
  z-index: 15;
  box-shadow: 0 0 16px rgba(255, 51, 102, 0.4);
}

.boss-title-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 4px;
}

.boss-hp-bar-bg {
  width: 100%;
  height: 10px;
  background: #11050b;
  border-radius: 4px;
  overflow: hidden;
}

.boss-hp-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff3366, #ffbe38);
  transition: width 0.15s ease;
}

/* E. BOTTOM HUD */
.bottom-hud {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(0deg, rgba(5, 11, 27, 0.95) 0%, rgba(5, 11, 27, 0.65) 80%, transparent 100%);
  display: grid;
  grid-template-columns: 240px 1fr 240px;
  align-items: center;
  padding: 14px 24px;
  border-top: 1px solid rgba(0, 200, 255, 0.2);
  z-index: 12;
  pointer-events: none;
}

.hud-vitals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.bar-tag {
  font-size: 10px;
  font-weight: 800;
  width: 48px;
}

.hud-track {
  flex: 1;
  height: 8px;
  background: #050b1b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.hud-fill {
  height: 100%;
  transition: width 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bg-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.bg-cyan { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

.bar-val {
  font-size: 10px;
  font-family: var(--font-mono);
  width: 50px;
  text-align: right;
}

.hud-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.hud-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.metric-title {
  font-size: 9px;
  color: #8da4c4;
  letter-spacing: 1px;
}

.metric-value {
  font-size: 20px;
  font-weight: 900;
  font-family: var(--font-mono);
}

.hud-ability-zone {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.ability-slot {
  position: relative;
  width: 54px;
  height: 54px;
  background: rgba(8, 22, 45, 0.8);
  border: 2px solid var(--purple);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.ability-cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(154, 53, 255, 0.4);
  transition: height 0.1s linear;
}

.ability-key {
  font-size: 11px;
  font-weight: 900;
  color: var(--cyan);
}

.ability-title {
  font-size: 8px;
  color: #8da4c4;
}

.hud-controls-hint {
  display: flex;
  flex-direction: column;
  font-size: 8px;
  color: #6d84a5;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

/* D. RIGHT SIDEBAR */
.sidebar-right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  background: rgba(5, 11, 27, 0.85);
  border-left: 1px solid var(--border-neon);
  padding: 16px;
  gap: 16px;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 200, 255, 0.15);
  padding-bottom: 4px;
}

.section-title-bar h3 {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--white);
}

.refresh-time, .upgrade-currency {
  font-size: 10px;
  color: #8da4c4;
  font-family: var(--font-mono);
}

.missions-scroll, .upgrades-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

/* Mission item cards */
.mission-card {
  background: rgba(8, 22, 45, 0.6);
  border: 1px solid rgba(0, 200, 255, 0.15);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mission-top {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
}

.mission-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mission-btn {
  background: var(--cyan);
  border: none;
  color: #050b1b;
  font-size: 9px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.mission-btn:disabled {
  background: #23354f;
  color: #556a87;
  cursor: not-allowed;
}

/* Upgrade item cards */
.upgrade-card {
  background: rgba(8, 22, 45, 0.6);
  border: 1px solid rgba(154, 53, 255, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upgrade-meta {
  display: flex;
  flex-direction: column;
}

.upgrade-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--white);
}

.upgrade-level {
  font-size: 9px;
  color: var(--purple);
  font-family: var(--font-mono);
}

.upgrade-btn {
  background: linear-gradient(135deg, var(--purple), #6a1bbd);
  border: none;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upgrade-btn:hover:not(:disabled) {
  filter: brightness(1.2);
  box-shadow: 0 0 10px rgba(154, 53, 255, 0.6);
}

.upgrade-btn:disabled {
  background: #1c2738;
  color: #5a6e88;
  cursor: not-allowed;
}

.vault-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vault-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vault-badge {
  font-size: 9px;
  color: var(--gold);
  font-weight: 800;
}

.vault-reward-desc {
  font-size: 11px;
  color: #b5cae6;
}

/* BUTTONS & GLOWS */
.neon-btn {
  background: rgba(0, 200, 255, 0.15);
  border: 1px solid var(--cyan);
  color: var(--white);
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.neon-btn:hover {
  background: var(--cyan);
  color: #050b1b;
  box-shadow: 0 0 16px var(--cyan);
}

.neon-btn-compact {
  background: rgba(0, 200, 255, 0.12);
  border: 1px solid var(--cyan);
  color: var(--white);
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.neon-btn-compact:hover {
  background: rgba(0, 200, 255, 0.3);
}

.neon-btn-ghost {
  background: transparent;
  border: 1px solid #334e72;
  color: #8da4c4;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.neon-btn-ghost:hover {
  border-color: #fff;
  color: #fff;
}

.glow-blue { box-shadow: 0 0 10px rgba(0, 200, 255, 0.25); }
.glow-cyan { box-shadow: 0 0 10px rgba(0, 200, 255, 0.35); }
.glow-green { border-color: var(--green); color: var(--green); }
.glow-green:hover { background: var(--green); color: #050b1b; box-shadow: 0 0 16px var(--green); }
.glow-gold { border-color: var(--gold); color: var(--gold); }
/* .glow-gold:hover { background: var(--gold); color: #050b1b; box-shadow: 0 0 16px var(--gold); } */
.glow-red { border-color: var(--red); box-shadow: 0 0 20px rgba(255, 51, 102, 0.4); }

.wallet-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
}

/* MODALS & OVERLAYS */
.modal-backdrop, .screen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 11, 27, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-box {
  width: 90%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-large { max-width: 760px; }
.modal-medium { max-width: 580px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 16px;
  letter-spacing: 2px;
}

.modal-close {
  background: transparent;
  border: none;
  color: #8da4c4;
  font-size: 18px;
  cursor: pointer;
}

.modal-close:hover { color: #fff; }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-desc {
  font-size: 12px;
  color: #a4b8d4;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* Hangar Modal */
.hangar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.hangar-card {
  background: rgba(8, 22, 45, 0.6);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hangar-card.active {
  border-color: var(--cyan);
  background: rgba(0, 200, 255, 0.15);
  box-shadow: 0 0 16px rgba(0, 200, 255, 0.3);
}

.hangar-ship-preview {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

/* Pause & Game Over */
.pause-box, .gameover-box, .victory-box {
  width: 90%;
  max-width: 440px;
  padding: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.gameover-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}

.stat-card {
  background: rgba(5, 11, 27, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.card-label { font-size: 9px; color: #8da4c4; }
.card-val { font-size: 18px; font-weight: 900; font-family: var(--font-mono); }

.gameover-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Leaderboard Table */
.leader-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.leader-table th {
  padding: 8px;
  border-bottom: 1px solid rgba(0, 200, 255, 0.3);
  color: #8da4c4;
}

.leader-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Loader Screen */
.loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loader-logo {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.loader-bar-bg {
  width: 280px;
  height: 8px;
  background: #08162d;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  overflow: hidden;
}

.loader-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  transition: width 0.15s ease;
}

.loader-text {
  font-size: 11px;
  font-family: var(--font-mono);
  color: #8da4c4;
  letter-spacing: 2px;
}

/* UTILITIES */
.hide {
  display: none !important;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@keyframes pulse-warn {
  0% { opacity: 0.4; transform: translateX(-50%) scale(0.96); }
  100% { opacity: 1; transform: translateX(-50%) scale(1.04); }
}

/* RESPONSIVE DESIGN (BREAKPOINTS) */
@media (max-width: 1280px) {
  .app-layout {
    grid-template-columns: 220px 1fr 260px;
  }
}

@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 200px 1fr;
    grid-template-areas:
      "top top"
      "left center";
  }
  .sidebar-right {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "center";
  }
  .sidebar-left {
    display: none;
  }
  .bottom-hud {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }
  .hud-stats {
    gap: 14px;
  }
  .hud-controls-hint {
    display: none;
  }
  .touch-controls-layer {
    display: block !important;
  }
}