/* ============================
   BASE & VARIABLES
   ============================ */
:root {
  --bg-dark: #0d0f14;
  --bg-panel: #161a23;
  --bg-card: #1e2330;
  --bg-hover: #252b3a;
  --border: #2a3147;
  --border-light: #3a4560;

  --text-primary: #e8ecf5;
  --text-secondary: #8090b0;
  --text-muted: #4a5570;

  --team-a: #4a9eff;
  --team-a-dark: #1a4a8a;
  --team-a-glow: rgba(74, 158, 255, 0.3);
  --team-b: #ff5555;
  --team-b-dark: #8a1a1a;
  --team-b-glow: rgba(255, 85, 85, 0.3);

  --gold: #f0c040;
  --gold-dark: #8a6010;
  --green: #40c080;
  --purple: #c080f0;
  --orange: #f0a040;

  --nexus-hp: #40c080;
  --damage: #ff4444;
  --heal: #44ff88;

  --radius: 8px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================
   SCROLLBARS
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ============================
   BUTTONS
   ============================ */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  transition: all 0.15s;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--team-a);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #6ab0ff; box-shadow: 0 0 12px var(--team-a-glow); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--team-a); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--team-b);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #ff7777; }

.btn-large { padding: 12px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* ============================
   SETUP SCREEN
   ============================ */
#setup-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0d1525 0%, #050708 100%);
}

.setup-container {
  text-align: center;
  max-width: 480px;
  width: 100%;
  padding: 40px 20px;
}

.setup-logo h1 {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--team-a);
  text-shadow: 0 0 40px var(--team-a-glow), 0 0 80px rgba(74,158,255,0.15);
  margin-bottom: 8px;
}

.setup-tagline {
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 48px;
}

.setup-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.load-menu {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
}

.load-menu h3 { margin-bottom: 12px; color: var(--text-secondary); }

.saves-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 300px; overflow-y: auto; }

.save-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s;
}
.save-item:hover { border-color: var(--team-a); background: var(--bg-hover); }

.save-item-info { flex: 1; }
.save-item-name { font-weight: 600; margin-bottom: 2px; }
.save-item-meta { font-size: 0.75rem; color: var(--text-secondary); }

.save-item-actions { display: flex; gap: 8px; }

/* ============================
   HERO SELECT SCREEN
   ============================ */
#hero-select-screen {
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at center, #0d1525 0%, #050708 100%);
  overflow-y: auto;
}

.hero-select-container {
  max-width: 1100px;
  margin: 0 auto;
}

.hero-select-container h2 {
  text-align: center;
  font-size: 1.8rem;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.teams-select {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

.team-select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.team-header {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  text-align: center;
}
.team-a-header { background: var(--team-a-dark); border: 1px solid var(--team-a); }
.team-b-header { background: var(--team-b-dark); border: 1px solid var(--team-b); }

.team-label { display: block; font-weight: 800; letter-spacing: 0.1em; font-size: 0.9rem; }
.team-subtitle { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  max-height: 340px;
  overflow-y: auto;
}

.faction-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.faction-btn {
  padding: 4px 10px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.faction-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.faction-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.faction-btn.liothan.active { background: #3a7ad4; border-color: #3a7ad4; }
.faction-btn.kurumo.active  { background: #c04040; border-color: #c04040; }
.faction-btn.taulot.active  { background: #c07830; border-color: #c07830; }
.faction-btn.nupten.active  { background: #7040a0; border-color: #7040a0; }

.hero-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.hero-card:hover { border-color: var(--border-light); background: var(--bg-hover); }
.hero-card.selected-a { border-color: var(--team-a); background: rgba(74,158,255,0.1); }
.hero-card.selected-b { border-color: var(--team-b); background: rgba(255,85,85,0.1); }
.hero-card.unavailable { opacity: 0.35; cursor: not-allowed; }

.hero-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.hero-card-name { font-size: 0.85rem; font-weight: 700; }
.hero-card-role { font-size: 0.7rem; color: var(--text-secondary); }

.selected-heroes {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.selected-list { display: flex; gap: 6px; }
.selected-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.selected-badge.team-a { background: var(--team-a-dark); border: 1px solid var(--team-a); color: var(--team-a); }
.selected-badge.team-b { background: var(--team-b-dark); border: 1px solid var(--team-b); color: var(--team-b); }

.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-muted);
  padding: 0 8px;
}

.hero-detail-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hint-text { color: var(--text-muted); font-style: italic; }

.hero-detail-content { width: 100%; }
.hero-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.hero-detail-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
}
.hero-detail-title h3 { font-size: 1.2rem; }
.hero-detail-title .hero-faction { font-size: 0.8rem; color: var(--text-secondary); }

.hero-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.hero-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  text-align: center;
}
.hero-stat-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; }
.hero-stat-value { font-size: 1.1rem; font-weight: 700; }

.hero-cards-preview { display: flex; gap: 6px; flex-wrap: wrap; }
.card-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.75rem;
  width: 140px;
}
.card-preview-name { font-weight: 600; margin-bottom: 2px; }
.card-preview-atk { color: var(--damage); font-size: 0.7rem; }
.card-preview-spell { color: var(--text-secondary); font-size: 0.7rem; }

.setup-actions { display: flex; justify-content: center; gap: 16px; }

/* ============================
   HUD
   ============================ */
#hud {
  display: flex;
  align-items: center;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  gap: 16px;
  height: 60px;
}

.hud-team {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}
.hud-team-b { justify-content: flex-end; }

.nexus-hp {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nexus-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; color: var(--text-secondary); }
.nexus-bar {
  width: 80px;
  height: 10px;
  background: var(--bg-card);
  border-radius: 5px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}
.nexus-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s;
}
.nexus-bar-fill.team-a { background: var(--team-a); }
.nexus-bar-fill.team-b { background: var(--team-b); }
.nexus-hp-text { font-size: 0.8rem; font-weight: 700; min-width: 16px; }

.team-gold {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
}
.gold-icon { font-size: 0.9rem; }

.hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.phase-info { display: flex; align-items: center; gap: 8px; }
.phase-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 2px 10px;
  border-radius: 20px;
  color: var(--gold);
}
.round-label { font-size: 0.75rem; color: var(--text-secondary); }
.turn-info { font-size: 0.85rem; font-weight: 600; }
.hud-actions { display: flex; gap: 6px; }

/* ============================
   MAIN GAME LAYOUT
   ============================ */
#main-area {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ============================
   LEFT PANEL
   ============================ */
#left-panel {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-title {
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-dark);
}

#active-hero-panel { flex-shrink: 0; }

.no-hero {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.hero-display {
  padding: 12px;
}

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

.hero-token {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.hero-display-name { font-weight: 700; font-size: 0.9rem; }
.hero-display-role { font-size: 0.7rem; color: var(--text-secondary); }
.hero-display-exhausted { font-size: 0.65rem; color: var(--damage); font-weight: 600; }

.hero-hp-bar {
  margin-bottom: 8px;
}
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.bar-track {
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.bar-fill.hp { background: var(--green); }
.bar-fill.hp.low { background: var(--orange); }
.bar-fill.hp.critical { background: var(--damage); }
.bar-fill.mp { background: var(--team-a); }
.bar-fill.ap { background: var(--gold); }

.hero-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.stat-chip {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  text-align: center;
}
.stat-chip-label { font-size: 0.6rem; color: var(--text-muted); display: block; }
.stat-chip-val { font-size: 0.85rem; font-weight: 700; }

.status-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.status-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 20px;
  font-weight: 600;
}
.status-poison { background: #2a1a3a; color: #c080f0; border: 1px solid #6030a0; }
.status-immobilized { background: #1a2a3a; color: #4a9eff; border: 1px solid #2a4a7a; }
.status-marked { background: #3a1a1a; color: #ff5555; border: 1px solid #8a2020; }
.status-untargetable { background: #2a2a1a; color: #f0c040; border: 1px solid #8a6010; }
.status-retaliate { background: #2a1a0a; color: #f0a040; border: 1px solid #8a4010; }
.status-counter { background: #2a1a0a; color: #f0a040; border: 1px solid #8a4010; }
.status-armor-buff { background: #0a1a2a; color: #4a9eff; border: 1px solid #1a4a8a; }
.status-ap-boost { background: #2a2a0a; color: #f0c040; border: 1px solid #8a6010; }

.hero-items {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.item-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid;
  font-weight: 600;
}
.item-red   { background: #2a0a0a; color: #ff7777; border-color: #7a2020; }
.item-blue  { background: #0a0a2a; color: #7777ff; border-color: #20207a; }
.item-green { background: #0a2a0a; color: #77ff77; border-color: #207a20; }
.item-yellow{ background: #2a2a0a; color: #ffee77; border-color: #7a7a20; }
.item-purple{ background: #1a0a2a; color: #cc77ff; border-color: #5a2070; }

#hand-panel {
  flex: 1;
  overflow-y: auto;
}

.hand-cards {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hand-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.hand-card:hover { border-color: var(--gold); background: var(--bg-hover); }
.hand-card.selected { border-color: var(--gold); background: rgba(240,192,64,0.1); }
.hand-card.casting-disabled { opacity: 0.4; cursor: not-allowed; }

.hand-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.hand-card-name { font-size: 0.8rem; font-weight: 600; }
.hand-card-atk {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--damage);
  background: rgba(255,68,68,0.1);
  border: 1px solid rgba(255,68,68,0.3);
  border-radius: 4px;
  padding: 1px 6px;
}
.hand-card-spell { font-size: 0.7rem; color: var(--text-secondary); line-height: 1.3; }

#action-buttons {
  padding: 8px;
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-action { flex: 1; }
.btn-onward { background: var(--gold-dark); color: var(--gold); border: 1px solid var(--gold); }
.btn-onward:hover:not(:disabled) { background: #5a4010; box-shadow: 0 0 10px rgba(240,192,64,0.3); }

/* ============================
   BOARD
   ============================ */
#board-container {
  position: relative;
  overflow: hidden;
  background: #080c12;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board {
  display: grid;
  grid-template-columns: 100px 110px 130px 100px 130px 110px 100px;
  grid-template-rows: 140px 100px 140px;
  gap: 6px;
  padding: 16px;
}

.board-area {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  position: relative;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.board-area:hover { border-color: var(--border-light); }
.board-area.movable { border-color: var(--green); background: rgba(64,192,128,0.08); cursor: pointer; }
.board-area.movable:hover { background: rgba(64,192,128,0.15); }
.board-area.attackable { border-color: var(--damage); background: rgba(255,68,68,0.08); cursor: crosshair; }
.board-area.attackable:hover { background: rgba(255,68,68,0.15); }
.board-area.selected-area { border-color: var(--gold); background: rgba(240,192,64,0.08); }

.board-area.area-nexus-a { grid-column: 1; grid-row: 1 / span 3; background: rgba(74,158,255,0.05); border-color: var(--team-a-dark); }
.board-area.area-nexus-b { grid-column: 7; grid-row: 1 / span 3; background: rgba(255,85,85,0.05); border-color: var(--team-b-dark); }
.board-area.area-a-t1   { grid-column: 2; grid-row: 1; }
.board-area.area-a-l1   { grid-column: 3; grid-row: 1; }
.board-area.area-mid-l1 { grid-column: 4; grid-row: 1; background: rgba(255,255,255,0.02); }
.board-area.area-b-l1   { grid-column: 5; grid-row: 1; }
.board-area.area-b-t1   { grid-column: 6; grid-row: 1; }
.board-area.area-a-jgl  { grid-column: 2; grid-row: 2; background: rgba(64,192,128,0.05); }
.board-area.area-river  { grid-column: 3 / span 3; grid-row: 2; background: rgba(192,128,240,0.05); border-color: #3a2a5a; }
.board-area.area-b-jgl  { grid-column: 6; grid-row: 2; background: rgba(64,192,128,0.05); }
.board-area.area-a-t2   { grid-column: 2; grid-row: 3; }
.board-area.area-a-l2   { grid-column: 3; grid-row: 3; }
.board-area.area-mid-l2 { grid-column: 4; grid-row: 3; background: rgba(255,255,255,0.02); }
.board-area.area-b-l2   { grid-column: 5; grid-row: 3; }
.board-area.area-b-t2   { grid-column: 6; grid-row: 3; }

.area-name {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.area-structures { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }

.structure-display {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-dark);
  border-radius: 3px;
  padding: 3px 5px;
}
.structure-icon { font-size: 0.8rem; }
.structure-hp { font-size: 0.7rem; font-weight: 700; }
.structure-hp.team-a { color: var(--team-a); }
.structure-hp.team-b { color: var(--team-b); }
.structure-hp-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-panel);
  border-radius: 2px;
  overflow: hidden;
}
.structure-hp-fill { height: 100%; border-radius: 2px; }
.structure-hp-fill.team-a { background: var(--team-a); }
.structure-hp-fill.team-b { background: var(--team-b); }
.structure-hp-fill.nexus { background: var(--nexus-hp); }

.area-minions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-shrink: 0;
}
.minion-group {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  font-weight: 600;
}
.minion-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.minion-dot.team-a { background: var(--team-a); }
.minion-dot.team-b { background: var(--team-b); }

.area-heroes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  flex: 1;
  align-content: flex-start;
  overflow: hidden;
}

.board-hero-token {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  border: 2px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  flex-shrink: 0;
}
.board-hero-token:hover { transform: scale(1.1); }
.board-hero-token.active { border-color: var(--gold); box-shadow: 0 0 8px var(--gold); }
.board-hero-token.exhausted { opacity: 0.5; }
.board-hero-token.dead { opacity: 0.2; filter: grayscale(1); }
.board-hero-token .token-hp {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  font-size: 0.55rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.area-monsters {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 4px;
  flex-shrink: 0;
}
.monster-token {
  background: #1a1a0a;
  border: 1px solid #4a4010;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.6rem;
  color: var(--orange);
  cursor: pointer;
}
.monster-token:hover { border-color: var(--orange); }

.outsider-token {
  background: #1a0a2a;
  border: 1px solid var(--purple);
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 0.65rem;
  color: var(--purple);
  cursor: pointer;
  text-align: center;
  margin-top: 4px;
}

.area-momentum {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-shrink: 0;
}
.momentum-badge {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 20px;
  font-weight: 600;
}
.momentum-badge.team-a { background: rgba(74,158,255,0.15); color: var(--team-a); border: 1px solid rgba(74,158,255,0.3); }
.momentum-badge.team-b { background: rgba(255,85,85,0.15); color: var(--team-b); border: 1px solid rgba(255,85,85,0.3); }

/* Phase overlay */
#phase-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.phase-overlay-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px 32px;
  text-align: center;
  max-width: 400px;
}

/* ============================
   RIGHT PANEL
   ============================ */
#right-panel {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#shop-panel { flex-shrink: 0; max-height: 45%; display: flex; flex-direction: column; }

.shop-items {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
}

.shop-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s;
  gap: 6px;
}
.shop-item:hover:not(.cant-afford):not(.already-owned) { border-color: var(--gold); background: var(--bg-hover); }
.shop-item.cant-afford { opacity: 0.45; cursor: not-allowed; }
.shop-item.already-owned { opacity: 0.35; cursor: not-allowed; }

.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name { font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-item-effect { font-size: 0.65rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-item-cost { font-size: 0.75rem; font-weight: 700; color: var(--gold); white-space: nowrap; }

.shop-color-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

#log-panel { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.log-entries {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  flex-direction: column-reverse;
}

.log-entry {
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding: 3px 6px;
  border-radius: 3px;
  line-height: 1.3;
}
.log-entry.log-attack { color: var(--damage); }
.log-entry.log-heal { color: var(--heal); }
.log-entry.log-move { color: var(--text-secondary); }
.log-entry.log-spell { color: var(--purple); }
.log-entry.log-minion { color: var(--text-muted); }
.log-entry.log-phase { color: var(--gold); font-weight: 600; border-top: 1px solid var(--border); padding-top: 5px; margin-top: 2px; }
.log-entry.log-kill { color: var(--orange); font-weight: 600; }
.log-entry.log-nexus { color: #ff4444; font-weight: 700; font-size: 0.8rem; }

/* ============================
   MODALS
   ============================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5,7,10,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}

/* Plan modal */
.plan-modal-content h2 { text-align: center; margin-bottom: 4px; }
.plan-instructions { text-align: center; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 4px; }
.plan-secret-notice { text-align: center; color: var(--orange); font-size: 0.75rem; margin-bottom: 20px; font-style: italic; }
.plan-section-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.plan-hero-list { display: flex; gap: 8px; margin-bottom: 20px; }
.plan-hero-btn {
  flex: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.plan-hero-btn:hover:not(:disabled) { border-color: var(--border-light); background: var(--bg-hover); }
.plan-hero-btn.selected { border-color: var(--gold); background: rgba(240,192,64,0.1); }
.plan-hero-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.plan-hero-btn .phb-name { font-weight: 700; font-size: 0.85rem; }
.plan-hero-btn .phb-meta { font-size: 0.7rem; color: var(--text-secondary); }

.plan-card-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; max-height: 200px; overflow-y: auto; }
.plan-card-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.plan-card-btn:hover { border-color: var(--border-light); background: var(--bg-hover); }
.plan-card-btn.selected { border-color: var(--gold); background: rgba(240,192,64,0.1); }
.plan-card-btn .pcb-name { font-weight: 600; font-size: 0.8rem; }
.plan-card-btn .pcb-spell { font-size: 0.7rem; color: var(--text-secondary); }
.plan-card-btn .pcb-atk { font-size: 0.75rem; color: var(--damage); }

/* Attack modal */
.attack-modal-content { text-align: center; }
.attack-reveal-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 16px; }
.attack-card-display {
  background: var(--bg-card);
  border: 2px solid var(--damage);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.attack-card-value { font-size: 3rem; font-weight: 900; color: var(--damage); }
.attack-card-name { font-size: 0.9rem; color: var(--text-secondary); }
.attack-result-text { font-size: 1rem; color: var(--text-primary); margin-bottom: 20px; }

/* Spell modal */
.spell-modal-content { }
.spell-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.spell-description { font-size: 0.85rem; color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.spell-target-section { margin-bottom: 16px; }
.spell-section-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.spell-target-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.spell-target-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.spell-target-btn:hover { border-color: var(--gold); background: var(--bg-hover); }
.spell-target-btn.selected { border-color: var(--gold); background: rgba(240,192,64,0.1); }
.spell-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Item modal */
.item-modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.item-modal-body { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.item-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Save modal */
.save-modal-content h3 { margin-bottom: 12px; }
.save-name-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 8px 12px;
  margin-bottom: 16px;
  outline: none;
}
.save-name-input:focus { border-color: var(--team-a); }
.existing-saves { margin-bottom: 16px; }
.save-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Confirm modal */
.confirm-message { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 20px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Game over modal */
.gameover-modal-content { text-align: center; }
.gameover-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  margin-bottom: 8px;
}
.gameover-winner { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 16px; }
.gameover-stats { margin-bottom: 24px; font-size: 0.85rem; color: var(--text-muted); }

/* Outsider modal */
.outsider-modal-content h3 { margin-bottom: 8px; }
.outsider-reward-text { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 16px; }
.outsider-lanes { display: flex; gap: 12px; }

/* ============================
   UTILITIES
   ============================ */
.hidden { display: none !important; }
.text-a { color: var(--team-a); }
.text-b { color: var(--team-b); }
.text-gold { color: var(--gold); }
.text-damage { color: var(--damage); }
.text-heal { color: var(--heal); }

/* Damage flash animation */
@keyframes damage-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; background: rgba(255,68,68,0.4); }
}
.damage-flash { animation: damage-flash 0.4s ease; }

/* Heal flash */
@keyframes heal-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; background: rgba(68,255,136,0.3); }
}
.heal-flash { animation: heal-flash 0.4s ease; }

/* Floating damage numbers */
.float-num {
  position: absolute;
  font-size: 0.9rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 50;
  animation: float-up 1s ease forwards;
}
.float-num.damage { color: var(--damage); }
.float-num.heal { color: var(--heal); }

@keyframes float-up {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
  #main-area {
    grid-template-columns: 180px 1fr 180px;
  }
  #board {
    grid-template-columns: 70px 80px 100px 80px 100px 80px 70px;
    grid-template-rows: 110px 80px 110px;
  }
}
