/* ══════════════════════════════════════════════════════════════
   CLICK WARS — WAR ROOM / TACTICAL HUD THEME
   ══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0e0a;
  --bg2: #10120e;
  --accent: #aaff00;
  --accent2: #ff6600;
  --gold: #ff6600;
  --green: #aaff00;
  --red: #ff3333;
  --text: #c8c8b0;
  --muted: #555;
  --card: rgba(170,255,0,0.015);
  --border: rgba(170,255,0,0.12);
  --radius: 0px;
  --radius-lg: 0px;
  --font-heading: 'Bebas Neue', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  --font-body: 'DM Sans', sans-serif;
}

html, body {
  height: 100%;
  height: 100dvh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Grid background overlay on all screens */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(170,255,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(170,255,0,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}
/* Lock scrolling/pull-to-refresh only during gameplay */
#screen-match {
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* ── Home ─────────────────────────────────────────────────── */
.home-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 28px;
  position: relative;
  min-width: 340px;
}

/* Status bar */
.wr-status-bar {
  position: absolute;
  top: -32px;
  left: 0;
  right: 0;
  padding: 6px 14px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: rgba(170,255,0,0.4);
  border-bottom: 1px solid rgba(170,255,0,0.08);
}

.logo {
  font-family: var(--font-heading);
  font-size: 3.2rem;
  color: var(--accent);
  letter-spacing: 8px;
  text-transform: uppercase;
  position: relative;
  -webkit-text-fill-color: var(--accent);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
}
.logo::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.tagline {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 6px;
  margin-top: -10px;
}

.name-row input {
  background: rgba(170,255,0,0.03);
  border: 1px solid rgba(170,255,0,0.2);
  border-radius: 0;
  padding: 10px 16px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  width: 280px;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.2s;
}
.name-row input::placeholder { color: rgba(170,255,0,0.25); }
.name-row input:focus { border-color: var(--accent); }

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 320px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  font-family: var(--font-heading);
  font-size: 1rem;
  padding: 10px 16px;
  border: 1px solid;
  background: transparent;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 3px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  border-radius: 0;
}
.btn:active { transform: scale(0.96); }

.btn-icon {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  opacity: 0.5;
}

.btn-primary {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(170,255,0,0.05);
}
.btn-primary:hover {
  background: rgba(170,255,0,0.15);
  box-shadow: 0 0 20px rgba(170,255,0,0.2);
}

.btn-secondary {
  color: #888;
  border-color: #333;
}
.btn-secondary:hover {
  border-color: var(--accent2);
  color: var(--accent2);
}

.btn-hard {
  color: var(--red);
  border-color: #333;
}
.btn-hard:hover {
  border-color: var(--red);
  background: rgba(255,50,50,0.05);
}

.btn-outline {
  color: #888;
  border-color: #333;
}
.btn-outline:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* ── Queue ───────────────────────────────────────────────── */
.queue-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(170,255,0,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#queue-heading {
  font-family: var(--font-heading);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
}
#queue-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.hidden { display: none !important; }

/* ── Countdown ───────────────────────────────────────────── */
.countdown-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 680px;
  padding: 12px 16px;
  height: 100%;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cd-top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-shrink: 0;
}
#opponent-reveal {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 3px;
}
#opponent-reveal span { color: var(--accent2); font-weight: 700; }

.countdown-num {
  font-family: var(--font-heading);
  font-size: 2.8rem;
  font-weight: 400;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 0 20px rgba(170,255,0,0.5);
  letter-spacing: 2px;
  min-width: 60px;
}
.countdown-num.pop {
  animation: pop 0.4s ease;
}

/* ── Character Selection ────────────────────────────────── */
.char-select-heading {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--accent);
  letter-spacing: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.char-select-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 16px;
}
.char-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  user-select: none;
}
.char-card:hover {
  border-color: rgba(170,255,0,0.3);
  background: rgba(170,255,0,0.03);
}
.char-card.char-selected {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(170,255,0,0.25), inset 0 0 12px rgba(170,255,0,0.05);
  background: rgba(170,255,0,0.04);
}
.char-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}
.char-info {
  text-align: left;
  min-width: 0;
}
.char-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.char-selected .char-name {
  color: var(--accent);
}
.char-passive {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text);
  line-height: 1.4;
  opacity: 0.85;
}
.char-tradeoff {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
}
@keyframes pop {
  0%   { transform: scale(2.2); opacity: 0; }
  60%  { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── Match ───────────────────────────────────────────────── */
.match-layout {
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  padding-top: calc(12px + env(safe-area-inset-top));
  gap: 6px;
  overflow: hidden;
}

.match-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  width: 100%;
  max-width: 700px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: rgba(170,255,0,0.02);
}

.score-block {
  flex: 1;
  text-align: center;
}
.score-block.opp { text-align: center; }
.score-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: rgba(170,255,0,0.4);
  letter-spacing: 3px;
}
.score-val {
  display: block;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--accent);
  letter-spacing: 2px;
}
.score-block.self .score-val { color: var(--accent); }
.score-block.opp  .score-val { color: var(--accent2); }

.timer-block {
  text-align: center;
  border-left: 1px solid rgba(170,255,0,0.1);
  border-right: 1px solid rgba(170,255,0,0.1);
  padding: 0 16px;
}
.timer {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
  letter-spacing: 2px;
}
.timer.urgent { color: var(--red); animation: pulse-red 0.5s ease infinite alternate; }
.timer.spectating { color: var(--muted); font-size: 1.4rem; }
@keyframes pulse-red { from { opacity: 1; } to { opacity: 0.5; } }
.timer-label {
  font-family: var(--font-mono);
  font-size: 0.45rem;
  color: var(--muted);
  letter-spacing: 2px;
}

.vs-sep { font-size: 1.2rem; color: var(--muted); font-weight: 900; }

/* XP bar */
.xp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 700px;
}
.level-badge {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 2px;
  background: none;
  padding: 0;
  border-radius: 0;
  white-space: nowrap;
}
.xp-bar-wrap {
  flex: 1;
  height: 4px;
  background: #1a1e12;
  border: 1px solid rgba(170,255,0,0.1);
  border-radius: 0;
  overflow: hidden;
}
.xp-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(170,255,0,0.4);
  transition: width 0.15s ease;
  border-radius: 0;
}
.xp-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: #444;
  white-space: nowrap;
}

/* ── Shop Bar ────────────────────────────────────────────────── */
.shop-bar {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 700px;
  align-items: stretch;
}

.reroll-countdown {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: #333;
  text-align: center;
  margin-top: 2px;
  margin-bottom: 2px;
  transition: color 0.2s;
}
.reroll-countdown.reroll-soon {
  color: var(--accent2);
  font-weight: 700;
}
.reroll-countdown.reroll-now {
  color: var(--accent);
  font-weight: 700;
}

/* ── Shop Slot — Icon Cards ─────────────────────────────── */
.shop-slot {
  flex: 1;
  background: var(--surface, #1a1e12);
  border: 1px solid rgba(170,255,0,0.15);
  padding: 0;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 0;
}
.shop-slot:hover:not(.shop-slot-disabled) {
  border-color: rgba(170,255,0,0.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.shop-slot:active:not(.shop-slot-disabled) {
  transform: scale(0.97);
}
.shop-slot.shop-slot-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* Rarity glow effects */
.shop-slot.shop-slot-epic {
  box-shadow: 0 0 10px rgba(176,64,224,0.25);
}
.shop-slot.shop-slot-legendary {
  animation: legendary-shimmer 1.8s ease-in-out infinite;
}
@keyframes legendary-shimmer {
  0%, 100% { box-shadow: 0 0 12px rgba(255,102,0,0.4), 0 0 0 rgba(255,102,0,0); }
  50%       { box-shadow: 0 0 28px rgba(255,102,0,0.8), 0 0 50px rgba(255,102,0,0.2); }
}

/* Rarity top bar (replaces left border) */
.ic-rarity-bar {
  height: 3px;
  width: 100%;
  flex-shrink: 0;
}
.shop-slot.r-common    .ic-rarity-bar { background: var(--common-color, #8a9a6e); }
.shop-slot.r-uncommon  .ic-rarity-bar { background: var(--uncommon-color, #4CAF50); }
.shop-slot.r-rare      .ic-rarity-bar { background: var(--rare-color, #2196F3); }
.shop-slot.r-epic      .ic-rarity-bar { background: var(--epic-color, #b040e0); }
.shop-slot.r-legendary .ic-rarity-bar { background: var(--legendary-color, #ff6600); }

/* Hotkey badge */
.ic-key {
  position: absolute;
  top: 6px;
  left: 6px;
  font-family: var(--font-mono, 'Share Tech Mono', monospace);
  font-size: 0.5rem;
  color: var(--muted, #6b7a4a);
  opacity: 0.6;
}

/* Icon */
.ic-icon {
  font-size: 1.8rem;
  margin: 10px 0 2px;
  line-height: 1;
}

/* Stat value — the big number */
.ic-value {
  font-family: var(--font-heading, 'Bebas Neue', sans-serif);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--accent2, #aaff00);
}
/* Rarity-colored values */
.shop-slot.r-common    .ic-value { color: var(--common-color, #8a9a6e); }
.shop-slot.r-uncommon  .ic-value { color: var(--uncommon-color, #4CAF50); }
.shop-slot.r-rare      .ic-value { color: var(--rare-color, #2196F3); }
.shop-slot.r-epic      .ic-value { color: var(--epic-color, #b040e0); }
.shop-slot.r-legendary .ic-value { color: var(--legendary-color, #ff6600); }

/* Type label */
.ic-type {
  font-family: var(--font-mono, 'Share Tech Mono', monospace);
  font-size: 0.5rem;
  color: var(--muted, #6b7a4a);
  letter-spacing: 1px;
  margin: 2px 0;
}

/* Cost strip */
.ic-cost {
  font-family: var(--font-mono, 'Share Tech Mono', monospace);
  font-size: 0.65rem;
  color: var(--accent2, #aaff00);
  background: rgba(170,255,0,0.08);
  padding: 4px 0;
  width: 100%;
  margin-top: auto;
  font-weight: 700;
}

/* Reroll animation: flash all slots */
@keyframes shop-reroll-flash {
  0%   { opacity: 1; }
  25%  { opacity: 0.2; transform: scaleY(0.85); }
  60%  { opacity: 1; transform: scaleY(1.04); }
  100% { opacity: 1; transform: scaleY(1); }
}
.shop-bar.shop-rerolling .shop-slot {
  animation: shop-reroll-flash 0.35s ease forwards;
}

/* Active power-ups */
.active-powerups {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 28px;
}

/* ── Stats Bar ───────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: rgba(170,255,0,0.02);
  border-radius: 0;
  width: 100%;
  max-width: 500px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 50px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-multiplier {
  color: var(--accent);
  transition: color 0.2s, transform 0.2s;
}
.stat-multiplier.boosted {
  color: var(--accent2);
  transform: scale(1.15);
}
.stat-multiplier.mega {
  color: var(--red);
  transform: scale(1.25);
  text-shadow: 0 0 8px rgba(255,51,51,0.5);
}

.stat-auto {
  color: var(--accent);
}

.stats-spacer {
  flex: 1;
}

.stat-auto-wrap {
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.pup-tag {
  font-family: var(--font-mono);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 0;
  padding: 3px 10px;
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 600;
  position: relative;
  cursor: default;
  letter-spacing: 1px;
}
.pup-tag.golden {
  border-color: var(--accent2);
  color: var(--accent2);
  animation: golden-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes golden-pulse {
  from { box-shadow: 0 0 4px rgba(255,102,0,0.3); }
  to   { box-shadow: 0 0 12px rgba(255,102,0,0.7); }
}

.pup-tag .pup-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 12px;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.pup-tag .pup-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}
.pup-tag:hover .pup-tooltip,
.pup-tag.tooltip-active .pup-tooltip {
  display: block;
}
.pup-tag.timed { border-color: var(--accent2); color: var(--accent2); }
.pup-tag.sabotage-active { border-color: var(--red); color: var(--red); }

/* Click area */
.click-area {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 500px;
  min-height: 120px;
  border: 1px solid rgba(170,255,0,0.1);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(170,255,0,0.03) 0%, transparent 60%);
  transition: all 0.2s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.click-area:hover {
  border-color: rgba(170,255,0,0.3);
  box-shadow: 0 0 40px rgba(170,255,0,0.08);
}
.click-area:active { transform: scale(0.995); }

.click-ring {
  position: absolute;
  z-index: 1;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.click-ring.pulse {
  animation: ring-pulse 0.4s ease-out forwards;
}
@keyframes ring-pulse {
  from { transform: scale(0.3); opacity: 0.6; }
  to   { transform: scale(2.2); opacity: 0; }
}

/* Tactical reticle (replaces red button) */
.red-button {
  width: 120px;
  height: 120px;
  position: relative;
  z-index: 2;
  pointer-events: none;
  transition: transform 0.08s ease;
}

/* Outer ring */
.red-button::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid rgba(170,255,0,0.3);
  border-radius: 50%;
}

/* Inner ring */
.red-button::after {
  content: '';
  position: absolute;
  inset: 15px;
  border: 2px solid rgba(255,102,0,0.4);
  border-radius: 50%;
}

/* Center dot */
.reticle-inner {
  position: absolute;
  inset: 30px;
  background: radial-gradient(circle, #ff3300, #cc2200);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(255,50,0,0.5);
}

/* Crosshairs */
.crosshair-h, .crosshair-v {
  position: absolute;
  background: rgba(170,255,0,0.15);
}
.crosshair-h { height: 1px; width: 100%; top: 50%; left: 0; }
.crosshair-v { width: 1px; height: 100%; left: 50%; top: 0; }

/* Press animation (added via JS) */
.red-button.pressed {
  animation: reticle-press 0.15s ease-out;
}
@keyframes reticle-press {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.85); }
  70%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Glow effect on rapid clicking */
.red-button.hot {
  filter: drop-shadow(0 0 20px rgba(170,255,0,0.4)) drop-shadow(0 0 40px rgba(255,50,0,0.3));
}
.red-button.hot .reticle-inner {
  box-shadow: 0 0 40px rgba(255,50,0,0.8);
}

.click-hint {
  position: relative;
  z-index: 2;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: #333;
  letter-spacing: 6px;
  margin-top: 10px;
  pointer-events: none;
}

/* Frenzy indicator */
.frenzy-indicator {
  font-family: var(--font-heading);
  color: var(--accent2);
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 4px;
  text-shadow: 0 0 12px var(--accent2);
  animation: glow-pulse 0.6s ease infinite alternate;
}
@keyframes glow-pulse {
  from { text-shadow: 0 0 8px var(--accent2); }
  to   { text-shadow: 0 0 24px var(--accent2); }
}

/* ── Level-Up Overlay ─────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  padding-top: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
}

.levelup-box {
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 0;
  padding: 24px;
  text-align: center;
  max-width: 540px;
  width: 90%;
  box-shadow: 0 0 60px rgba(170,255,0,0.2);
  animation: slide-down 0.3s ease;
}
@keyframes slide-down {
  from { transform: translateY(-30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.levelup-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(170,255,0,0.5);
  margin-bottom: 4px;
  letter-spacing: 4px;
}
.levelup-sub {
  font-family: var(--font-mono);
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 0.75rem;
}

.powerup-cards {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.pup-card {
  background: rgba(170,255,0,0.02);
  border: 1px solid rgba(170,255,0,0.15);
  border-radius: 0;
  padding: 16px 14px;
  width: 150px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  text-align: center;
}
.pup-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(170,255,0,0.15);
}
.pup-card:active { transform: scale(0.96); }
.pup-card .pup-name {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--accent);
  letter-spacing: 1px;
}
.pup-card .pup-desc {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.4;
}

.auto-pick-bar {
  margin-top: 16px;
  height: 4px;
  background: rgba(170,255,0,0.1);
  border-radius: 0;
  overflow: hidden;
}
.auto-pick-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  animation: drain 3s linear forwards;
}
@keyframes drain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Results ─────────────────────────────────────────────── */
.results-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 0;
  min-width: 360px;
}

.result-banner {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  padding: 10px 30px;
  border-radius: 0;
  letter-spacing: 4px;
}
.result-banner.win  { color: var(--accent);  background: rgba(170,255,0,0.08); border: 1px solid rgba(170,255,0,0.3); }
.result-banner.loss { color: var(--red);    background: rgba(255,51,51,0.08); border: 1px solid rgba(255,51,51,0.3); }
.result-banner.draw { color: var(--accent2); background: rgba(255,102,0,0.08); border: 1px solid rgba(255,102,0,0.3); }

.result-scores {
  display: flex;
  align-items: center;
  gap: 24px;
}
.result-player { text-align: center; }
.result-name {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 3px;
  margin-bottom: 6px;
}
.result-score {
  font-family: var(--font-heading);
  font-size: 3rem;
  color: var(--accent);
}
.result-level {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
}
.result-vs {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--muted);
  letter-spacing: 2px;
}

.rematch-row { display: flex; gap: 12px; }

/* ── Leaderboard ─────────────────────────────────────────── */
.leaderboard-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 0;
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  max-height: 80dvh;
}

.leaderboard-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--accent);
  letter-spacing: 4px;
  -webkit-text-fill-color: var(--accent);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
}

.leaderboard-sub {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: -8px;
  letter-spacing: 1px;
}

.leaderboard-list {
  width: 100%;
  overflow-y: auto;
  max-height: 50vh;
  max-height: 50dvh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leaderboard-empty {
  font-family: var(--font-mono);
  color: var(--muted);
  text-align: center;
  padding: 24px;
  font-size: 0.75rem;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 0;
  background: rgba(170,255,0,0.02);
  border: 1px solid transparent;
  transition: border-color 0.15s;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.lb-row:hover { border-color: var(--border); }
.lb-row.top-1 { border-color: var(--accent); background: rgba(170,255,0,0.06); }
.lb-row.top-2 { border-color: var(--accent2); background: rgba(255,102,0,0.04); }
.lb-row.top-3 { border-color: #cd7f32; background: rgba(205,127,50,0.04); }

.lb-rank {
  width: 28px;
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}
.lb-row.top-1 .lb-rank { color: var(--accent); }
.lb-row.top-2 .lb-rank { color: var(--accent2); }
.lb-row.top-3 .lb-rank { color: #cd7f32; }

.lb-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-details {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.lb-score {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.lb-outcome {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.lb-outcome.win  { color: var(--accent); background: rgba(170,255,0,0.1); }
.lb-outcome.loss { color: var(--red);   background: rgba(255,51,51,0.1); }
.lb-outcome.draw { color: var(--accent2); background: rgba(255,102,0,0.1); }

.lb-meta {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Particles ───────────────────────────────────────────── */
.particles-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
.particle {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent);
  pointer-events: none;
  animation: float-up 0.7s ease-out forwards;
  white-space: nowrap;
}
@keyframes float-up {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-70px) scale(0.6); }
}
.particle.big { font-size: 1.2rem; color: var(--accent2); }
.particle.auto { color: var(--accent); font-size: 0.85rem; opacity: 0.85; }
.particle.sabotage { color: var(--red); }
.particle.shield { color: var(--accent); }

/* Sabotage flash overlay */
.sabotage-flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 51, 51, 0.15);
  z-index: 50;
  pointer-events: none;
  animation: flash-out 0.5s ease forwards;
}
@keyframes flash-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Scoreboard (in-match) ───────────────────────────────── */
.scoreboard {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid rgba(170,255,0,0.08);
  border-radius: 0;
  padding: 6px 8px;
  background: transparent;
}

.sb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
}

.sb-row.sb-self {
  background: rgba(170,255,0,0.06);
  border-left: 2px solid var(--accent);
}

.sb-rank { width: 22px; text-align: center; font-size: 0.75rem; flex-shrink: 0; color: var(--muted); }
.sb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #888; }
.sb-row.sb-self .sb-name { color: var(--accent); }
.sb-class { font-size: 0.7rem; flex-shrink: 0; margin-right: 2px; }
.sb-score { font-weight: 800; color: var(--accent2); font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; }
.sb-level { font-size: 0.6rem; color: var(--muted); min-width: 28px; }
.sb-timer { font-size: 0.6rem; color: var(--muted); min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.sb-separator { text-align: center; color: var(--muted); font-size: 0.5rem; padding: 1px 0; letter-spacing: 3px; }
.sb-footer { text-align: center; color: var(--muted); font-size: 0.55rem; padding: 2px 0; font-family: var(--font-mono); }

/* ── Rank block in match header ──────────────────────────── */
.rank-block { text-align: center; }
.rank-val {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--accent2);
  line-height: 1.1;
  letter-spacing: 2px;
}

/* ── Lobby info in queue screen ──────────────────────────── */
.lobby-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--accent);
  background: rgba(170,255,0,0.03);
  border-radius: 0;
  padding: 16px 20px;
  width: 100%;
  max-width: 360px;
  animation: slide-down 0.3s ease;
}

.lobby-countdown {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--accent2);
  letter-spacing: 2px;
}

.lobby-players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.lobby-player-name {
  background: rgba(170,255,0,0.03);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text);
}

/* ── Result rankings ─────────────────────────────────────── */
.result-rankings {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.result-rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 0;
  background: rgba(170,255,0,0.02);
  border: 1px solid transparent;
  font-family: var(--font-mono);
}

.result-rank-row.result-rank-self {
  border-color: var(--accent);
  background: rgba(170,255,0,0.06);
}

.rr-rank { width: 30px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.rr-name { flex: 1; font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-rank-self .rr-name { color: var(--accent); }
.rr-score { font-weight: 800; font-size: 1rem; color: var(--accent2); font-variant-numeric: tabular-nums; }
.rr-level { font-size: 0.75rem; color: var(--muted); }

/* ── Mute Button ─────────────────────────────────────── */
.mute-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: rgba(170,255,0,0.03);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  padding: 0;
  line-height: 1;
}
.mute-btn:hover { background: var(--bg2); border-color: var(--accent); transform: scale(1.1); }
.mute-btn:active { transform: scale(0.92); }

/* ── Button hover glow ───────────────────────────────── */
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary:hover {
  box-shadow: 0 0 20px rgba(170,255,0,0.2);
}
.btn-secondary:hover {
  border-color: var(--accent2);
  color: var(--accent2);
}
.btn-hard:hover {
  border-color: var(--red);
  box-shadow: 0 0 20px rgba(255,51,51,0.2);
}
.btn-outline:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* ── Click-area idle pulse glow ──────────────────────── */
.click-area {
  animation: click-area-idle 2.8s ease-in-out infinite;
}
@keyframes click-area-idle {
  0%, 100% { box-shadow: 0 0 10px rgba(170,255,0,0.04); }
  50%       { box-shadow: 0 0 30px rgba(170,255,0,0.1), 0 0 60px rgba(170,255,0,0.03); }
}
.click-area:hover { animation: none; }

/* ── Score pop animation ─────────────────────────────── */
@keyframes score-pop {
  0%   { transform: scale(1);   color: var(--accent); }
  40%  { transform: scale(1.5); color: var(--accent2); text-shadow: 0 0 20px var(--accent2); }
  100% { transform: scale(1);   color: var(--accent); }
}
.score-val.score-pop {
  animation: score-pop 0.45s ease forwards;
}

/* ── Combo counter ───────────────────────────────────── */
.combo-display {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-heading);
  font-size: 1.6rem;
  letter-spacing: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
  z-index: 15;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.combo-display.combo-visible {
  opacity: 1;
}
.combo-display.combo-med {
  color: var(--accent2);
}
.combo-display.combo-high {
  color: var(--accent);
  font-size: 1.9rem;
  text-shadow: 0 0 14px rgba(170,255,0,0.6), 0 2px 8px rgba(0,0,0,0.6);
}
.combo-display.combo-ultra {
  color: var(--red);
  font-size: 2.2rem;
  text-shadow: 0 0 24px rgba(255,51,51,0.8), 0 0 48px rgba(255,51,51,0.3), 0 2px 8px rgba(0,0,0,0.6);
}
@keyframes combo-bump {
  from { transform: translateX(-50%) scale(1.35); }
  to   { transform: translateX(-50%) scale(1); }
}
.combo-display.combo-bump {
  animation: combo-bump 0.18s ease;
}

/* ── Confetti particles ──────────────────────────────── */
.confetti-particle {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 0;
  pointer-events: none;
  animation: confetti-fall 1.8s ease-in forwards;
}
@keyframes confetti-fall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  80%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(105vh) rotate(780deg) scale(0.4); }
}

/* ── Level-up golden burst ───────────────────────────── */
@keyframes levelup-burst {
  0%   { box-shadow: 0 0 60px rgba(170,255,0,0.7), 0 0 0 rgba(255,102,0,0); }
  50%  { box-shadow: 0 0 80px rgba(170,255,0,0.5), 0 0 120px rgba(255,102,0,0.2); }
  100% { box-shadow: 0 0 60px rgba(170,255,0,0.2), 0 0 0 rgba(255,102,0,0); }
}
.levelup-box.burst {
  animation: slide-down 0.3s ease, levelup-burst 0.6s ease 0.1s;
}

/* ── Victory banner pulse ────────────────────────────── */
@keyframes banner-green-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(170,255,0,0.2); }
  50%       { box-shadow: 0 0 50px rgba(170,255,0,0.5), 0 0 80px rgba(255,102,0,0.15); }
}
.result-banner.win.banner-pulse {
  animation: banner-green-pulse 1.6s ease-in-out infinite;
}

/* Silver shimmer for 2nd place */
@keyframes silver-shimmer {
  0%, 100% { box-shadow: 0 0 10px rgba(192,192,192,0.2); }
  50%       { box-shadow: 0 0 30px rgba(192,192,192,0.55); }
}
.result-banner.draw.rank-2-shimmer {
  animation: silver-shimmer 2s ease-in-out infinite;
}

/* Bronze shimmer for 3rd place */
@keyframes bronze-shimmer {
  0%, 100% { box-shadow: 0 0 8px rgba(205,127,50,0.2); }
  50%       { box-shadow: 0 0 24px rgba(205,127,50,0.5); }
}
.result-banner.draw.rank-3-shimmer {
  animation: bronze-shimmer 2s ease-in-out infinite;
}

/* ── Loss vignette ───────────────────────────────────── */
.loss-vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(255,51,51,0.3) 100%);
  pointer-events: none;
  z-index: 5;
  animation: vignette-in 0.8s ease forwards;
}
@keyframes vignette-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Countdown enhancement ───────────────────────────── */
@keyframes go-burst {
  0%   { transform: scale(0.4); opacity: 0; color: var(--accent); text-shadow: 0 0 0 rgba(170,255,0,0); }
  50%  { transform: scale(1.25); color: var(--accent); text-shadow: 0 0 80px rgba(170,255,0,1), 0 0 120px rgba(255,102,0,0.4); }
  100% { transform: scale(1); opacity: 1; color: var(--accent); text-shadow: 0 0 30px rgba(170,255,0,0.5); }
}
.countdown-num.go-flash {
  animation: go-burst 0.55s ease forwards;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 500px) {
  .match-header { padding: 8px 10px; gap: 6px; }
  .score-val { font-size: 1.4rem; }
  .rank-val { font-size: 1.2rem; }
  .timer { font-size: 1.1rem; }
  .logo { font-size: 2.4rem; letter-spacing: 4px; }
  .home-inner { padding: 24px 20px; min-width: 0; width: 90%; }
  .results-inner { padding: 24px 20px; min-width: 0; width: 90%; }
  .red-button { width: 100px; height: 100px; }
  .countdown-num { font-size: 2.2rem; }
  .char-select-heading { font-size: 1rem; letter-spacing: 4px; }
  .char-card { padding: 8px 10px; gap: 8px; }
  .char-icon { font-size: 1.4rem; width: 32px; }
  .char-name { font-size: 0.85rem; }
  .char-passive { font-size: 0.55rem; }
  .char-tradeoff { font-size: 0.5rem; }
  .stats-bar { padding: 4px 10px; gap: 4px; }
  .stat-value { font-size: 0.95rem; }
  .stat-label { font-size: 0.45rem; }
  .stat-item { min-width: 40px; }
  .scoreboard { max-height: 80px; font-size: 0.65rem; }
  .sb-timer { display: none; }
  .sb-class { display: none; }
  .sb-level { display: none; }
  .sb-score { min-width: 40px; font-size: 0.65rem; }
  .shop-bar { gap: 4px; }
  .shop-slot { padding: 0; }
  .ic-icon { font-size: 1.3rem; margin: 6px 0 1px; }
  .ic-value { font-size: 1rem; }
  .ic-type { font-size: 0.4rem; }
  .ic-cost { font-size: 0.5rem; padding: 3px 0; }
  .ic-key { font-size: 0.4rem; top: 4px; left: 4px; }
  .btn { font-size: 0.85rem; padding: 8px 12px; letter-spacing: 2px; }
  .btn-group { max-width: 100%; }
  .wr-status-bar { font-size: 0.5rem; }
}

/* Very small screens (short portrait phones) */
@media (max-height: 600px) {
  .match-header { padding: 6px 10px; }
  .score-val { font-size: 1.2rem; }
  .timer { font-size: 1rem; }
  .xp-row { gap: 6px; }
  .level-badge { padding: 0; font-size: 0.8rem; }
  .red-button { width: 80px; height: 80px; }
  .click-hint { display: none; }
  .match-layout { gap: 4px; padding: 8px; }
  .stats-bar { padding: 3px 8px; }
  .stat-value { font-size: 0.85rem; }
  .stat-divider { font-size: 0.75rem; }
}

/* ── Lock Button ─────────────────────────────────────────── */
.shop-lock-btn {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 28px;
  height: 28px;
  font-size: 13px;
  line-height: 28px;
  text-align: center;
  border-radius: 0;
  background: rgba(170,255,0,0.08);
  cursor: pointer;
  z-index: 10;
  transition: background 0.15s, transform 0.15s;
  user-select: none;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.shop-lock-btn:hover {
  background: rgba(170,255,0,0.15);
  transform: scale(1.15);
}
.shop-lock-btn.locked {
  background: rgba(255,102,0,0.2);
}
.shop-slot-locked {
  border-style: dashed !important;
  box-shadow: 0 0 8px rgba(255,102,0,0.2) !important;
}

/* ── Tactical Formation Display ─────────────────────────── */
/* formation-widget class no longer used — formation is now in click-area background */
.formation-widget::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(170,255,0,0.04) 19px, rgba(170,255,0,0.04) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(170,255,0,0.04) 19px, rgba(170,255,0,0.04) 20px);
  pointer-events: none;
}
.formation-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 0.45rem;
  letter-spacing: 2px;
  color: rgba(170,255,0,0.3);
  text-transform: uppercase;
  padding: 3px 6px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid rgba(170,255,0,0.06);
  display: flex;
  justify-content: space-between;
  z-index: 2;
}
.formation-count {
  color: var(--accent);
  font-weight: 700;
}
.formation-count.at-cap {
  color: var(--accent2);
  animation: cap-pulse 1.5s ease-in-out infinite;
}
@keyframes cap-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.formation-field {
  position: absolute;
  inset: 0;
  top: 16px;
}
.formation-bullet-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.formation-hint {
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.38rem;
  color: rgba(170,255,0,0.2);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  z-index: 3;
}

/* Operator dot */
.op-dot {
  position: absolute;
  border-radius: 50%;
  width: 8px;
  height: 8px;
  transition: all 0.3s ease;
  z-index: 2;
}
.formation-widget.expanded .op-dot {
  width: 14px;
  height: 14px;
}

/* Rarity glow for dots */
.op-dot.r-common    { background: var(--common-color, #8a9a6e); box-shadow: 0 0 4px var(--common-color, #8a9a6e); }
.op-dot.r-uncommon  { background: var(--uncommon-color, #4CAF50); box-shadow: 0 0 6px var(--uncommon-color, #4CAF50); }
.op-dot.r-rare      { background: var(--rare-color, #2196F3); box-shadow: 0 0 8px var(--rare-color, #2196F3); }
.op-dot.r-epic      { background: var(--epic-color, #b040e0); box-shadow: 0 0 10px var(--epic-color, #b040e0); }
.op-dot.r-legendary { background: var(--legendary-color, #ff6600); box-shadow: 0 0 12px var(--legendary-color, #ff6600); }

/* Dot tooltip on hover */
.op-dot { cursor: pointer; }
.op-dot .dot-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12,14,10,0.95);
  border: 1px solid rgba(170,255,0,0.3);
  padding: 6px 10px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  min-width: 140px;
}
.op-dot:hover .dot-tooltip,
.op-dot.tooltip-active .dot-tooltip { display: block; }
.dot-tooltip-class {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 2px;
  margin-bottom: 2px;
}
.dot-tooltip-name {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.dot-tooltip-desc {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--text-dim);
  opacity: 0.8;
}
.dot-tooltip-rarity {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 3px;
}
.dot-tooltip-rarity.r-common    { color: var(--common-color); }
.dot-tooltip-rarity.r-uncommon  { color: var(--uncommon-color); }
.dot-tooltip-rarity.r-rare      { color: var(--rare-color); }
.dot-tooltip-rarity.r-epic      { color: var(--epic-color); }
.dot-tooltip-rarity.r-legendary { color: var(--legendary-color); }
/* Edge-guard: if tooltip goes off right side */
.op-dot[style*="left: calc(7"] .dot-tooltip,
.op-dot[style*="left: calc(8"] .dot-tooltip,
.op-dot[style*="left: calc(9"] .dot-tooltip {
  left: auto;
  right: 0;
  transform: none;
}

@keyframes dot-appear {
  0% { transform: scale(0); opacity: 0; box-shadow: 0 0 20px currentColor; }
  60% { transform: scale(1.4); }
  100% { transform: scale(1); opacity: 1; }
}
.op-dot.appearing {
  animation: dot-appear 0.5s ease-out;
}

/* Border glow based on highest rarity */
.formation-widget.glow-common    { border-color: rgba(138,154,110,0.35); }
.formation-widget.glow-uncommon  { border-color: rgba(76,175,80,0.4); }
.formation-widget.glow-rare      { border-color: rgba(33,150,243,0.4); box-shadow: 0 0 10px rgba(33,150,243,0.15); }
.formation-widget.glow-epic      { border-color: rgba(176,64,224,0.4); box-shadow: 0 0 12px rgba(176,64,224,0.15); }
.formation-widget.glow-legendary { border-color: rgba(255,102,0,0.5); box-shadow: 0 0 15px rgba(255,102,0,0.2); }

/* Expanded row labels */
.formation-row-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.42rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 3;
  white-space: nowrap;
  color: rgba(170,255,0,0.2);
  display: none;
}
.formation-widget.expanded .formation-row-label {
  display: block;
}

/* Mobile responsive */
@media (max-width: 500px) {
  .formation-widget {
    width: 80px;
    height: 80px;
    bottom: 64px;
    left: 8px;
  }
  .formation-widget.expanded {
    width: 200px;
    height: 200px;
  }
  .op-dot { width: 6px; height: 6px; }
  .formation-widget.expanded .op-dot { width: 10px; height: 10px; }
  .formation-header { font-size: 0.4rem; padding: 2px 4px; }
  .formation-hint { font-size: 0.32rem; }
}
@media (max-height: 600px) {
  .formation-widget {
    width: 70px;
    height: 70px;
    bottom: 56px;
  }
  .formation-widget.expanded {
    width: 180px;
    height: 180px;
  }
}

/* ── Debug Purchase Log ─────────────────────────────── */
.debug-log-btn {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}
.debug-log-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.debug-log-panel {
  position: fixed;
  bottom: 56px;
  right: 12px;
  width: 340px;
  max-height: 50vh;
  background: rgba(12,14,10,0.96);
  border: 1px solid var(--border);
  z-index: 89;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.debug-log-panel.open { display: flex; }
.debug-log-header {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  letter-spacing: 3px;
  color: var(--primary);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(170,255,0,0.04);
}
.debug-log-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}
.debug-log-row {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(170,255,0,0.06);
}
.debug-log-row:last-child { border-bottom: none; }
.debug-log-time {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.debug-log-name {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 2px;
  margin-bottom: 3px;
}
.debug-log-name.r-common    { color: var(--common-color); }
.debug-log-name.r-uncommon  { color: var(--uncommon-color); }
.debug-log-name.r-rare      { color: var(--rare-color); }
.debug-log-name.r-epic      { color: var(--epic-color); }
.debug-log-name.r-legendary { color: var(--legendary-color); }
.debug-log-detail {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.debug-val {
  color: var(--primary);
}
@media (max-width: 500px) {
  .debug-log-panel { width: calc(100vw - 24px); right: 12px; }
  .debug-log-btn { width: 30px; height: 30px; font-size: 0.85rem; }
}

/* ── Formation Background (behind click button) ─────────────────────────── */
.formation-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
}
.formation-bg .formation-field {
  position: absolute;
  inset: 0;
}
.formation-bg-count {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--primary);
  background: rgba(12,14,10,0.7);
  padding: 2px 6px;
  pointer-events: none;
  letter-spacing: 1px;
  z-index: 3;
}
.formation-bg-count.at-cap {
  color: var(--accent);
  animation: pulse-red 0.8s ease infinite alternate;
}

/* ── War Map Widget (small, bottom-left) ─────────────────────────────────── */
.warmap-widget {
  position: fixed;
  bottom: 72px;
  left: 12px;
  width: 100px;
  height: 100px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(170,255,0,0.2);
  overflow: hidden;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
}
.warmap-widget:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(170,255,0,0.15);
}
.warmap-widget-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.warmap-widget-label {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: var(--primary);
  background: rgba(12,14,10,0.85);
  padding: 1px 4px;
  pointer-events: none;
  letter-spacing: 1px;
}

/* Full overlay */
.warmap-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12,14,10,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.warmap-overlay-inner {
  position: relative;
  width: min(90vw, 720px);
  height: min(70vh, 500px);
  background: var(--bg);
  border: 1px solid rgba(170,255,0,0.2);
}
.warmap-full-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.warmap-hud {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(12,14,10,0.88);
  border: 1px solid rgba(170,255,0,0.2);
  padding: 8px 10px;
  font-family: var(--font-mono);
}
.warmap-hud-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--primary);
  letter-spacing: 1px;
}
.warmap-hud-stat {
  font-size: 0.6rem;
  color: var(--text);
  margin-top: 2px;
}
.warmap-hud-stat span {
  color: var(--primary);
  font-weight: 700;
}
.warmap-legend {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
}
.warmap-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.warmap-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.warmap-close {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  background: rgba(12,14,10,0.8);
  border: 1px solid rgba(170,255,0,0.2);
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.warmap-close:hover { background: rgba(170,255,0,0.1); }

@media (max-width: 500px) {
  .warmap-overlay-inner {
    width: 95vw;
    height: 60vh;
  }
  .warmap-widget {
    width: 70px;
    height: 70px;
    bottom: 60px;
    left: 8px;
  }
  .warmap-widget-label { font-size: 0.4rem; }
  .formation-bg-count { font-size: 0.45rem; }
}
