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

:root {
  --bg: #080b12;
  --bg2: #0e1320;
  --bg3: #141c2e;
  --bg4: #1a2238;
  --border: #1e2d45;
  --border-bright: #2a3f5e;
  --accent: #e65c00;
  --accent2: #ffb300;
  --accent3: #00aacc;
  --text: #c8d8e8;
  --text-dim: #6a7d90;
  --text-bright: #e8f0f8;
  --red: #cc2244;
  --green: #33aa66;
  --radius: 6px;
  --shadow: 0 2px 16px rgba(0,0,0,0.6);
}

html { scroll-behavior: smooth; }
body {
  background:
    linear-gradient(180deg, rgba(4,5,9,0.88) 0%, rgba(4,5,9,0.94) 60%, var(--bg) 100%),
    url('../img/hive-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* iOS Safari: background-attachment:fixed is a known rendering bug — swap it out on touch devices */
@supports (-webkit-touch-callout: none) {
  body { background-attachment: scroll; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

/* ── Navbar ────────────────────────────────────────────────────────────── */
.navbar {
  background: linear-gradient(180deg, #0a0e18 0%, #0d1220 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-shrink: 0;
}

.skull { color: var(--accent); font-size: 18px; }

.brand-text {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--text-bright);
  font-family: monospace;
}

.sub-brand {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  font-family: monospace;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  align-items: center;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-bright);
  background: var(--bg3);
  border-color: var(--border);
}

.nav-links a.active { color: var(--accent); }

.btn-nav {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  font-weight: 600 !important;
}

.btn-nav:hover { background: var(--accent2) !important; border-color: var(--accent2) !important; }

.btn-nav-plain {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.nav-icon { font-size: 12px; }

/* ── Flash Messages ────────────────────────────────────────────────────── */
.flash-container { position: fixed; top: 64px; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: opacity 0.5s;
  min-width: 240px;
}
.flash-success { background: #1a3a2a; border: 1px solid var(--green); color: #80e0a0; }
.flash-error { background: #3a1a1a; border: 1px solid var(--red); color: #ff8080; }
.flash-warning { background: #3a2a00; border: 1px solid var(--accent2); color: #ffd080; }

/* ── Main Layout ───────────────────────────────────────────────────────── */
.main-content { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── Page Header ───────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.5px;
}

.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #ff7a20; color: #fff; border-color: #ff7a20; }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border-bright); }
.btn-secondary:hover { background: var(--bg4); color: var(--text-bright); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 12px; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 11px; }
.btn-lg { padding: 0.6rem 1.4rem; font-size: 14px; }

/* ── Dashboard ─────────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-section, .section-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.dashboard-side {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-number { font-size: 28px; font-weight: 800; color: var(--accent); font-family: monospace; }
.stat-label { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; margin-top: 0.2rem; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Data Tables ────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg3);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:hover td { background: var(--bg3); }
.data-table tr:last-child td { border-bottom: none; }

.table-scroll { overflow-x: auto; }

/* Stats table specific */
.stat-table th, .stat-table td { padding: 0.4rem 0.5rem; }
.stat { text-align: center; font-family: monospace; font-size: 12px; color: var(--text-bright); font-weight: 600; }
.fighter-name { font-weight: 600; color: var(--text-bright); white-space: nowrap; }
.fighter-type { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.credits { font-family: monospace; color: var(--accent2); }

.fighter-dead td { opacity: 0.5; }
.fighter-recovery td { opacity: 0.75; }

.rank { color: var(--text-dim); font-family: monospace; }

.gang-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.gang-link { color: var(--text-bright); font-weight: 600; }
.gang-link:hover { color: var(--accent); }

.rep-badge { background: var(--bg3); border: 1px solid var(--border-bright); color: var(--accent2); padding: 1px 6px; border-radius: 3px; font-family: monospace; font-size: 12px; font-weight: 700; }
.faction-badge { font-size: 11px; color: var(--text-dim); }
.territory-count { color: var(--text-dim); font-family: monospace; }
.territory-count.has-territories { color: var(--accent); font-weight: 700; }

/* ── Gang Cards ─────────────────────────────────────────────────────────── */
.gang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.gang-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}

.gang-card:hover { border-color: var(--gang-color, var(--accent)); transform: translateY(-2px); }

.gang-card-header { display: flex; align-items: stretch; }
.gang-color-bar { width: 4px; flex-shrink: 0; }
.gang-card-title { padding: 0.9rem 1rem; flex: 1; }
.gang-card-title h3 { font-size: 15px; font-weight: 700; margin-bottom: 0.2rem; }
.gang-card-title h3 a { color: var(--text-bright); }
.gang-card-title h3 a:hover { color: var(--accent); }
.faction-tag { font-size: 11px; color: var(--text-dim); }

.gang-card-stats {
  display: flex;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.mini-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  border-right: 1px solid var(--border);
}
.mini-stat:last-child { border-right: none; }
.mini-val { font-size: 14px; font-weight: 700; font-family: monospace; color: var(--text-bright); }
.mini-label { font-size: 9px; color: var(--text-dim); letter-spacing: 0.5px; }

.gang-card-actions { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; }

/* ── Game Cards ─────────────────────────────────────────────────────────── */
.game-list { display: flex; flex-direction: column; gap: 0.75rem; }

.game-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.game-vs {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.gang-name-tag {
  padding: 2px 8px;
  border: 1px solid var(--border-bright);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
}

.vs-text { color: var(--accent); font-weight: 800; font-size: 11px; font-family: monospace; }

.game-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-left: auto; }
.scenario { font-size: 11px; color: var(--text-dim); }
.territory-tag { font-size: 11px; color: var(--accent3); }
.winner-tag { font-size: 11px; color: var(--accent2); font-weight: 600; }
.loss-tag { font-size: 11px; color: var(--red); font-weight: 600; }
.draw-tag { font-size: 11px; color: var(--text-dim); }
.game-date { font-size: 11px; color: var(--text-dim); font-family: monospace; white-space: nowrap; }

/* Full game cards in battle log */
.game-full-list { display: flex; flex-direction: column; gap: 0.75rem; }

.game-card.full {
  align-items: stretch;
  padding: 1rem 1.2rem;
  gap: 1rem;
}

.game-number { font-family: monospace; font-size: 11px; color: var(--text-dim); min-width: 30px; }
.game-main { flex: 1; }

.game-vs-large {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.combatant { display: flex; align-items: center; gap: 0.5rem; }
.combatant-dot { width: 12px; height: 12px; border-radius: 50%; }
.combatant-name { font-weight: 700; color: var(--text-bright); font-size: 14px; }
.combatant-score { font-family: monospace; font-size: 18px; font-weight: 800; color: var(--accent2); margin-left: 0.5rem; }

.vs-center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.vs-badge { font-size: 11px; font-weight: 800; color: var(--accent); font-family: monospace; }
.result-arrow { font-size: 11px; font-weight: 700; color: var(--green); }
.draw-center { font-size: 10px; color: var(--text-dim); }

.combatant.defender { flex-direction: row-reverse; }

.game-details-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.detail-tag { padding: 2px 7px; border-radius: 3px; font-size: 11px; }
.scenario-tag { background: var(--bg4); color: var(--text-dim); border: 1px solid var(--border); }
.date-tag { background: transparent; color: var(--text-dim); font-family: monospace; }

.game-notes { font-size: 12px; color: var(--text-dim); margin-top: 0.4rem; font-style: italic; }
.game-card-actions { display: flex; align-items: flex-start; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-container { max-width: 700px; }
.form-container.wide { max-width: 960px; }

.form-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.form-section h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.form-input {
  background: var(--bg3);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text-bright);
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.15s;
}

.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(230,92,0,0.15); }
.form-input option { background: var(--bg3); }

textarea.form-input { resize: vertical; }

.form-hint { font-size: 11px; color: var(--text-dim); }

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-top: 0.5rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  z-index: 10;
}

/* Color picker */
.color-picker { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.color-option { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.color-option input[type="radio"] { display: none; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
}
.color-option input:checked + .color-swatch { border-color: #fff; transform: scale(1.15); }
.color-option input[type="color"] { width: 28px; height: 28px; border: none; border-radius: 50%; cursor: pointer; padding: 0; background: none; }

/* ── Stat Grid (fighter create) ─────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.75rem; }
.stat-input-group { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.stat-input-group label { font-size: 11px; font-weight: 700; color: var(--accent2); text-align: center; letter-spacing: 0.5px; }
.stat-input { text-align: center; width: 70px; padding: 0.4rem; font-size: 14px; font-weight: 700; font-family: monospace; }
.stat-unit { font-size: 11px; color: var(--text-dim); }

/* ── Gang Overview (detail page) ────────────────────────────────────────── */
.gang-overview {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.overview-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.2rem;
  min-width: 90px;
}

.ov-val { font-size: 22px; font-weight: 800; font-family: monospace; color: var(--text-bright); }
.ov-label { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; margin-top: 0.1rem; }

.faction-badge-lg { background: var(--bg3); border: 1px solid var(--border-bright); color: var(--text-dim); padding: 3px 10px; border-radius: 3px; font-size: 12px; margin-top: 0.3rem; display: inline-block; }

.notes-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 13px; color: var(--text-dim); font-style: italic; }

/* Section blocks */
.section-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.section-block h2 {
  font-size: 14px; font-weight: 700; color: var(--text-bright);
  margin-bottom: 1rem; display: flex; align-items: center; gap: 0.4rem;
}

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.section-header h2 { margin-bottom: 0; }

/* Status select */
.status-select {
  padding: 2px 6px;
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
}
.status-active { border-color: var(--green) !important; color: var(--green) !important; }
.status-recovery { border-color: var(--accent2) !important; color: var(--accent2) !important; }
.status-captured { border-color: var(--accent) !important; color: var(--accent) !important; }
.status-dead { border-color: var(--red) !important; color: var(--red) !important; }

.inline-form { display: inline; }

/* Equipment tags */
.equip-cell { max-width: 200px; }
.equip-tag {
  display: inline-block;
  margin: 1px 2px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
}
.equip-weapon { background: rgba(204,34,68,0.15); border: 1px solid var(--red); color: #ff8080; }
.equip-armour { background: rgba(0,100,200,0.15); border: 1px solid #0066cc; color: #80aaff; }
.equip-wargear { background: rgba(100,100,0,0.15); border: 1px solid #888800; color: #cccc60; }

.actions-cell { white-space: nowrap; }

/* ── Equipment Page ─────────────────────────────────────────────────────── */
.equip-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; }

.equip-info { position: sticky; top: 70px; align-self: start; display: flex; flex-direction: column; gap: 1rem; }

.fighter-profile-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.fighter-profile-card h3 { color: var(--text-bright); font-size: 16px; font-weight: 700; }
.profile-type { color: var(--accent); font-size: 12px; margin-top: 0.2rem; }
.profile-gang { color: var(--text-dim); font-size: 11px; }

.equip-summary {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.equip-summary h3 { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem; }

.selected-equip-list { display: flex; flex-direction: column; gap: 0.3rem; min-height: 40px; }
.sel-item { font-size: 12px; color: var(--text); display: flex; justify-content: space-between; }
.sel-item em { color: var(--accent2); font-style: normal; }
.no-equip { font-size: 12px; color: var(--text-dim); font-style: italic; }

.equip-total { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-dim); }
.equip-total strong { color: var(--accent2); }

.equip-main { min-width: 0; }

.equip-category {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.equip-cat-header { font-size: 14px; font-weight: 700; color: var(--text-bright); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 1px; }
.equip-subgroup { margin-bottom: 0.75rem; }
.equip-subtype { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--border); }

.equip-item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.5rem; }

.equip-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.equip-item:hover { border-color: var(--border-bright); background: var(--bg4); }
.equip-item.selected { border-color: var(--accent); background: rgba(230,92,0,0.08); }
.equip-item.rarity-rare { border-color: rgba(170,100,200,0.3); }

.equip-item input[type="checkbox"] { position: absolute; top: 0.5rem; right: 0.5rem; accent-color: var(--accent); }
.equip-name { font-size: 12px; font-weight: 600; color: var(--text-bright); padding-right: 18px; }
.equip-cost { font-size: 11px; color: var(--accent2); font-family: monospace; }
.equip-desc { font-size: 10px; color: var(--text-dim); font-style: italic; line-height: 1.3; }
.rarity-badge { font-size: 9px; color: #c080e0; letter-spacing: 0.5px; }

/* ── Territory section ───────────────────────────────────────────────────── */
.territory-list { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.territory-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 180px;
  max-width: 220px;
}
.territory-name { font-weight: 600; color: var(--text-bright); font-size: 13px; }
.territory-type-badge { font-size: 10px; color: var(--accent3); margin: 0.2rem 0; text-transform: uppercase; letter-spacing: 0.5px; }
.territory-income { font-size: 11px; color: var(--text-dim); font-style: italic; }

/* ── Map ─────────────────────────────────────────────────────────────────── */
.map-layout { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; align-items: start; }
.map-container { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.map-controls { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg3); }
.map-hint { font-size: 11px; color: var(--text-dim); }
.map-wrapper { overflow: hidden; cursor: grab; user-select: none; }
.map-wrapper:active { cursor: grabbing; }
#territoryMap { display: block; transition: transform 0.05s linear; }

.territory-node { transition: opacity 0.15s; }
.territory-node:hover { opacity: 0.9; }

/* Map sidebar */
.map-sidebar { display: flex; flex-direction: column; gap: 1rem; }

.legend-panel, .territory-detail, .territory-counts {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.legend-panel h3, .territory-detail h3, .territory-counts h3 {
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 0.75rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.legend-item { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; font-size: 12px; color: var(--text); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.territory-detail { min-height: 180px; }
.detail-placeholder { font-size: 12px; color: var(--text-dim); font-style: italic; }
.detail-name { font-size: 15px; font-weight: 700; color: var(--text-bright); margin-bottom: 0.3rem; }
.detail-type { font-size: 11px; color: var(--accent3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.detail-control { font-size: 12px; margin-bottom: 0.5rem; }
.detail-gang { font-weight: 700; }
.detail-unclaimed { color: var(--text-dim); }
.detail-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 0.5rem; line-height: 1.4; }
.detail-income { font-size: 12px; color: var(--text); margin-bottom: 0.75rem; }

.count-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; font-size: 12px; }
.count-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.count-name { flex: 1; color: var(--text); }
.count-num { font-family: monospace; font-weight: 700; color: var(--text-bright); }
.count-row.unclaimed .count-name { color: var(--text-dim); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 1.5rem;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}

.modal h3 { font-size: 16px; font-weight: 700; color: var(--text-bright); margin-bottom: 0.5rem; }
.modal p { font-size: 13px; color: var(--text-dim); margin-bottom: 0.5rem; line-height: 1.4; }
.modal-income { font-size: 12px; color: var(--accent2); margin-bottom: 1rem; }

/* ── Versus layout (game create) ─────────────────────────────────────────── */
.versus-layout { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.5rem; align-items: start; }
.versus-side h3 { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem; }
.versus-center-display { display: flex; align-items: center; justify-content: center; padding-top: 2rem; }
.vs-divider { font-size: 24px; color: var(--accent); }
.gang-select { font-size: 13px; }
.score-input { text-align: center; font-size: 18px; font-weight: 700; font-family: monospace; }

/* ── Empty States ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2rem; color: var(--text-dim); }
.empty-state p { margin-bottom: 1rem; }
.empty-state.large { padding: 4rem 2rem; }
.empty-icon { font-size: 48px; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h2 { font-size: 18px; color: var(--text); margin-bottom: 0.5rem; }

/* Alert */
.alert { padding: 1rem 1.2rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.alert-warning { background: rgba(255,180,0,0.1); border: 1px solid var(--accent2); color: var(--accent2); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
  letter-spacing: 0.5px;
}
.footer-skull { letter-spacing: 6px; color: #1e2a38; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { flex-direction: row; flex-wrap: wrap; }
  .stat-card { flex: 1; min-width: 100px; }
  .map-layout { grid-template-columns: 1fr; }
  .equip-layout { grid-template-columns: 1fr; }
  .equip-info { position: static; }
  .versus-layout { grid-template-columns: 1fr; }
  .versus-center-display { display: none; }
  .nav-brand .sub-brand { display: none; }
}

@media (max-width: 600px) {
  .navbar { padding: 0 0.75rem; gap: 0.5rem; }
  .nav-links { gap: 0; }
  .nav-links a .nav-label { display: none; }
  /* "+ Record Battle" is redundant on mobile — the same action exists as a
     page-level button on the Dashboard/Battle Log pages, and there isn't
     room for its full-text label alongside icon nav + the login control
     without overflowing the fixed-height navbar (see Log In/Out below,
     which stays since it's the one nav item with no on-page equivalent). */
  .nav-record-battle { display: none; }
  .btn-nav { padding: 0.3rem 0.5rem !important; font-size: 12px !important; }
  .brand-text { font-size: 11px; letter-spacing: 1px; }
  .main-content { padding: 1rem; }
  .gang-grid { grid-template-columns: 1fr; }
  .stat-table { font-size: 11px; }
  .stat-table th, .stat-table td { padding: 0.3rem; }
}
