:root {
  --cr-navy-dark: #0a0f1d;
  --cr-navy-panel: #131c33;
  --cr-navy-light: #1e2c4f;
  --cr-border-steel: #3b4f82;
  --cr-gold-bright: #ffe066;
  --cr-gold-main: #f59e0b;
  --cr-gold-dark: #92400e;
  --cr-cyan: #38bdf8;
  --cr-green: #22c55e;
  --cr-green-dark: #14532d;
  --cr-red: #f43f5e;
  --cr-red-dark: #881337;
  --font-display: 'Russo One', 'Rubik', sans-serif;
  --font-ui: 'Rubik', system-ui, -apple-system, 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: #070b14;
  font-family: var(--font-ui);
  color: #ffffff;
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#floating-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.float-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.03em;
  text-shadow:
    0 2px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 4px 10px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  white-space: nowrap;
  animation: crFloatUp 0.9s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes crFloatUp {
  0% {
    opacity: 1;
    transform: translate(-50%, -10%) scale(0.65);
  }
  25% {
    transform: translate(-50%, -65%) scale(1.18);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -185%) scale(0.95);
  }
}

/* ==========================================
   TOP HUD BAR (Clash Royale / Rush Royale)
   ========================================== */
#hud-top {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.svg-icon {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.65));
}

/* Arena Crest Pill */
.cr-crest-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 16px 5px 7px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1e2b4d 0%, #0f172a 100%);
  border: 2px solid #eab308;
  box-shadow:
    0 4px 0 #060913,
    0 8px 18px rgba(0, 0, 0, 0.65),
    inset 0 1px 1px rgba(255, 255, 255, 0.28);
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.cr-crest-pill:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.crest-icon-box {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.crest-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.crest-sub {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fbbf24;
  text-shadow: 0 1px 2px #000;
}

.crest-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: #ffffff;
  text-shadow: 0 2px 0 #050811;
}

/* Supercell Resource Bars with Overlapping Left Icon */
.cr-resource-bar {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 118px;
  height: 40px;
  padding: 0 14px 0 32px;
  margin-left: 12px;
  border-radius: 11px;
  background: linear-gradient(180deg, #0d1324 0%, #17223d 100%);
  border: 2px solid #384b7a;
  box-shadow:
    0 4px 0 #060913,
    0 6px 14px rgba(0, 0, 0, 0.6),
    inset 0 2px 4px rgba(0, 0, 0, 0.75);
}

.res-icon-wrap {
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
}

.res-content {
  display: flex;
  flex-direction: column;
  line-height: 1.02;
}

.res-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.res-value {
  font-family: var(--font-display);
  font-size: 17px;
  color: #ffffff;
  text-shadow: 0 2px 0 #000;
}

.gold-bar {
  border-color: #b45309;
}

.gold-bar .res-value {
  color: #fde047;
}

.hp-bar {
  border-color: #9f1239;
}

.gems-bar {
  border-color: #9333ea;
}

.gems-bar .res-value {
  color: #f0abfc;
}

.cr-btn-chest {
  position: relative;
  background: linear-gradient(180deg, #ec4899 0%, #9333ea 100%);
  border-color: #f9a8d4;
  box-shadow: 0 4px 0 #581c87, 0 0 16px rgba(236, 72, 153, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.55);
}

.chest-notif-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #facc15;
  color: #451a03;
  border: 2px solid #ffffff;
  font-family: var(--font-display);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: none;
  animation: pulseBadge 1.3s infinite ease-in-out;
}

.chest-notif-badge.hidden {
  display: none;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* Center Wave & Battle Crest */
.hud-center-crest {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(19, 28, 51, 0.94) 0%, rgba(10, 15, 29, 0.96) 100%);
  border: 2px solid #334673;
  padding: 5px 8px 5px 14px;
  border-radius: 16px;
  box-shadow: 0 6px 0 #060913, 0 10px 24px rgba(0, 0, 0, 0.7);
}

.wave-progress-box {
  display: flex;
  flex-direction: column;
  padding-right: 6px;
}

.wave-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.09em;
  color: #38bdf8;
}

.wave-num {
  font-family: var(--font-display);
  font-size: 16px;
  color: #fff;
  text-shadow: 0 2px 0 #000;
}

/* 3D Beveled Game Buttons */
.cr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 12px;
  border: 2px solid #475d94;
  background: linear-gradient(180deg, #2b3b63 0%, #19233d 100%);
  color: #ffffff;
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8);
  cursor: pointer;
  box-shadow:
    0 4px 0 #0b1021,
    0 7px 14px rgba(0, 0, 0, 0.55),
    inset 0 1px 1px rgba(255, 255, 255, 0.35);
  transition: transform 0.1s ease, filter 0.1s ease, box-shadow 0.1s ease;
}

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

.cr-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0b1021, 0 3px 6px rgba(0, 0, 0, 0.5);
}

.btn-svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7));
}

.cr-btn-square {
  width: 42px;
  height: 42px;
  padding: 0;
  font-family: var(--font-display);
  font-size: 14px;
}

.cr-btn-battle {
  background: linear-gradient(180deg, #fbbf24 0%, #ea580c 100%);
  border-color: #fef08a;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 13px;
  padding: 9px 18px;
  box-shadow:
    0 4px 0 #7c2d12,
    0 0 18px rgba(245, 158, 11, 0.45),
    inset 0 2px 1px rgba(255, 255, 255, 0.55);
}

.cr-btn-gold {
  background: linear-gradient(180deg, #facc15 0%, #d97706 100%);
  border-color: #fef08a;
  box-shadow: 0 4px 0 #78350f, 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.cr-btn-cyan {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  border-color: #bae6fd;
  box-shadow: 0 4px 0 #0c4a6e, 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.55);
}

.cr-btn-purple {
  background: linear-gradient(180deg, #8b5cf6 0%, #5b21b6 100%);
  border-color: #c4b5fd;
  box-shadow: 0 4px 0 #2e1065, 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.cr-btn-green {
  background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  border-color: #86efac;
  box-shadow: 0 4px 0 #052e16, 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.cr-btn-red {
  background: linear-gradient(180deg, #f43f5e 0%, #be123c 100%);
  border-color: #fda4af;
  box-shadow: 0 4px 0 #4c0519, 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.meshy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
}

/* ==========================================
   CENTER WAVE BANNER
   ========================================== */
#wave-banner {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#wave-banner.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-16px) scale(0.92);
}

.wave-banner-inner {
  padding: 10px 36px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(22, 33, 62, 0.96) 0%, rgba(11, 17, 32, 0.98) 100%);
  border: 2px solid #fbbf24;
  box-shadow:
    0 6px 0 #050811,
    0 16px 36px rgba(0, 0, 0, 0.8),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  text-align: center;
}

.wave-banner-sub {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fbbf24;
}

.wave-banner-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: #ffffff;
  text-shadow: 0 3px 0 #000;
}

/* ==========================================
   RIGHT UNIT INSPECTOR CARD
   ========================================== */
.cr-inspector {
  position: fixed;
  right: 18px;
  bottom: 196px;
  width: 288px;
  z-index: 12;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1b2747 0%, #0f172a 100%);
  border: 2px solid #475d94;
  box-shadow:
    0 6px 0 #060913,
    0 18px 38px rgba(0, 0, 0, 0.78),
    inset 0 1px 2px rgba(255, 255, 255, 0.25);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.cr-inspector.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.95);
}

.insp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.insp-portrait-box {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 35%, #334e85 0%, #11192e 100%);
  border: 2px solid #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.insp-portrait-box img {
  width: 92%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.7));
}

.insp-head-text {
  flex: 1;
  min-width: 0;
}

.insp-level-stars {
  font-size: 13px;
  color: #fbbf24;
  text-shadow: 0 1px 2px #000;
  letter-spacing: 2px;
}

.insp-head-text h3 {
  font-family: var(--font-display);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 #000;
}

.insp-head-text p {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

.cr-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid #475d94;
  background: #1e293b;
  color: #cbd5e1;
  font-weight: 900;
  cursor: pointer;
}

.insp-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.insp-stats.hidden, .insp-actions.hidden {
  display: none;
}

.stat-box {
  background: rgba(9, 13, 26, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 7px 10px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 9px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.06em;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 14px;
  color: #38bdf8;
  text-shadow: 0 1px 2px #000;
}

.insp-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insp-actions .cr-btn {
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
}

/* ==========================================
   BOTTOM RUSH ROYALE / CLASH ROYALE DECK
   ========================================== */
#hud-bottom {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}

.deck-frame {
  pointer-events: auto;
  padding: 8px 14px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(22, 32, 58, 0.95) 0%, rgba(10, 15, 29, 0.98) 100%);
  border: 2px solid #3b4f82;
  box-shadow:
    0 8px 0 #050811,
    0 16px 36px rgba(0, 0, 0, 0.85),
    inset 0 1px 1px rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.deck-header-ribbon {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #94a3b8;
  text-transform: uppercase;
}

.deck-cards {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Collectible 3D Unit Card */
.tower-card {
  position: relative;
  width: 132px;
  height: 156px;
  border-radius: 15px;
  background: linear-gradient(180deg, #273863 0%, #131c33 65%, #0c1222 100%);
  border: 3px solid #4a639e;
  box-shadow:
    0 5px 0 #070b14,
    0 8px 16px rgba(0, 0, 0, 0.65),
    inset 0 1px 2px rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px 8px;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.16s ease, box-shadow 0.16s ease;
}

.tower-card:hover {
  transform: translateY(-7px);
  border-color: #93c5fd;
}

.tower-card.selected {
  transform: translateY(-12px) scale(1.04);
  border-color: #fbbf24;
  background: linear-gradient(180deg, #3b4e82 0%, #1e293b 65%, #0f172a 100%);
  box-shadow:
    0 8px 0 #78350f,
    0 0 22px rgba(251, 191, 36, 0.55),
    inset 0 2px 3px rgba(255, 255, 255, 0.55);
}

.tower-card.unaffordable {
  filter: saturate(0.35) brightness(0.75);
}

.tower-card-key {
  position: absolute;
  top: 5px;
  left: 7px;
  background: rgba(7, 11, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 900;
  color: #cbd5e1;
  z-index: 2;
}

.tower-card-stage {
  width: 100%;
  height: 78px;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 45%, rgba(56, 189, 248, 0.28) 0%, rgba(10, 15, 29, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tower-card-stage img {
  width: 92%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.75));
  transition: transform 0.16s ease;
}

.tower-card:hover .tower-card-stage img,
.tower-card.selected .tower-card-stage img {
  transform: scale(1.1);
}

.tower-card-title {
  font-family: var(--font-display);
  font-size: 12px;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 2px 0 #000;
  line-height: 1.1;
}

.tower-card-role {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  margin-top: -2px;
}

.tower-card-cost-pill {
  width: 100%;
  padding: 3px 8px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
  border: 1px solid #fde047;
  box-shadow: 0 2px 0 #451a03;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

/* ==========================================
   MODALS
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(5, 8, 17, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.cr-modal {
  width: min(94vw, 800px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, #1b2848 0%, #0e1526 100%);
  border: 3px solid #4a639e;
  box-shadow:
    0 10px 0 #050811,
    0 24px 60px rgba(0, 0, 0, 0.9),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fbbf24;
  text-transform: uppercase;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  text-shadow: 0 3px 0 #000;
}

.modal-desc {
  font-size: 13px;
  color: #cbd5e1;
  margin-bottom: 16px;
  line-height: 1.45;
}

/* Worlds & Multi-Level Campaign Grid */
.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px;
}

.world-card {
  position: relative;
  padding: 15px;
  border-radius: 16px;
  border: 2px solid #334673;
  background: linear-gradient(180deg, #16213d 0%, #0c1222 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}

.world-card.active {
  border-color: #38bdf8;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.25);
}

.world-card.locked {
  border-color: #27324a;
  opacity: 0.72;
  filter: grayscale(0.45);
}

.world-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.world-card-thumb {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: radial-gradient(circle, #2b3f70 0%, #0f172a 100%);
  border: 2px solid #fbbf24;
  object-fit: contain;
  flex-shrink: 0;
}

.world-card.locked .world-card-thumb {
  border-color: #475569;
}

.world-card-meta {
  flex: 1;
  min-width: 0;
}

.world-card-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: #fbbf24;
  margin-top: 3px;
}

.world-progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #090e1c;
  border: 1px solid #2b3b63;
  overflow: hidden;
  margin-top: 4px;
}

.world-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width 0.25s ease;
}

.world-lock-banner {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #475569;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

/* 4 Stage Nodes inside each Arena Card */
.levels-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 2px;
}

.level-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid #384b7a;
  background: linear-gradient(180deg, #1f2e54 0%, #11192e 100%);
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}

.level-node:hover:not(.locked) {
  transform: translateY(-2px);
  border-color: #fbbf24;
  filter: brightness(1.12);
}

.level-node.current {
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
}

.level-node.completed {
  border-color: #22c55e;
  background: linear-gradient(180deg, #163a2b 0%, #0d2219 100%);
}

.level-node.locked {
  border-color: #25304a;
  background: #0d1324;
  color: #64748b;
  cursor: not-allowed;
}

.level-node-num {
  font-family: var(--font-display);
  font-size: 13px;
}

.level-node-name {
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.level-node-stars {
  font-size: 11px;
  color: #fbbf24;
  letter-spacing: 1px;
}

.world-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  text-shadow: 0 2px 0 #000;
}

.world-card p {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.38;
}

/* Permanent Bastion Upgrades Modal */
.upgrades-bank-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #172342 0%, #0d1426 100%);
  border: 2px solid #eab308;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 800;
}

.upgrades-bank-banner strong {
  font-family: var(--font-display);
  font-size: 20px;
  color: #fde047;
  text-shadow: 0 2px 0 #000;
}

.upgrades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.upgrade-card {
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #16213d 0%, #0c1222 100%);
  border: 2px solid #334673;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgrade-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upgrade-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: #1e2c4f;
  border: 2px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.upgrade-pips {
  display: flex;
  gap: 5px;
  margin: 2px 0;
}

.upgrade-pip {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: #0b1020;
  border: 1px solid #334673;
}

.upgrade-pip.filled {
  background: linear-gradient(90deg, #fbbf24, #22c55e);
  border-color: #fde047;
}

.upgrade-bonus-text {
  font-family: var(--font-display);
  font-size: 13px;
  color: #4ade80;
}

/* Meshy Showcase Grid */
.meshy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.meshy-summary {
  font-family: var(--font-display);
  font-size: 13px;
  color: #38bdf8;
}

.meshy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.meshy-card {
  padding: 12px;
  border-radius: 16px;
  background: #11182b;
  border: 2px solid #2e3e66;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.meshy-card.ready {
  border-color: #22c55e;
}

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

.meshy-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background: #1e293b;
  color: #cbd5e1;
}

.meshy-badge.glb {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.meshy-badge.gen {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.meshy-thumb-wrap {
  width: 100%;
  height: 124px;
  border-radius: 12px;
  background: radial-gradient(circle, #263863 0%, #0b1020 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.meshy-thumb {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.75));
}

.meshy-card h4 {
  font-family: var(--font-display);
  font-size: 14px;
}

.meshy-card p {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
}

/* Rarity Styles for Deck Cards, Lootbox Drops & Collection */
.rarity-common { border-color: #3b82f6 !important; }
.rarity-rare { border-color: #f59e0b !important; }
.rarity-epic { border-color: #a855f7 !important; box-shadow: 0 5px 0 #070b14, 0 0 16px rgba(168, 85, 247, 0.42) !important; }
.rarity-legendary {
  border-color: #fde047 !important;
  background: linear-gradient(145deg, #164e63 0%, #4c1d95 52%, #713f12 100%) !important;
  box-shadow: 0 5px 0 #451a03, 0 0 22px rgba(253, 224, 71, 0.58) !important;
}

.rarity-pill {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  text-shadow: 0 1px 2px #000;
}

.rarity-pill.common { background: rgba(59, 130, 246, 0.28); color: #93c5fd; border: 1px solid #3b82f6; }
.rarity-pill.rare { background: rgba(245, 158, 11, 0.28); color: #fde68a; border: 1px solid #f59e0b; }
.rarity-pill.epic { background: rgba(168, 85, 247, 0.32); color: #e9d5ff; border: 1px solid #a855f7; }
.rarity-pill.legendary {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.4), rgba(253, 224, 71, 0.4));
  color: #fef08a;
  border: 1px solid #fde047;
}

.tower-card-rank {
  position: absolute;
  top: 5px;
  right: 7px;
  background: rgba(7, 11, 20, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 900;
  color: #fde047;
  z-index: 2;
}

.tower-card.empty-deck-slot {
  border-style: dashed;
  border-color: #475569;
  background: rgba(15, 23, 42, 0.6);
  justify-content: center;
  gap: 6px;
  opacity: 0.85;
}

.tower-card.empty-deck-slot:hover {
  border-color: #f472b6;
  opacity: 1;
}

/* Lootbox & Collection Modal */
.lootbox-modal {
  width: min(96vw, 900px);
}

.lootbox-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #263559;
}

.lootbox-tabs {
  display: flex;
  gap: 8px;
}

.cr-tab {
  padding: 8px 16px;
  border-radius: 10px;
  border: 2px solid #334673;
  background: #11182b;
  color: #94a3b8;
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
}

.cr-tab.active {
  border-color: #fbbf24;
  background: linear-gradient(180deg, #273863 0%, #15203b 100%);
  color: #ffffff;
}

.lootbox-gems-wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 12px;
  background: #0d1324;
  border: 2px solid #9333ea;
  font-family: var(--font-display);
  font-size: 15px;
  color: #f0abfc;
}

#panel-chests.hidden, #panel-collection.hidden {
  display: none;
}

.chests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.chest-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1b2848 0%, #0d1426 100%);
  border: 3px solid #3b4f82;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.chest-card:hover {
  transform: translateY(-4px);
}

.chest-visual {
  width: 92px;
  height: 92px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.7));
}

.chest-card h3 {
  font-family: var(--font-display);
  font-size: 16px;
}

.chest-odds {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
  background: rgba(7, 11, 20, 0.55);
  padding: 6px 10px;
  border-radius: 9px;
  width: 100%;
}

/* Animated Chest Opening Stage */
.chest-opening-stage {
  position: relative;
  min-height: 280px;
  margin-bottom: 16px;
  padding: 24px 16px;
  border-radius: 20px;
  background: radial-gradient(circle at 50% 45%, #2a1f52 0%, #090d1a 100%);
  border: 3px solid #fbbf24;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chest-opening-stage.hidden {
  display: none;
}

.chest-rays {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(251, 191, 36, 0.2) 0deg 15deg, transparent 15deg 30deg);
  animation: spinRays 9s linear infinite;
  pointer-events: none;
}

@keyframes spinRays {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.chest-shake-box {
  position: relative;
  z-index: 2;
  font-size: 74px;
  animation: chestShake 0.22s infinite;
  filter: drop-shadow(0 8px 18px rgba(251, 191, 36, 0.6));
}

@keyframes chestShake {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-10deg) scale(1.08); }
  50% { transform: rotate(0deg) scale(1.12); }
  75% { transform: rotate(10deg) scale(1.08); }
  100% { transform: rotate(0deg) scale(1); }
}

.chest-reveal-title {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-size: 20px;
  color: #fde047;
  text-shadow: 0 3px 0 #000;
  margin: 8px 0 14px;
}

.chest-drops-row {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.drop-card {
  width: 176px;
  padding: 12px;
  border-radius: 16px;
  border: 3px solid #38bdf8;
  background: linear-gradient(180deg, #1b2848 0%, #0c1222 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  animation: popDropCard 0.42s cubic-bezier(0.2, 1.25, 0.35, 1) forwards;
}

@keyframes popDropCard {
  0% { opacity: 0; transform: scale(0.35) translateY(30px) rotateY(70deg); }
  100% { opacity: 1; transform: scale(1) translateY(0) rotateY(0deg); }
}

.drop-card-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.75));
}

.drop-tag-new {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
  background: #22c55e;
  color: #052e16;
}

.drop-tag-dup {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fbbf24;
  color: #451a03;
}

/* Deck Builder & Collection Grid */
.deck-builder-box {
  padding: 12px;
  border-radius: 16px;
  background: #0d1426;
  border: 2px solid #3b4f82;
  margin-bottom: 14px;
}

.deck-builder-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fbbf24;
  margin-bottom: 10px;
  text-align: center;
}

.active-deck-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.deck-slot-mini {
  padding: 8px;
  border-radius: 12px;
  border: 2px solid #384b7a;
  background: #16213d;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.deck-slot-mini.empty {
  border-style: dashed;
  justify-content: center;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.deck-slot-mini img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 12px;
}

.coll-card {
  padding: 12px;
  border-radius: 15px;
  border: 2px solid #334673;
  background: linear-gradient(180deg, #16213d 0%, #0c1222 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coll-card.locked {
  opacity: 0.62;
  filter: grayscale(0.7);
}

.coll-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.coll-card-img-wrap {
  height: 82px;
  border-radius: 10px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, #090d1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.coll-card-img-wrap img {
  max-height: 76px;
  max-width: 90%;
  object-fit: contain;
}

/* Result Modal */
.result-modal {
  width: min(92vw, 420px);
  text-align: center;
}

.result-crown-badge {
  font-size: 54px;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.7));
}

.result-stars {
  font-size: 34px;
  color: #fbbf24;
  text-shadow: 0 3px 0 #000;
  letter-spacing: 6px;
  margin: 14px 0 20px;
}

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

@media (max-width: 760px) {
  .tower-card {
    width: 108px;
    height: 138px;
  }
  .tower-card-stage {
    height: 62px;
  }
  .hud-center-crest {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
}
