/* =========================================================
   AETHER DEFENSE - MODERN MOBILE IDLE TOWER DEFENSE
   Portrait-First Mobile Architecture, Retina-Sharp Visuals,
   Glassmorphism UI, Responsive Deck & Thumb Navigation
   ========================================================= */

:root {
  --bg-deep: #060913;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(56, 189, 248, 0.5);
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.35);
  --gold: #facc15;
  --gold-glow: rgba(250, 204, 21, 0.3);
  --purple: #c084fc;
  --purple-glow: rgba(192, 132, 252, 0.3);
  --green: #4ade80;
  --red: #f87171;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  font-family: var(--font-family);
  color: var(--text-main);
  touch-action: manipulation;
}

/* Ambient Background for Desktop Frame */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 30%, #111a30 0%, #060913 100%);
}

/* ================= MOBILE PHONE SHELL ================= */
#mobile-app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #090e1a;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8), 0 0 20px rgba(56, 189, 248, 0.1);
}

@media (min-width: 601px) {
  #mobile-app {
    height: 94vh;
    border-radius: 32px;
    border: 2px solid rgba(255, 255, 255, 0.12);
  }
}

/* ================= 1. TOP HEADER & HUD ================= */
#top-hud {
  flex-shrink: 0;
  padding: 8px 12px;
  background: rgba(11, 17, 33, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wave-badge-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wave-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
}

.wave-progress-bar-wrap {
  width: 90px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.wave-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.1s ease;
}

.mini-btn:active {
  transform: scale(0.94);
}

.mini-btn.active {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
  color: #4ade80;
}

/* Currency Row */
.hud-row-currencies {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.currency-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 12px;
}

.curr-gold { color: #fde047; }
.curr-gems { color: #7dd3fc; }
.curr-shards { color: #e9d5ff; }
.gps-tag {
  font-size: 10px;
  color: #a3e635;
  margin-left: 2px;
  font-weight: normal;
}

/* ================= 2. BATTLEFIELD CANVAS ================= */
#battlefield-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 42%;
  min-height: 220px;
  background: radial-gradient(circle at center, #0e1628 0%, #060913 100%);
  overflow: hidden;
  cursor: crosshair;
}

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

/* Floating Tower Health & Shield Bar */
#tower-status-overlay {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  z-index: 20;
}

.tower-bars-wrap {
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bar-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

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

.bar-shield-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  transition: width 0.15s ease;
}

.status-label {
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  color: #f1f5f9;
}

/* Active Tap-To-Zap floating tip */
.tap-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: #7dd3fc;
  pointer-events: none;
  opacity: 0.8;
}

/* ================= 3. MOBILE UPGRADE DECK ================= */
#deck-container {
  flex: 1 1 58%;
  display: flex;
  flex-direction: column;
  background: #090e1c;
  border-top: 1px solid var(--border-subtle);
  overflow: hidden;
  z-index: 30;
}

/* Deck Sub-Header: Tabs + Multiplier Toggle */
.deck-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.tab-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.tab-btn.active {
  color: #fff;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.tab-btn:active {
  transform: scale(0.95);
}

/* Buy Multiplier Button (x1, x5, x10, MAX) */
.btn-multiplier {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(250, 204, 21, 0.5);
  color: #facc15;
  font-weight: 800;
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-multiplier:active {
  transform: scale(0.92);
}

/* Upgrades Scrollable List */
.upgrades-scroll-view {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Modern Upgrade Card */
.upgrade-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 8px 12px;
  transition: all 0.12s ease;
  min-height: 54px;
}

.upgrade-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.up-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.up-icon {
  font-size: 22px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  flex-shrink: 0;
}

.up-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.up-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.up-name {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.up-level {
  font-size: 11px;
  color: var(--cyan);
  font-weight: 800;
}

.up-stat-val {
  font-size: 11px;
  color: var(--text-muted);
}

.up-next-val {
  color: var(--green);
  font-weight: 700;
}

/* Big Finger-Friendly Buy Button */
.btn-buy-upgrade {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #fff;
  border-radius: 10px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  transition: all 0.1s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-buy-upgrade:active {
  transform: scale(0.94);
}

.btn-buy-upgrade.disabled {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(255, 255, 255, 0.05);
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-buy-cost {
  color: #fde047;
  font-size: 11px;
  font-weight: 700;
}

/* ================= 4. MODALS & POPUPS ================= */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-box {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.2);
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #f1f5f9;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

/* Perk Choice Cards (Milestone waves) */
.perk-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}

.perk-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  border: 1px solid var(--cyan);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.15s ease;
}

.perk-card:active {
  transform: scale(0.96);
  border-color: var(--gold);
}

.perk-icon {
  font-size: 32px;
}

.perk-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.perk-desc {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Boss Warning Banner */
#boss-warning-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(185, 28, 28, 0.9);
  border: 2px solid #ef4444;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.7);
  padding: 14px 24px;
  border-radius: 16px;
  text-align: center;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#boss-warning-banner.active {
  opacity: 1;
  animation: pulse-ring 0.6s infinite alternate;
}

@keyframes pulse-ring {
  from { transform: translate(-50%, -50%) scale(0.96); }
  to { transform: translate(-50%, -50%) scale(1.04); }
}
