:root {
  --bg: #12101c;
  --bg-deep: #0c0a14;
  --panel: #1e1830;
  --panel-border: #3d3258;
  --panel-gold: #c9a227;
  --text: #f5f0ff;
  --muted: #9d94b8;
  --accent: #ff9a2e;
  --accent-dark: #e06a1a;
  --gold: #ffd54a;
  --gold-dim: #c9a227;
  --success: #5dff8a;
  --success-glow: rgba(93, 255, 138, 0.45);
  --portal: #4a8cff;
  --portal-glow: rgba(74, 140, 255, 0.55);
  --danger: #e63946;
  --font-display: 'Bangers', cursive;
  --font-math: 'Fredoka One', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --tap-min: 44px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(88, 56, 160, 0.25), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 140, 66, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: var(--font-body);
}

body.dev-mode .topbar-actions .dev-play-btn {
  color: var(--gold);
  border: 1px solid rgba(255, 179, 71, 0.45);
  margin-right: 2px;
  padding: 4px 8px;
  font-size: 0.72rem;
}

body.dev-mode .topbar::after {
  content: 'DEV';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  background: var(--danger);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px 12px;
  background: rgba(12, 10, 20, 0.94);
  border-bottom: 2px solid rgba(201, 162, 39, 0.35);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  overflow: visible;
}

.topbar > :not(.topbar-brand) {
  align-self: center;
}

.gb-topbar {
  position: relative;
}

.topbar-badges {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
}

.topbar-badges.badge-row-compact .badge-slot {
  position: relative;
  width: auto;
  min-width: 44px;
  padding: 2px 3px 3px;
  gap: 1px;
  border-radius: 8px;
  transition: opacity 0.25s ease, filter 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.topbar-badges.badge-row-compact .badge-slot .badge-img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.topbar-badges.badge-row-compact .badge-slot .badge-label {
  font-size: 0.54rem;
  margin-top: 0;
  line-height: 1;
  transition: color 0.25s ease;
}

.topbar-brand {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  min-width: 0;
  align-self: flex-end;
  position: relative;
  z-index: 12;
  margin-bottom: -48px;
}

.brand-logo {
  display: block;
  width: auto;
  height: clamp(110px, 30vw, 155px);
  max-width: min(900px, 96vw);
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.topbar-portals {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

@media (min-width: 720px) {
  .topbar-portals {
    display: flex;
  }
}

.topbar-attack-ticks {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar-attack-tick {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 100, 60, 0.45);
  background: rgba(40, 16, 20, 0.85);
  display: grid;
  place-items: center;
}

.topbar-attack-tick-done {
  border-color: var(--success);
  background: rgba(20, 50, 28, 0.9);
}

.topbar-attack-tick-core {
  font-family: var(--font-display);
  font-size: 0.52rem;
  color: rgba(255, 140, 120, 0.95);
  line-height: 1;
}

.topbar-attack-tick-done .topbar-attack-tick-core {
  color: var(--success);
}

.topbar-hud {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-areas: 'rank stats actions';
  align-items: center;
  gap: 4px 12px;
  margin-left: auto;
}

.topbar-hud > .topbar-badges {
  grid-area: rank;
}

.topbar-stats {
  grid-area: stats;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.xp-pill {
  background: rgba(30, 24, 48, 0.9);
  border: 1px solid rgba(201, 162, 39, 0.55);
  color: var(--gold);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
}

.topbar-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 0;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.topbar-action-btn:hover {
  transform: scale(1.06);
  filter: brightness(1.08);
}

.topbar-action-btn:active {
  transform: scale(0.96);
}

.topbar-action-btn.is-muted {
  opacity: 0.52;
  filter: grayscale(0.45) brightness(0.88);
}

.topbar-fullscreen-btn .fs-exit {
  display: none;
}

.topbar-fullscreen-btn.is-fullscreen .fs-enter {
  display: none;
}

.topbar-fullscreen-btn.is-fullscreen .fs-exit {
  display: block;
}

.topbar-action-icon {
  display: block;
  width: auto;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}

/* ── Mobile topbar — two-row layout, no logo overlap ── */
@media (max-width: 640px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      'brand'
      'hud';
    align-items: center;
    gap: 6px 8px;
    padding:
      calc(8px + env(safe-area-inset-top, 0px))
      10px
      10px;
  }

  .topbar-brand {
    grid-area: brand;
    justify-content: center;
    align-self: center;
    margin-bottom: 0;
    z-index: 1;
  }

  .brand-logo {
    height: clamp(48px, 13vw, 68px);
    max-width: min(280px, 86vw);
    object-position: center bottom;
    margin-inline: auto;
  }

  /* Pills and icons don't fit side by side next to the rank on a phone, so the icons drop underneath. */
  .topbar-hud {
    grid-area: hud;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      'rank stats'
      'rank actions';
    gap: 6px;
    margin-left: 0;
  }

  .topbar-stats {
    justify-content: flex-end;
    min-width: 0;
    gap: 6px;
  }

  .topbar-hud > .topbar-actions {
    justify-self: end;
  }

  .topbar-badges.badge-row-compact .badge-slot {
    min-width: 34px;
    flex-shrink: 0;
    padding: 1px 2px 2px;
  }

  .topbar-badges.badge-row-compact .badge-slot .badge-img {
    width: 32px;
    height: 32px;
  }

  .topbar-badges.badge-row-compact .badge-slot .badge-label {
    font-size: 0.46rem;
  }

  .topbar-actions {
    flex-shrink: 0;
    gap: 2px;
  }

  .topbar-action-icon {
    height: 36px;
  }

  #app {
    padding-top: 14px;
  }
}

#app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 16px 16px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.panel-title,
.hero-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--gold);
  margin: 0 0 12px;
  letter-spacing: 0.03em;
}

.mission-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 4px;
}

.granny-line,
.hero-copy {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 16px;
}

.hook {
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 8px;
}

.welcome-panel {
  text-align: center;
  max-width: 480px;
  margin: 24px auto;
}

.splash-squircle {
  width: min(100%, 460px);
  aspect-ratio: 4 / 3;
  margin: 0 auto 16px;
  border-radius: 12%;
  overflow: hidden;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 3px var(--panel-border),
    0 0 24px rgba(255, 140, 66, 0.15);
}

.splash-squircle img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.name-label {
  display: block;
  text-align: left;
  font-weight: 600;
  margin-bottom: 6px;
}

.name-input {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 16px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: var(--tap-min);
  padding: 10px 18px;
  transition: transform 0.1s, background 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #1a1208;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-lg {
  width: 100%;
  font-size: 1.05rem;
}

.forge-panel {
  max-width: 560px;
  margin: 0 auto;
}

/* ── Times tables drill ── */
.times-panel {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.times-back {
  margin-bottom: 8px;
}

.times-pick-bar {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.times-pick-bar .times-back {
  margin-bottom: 0;
  flex: 0 0 auto;
}

.times-pick-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--gold, #ffe27a);
  line-height: 1.1;
}

.times-pick-title span {
  font-size: 0.72em;
  letter-spacing: 0.06em;
  color: rgba(255, 200, 160, 0.85);
}

.times-pick-sets {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 180, 160, 0.75);
}

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

.times-table-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.times-table-btn:hover {
  border-color: var(--accent);
  background: rgba(255, 140, 66, 0.1);
}

.times-table-done {
  border-color: rgba(124, 252, 0, 0.45);
  background: rgba(124, 252, 0, 0.06);
}

.times-table-check {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #2fbf6a;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  box-shadow:
    0 2px 0 rgba(0, 40, 18, 0.55),
    0 0 10px rgba(60, 220, 120, 0.65);
}

.times-table-btn {
  position: relative;
}

.times-gate-progress {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ff6b5a;
  text-align: center;
}

.times-gate-added {
  margin: 8px 0 0;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--success);
  text-align: center;
}

.length-question {
  font-size: 1.35rem !important;
}

.times-table-num {
  font-family: var(--font-math);
  font-size: 1.35rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.times-table-sub {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 2px;
}

.times-table-mixed {
  grid-column: span 2;
}

.times-quiz-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 12px;
}

.times-quiz-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.times-quiz-toolbar .times-back {
  margin-bottom: 0;
}

.times-toolbar-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  min-width: 0;
}

.times-toolbar-centre {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
}

.times-toolbar-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  min-height: 2rem;
}

.times-toolbar-right .times-streak {
  margin: 0;
}

.times-toolbar-centre .session-xp-badge {
  margin: 0;
  width: clamp(3.8rem, 9.5vw, 4.8rem);
  height: clamp(3.8rem, 9.5vw, 4.8rem);
  gap: 0;
  padding: 0;
}

.times-toolbar-centre .session-xp-badge-label {
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  letter-spacing: 0.08em;
  line-height: 1;
}

.times-toolbar-centre .session-xp-badge-num {
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  line-height: 0.88;
}

.times-quiz-toolbar .times-quiz-tag {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.8vw, 1.55rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: #ffb02e;
  text-shadow: 0 2px 0 #4a2200, 0 0 12px rgba(255, 160, 40, 0.45);
  text-transform: uppercase;
}

.times-quiz-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.times-quiz-progress {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.times-streak {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124, 252, 0, 0.12);
  border: 1px solid rgba(124, 252, 0, 0.35);
}

.times-streak-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--success);
}

.times-streak-num {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--success);
}

.times-question-wrap {
  text-align: center;
  padding: 24px 12px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--panel-border);
}

.times-question {
  margin: 0;
  font-family: var(--font-math);
  font-size: clamp(2rem, 8vw, 2.75rem);
  color: var(--gold);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.times-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.times-answer-btn {
  min-height: var(--tap-min);
  font-family: var(--font-math);
  font-size: 1.5rem;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.times-answer-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.times-answer-btn:disabled {
  cursor: default;
}

.times-answer-btn.is-correct {
  border-color: var(--success);
  background: rgba(124, 252, 0, 0.15);
  color: var(--success);
}

.times-answer-btn.is-wrong {
  border-color: var(--danger);
  background: rgba(230, 57, 70, 0.12);
  opacity: 0.85;
}

.times-session-xp {
  display: none;
}

/* Big session XP medallion — header of every quiz / Battle Prep screen. */
.session-xp-badge {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: center;
  gap: 0;
  flex: 0 0 auto;
  width: clamp(4.6rem, 12vw, 5.8rem);
  height: clamp(4.6rem, 12vw, 5.8rem);
  margin-left: auto;
  border-radius: 50%;
  border: 3px solid #fff4c2;
  background:
    radial-gradient(circle at 32% 26%, #fff6c8 0%, #ffd23a 38%, #ff9a1a 72%, #b85a08 100%);
  box-shadow:
    0 0 0 3px #5a2a08,
    0 6px 0 #3a1804,
    0 0 28px rgba(255, 170, 40, 0.7),
    inset 0 5px 10px rgba(255, 255, 255, 0.4),
    inset 0 -8px 12px rgba(80, 30, 0, 0.35);
  color: #3a1804;
  line-height: 1;
  transform: translateZ(0);
}

.session-xp-badge-label {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1;
  color: rgba(74, 32, 4, 0.85);
  text-shadow: 0 1px 0 rgba(255, 240, 180, 0.55);
}

.session-xp-badge-num {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 2.45rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 0.9;
  color: #2a1000;
  text-shadow: 0 1px 0 rgba(255, 245, 200, 0.65);
}

.session-xp-badge.is-pop {
  animation: session-xp-pop 0.45s ease-out;
}

@keyframes session-xp-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); filter: brightness(1.2); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .session-xp-badge.is-pop {
    animation: none;
  }
}

.times-done {
  position: relative;
  text-align: center;
  padding-top: 8px;
}

.times-done-home {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  margin: 0;
}

.times-done-xp {
  margin: 16px 0;
}

.times-done-xp-num {
  display: block;
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--success);
  line-height: 1;
}

.times-done-xp-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.times-bonus-note {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.times-charge-note {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.6vw, 1.25rem);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #ffb08a;
  text-shadow: 0 1px 0 rgba(40, 8, 6, 0.65);
}

.times-done-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.times-done-actions.is-again-only {
  display: flex;
  justify-content: center;
  grid-auto-flow: unset;
  grid-auto-columns: unset;
}

.times-done-actions.is-again-only .times-done-again {
  width: min(100%, 20rem);
  text-align: center;
}

.times-done-actions.is-empty {
  display: none;
}

.times-done-actions .btn {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  line-height: 1.15;
  white-space: normal;
  padding-block: 12px;
  text-align: center;
}

.times-done-actions .done-action-btn {
  background: linear-gradient(180deg, #ff9a2e, #e8481c);
  box-shadow: 0 0 16px rgba(255, 110, 40, .55);
  /* Soft pop + glow only — no shake/wiggle. */
  animation: done-action-pop 1.6s ease-in-out infinite;
}

@keyframes done-action-pop {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 16px rgba(255, 110, 40, 0.55);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 28px rgba(255, 150, 60, 0.95);
  }
}

@media (max-width: 540px) {
  .times-done-actions {
    grid-auto-flow: row;
  }
}

@media (prefers-reduced-motion: reduce) {
  .times-done-actions .done-action-btn { animation: none; }
}

.quest-set-grid {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.quest-set-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(12, 10, 20, 0.92);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}

.quest-set-btn:hover {
  border-color: rgba(201, 162, 39, 0.55);
  transform: translateY(-2px);
}

.quest-set-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.quest-set-sub {
  font-size: 0.88rem;
  color: var(--muted);
}

.quest-set-meta {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(93, 255, 138, 0.85);
}

.quest-prompt {
  font-size: 1.05rem;
  line-height: 1.45;
}

.quest-numeric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.quest-numeric-input {
  flex: 1 1 160px;
  max-width: 220px;
  text-align: center;
}

.quest-numeric-input.is-correct {
  border-color: var(--success);
}

.quest-numeric-input.is-wrong {
  border-color: var(--danger);
}

.forge-slot {
  margin-bottom: 14px;
}

.slot-role {
  display: block;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
}

.slot-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.slot-opt {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.slot-opt.selected {
  border-color: var(--accent);
  background: rgba(255, 140, 66, 0.15);
}

.slot-opt.wrong-flash {
  animation: shake 0.35s;
  border-color: var(--danger);
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.lock-in-row {
  margin: 20px 0 16px;
}

.lock-in-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.lock-in-row input {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
}

.siege-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.siege-canvas-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--panel-border);
  background: #0a120a;
}

#siege-canvas {
  display: block;
  width: 100%;
  height: min(58vh, 480px);
  touch-action: none;
  cursor: default;
}

.wave-controls {
  position: absolute;
  top: 44px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.wave-controls #btn-speed {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  border-color: rgba(0, 0, 0, 0.55);
  background: rgba(0, 0, 0, 0.42);
  text-shadow:
    0 0 6px #000,
    0 0 12px #000,
    0 1px 3px #000,
    0 2px 8px rgba(0, 0, 0, 0.95);
  box-shadow:
    0 0 10px rgba(0, 0, 0, 0.85),
    0 2px 8px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.wave-controls #btn-speed:hover {
  background: rgba(0, 0, 0, 0.55);
  box-shadow:
    0 0 14px rgba(0, 0, 0, 0.9),
    0 2px 10px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.siege-command-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-fire-nukes {
  margin-left: auto;
}

/* Shared nuke fire control: round, red, thick white stroke (Granny siege + Doompickle). */

.nuke-cache-panel {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(100%, 420px);
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  background: linear-gradient(135deg, rgba(26, 34, 45, 0.95), rgba(15, 20, 25, 0.98));
}

.nuke-cache-panel.nuke-cache-ready {
  border-color: rgba(124, 252, 0, 0.45);
  box-shadow: 0 0 18px rgba(124, 252, 0, 0.12);
}

.nuke-cache-visual {
  --fill: 0%;
  position: relative;
  width: 44px;
  height: 58px;
  flex-shrink: 0;
}

.nuke-cache-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.nuke-cache-ghost {
  filter: grayscale(1) brightness(0.42) contrast(0.9);
  opacity: 0.85;
}

.nuke-cache-lit {
  clip-path: inset(calc(100% - var(--fill)) 0 0 0);
  filter: drop-shadow(0 0 5px rgba(124, 252, 0, 0.55));
  transition: clip-path 0.35s ease;
}

.nuke-cache-visual.nuke-cache-full .nuke-cache-lit {
  filter: drop-shadow(0 0 10px rgba(124, 252, 0, 0.85));
  animation: nuke-pulse 1.4s ease-in-out infinite;
}

@keyframes nuke-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(124, 252, 0, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 16px rgba(255, 200, 80, 0.95));
  }
}

.nuke-cache-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex-shrink: 1;
}

.nuke-cache-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  white-space: nowrap;
}

.nuke-cache-progress {
  font-weight: 700;
  font-size: 0.85rem;
}

.nuke-cache-status {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.nuke-cache-status.is-ready {
  color: var(--success);
  font-weight: 700;
}

.btn-fire-nukes {
  --nuke-red: #e82010;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  align-content: center;
  width: clamp(72px, 11vw, 96px);
  height: clamp(72px, 11vw, 96px);
  padding: 0;
  border: 4px solid #fff;
  border-radius: 50%;
  background: linear-gradient(180deg, #5a2020 0%, #3a1010 100%);
  color: rgba(255, 255, 255, 0.45);
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.28);
  opacity: 0.7;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s, color 0.2s, transform 0.12s;
}

.btn-fire-nukes-icon {
  font-size: 1.55em;
  line-height: 1;
}

.btn-fire-nukes-label {
  margin-top: 0.05em;
}

.btn-fire-nukes.is-armed,
.btn-fire-nukes.is-inbound {
  opacity: 1;
  color: #fff;
  background: radial-gradient(circle at 50% 28%, #ff6a4a, var(--nuke-red) 68%, #9a0c08);
  border-color: #fff;
  box-shadow:
    0 0 22px rgba(232, 32, 16, 0.65),
    0 0 40px rgba(255, 80, 40, 0.35),
    inset 0 -4px 0 rgba(0, 0, 0, 0.28);
}

.btn-fire-nukes.is-armed {
  animation: nuke-btn-pulse 1.25s ease-in-out infinite;
}

.btn-fire-nukes.is-inbound {
  animation: nuke-btn-pulse 0.65s ease-in-out infinite;
}

@keyframes nuke-btn-pulse {
  0%,
  100% {
    box-shadow:
      0 0 18px rgba(232, 32, 16, 0.55),
      inset 0 -4px 0 rgba(0, 0, 0, 0.28);
    transform: scale(1);
  }
  50% {
    box-shadow:
      0 0 34px rgba(255, 70, 50, 0.95),
      inset 0 -4px 0 rgba(0, 0, 0, 0.28);
    transform: scale(1.05);
  }
}

.btn-fire-nukes.is-armed:hover:not(:disabled) {
  background: radial-gradient(circle at 50% 28%, #ff8a5a, #ff2a18 70%, #b01008);
}

.btn-fire-nukes.is-armed:disabled {
  opacity: 1;
  cursor: default;
}

.btn-fire-nukes:disabled:not(.is-armed):not(.is-inbound) {
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .siege-command-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-fire-nukes {
    margin-left: 0;
    order: 0;
    justify-self: center;
  }

  .nuke-cache-panel {
    max-width: none;
    flex-wrap: wrap;
  }
}

.shop-bar {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 10px;
}

.shop-budget {
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.shop-budget strong {
  color: var(--gold);
  font-size: 1.1rem;
}

.shop-turrets {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 6px;
  overflow: hidden;
}

.shop-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 6px;
  line-height: 1.25;
}

.shop-empty {
  margin: 0;
  padding: 12px 8px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  grid-column: 1 / -1;
}

.shop-buy-btn {
  position: relative;
  touch-action: manipulation;
  min-height: 0;
  min-width: 0;
  padding: 2px 1px 2px;
  border-radius: 6px;
  border: 1.5px solid var(--turret-color, var(--accent));
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.shop-buy-btn.selected {
  background: color-mix(in srgb, var(--turret-color) 25%, rgba(0, 0, 0, 0.5));
  box-shadow: 0 0 0 2px var(--gold);
}

.shop-buy-btn.locked {
  opacity: 0.55;
}

.shop-buy-btn.locked img {
  filter: grayscale(0.85);
}

.shop-buy-btn.cant-unlock {
  opacity: 0.4;
}

.price-tag {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 0.48rem;
  font-weight: 800;
  padding: 0 3px;
  border-radius: 4px;
  line-height: 1.2;
  max-width: calc(100% - 2px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-tag.price-unlock {
  background: #6a5acd;
  color: #fff;
}

.price-tag.price-place {
  background: var(--gold);
  color: #1a1208;
}

.shop-buy-btn.cant-afford {
  opacity: 0.45;
}

.shop-buy-btn img {
  width: 39px;
  height: 39px;
  object-fit: contain;
  margin-top: 6px;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.shop-buy-btn.flip-x img {
  transform: scaleX(-1);
}

.turret-name {
  font-size: 0.48rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.05;
  width: 100%;
  padding: 0 1px 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Turret shop popover ── */
.shop-popover {
  position: fixed;
  z-index: 200;
  width: min(280px, calc(100vw - 20px));
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition:
    opacity 0.22s ease,
    transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.55));
}

.shop-popover.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.shop-popover.shop-popover-below {
  transform: translateY(-6px) scale(0.96);
}

.shop-popover.shop-popover-below.visible {
  transform: translateY(0) scale(1);
}

.shop-popover.shop-popover-pulse .shop-popover-inner {
  animation: shop-popover-shake 0.45s ease;
}

@keyframes shop-popover-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

.shop-popover-glow {
  position: absolute;
  inset: -1px;
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--turret-color) 70%, white) 0%,
    var(--turret-color) 45%,
    color-mix(in srgb, var(--turret-color) 40%, transparent) 100%
  );
  opacity: 0.85;
}

.shop-popover-inner {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(38, 30, 58, 0.97) 0%, rgba(14, 11, 22, 0.98) 100%);
  border: 2px solid rgba(201, 162, 39, 0.32);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.shop-popover-art {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.35));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--turret-color) 35%, transparent);
}

.shop-popover-art img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.shop-popover-art img.flip-x {
  transform: scaleX(-1);
}

.shop-popover-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.shop-popover-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  line-height: 1.1;
}

.shop-popover-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.35;
}

.shop-popover-stat {
  font-size: 0.68rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--turret-color) 65%, var(--text));
  letter-spacing: 0.02em;
}

.shop-popover-badge {
  align-self: flex-start;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shop-popover-badge--ready {
  background: rgba(124, 252, 0, 0.15);
  color: var(--success);
  box-shadow: 0 0 12px rgba(124, 252, 0, 0.2);
}

.shop-popover-badge--unlock {
  background: rgba(255, 179, 71, 0.18);
  color: var(--gold);
}

.shop-popover-badge--warn {
  background: rgba(255, 140, 66, 0.18);
  color: var(--accent);
}

.shop-popover-badge--locked {
  background: rgba(106, 90, 205, 0.22);
  color: #c4b5fd;
}

.shop-popover-detail {
  font-size: 0.68rem;
  color: var(--muted);
}

.shop-popover-arrow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: rgba(22, 28, 36, 0.98);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transform: rotate(45deg);
}

.shop-popover-below .shop-popover-arrow {
  bottom: auto;
  top: -6px;
  transform: rotate(225deg);
}

.armory-panel {
  max-width: 920px;
  margin: 0 auto;
}

.armory-lead {
  margin-bottom: 14px;
}

.armory-xp-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

.armory-xp-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.armory-xp-val {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.armory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.armory-card {
  position: relative;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 12px;
  border-radius: 12px;
  border: 2px solid rgba(61, 50, 88, 0.65);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, filter 0.2s, opacity 0.2s;
}

.armory-card img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.armory-card--locked {
  opacity: 0.82;
  filter: grayscale(1) brightness(0.88);
  cursor: not-allowed;
}

.armory-card--owned {
  border-color: rgba(93, 255, 138, 0.35);
  background: rgba(93, 255, 138, 0.06);
}

.armory-card--unlock,
.armory-card--ready {
  border-color: rgba(255, 179, 71, 0.55);
  box-shadow: 0 0 14px rgba(255, 179, 71, 0.2);
}

.armory-card--ready {
  animation: armory-card-ready 1.8s ease-in-out infinite;
}

@keyframes armory-card-ready {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 179, 71, 0.2); }
  50% { box-shadow: 0 0 20px rgba(255, 179, 71, 0.45); }
}

.armory-card-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
}

.armory-card-badge--owned {
  color: var(--success);
  border: 1px solid rgba(93, 255, 138, 0.35);
}

.armory-card-badge--unlock {
  color: var(--gold);
  border: 1px solid rgba(255, 179, 71, 0.45);
}

.armory-card-badge--locked {
  color: rgba(180, 186, 198, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.armory-card-art img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}

.armory-card-art img.flip-x {
  transform: scaleX(-1);
}

.armory-card-name {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
}

.armory-card-stat {
  font-size: 0.58rem;
  color: var(--muted);
  line-height: 1.2;
}

.armory-card-price {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--gold);
}

.armory-card-detail {
  font-size: 0.54rem;
  color: var(--muted);
  line-height: 1.2;
}

.results-panel {
  max-width: 520px;
  margin: 16px auto;
  text-align: center;
}

.brag-panel {
  max-width: 560px;
}

.brag-eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.brag-headline {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(255, 140, 66, 0.35);
}

.brag-hero-stat {
  margin: 18px 0 8px;
  padding: 18px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 140, 66, 0.12) 0%, rgba(0, 0, 0, 0.2) 100%);
  border: 1px solid rgba(255, 179, 71, 0.35);
}

.brag-hero-stat .stat-num {
  font-size: clamp(2.75rem, 10vw, 3.5rem);
}

.brag-hero-stat .stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.results-stats-compact {
  margin: 16px 0 20px;
}

.stat-num-sm {
  font-size: 1.65rem !important;
}

.next-goal-card {
  text-align: left;
  margin: 0 0 24px;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg);
  border: 2px solid var(--panel-border);
  box-shadow: inset 0 0 0 1px rgba(124, 252, 0, 0.08);
}

.next-goal-label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7cfc00;
}

.next-goal-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.next-goal-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.next-goal-copy {
  flex: 1;
  min-width: 0;
}

.next-goal-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gold);
  line-height: 1.15;
}

.next-goal-detail {
  margin: 6px 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.next-goal-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.next-goal-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff6b35, #ffb347);
  transition: width 0.4s ease;
}

.next-goal-progress-text {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.results-badges {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
}

.badge-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 72px;
  opacity: 0.35;
  filter: grayscale(1);
  transition: opacity 0.2s, filter 0.2s;
}

.badge-slot.earned {
  opacity: 1;
  filter: none;
}

.badge-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.badge-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
  background: var(--bg);
}

.badge-slot.earned .badge-fallback {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(255, 179, 71, 0.35);
}

.badge-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.1;
}

.badge-slot.earned .badge-label {
  color: var(--gold);
}

/* Topbar: grey locked tiers until earned (must follow global .badge-* rules) */
.topbar-badges.badge-row-compact .badge-slot:not(.earned),
.topbar-badges.badge-row-compact .badge-slot.badge-locked {
  opacity: 0.78;
  filter: grayscale(1) brightness(0.82);
  border: 1px solid rgba(90, 82, 120, 0.45);
  background: rgba(0, 0, 0, 0.28);
}

.topbar-badges.badge-row-compact .badge-slot:not(.earned) .badge-img,
.topbar-badges.badge-row-compact .badge-slot.badge-locked .badge-img {
  filter: none;
}

.topbar-badges.badge-row-compact .badge-slot:not(.earned) .badge-label,
.topbar-badges.badge-row-compact .badge-slot.badge-locked .badge-label {
  color: rgba(150, 158, 172, 0.95);
}

.topbar-badges.badge-row-compact .badge-slot.earned {
  opacity: 1;
  filter: none;
  border: 1px solid rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.08);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.12);
}

.topbar-badges.badge-row-compact .badge-slot.earned .badge-img {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
  opacity: 1;
}

.topbar-badges.badge-row-compact .badge-slot.earned .badge-label {
  color: var(--gold);
}

.results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 24px;
}

.stat-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px 10px;
  border: 1px solid var(--panel-border);
}

.stat-highlight {
  grid-column: 1 / -1;
  border-color: var(--accent);
}

.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 2.25rem;
  color: var(--gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-num.tallying {
  filter: drop-shadow(0 0 8px rgba(255, 179, 71, 0.35));
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

/* Guided Battle Prep — keep the header tight so the invasion strip fits below. */
.prep-panel {
  max-width: 620px;
  padding: 12px 16px 14px;
}

.prep-panel .times-back {
  margin-bottom: 0;
}

.prep-toolbar {
  margin-bottom: 6px;
}

.prep-toolbar .times-toolbar-right {
  min-height: 0;
}

.prep-toolbar .prep-module-rail {
  justify-content: flex-end;
  flex: 0 0 auto;
}

.prep-toolbar .session-xp-badge {
  width: clamp(3.8rem, 9.5vw, 4.8rem);
  height: clamp(3.8rem, 9.5vw, 4.8rem);
}

.prep-toolbar .session-xp-badge-label {
  font-size: clamp(0.85rem, 2vw, 1.05rem);
}

.prep-toolbar .session-xp-badge-num {
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  line-height: 0.88;
}

.prep-panel .times-question {
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.25;
}

.prep-panel .times-question-wrap {
  padding: 14px 10px;
  margin-bottom: 10px;
}

.prep-panel .times-answers {
  margin-bottom: 8px;
}

.prep-panel .times-quiz-header {
  margin-bottom: 8px;
}

.prep-module-rail {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin: 0;
  flex: 1 1 auto;
}

.prep-module-node {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border: 1px solid rgba(163, 128, 255, 0.4);
  border-radius: 50%;
  background: rgba(12, 8, 28, 0.8);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.prep-module-node.is-current {
  transform: scale(1.12);
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--accent), #6d28d9);
  color: #fff;
  box-shadow: 0 0 14px rgba(255, 179, 71, 0.45);
}

.prep-module-node.is-done {
  border-color: rgba(74, 222, 128, 0.72);
  background: rgba(22, 101, 52, 0.48);
  color: #86efac;
}

.prep-track {
  height: 6px;
  margin: 6px 0 10px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.prep-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 220ms ease;
}

.prep-summary-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.prep-done {
  position: relative;
  text-align: center;
  padding-top: 8px;
}

@media (max-width: 440px) {
  .prep-module-rail {
    gap: 3px;
  }

  .prep-module-node {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
    font-size: 0.55rem;
  }

  .prep-panel .times-quiz-header {
    align-items: flex-start;
    gap: 8px;
  }

  .prep-panel .times-quiz-progress {
    text-align: right;
  }
}

/* First-time siege: keep the one essential instruction on-screen until a turret is placed. */
.siege-tutorial {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 0 auto 10px;
  padding: 11px 16px;
  max-width: 1080px;
  border: 2px solid rgba(255, 196, 59, 0.82);
  border-radius: 12px;
  background: rgba(34, 24, 5, 0.94);
  color: #fff7df;
  font-size: clamp(0.85rem, 2vw, 1rem);
  line-height: 1.45;
}
.siege-tutorial strong {
  color: #ffd36b;
  letter-spacing: 0.03em;
}
.siege-tutorial[hidden] { display: none; }
