:root {
  --bg-deep: #110d0b;
  --bg-panel: #1b1411;
  --bg-panel-hi: #271d18;
  --brass: #e0ab4e;
  --brass-bright: #ffd67a;
  --brass-dim: #7f5a26;
  --copper: #c96c38;
  --aether: #3ce7ff;
  --aether-dim: #176c82;
  --crimson: #e6524b;
  --steam: #f4ead7;
  --muted: #b5a38e;
  --emerald: #4ade80;
  --border: rgba(224, 171, 78, 0.34);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 0%, #2a1d14 0%, #120d0b 65%, #090706 100%);
  color: var(--steam);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden {
  display: none !important;
}

#app {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 100vh;
}

/* ==================== TOP BRASS HUD ==================== */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  background: linear-gradient(180deg, #2b2019 0%, #19120e 100%);
  border: 2px solid var(--brass-dim);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 222, 148, 0.25), 0 4px 16px rgba(0, 0, 0, 0.45);
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.brand-pill {
  background: linear-gradient(180deg, #4b331b 0%, #2f1e10 100%);
  border: 1px solid var(--brass);
  border-radius: 7px;
  padding: 4px 10px;
  font-weight: 800;
  font-size: 13px;
  color: var(--brass-bright);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #120d0a;
  border: 1px solid rgba(224, 171, 78, 0.28);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-gold { color: #ffd67a; border-color: rgba(255, 214, 122, 0.42); }
.stat-lives { color: #ff857d; border-color: rgba(230, 82, 75, 0.42); }
.stat-wave { color: #67e8f9; border-color: rgba(60, 231, 255, 0.35); }
.stat-score { color: #e9d5ff; border-color: rgba(192, 132, 252, 0.35); }

.hud-btn {
  background: linear-gradient(180deg, #35271e 0%, #201711 100%);
  color: var(--steam);
  border: 1px solid var(--brass-dim);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.08s ease, border-color 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

.hud-btn:hover {
  border-color: var(--brass-bright);
  filter: brightness(1.12);
}

.hud-btn:active {
  transform: translateY(1px);
}

.hud-btn-call {
  background: linear-gradient(180deg, #c97e24 0%, #8b4d11 100%);
  border-color: var(--brass-bright);
  color: #fff9eb;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.hud-btn-call.pulse {
  animation: brassPulse 1.4s ease-in-out infinite;
}

.hud-btn-star {
  background: linear-gradient(180deg, #503a16 0%, #2d1f0b 100%);
  border-color: var(--brass);
  color: var(--brass-bright);
}

.hud-btn.active {
  background: linear-gradient(180deg, #1b6980 0%, #0e3d4c 100%);
  border-color: var(--aether);
  color: #e0fbff;
}

@keyframes brassPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 214, 122, 0.55); }
  50% { box-shadow: 0 0 12px 3px rgba(255, 214, 122, 0.7); }
}

/* ==================== CHALLENGE BANNER ==================== */
.challenge-banner {
  background: linear-gradient(90deg, #3c260e 0%, #593511 50%, #3c260e 100%);
  border: 1px solid var(--brass-bright);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #fff3d1;
  text-align: center;
}

/* ==================== STAGE & CANVAS ==================== */
.stage-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.canvas-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 70vh;
  background: #14100e;
  border: 2px solid var(--brass-dim);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 214, 122, 0.15);
}

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

/* ==================== CONTEXTUAL PLOT / RAIL POPOVER ==================== */
.plot-popover {
  position: absolute;
  z-index: 24;
  min-width: 224px;
  max-width: 280px;
  background: linear-gradient(180deg, rgba(33, 24, 19, 0.97) 0%, rgba(18, 13, 10, 0.98) 100%);
  border: 2px solid var(--brass);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.78);
  color: var(--steam);
}

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid rgba(224, 171, 78, 0.25);
  padding-bottom: 5px;
  margin-bottom: 6px;
}

.pop-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--brass-bright);
  letter-spacing: 0.3px;
}

.pop-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(60, 231, 255, 0.16);
  border: 1px solid rgba(60, 231, 255, 0.5);
  color: var(--aether);
}

.pop-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 4px;
}
.pop-close:hover { color: #fff; }

.pop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.pop-tower-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: linear-gradient(180deg, #2d2119 0%, #1d1510 100%);
  border: 1px solid rgba(224, 171, 78, 0.35);
  border-radius: 8px;
  padding: 5px 4px;
  color: var(--steam);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, transform 0.08s ease;
}

.pop-tower-btn:hover:not(:disabled) {
  border-color: var(--brass-bright);
  transform: translateY(-1px);
  background: linear-gradient(180deg, #3c2b1e 0%, #241911 100%);
}

.pop-tower-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pop-tower-thumb {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
  object-fit: contain;
}

.pop-tower-name {
  font-size: 11px;
  font-weight: 800;
  color: #fff6e5;
  line-height: 1.1;
}

.pop-tower-role {
  font-size: 9.5px;
  color: var(--muted);
  line-height: 1.1;
}

.pop-tower-cost {
  font-size: 11px;
  font-weight: 800;
  color: var(--brass-bright);
}

.pop-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.pop-stat-box {
  background: #120d0a;
  border: 1px solid rgba(224, 171, 78, 0.22);
  border-radius: 6px;
  padding: 4px;
  text-align: center;
}

.pop-stat-lbl {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}

.pop-stat-val {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--steam);
}

.pop-rail-banner {
  background: linear-gradient(90deg, rgba(60, 231, 255, 0.14), rgba(224, 171, 78, 0.18));
  border: 1px solid rgba(255, 214, 122, 0.5);
  border-radius: 6px;
  padding: 5px 6px;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff1cc;
  line-height: 1.25;
}

.pop-rail-stops {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.pop-rail-stop-btn {
  background: linear-gradient(180deg, #1a586c 0%, #0f3644 100%);
  border: 1px solid var(--aether);
  border-radius: 5px;
  color: #e2fbff;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 6px;
  cursor: pointer;
}
.pop-rail-stop-btn:hover:not(:disabled) {
  filter: brightness(1.18);
}
.pop-rail-stop-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pop-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.pop-act-btn {
  flex: 1;
  min-width: 72px;
  border-radius: 7px;
  padding: 6px 6px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--brass-dim);
  color: #fff;
}

.pop-act-upg {
  background: linear-gradient(180deg, #c98624 0%, #86500f 100%);
  border-color: var(--brass-bright);
}
.pop-act-upg:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.pop-act-tgt {
  background: linear-gradient(180deg, #2d3c47 0%, #1a232b 100%);
  border-color: #60859c;
}

.pop-act-sell {
  background: linear-gradient(180deg, #6e2724 0%, #451513 100%);
  border-color: #c95852;
}

/* ==================== STAGE FLOATING BANNERS ==================== */
.rail-hint-pill {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(15, 29, 36, 0.92);
  border: 1.5px solid var(--aether);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 800;
  color: #d8fbff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  white-space: nowrap;
}

.boss-banner {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  background: linear-gradient(90deg, rgba(110, 20, 18, 0.95), rgba(168, 42, 24, 0.96), rgba(110, 20, 18, 0.95));
  border: 2px solid var(--brass-bright);
  border-radius: 10px;
  padding: 7px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.9px;
  color: #fff5d6;
  text-shadow: 0 2px 4px #000;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.stage-toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  background: rgba(20, 14, 11, 0.92);
  border: 1px solid var(--brass);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brass-bright);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== OVERLAY & CAMPAIGN CARD ==================== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: radial-gradient(circle at 50% 35%, rgba(34, 22, 14, 0.84) 0%, rgba(12, 9, 7, 0.92) 100%);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
}

.overlay-card {
  width: 100%;
  max-width: 660px;
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, #271c15 0%, #17110d 100%);
  border: 2px solid var(--brass);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 224, 150, 0.25);
}

.ov-crest {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 2px;
}

.ov-title {
  margin: 0;
  font-family: 'Georgia', 'Palatino Linotype', serif;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--brass-bright);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.75);
}

.ov-subtitle {
  margin: 2px 0 10px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Daily Strip */
.daily-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: linear-gradient(90deg, rgba(22, 62, 74, 0.65), rgba(55, 36, 16, 0.75));
  border: 1px solid rgba(60, 231, 255, 0.45);
  border-radius: 9px;
  padding: 7px 10px;
  margin-bottom: 10px;
  text-align: left;
}

.daily-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.daily-badge {
  font-size: 11px;
  font-weight: 900;
  color: var(--aether);
  letter-spacing: 0.6px;
}

.daily-mod {
  font-size: 11.5px;
  color: var(--steam);
  font-weight: 600;
}

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

.streak-pill {
  font-size: 11px;
  font-weight: 800;
  color: #ffb86c;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 184, 108, 0.4);
  border-radius: 99px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* 6-Map Grid */
.map-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}

.map-card {
  background: linear-gradient(180deg, #2f2219 0%, #1d1510 100%);
  border: 1.5px solid rgba(224, 171, 78, 0.3);
  border-radius: 9px;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  color: var(--steam);
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.map-card:hover:not(.locked) {
  border-color: var(--brass-bright);
  transform: translateY(-1px);
}

.map-card.selected {
  border-color: var(--aether);
  box-shadow: 0 0 0 1px var(--aether), 0 4px 14px rgba(60, 231, 255, 0.25);
  background: linear-gradient(180deg, #322a20 0%, #1a2124 100%);
}

.map-card.locked {
  opacity: 0.48;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

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

.map-card-num {
  font-size: 10px;
  font-weight: 800;
  color: var(--brass);
  text-transform: uppercase;
}

.map-card-stars {
  font-size: 11px;
  color: var(--brass-bright);
  letter-spacing: 1px;
}

.map-card-name {
  font-size: 12.5px;
  font-weight: 800;
  color: #fff8ea;
  line-height: 1.2;
}

.map-card-tag {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.2;
}

/* Post-Run Stats */
.ov-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 9px;
}

.ov-stat-card {
  background: #120d0a;
  border: 1px solid rgba(224, 171, 78, 0.3);
  border-radius: 8px;
  padding: 6px 4px;
}

.ov-stat-k {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.ov-stat-v {
  font-size: 15px;
  font-weight: 900;
  color: var(--brass-bright);
  margin-top: 2px;
}

.cliffhanger {
  background: linear-gradient(90deg, rgba(224, 171, 78, 0.14), rgba(60, 231, 255, 0.12));
  border: 1px dashed rgba(255, 214, 122, 0.55);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: #ffeec2;
  margin-bottom: 9px;
}

.lb-submit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.lb-submit-row input {
  background: #120d0a;
  border: 1px solid var(--brass-dim);
  border-radius: 7px;
  padding: 6px 10px;
  color: var(--steam);
  font-size: 12.5px;
  width: 170px;
}

.lb-submit-msg {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--emerald);
}

.share-preview {
  background: #120d0a;
  border: 1px solid rgba(224, 171, 78, 0.28);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #ebdcb9;
  margin-bottom: 9px;
  word-break: break-word;
}

/* Buttons */
.ov-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.btn {
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #d88f28 0%, #945510 100%);
  border-color: var(--brass-bright);
  color: #fff9eb;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.btn-secondary {
  background: linear-gradient(180deg, #3a2c22 0%, #221913 100%);
  border-color: var(--brass-dim);
  color: var(--steam);
}

.btn-gold {
  background: linear-gradient(180deg, #5d4217 0%, #37250b 100%);
  border-color: var(--brass);
  color: var(--brass-bright);
}

.btn-daily {
  background: linear-gradient(180deg, #1b7c96 0%, #0f4c5e 100%);
  border-color: var(--aether);
  color: #e6fcff;
  padding: 5px 11px;
  font-size: 12px;
}

.btn-share {
  background: linear-gradient(180deg, #27684b 0%, #15402d 100%);
  border-color: #4ade80;
  color: #ecfdf5;
}

.btn-small {
  padding: 4px 9px;
  font-size: 11px;
}

.ov-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

/* ==================== MODALS (BLUEPRINT TREE + LEADERBOARD) ==================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(10, 7, 5, 0.85);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 94%;
  overflow-y: auto;
  background: linear-gradient(180deg, #281d16 0%, #16100c 100%);
  border: 2px solid var(--brass);
  border-radius: 13px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(224, 171, 78, 0.25);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--brass-bright);
  font-family: 'Georgia', serif;
}

.modal-sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.modal-close {
  background: #2f2219;
  border: 1px solid var(--brass-dim);
  border-radius: 7px;
  color: var(--steam);
  width: 28px;
  height: 28px;
  font-weight: 800;
  cursor: pointer;
}

.stars-bank-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: #120d0a;
  border: 1px solid rgba(224, 171, 78, 0.3);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.stars-bank-bar strong {
  color: var(--brass-bright);
}

.stars-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.perk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, #2d2018 0%, #1d1510 100%);
  border: 1px solid rgba(224, 171, 78, 0.3);
  border-radius: 9px;
  padding: 8px 10px;
}

.perk-info {
  text-align: left;
}

.perk-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff6e0;
}

.perk-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.perk-pips {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
}

.perk-pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3d2f24;
  border: 1px solid var(--brass-dim);
  display: inline-block;
}
.perk-pip.filled {
  background: var(--brass-bright);
  border-color: #fff2c2;
  box-shadow: 0 0 6px rgba(255, 214, 122, 0.7);
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 8px;
  background: #140e0b;
  border: 1px solid rgba(224, 171, 78, 0.22);
  border-radius: 7px;
  padding: 6px 10px;
}

.lb-rank { font-weight: 900; color: var(--brass-bright); }
.lb-name { font-weight: 700; color: var(--steam); text-align: left; overflow: hidden; text-overflow: ellipsis; }
.lb-wave { font-size: 11px; color: var(--aether); font-weight: 700; }
.lb-score { font-weight: 900; color: #ffd67a; font-variant-numeric: tabular-nums; }

/* ==================== BOTTOM COMMAND DECK ==================== */
.command-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: linear-gradient(180deg, #271c15 0%, #17110d 100%);
  border: 2px solid var(--brass-dim);
  border-radius: 10px;
  padding: 7px 10px;
}

.spell-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.spell-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(180deg, #3c2a1a 0%, #22170e 100%);
  border: 1.5px solid var(--brass);
  border-radius: 9px;
  padding: 5px 10px;
  color: var(--steam);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

.spell-btn:hover:not(:disabled) {
  box-shadow: 0 0 12px rgba(255, 214, 122, 0.35);
  border-color: var(--brass-bright);
}

.spell-btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  border-color: #574434;
}

.spell-btn.casting {
  border-color: var(--aether);
  box-shadow: 0 0 14px rgba(60, 231, 255, 0.55);
}

.spell-key {
  background: #120d0a;
  border: 1px solid var(--brass-dim);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 900;
  color: var(--brass-bright);
}

.spell-icon {
  font-size: 17px;
  line-height: 1;
}

.spell-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
}

.spell-name {
  font-size: 12px;
  font-weight: 800;
  color: #fff6e0;
}

.spell-cd {
  font-size: 10px;
  font-weight: 800;
  color: var(--emerald);
  font-variant-numeric: tabular-nums;
}

.spell-btn:disabled .spell-cd {
  color: #fbbf24;
}

.wave-intel {
  flex: 1;
  min-width: 170px;
  background: #120d0a;
  border: 1px solid rgba(60, 231, 255, 0.28);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #d9f7ff;
  text-align: left;
}

.intel-label {
  font-weight: 900;
  color: var(--aether);
  margin-right: 5px;
  letter-spacing: 0.4px;
}

.deck-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.leg-chip {
  background: #15100c;
  border: 1px solid rgba(224, 171, 78, 0.25);
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 700;
  color: #e4d3bc;
  white-space: nowrap;
}

/* ==================== FOOTER ==================== */
.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 6px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ==================== MOBILE RESPONSIVE (390x844 — 0px overflow) ==================== */
@media (max-width: 720px) {
  #app {
    padding: 5px 6px 8px;
    gap: 5px;
  }

  .hud-bar {
    padding: 5px 6px;
    gap: 4px;
  }

  .brand-pill {
    font-size: 11.5px;
    padding: 3px 7px;
  }

  .stat-pill {
    font-size: 11.5px;
    padding: 3px 6px;
  }

  .hud-btn {
    font-size: 11px;
    padding: 4px 7px;
  }

  .canvas-shell {
    max-height: none;
    border-radius: 9px;
  }

  .overlay,
  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    padding: 10px;
    align-items: center;
  }

  .overlay-card,
  .modal-card {
    padding: 12px 11px;
    border-radius: 12px;
    max-height: 92vh;
  }

  .ov-title {
    font-size: 19px;
  }

  .ov-subtitle {
    font-size: 11px;
    margin-bottom: 7px;
  }

  .map-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .map-card {
    padding: 6px;
  }

  .map-card-name {
    font-size: 11.5px;
  }

  .ov-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .command-deck {
    padding: 6px;
    gap: 6px;
  }

  .spell-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .spell-btn {
    padding: 6px 7px;
    justify-content: center;
  }

  .spell-key {
    display: none;
  }

  .deck-legend {
    display: none;
  }

  .wave-intel {
    width: 100%;
    font-size: 11.5px;
  }

  .plot-popover {
    position: fixed;
    left: 50% !important;
    top: auto !important;
    bottom: 10px !important;
    transform: translateX(-50%);
    width: calc(100vw - 18px);
    min-width: 0;
    max-width: 372px;
    padding: 8px;
    z-index: 45;
  }

  .rail-hint-pill {
    font-size: 10.5px;
    padding: 4px 10px;
    max-width: 94%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
