/* Chrono Rift TD — 16-Bit Time-Travel Tower Defense Stylesheet */
:root {
  --bg-deep: #0b0f1e;
  --bg-panel: #131a30;
  --bg-panel-2: #1b2442;
  --border-dim: #2b3863;
  --border-bright: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --gold: #fbbf24;
  --cyan: #22d3ee;
  --violet: #c084fc;
  --emerald: #34d399;
  --danger: #f87171;
  --stone-accent: #d97706;
  --medieval-accent: #3b82f6;
  --future-accent: #22d3ee;
  --font-ui: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: radial-gradient(circle at 50% 0%, #17213e 0%, var(--bg-deep) 70%);
  color: var(--text-main);
  font-family: var(--font-ui);
  overflow-x: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  width: 100%;
  padding-bottom: 58px; /* Clear of floating studio-bar.js pill */
}

/* ==================== TOP HUD ==================== */
.hud {
  width: 100%;
  max-width: 1020px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(15, 22, 42, 0.94);
  border-bottom: 2px solid var(--border-dim);
  z-index: 20;
  flex-wrap: nowrap;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hud-era-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.5px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  transition: background 0.35s, border-color 0.35s, box-shadow 0.35s;
  white-space: nowrap;
}
.hud-era-badge.era-0 {
  background: linear-gradient(135deg, #5c3a1e, #854d0e);
  border-color: #f59e0b;
  color: #fef3c7;
}
.hud-era-badge.era-1 {
  background: linear-gradient(135deg, #1e3a8a, #4338ca);
  border-color: #93c5fd;
  color: #eff6ff;
}
.hud-era-badge.era-2 {
  background: linear-gradient(135deg, #083344, #4c1d95);
  border-color: #22d3ee;
  color: #cffafe;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.45);
}

.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(27, 36, 66, 0.9);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.stat-shards { color: var(--gold); border-color: rgba(251, 191, 36, 0.4); }
.stat-hp { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.4); }
.stat-wave { color: #93c5fd; }
.stat-score { color: #e9d5ff; }

.hud-btn, .hud-icon-btn {
  border: 1px solid var(--border-dim);
  background: var(--bg-panel-2);
  color: var(--text-main);
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.hud-icon-btn {
  padding: 5px 7px;
  font-size: 14px;
}
.hud-btn:hover, .hud-icon-btn:hover {
  border-color: var(--cyan);
  background: #233058;
}
.hud-btn:active, .hud-icon-btn:active {
  transform: scale(0.96);
}

.btn-wave-call {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: #38bdf8;
  color: #fff;
}
.btn-wave-call.pulse {
  animation: pulseGlow 1.3s ease-in-out infinite;
}
.bonus-tag {
  background: rgba(0, 0, 0, 0.35);
  color: var(--gold);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 11px;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.55); }
  50% { box-shadow: 0 0 12px 2px rgba(56, 189, 248, 0.8); }
}

/* ==================== STAGE & CANVAS ==================== */
#stage-wrap {
  width: 100%;
  max-width: 1020px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}

#canvas-shell {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #2b3a67;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(56, 189, 248, 0.18);
  background: #0b1020;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
  cursor: pointer;
}

/* Overlays inside Canvas Shell */
.rival-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: #fef3c7;
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 12;
  white-space: nowrap;
}

.era-banner {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: linear-gradient(135deg, rgba(11, 18, 40, 0.94), rgba(30, 27, 75, 0.94));
  border: 2px solid var(--cyan);
  border-radius: 12px;
  padding: 10px 24px;
  box-shadow: 0 0 32px rgba(34, 211, 238, 0.5);
  pointer-events: none;
  z-index: 15;
  animation: popIn 0.3s ease-out;
}
.era-banner-kicker {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cyan);
  font-weight: 800;
}
.era-banner-title {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 10px rgba(34, 211, 238, 0.65);
  margin: 2px 0;
}
.era-banner-sub {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
}

.rewind-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 47, 73, 0.94);
  border: 1.5px solid var(--cyan);
  color: #e0f2fe;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  max-width: 94%;
}
.mini-cancel {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}

.boss-bar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 86%);
  background: rgba(15, 12, 32, 0.9);
  border: 1.5px solid #f43f5e;
  border-radius: 8px;
  padding: 5px 9px;
  z-index: 13;
  pointer-events: none;
}
.boss-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: #fecdd3;
  margin-bottom: 4px;
}
.boss-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #fde047);
  transition: width 0.12s linear;
}

.toast {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--cyan);
  color: #f8fafc;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  z-index: 16;
  pointer-events: none;
}

@keyframes popIn {
  from { transform: translateX(-50%) scale(0.86); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ==================== BOTTOM COMMAND DECK ==================== */
.command-deck {
  width: 100%;
  max-width: 1020px;
  padding: 4px 8px 6px;
  z-index: 20;
}

.build-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  background: rgba(15, 22, 42, 0.94);
  border: 1.5px solid var(--border-dim);
  border-radius: 10px;
  padding: 7px 8px;
}

.tower-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  flex: 1 1 auto;
}

.tower-card {
  background: var(--bg-panel-2);
  border: 1.5px solid var(--border-dim);
  border-radius: 8px;
  padding: 5px 6px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.tower-card:hover {
  border-color: var(--cyan);
  background: #233058;
}
.tower-card.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, #273766, #1a2444);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
}
.tower-card.cant-afford {
  opacity: 0.56;
}
.tc-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
}
.tc-key {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-muted);
}
.tc-cost {
  color: var(--gold);
  font-family: var(--font-mono);
}
.tc-icon-wrap {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tc-icon-wrap canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}
.tc-name {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.tc-role {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Inspector */
.tower-inspector {
  flex: 1 1 auto;
  background: linear-gradient(135deg, #1b2547, #161d38);
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}
.insp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.insp-title {
  font-size: 13px;
  font-weight: 900;
  color: #fef3c7;
}
.insp-meta {
  font-size: 11px;
  color: #93c5fd;
  font-family: var(--font-mono);
}
.insp-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
}
.insp-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.insp-btn {
  flex: 1 1 auto;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-dim);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-upgrade {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #34d399;
}
.btn-upgrade:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-target {
  background: #25335e;
  border-color: #60a5fa;
}
.btn-sell {
  background: #7f1d1d;
  border-color: #f87171;
}

/* Active Time-Travel Spells */
.spell-rack {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.spell-btn {
  position: relative;
  min-width: 112px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--cyan);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  text-align: left;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}
.spell-rewind {
  background: linear-gradient(135deg, #0e7490, #155e75);
  border-color: #22d3ee;
}
.spell-overclock {
  background: linear-gradient(135deg, #7e22ce, #b45309);
  border-color: #fbbf24;
}
.spell-btn.active-cast {
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.85);
  transform: translateY(-1px);
}
.spell-btn.on-cd {
  opacity: 0.55;
  filter: grayscale(0.4);
  cursor: not-allowed;
}
.spell-key {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  font-weight: 800;
  opacity: 0.8;
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 4px;
  border-radius: 3px;
}
.spell-ico {
  font-size: 20px;
}
.spell-info {
  display: flex;
  flex-direction: column;
}
.spell-name {
  font-size: 12px;
  font-weight: 800;
}
.spell-cd {
  font-size: 10px;
  font-family: var(--font-mono);
  color: #fef08a;
}

/* ==================== FULL-VIEWPORT MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 20, 0.86);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 12px 68px; /* Keep clear of studio-bar floating pill */
  z-index: 100;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 82px);
  overflow-y: auto;
  background: linear-gradient(180deg, #161f3b 0%, #0f162b 100%);
  border: 2px solid #33457c;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(56, 189, 248, 0.2);
}
.modal-wide {
  max-width: 780px;
}
.modal-compact {
  max-width: 380px;
  text-align: center;
}

.hero-header {
  text-align: center;
  margin-bottom: 14px;
}
.hero-pill-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 6px;
}
.era-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}
.chip-stone { background: #78350f; color: #fde68a; border: 1px solid #f59e0b; }
.chip-medieval { background: #1e3a8a; color: #dbeafe; border: 1px solid #60a5fa; }
.chip-future { background: #164e63; color: #cffafe; border: 1px solid #22d3ee; }
.era-arrow { color: var(--text-muted); font-weight: 900; }

.game-title {
  margin: 2px 0 4px;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(90deg, #fde047, #38bdf8, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.game-subtitle {
  margin: 0 auto;
  max-width: 580px;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.4;
}

.menu-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.primary-cta {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border: 2px solid #7dd3fc;
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 0.4px;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.35);
}
.primary-cta:hover { filter: brightness(1.08); }
.primary-cta.small { padding: 9px 14px; font-size: 13px; }

.daily-cta {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: 2px solid #f0abfc;
  color: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
}
.daily-cta.compact {
  flex-direction: row;
  padding: 9px 14px;
  font-weight: 900;
  font-size: 13px;
}
.daily-top { font-size: 13px; font-weight: 900; }
.daily-sub { font-size: 11px; color: #fce7f3; }

.menu-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(11, 16, 32, 0.72);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  margin-bottom: 12px;
}
.meta-badge {
  font-size: 12px;
  color: #cbd5e1;
}
.meta-badge strong { color: var(--gold); }
.meta-btn {
  position: relative;
  background: var(--bg-panel-2);
  border: 1px solid #475d9e;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.meta-btn:hover { border-color: var(--cyan); }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  margin-left: 4px;
  box-shadow: 0 0 8px #34d399;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--cyan);
  margin-bottom: 8px;
}
.hint-text { color: var(--text-muted); font-weight: 600; }

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

.map-card {
  background: rgba(23, 32, 60, 0.92);
  border: 1.5px solid #33457c;
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.12s, border-color 0.15s;
}
.map-card:hover:not(.locked) {
  border-color: var(--cyan);
  transform: translateY(-2px);
}
.map-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}
.mc-stars { color: var(--gold); letter-spacing: 1px; font-size: 12px; }
.mc-name { font-size: 14px; font-weight: 900; color: #f8fafc; }
.mc-desc { font-size: 11px; color: #94a3b8; line-height: 1.3; }
.mc-foot {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #7dd3fc;
  font-weight: 700;
}

/* Archive & Leaderboard Modals */
.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-top h2 { margin: 0; font-size: 18px; }
.modal-sub { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }
.modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-dim);
  color: #fff;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}

.archive-balance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(11, 16, 32, 0.8);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.archive-balance strong { color: var(--gold); }

.perk-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(27, 36, 66, 0.88);
  border: 1px solid var(--border-dim);
  border-radius: 9px;
  padding: 9px 11px;
}
.perk-info h3 { margin: 0; font-size: 13px; color: #f8fafc; }
.perk-info p { margin: 2px 0 0; font-size: 11px; color: #cbd5e1; }
.perk-pips { display: flex; gap: 4px; margin-top: 4px; }
.perk-pip {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
}
.perk-pip.filled { background: var(--gold); box-shadow: 0 0 6px rgba(251, 191, 36, 0.6); }

.perk-buy-btn {
  background: linear-gradient(135deg, #059669, #0d9488);
  border: 1px solid #34d399;
  color: #fff;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.perk-buy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lb-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 8px;
  align-items: center;
  background: rgba(27, 36, 66, 0.75);
  border: 1px solid var(--border-dim);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12px;
}
.lb-rank { font-weight: 900; color: var(--gold); }
.lb-name { font-weight: 800; color: #f8fafc; overflow: hidden; text-overflow: ellipsis; }
.lb-wave { color: #93c5fd; font-family: var(--font-mono); }
.lb-score { color: #34d399; font-weight: 900; font-family: var(--font-mono); }
.lb-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* End Modal */
.end-badge {
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--cyan);
}
.end-title {
  text-align: center;
  margin: 4px 0 4px;
  font-size: 22px;
}
.end-stars {
  text-align: center;
  font-size: 30px;
  color: var(--gold);
  letter-spacing: 4px;
  margin-bottom: 12px;
}
.end-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}
.end-stat {
  background: rgba(11, 16, 32, 0.8);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}
.end-stat span { display: block; font-size: 10px; color: var(--text-muted); }
.end-stat strong { font-size: 14px; color: #f8fafc; font-family: var(--font-mono); }

.cliffhanger-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 116, 144, 0.25);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  color: #cffafe;
  margin-bottom: 12px;
}

.end-lb-submit {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.end-lb-submit input {
  flex: 1;
  background: #0b1020;
  border: 1px solid #475d9e;
  color: #fff;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.share-btn {
  background: linear-gradient(135deg, #059669, #10b981);
  border: 1.5px solid #6ee7b7;
  color: #fff;
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.secondary-btn {
  background: var(--bg-panel-2);
  border: 1px solid #475d9e;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.secondary-btn:hover { border-color: var(--cyan); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

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

.promo-slot {
  margin-top: 12px;
}

/* ==================== MOBILE RESPONSIVE (390x844 ZERO OVERFLOW) ==================== */
@media (max-width: 720px) {
  #app {
    padding-bottom: 64px; /* Extra clearance above studio-bar pill */
  }
  .hud {
    padding: 5px 8px;
    gap: 5px;
    flex-wrap: wrap;
  }
  .hud-left, .hud-right {
    gap: 5px;
  }
  .hud-left {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  .hud-right {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  .btn-wave-call {
    flex: 1 1 auto;
    justify-content: center;
  }
  .hide-sm {
    display: none !important;
  }
  .hud-era-badge {
    padding: 3px 7px;
    font-size: 11px;
  }
  .hud-stat {
    padding: 3px 6px;
    font-size: 11px;
  }
  .hud-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .hud-icon-btn {
    padding: 4px 7px;
    font-size: 13px;
  }
  .bonus-tag {
    display: inline-block;
  }
  #stage-wrap {
    padding: 4px 4px;
    flex: 0 0 auto;
  }
  .command-deck {
    padding: 4px 6px 6px;
  }
  .build-bar {
    flex-direction: column;
    gap: 6px;
    padding: 6px;
  }
  .tower-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  .tower-card {
    padding: 4px 3px;
  }
  .tc-icon-wrap {
    width: 28px;
    height: 28px;
  }
  .tc-icon-wrap canvas {
    width: 26px;
    height: 26px;
  }
  .tc-name {
    font-size: 10px;
  }
  .tc-role {
    display: none;
  }
  .spell-rack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }
  .spell-btn {
    min-width: 0;
    justify-content: center;
    padding: 6px 8px;
  }
  .menu-quick-actions {
    grid-template-columns: 1fr;
  }
  .map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .end-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .era-banner-title {
    font-size: 17px;
  }
}

@media (max-width: 420px) {
  .hud-era-badge .era-name {
    max-width: 66px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .map-grid {
    grid-template-columns: 1fr;
  }
  .modal-card {
    padding: 14px 12px;
  }
}
