* { box-sizing: border-box; }

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 15px;
  background: #2c3e50;
  overflow-x: hidden;
}

/* ─── Nav bar ──────────────────────────────────────────────────────────────── */

.nav-bar {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  background: #1a252f;
  padding: 10px 15px;
  border-radius: 8px;
}

.nav-link {
  color: #3498db;
  text-decoration: none;
  font-weight: bold;
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid #3498db;
  transition: all 0.2s;
}

.nav-link:hover {
  background: #3498db;
  color: white;
}

.nav-active {
  color: #ecf0f1;
  font-weight: bold;
  padding: 5px 12px;
}

.dm-role-btn {
  margin-left: 6px;
  cursor: pointer;
  font-size: 20px;
  padding: 2px 6px;
  border-radius: 5px;
  user-select: none;
  transition: background 0.15s;
}
.dm-role-btn:hover { background: rgba(255,255,255,0.1); }

/* ─── Game board layout ────────────────────────────────────────────────────── */

.container {
  display: flex;
  gap: 15px;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #1a252f;
  padding: 15px;
  border-radius: 10px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar h2, .sidebar h3 {
  margin-top: 0;
  color: #bdc3c7;
}

#unitForm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#unitForm input, #unitForm select {
  padding: 7px;
  border: 1px solid #4a6278;
  border-radius: 5px;
  font-size: 13px;
  background: #34495e;
  color: #ecf0f1;
}

#unitForm button {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 9px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
}

#unitForm button:hover { background: #c0392b; }

.game-area { flex: 1; min-width: 0; }

/* ─── Board ────────────────────────────────────────────────────────────────── */

.vp-wrap {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
}

#boardViewport {
  overflow: auto;
  max-height: 65vh;
  border-radius: 10px;
  touch-action: pan-x pan-y;
  scrollbar-width: thin;
  scrollbar-color: #4a6278 transparent;
  width: 100%;
}

.coord-display {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #ecf0f1;
  font-size: 11px;
  font-family: monospace;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 20;
  display: none;
}
#boardViewport::-webkit-scrollbar { width: 6px; height: 6px; }
#boardViewport::-webkit-scrollbar-thumb { background: #4a6278; border-radius: 3px; }
#boardViewport::-webkit-scrollbar-track { background: transparent; }

#board {
  display: grid;
  gap: 1px;
  background: #34495e;
  padding: 8px;
  width: fit-content;
  position: relative;
}

.tile {
  width: 50px;
  height: 50px;
  background: #2c3e50;
  border: 1px solid #3d566e;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.tile:hover { background: #34495e; }

/* ─── Units on board ───────────────────────────────────────────────────────── */

.unit {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.15s;
}

.unit:hover { transform: scale(1.05); }

.unit.enemy {
  background: rgba(231, 76, 60, 0.2);
  border-radius: 6px;
}

.unit.hero {
  background: rgba(52, 152, 219, 0.2);
  border-radius: 6px;
}

.unit.piece-incapacitated {
  opacity: 0.5;
  box-shadow: 0 0 0 3px #e74c3c inset;
  filter: grayscale(50%);
}

/* 2-letter name abbreviation on board */
.unit-label {
  font-size: 15px;
  font-weight: bold;
  line-height: 1;
  letter-spacing: 0.5px;
}

.unit-label.unit  { color: #c0392b; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.unit-label.hero  { color: #1a6fa8; }

.unit-num {
  font-size: 10px;
  font-weight: bold;
  opacity: 0.7;
  line-height: 1;
}

/* Hero initials badge on hero list */
.hero-avatar {
  font-size: 20px;
  font-weight: bold;
  color: #2c3e50;
  background: #bdc3c7;
  border-radius: 6px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* HP / MP bars on board pieces */
.hp-track {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  height: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: #e74c3c;
  border-radius: 2px;
  transition: width 0.25s;
}

.mp-track {
  position: absolute;
  bottom: 8px;
  left: 2px;
  right: 2px;
  height: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
  overflow: hidden;
}

.mp-fill {
  height: 100%;
  background: #3498db;
  border-radius: 2px;
  transition: width 0.25s;
}

/* ─── Highlights ───────────────────────────────────────────────────────────── */

.move-range {
  background-color: #3498db !important;
  box-shadow: inset 0 0 0 2px #2980b9;
}

.attack-range {
  background-color: #e74c3c !important;
  box-shadow: inset 0 0 0 2px #c0392b;
}

.deploy-range {
  background-color: rgba(46, 204, 113, 0.4) !important;
  box-shadow: inset 0 0 0 2px #27ae60;
  cursor: crosshair;
}

.ranged-range {
  background-color: rgba(155, 89, 182, 0.4) !important;
  box-shadow: inset 0 0 0 2px #8e44ad;
}

.spell-range {
  background-color: rgba(26, 188, 156, 0.4) !important;
  box-shadow: inset 0 0 0 2px #16a085;
}

.aoe-preview {
  background-color: rgba(192, 57, 43, 0.45) !important;
  box-shadow: inset 0 0 0 2px #e74c3c;
}

/* ─── Controls ─────────────────────────────────────────────────────────────── */

.controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.controls button {
  padding: 9px 16px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
}

.controls button:hover { background: #2980b9; }

.mode-btn { background: #95a5a6 !important; }
.mode-btn:hover { background: #7f8c8d !important; }
.mode-btn.active { background: #27ae60 !important; }
.mode-btn.active:hover { background: #229954 !important; }

.turn-banner {
  display: flex;
  align-items: center;
  background: #2c3e50;
  color: #ecf0f1;
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: bold;
  min-height: 42px;
}

/* ─── Deploy banner ────────────────────────────────────────────────────────── */

.deploy-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #27ae60;
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-weight: bold;
}

.btn-cancel-deploy {
  background: rgba(0,0,0,0.2);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

/* ─── Sidebar lists ────────────────────────────────────────────────────────── */

.units-list-item {
  background: #34495e;
  padding: 7px;
  margin-bottom: 4px;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  color: #ecf0f1;
}

.units-list-item:hover { background: #3d566e; }

.units-list-item.corpse {
  background: #2c3e50;
  opacity: 0.6;
  cursor: default;
}

.units-list-item.corpse:hover { background: #2c3e50; }

.fallen-header {
  color: #95a5a6;
  margin: 10px 0 5px;
  font-size: 13px;
}

.delete-unit {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}


/* ─── Turn queue ───────────────────────────────────────────────────────────── */

.turn-queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 7px;
  margin-bottom: 3px;
  border-radius: 5px;
  font-size: 12px;
  background: #34495e;
  color: #ecf0f1;
  border-left: 3px solid transparent;
}

.turn-queue-item.turn-queue-active {
  background: #3a3020;
  border-left-color: gold;
  font-weight: bold;
}

.turn-queue-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-queue-init {
  flex-shrink: 0;
  margin-left: 6px;
  color: #7f8c8d;
  font-size: 11px;
}

.turn-queue-empty {
  font-size: 12px;
  color: #999;
  margin: 4px 0;
}

/* ─── Heroes page ──────────────────────────────────────────────────────────── */

.heroes-container {
  display: flex;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-form-panel {
  width: 340px;
  flex-shrink: 0;
  background: #1a252f;
  padding: 20px;
  border-radius: 10px;
  height: fit-content;
}

.hero-form-panel h2 {
  margin-top: 0;
  color: #bdc3c7;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
}

.form-row label {
  font-size: 12px;
  font-weight: bold;
  color: #95a5a6;
}

.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 7px;
  border: 1px solid #4a6278;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: #34495e;
  color: #ecf0f1;
}

.form-row-full {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.multi-select {
  position: relative;
}

.multi-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px;
  border: 1px solid #4a6278;
  border-radius: 5px;
  background: #34495e;
  color: #ecf0f1;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}

.multi-select-trigger:hover { border-color: #6c8da3; }

.multi-select-arrow { color: #95a5a6; font-size: 11px; }

.multi-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: #34495e;
  border: 1px solid #4a6278;
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
  padding: 4px 0;
}

.multi-select-dropdown.open { display: block; }

.race-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #ecf0f1;
}

.race-option:hover { background: #3d566e; }

.race-option input[type="checkbox"] { cursor: pointer; }

.form-divider {
  margin: 12px 0;
  border-color: #3d566e;
}

.form-section-title {
  margin: 0 0 8px;
  color: #95a5a6;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-create {
  width: 100%;
  background: #27ae60;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  margin-top: 5px;
}

.btn-create:hover { background: #229954; }

/* Hero list panel */
.hero-list-panel {
  flex: 1;
}

.hero-list-panel h2 {
  color: #ecf0f1;
  margin-top: 0;
}

.hero-card {
  background: #34495e;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.hero-card.hero-dead { opacity: 0.5; }
.hero-card.hero-incapacitated { opacity: 0.65; border-left: 3px solid #e74c3c; }

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

.hero-avatar { font-size: 36px; }

.hero-title {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hero-title strong { font-size: 16px; color: #ecf0f1; }

.hero-sub { font-size: 12px; color: #7f8c8d; }

.enemy-rank-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #4a5568;
  color: #e2e8f0;
  margin-top: 2px;
  align-self: flex-start;
}
.enemy-tier-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  margin-top: 2px;
  align-self: flex-start;
}
.enemy-tier-badge { background: #5a6a82; }

.hero-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: bold;
}

.badge-deployed { background: #27ae60; color: white; }
.badge-bench { background: #95a5a6; color: white; }
.badge-dead { background: #7f8c8d; color: white; }

.btn-deploy {
  background: #3498db;
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
}

.btn-deploy:hover { background: #2980b9; }

.btn-recall {
  background: #e67e22;
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
}

.btn-recall:hover { background: #d35400; }

.btn-delete {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  padding: 5px 8px;
}

.btn-delete:hover { background: #c0392b; }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  color: #bdc3c7;
}

/* ─── Bestiary page ────────────────────────────────────────────────────────── */

.bestiary-container {
  display: flex;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Template/hero picker selects */
#templateSelect,
#templateEditSelect,
#heroSelect {
  padding: 7px;
  border: 1px solid #4a6278;
  border-radius: 5px;
  font-size: 13px;
  background: #34495e;
  color: #ecf0f1;
  cursor: pointer;
  width: 100%;
}

.hero-abilities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #95a5a6;
  background: rgba(255,255,255,0.06);
  padding: 6px 8px;
  border-radius: 6px;
}

.hero-notes {
  margin-top: 6px;
  font-size: 12px;
  color: #95a5a6;
  background: rgba(255,255,255,0.05);
  border-left: 3px solid #4a6278;
  padding: 5px 8px;
  border-radius: 0 4px 4px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── Spell panel ──────────────────────────────────────────────────────────── */

#spellPanel {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: #1a252f;
  border-radius: 8px;
}

.spell-btn {
  background: #16a085;
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
  transition: background 0.15s;
}

.spell-btn:hover { background: #1abc9c; }

.spell-btn.disabled {
  background: #555;
  color: #999;
  cursor: not-allowed;
  pointer-events: none;
}

.spell-btn.spell-hp-cost {
  background: #922b21;
  border: 1px solid #e74c3c;
}

.spell-btn.spell-hp-cost:hover { background: #c0392b; }

.dm-edit-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.dm-edit-row button {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
  background: #6c3483;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}

.dm-edit-row button:hover { background: #8e44ad; }

.log-entry.log-dm { border-left-color: #8e44ad; color: #bb8fce; font-style: italic; }

/* ─── Board saves panel ─────────────────────────────────────────────────────── */

.saves-add-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

#saveNameInput {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #4a6278;
  border-radius: 5px;
  font-size: 12px;
  background: #34495e;
  color: #ecf0f1;
}

.save-btn-save {
  padding: 6px 9px;
  font-size: 12px;
  background: #2980b9;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.save-btn-save:hover { background: #3498db; }

.saves-empty {
  color: #888;
  font-size: 12px;
  text-align: center;
  padding: 6px 0;
}

.save-item {
  background: #34495e;
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.save-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.save-item-name {
  font-size: 12px;
  font-weight: bold;
  color: #ecf0f1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-item-date {
  font-size: 10px;
  color: #888;
  margin-top: 1px;
}

.save-btn-load {
  padding: 3px 7px;
  font-size: 11px;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.save-btn-load:hover { background: #2ecc71; }

.save-btn-delete {
  padding: 3px 6px;
  font-size: 11px;
  background: transparent;
  color: #e74c3c;
  border: 1px solid #e74c3c;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.save-btn-delete:hover { background: #e74c3c; color: white; }

/* ─── Combat log ───────────────────────────────────────────────────────────── */

#combatLog {
  margin-top: 10px;
  background: #1a252f;
  border-radius: 8px;
  overflow: hidden;
}

.log-header {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: bold;
  color: #7f8c8d;
  border-bottom: 1px solid #2c3e50;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-clear-log {
  background: transparent;
  border: 1px solid #7f8c8d;
  color: #7f8c8d;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-clear-log:hover { color: #ecf0f1; border-color: #ecf0f1; }

.btn-reset-round { border-color: #e74c3c; color: #e74c3c; }
.btn-reset-round:hover { color: #e74c3c; border-color: #e74c3c; background: rgba(231,76,60,0.15); }

#logEntries {
  max-height: 180px;
  overflow-y: auto;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}

.log-entry {
  padding: 3px 12px;
  font-size: 12px;
  color: #ecf0f1;
  border-left: 3px solid transparent;
}

.log-entry.log-damage { border-left-color: #e74c3c; }
.log-entry.log-spell  { border-left-color: #1abc9c; }
.log-entry.log-death  { border-left-color: #7f8c8d; color: #95a5a6; }
.log-entry.log-turn   { border-left-color: #f39c12; color: #f39c12; }
.log-entry.log-round  { border-left-color: #9b59b6; color: #9b59b6; font-weight: bold; }

/* ─── End Combat button ────────────────────────────────────────────────────── */

.btn-end-combat {
  background: #7f8c8d !important;
  margin-left: auto;
}

/* ─── Detail panel ──────────────────────────────────────────────────────────── */

.board-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.detail-panel {
  width: 180px;
  flex-shrink: 0;
  background: #1a252f;
  border-radius: 10px;
  overflow: hidden;
  height: fit-content;
}

.detail-header {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: bold;
  color: #7f8c8d;
  border-bottom: 1px solid #2c3e50;
}

.detail-empty {
  color: #7f8c8d;
  font-size: 12px;
  padding: 10px 12px;
  margin: 0;
}

.detail-body {
  padding: 10px 12px;
}

.detail-name {
  font-size: 14px;
  font-weight: bold;
  color: #ecf0f1;
  margin-bottom: 10px;
}

.detail-hp-label {
  font-size: 11px;
  color: #7f8c8d;
  margin-bottom: 3px;
}

.detail-hp-track {
  background: #2c3e50;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}

.detail-hp-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s, background 0.3s;
}

.detail-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #bdc3c7;
}

.btn-end-combat:hover { background: #636e72 !important; }

.btn-viewport {
  background: transparent;
  border: 1px solid #4a6278;
  color: #95a5a6;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
}
.btn-viewport:hover { color: #ecf0f1; border-color: #ecf0f1; }

.zoom-label {
  display: inline-flex;
  align-items: center;
  color: #95a5a6;
  font-size: 13px;
  min-width: 34px;
  justify-content: center;
  cursor: pointer;
  border: 1px solid #4a6278;
  border-radius: 5px;
  padding: 4px 6px;
}
.zoom-label:hover { color: #ecf0f1; border-color: #ecf0f1; }

/* ─── Walls ─────────────────────────────────────────────────────────────────── */

.wall-seg {
  position: absolute;
  background: #c0392b;
  border-radius: 3px;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 0 4px rgba(0,0,0,0.6);
}

.wall-preview {
  position: absolute;
  background: rgba(192, 57, 43, 0.45);
  border-radius: 3px;
  pointer-events: none;
  z-index: 11;
  border: 1px dashed rgba(192, 57, 43, 0.8);
}

.wall-preview.wall-preview-remove {
  background: rgba(127, 140, 141, 0.45);
  border-color: rgba(127, 140, 141, 0.8);
}

.wall-controls {
  margin-bottom: 6px;
}

.wall-controls button {
  padding: 6px 14px;
  background: #7f8c8d;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
}

.wall-controls button:hover { background: #636e72; }

.wall-mode-active {
  background: #e67e22 !important;
}

.wall-mode-active:hover { background: #d35400 !important; }

/* ─── Gold panel ────────────────────────────────────────────────────────────── */

.gold-total {
  padding: 6px 10px;
  background: #2c3e50;
  border-radius: 6px;
  color: #f1c40f;
  font-size: 13px;
  font-weight: bold;
}
.gold-mission {
  margin-top: 4px;
  padding: 4px 10px;
  background: #1a252f;
  border-radius: 6px;
  color: #f39c12;
  font-size: 12px;
}
.gold-kills-list {
  margin-bottom: 4px;
}
.gold-kill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px;
  font-size: 12px;
  color: #bbb;
}
.gold-kill-row:hover {
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
}
.gold-kill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}
.gold-kill-badge {
  font-size: 11px;
  color: #f1c40f;
  font-weight: bold;
  flex-shrink: 0;
  margin-left: 6px;
}
.gold-kill-count {
  padding: 4px 10px;
  font-size: 12px;
  color: #bbb;
}
.mission-info-card {
  margin-top: 6px;
  padding: 6px 8px;
  background: #2c3e50;
  border-radius: 6px;
  font-size: 12px;
}
.mission-type-badge {
  display: inline-block;
  padding: 2px 6px;
  background: #1a252f;
  border-radius: 4px;
  color: #aaa;
  font-size: 11px;
  margin-bottom: 4px;
}
.mission-desc {
  color: #bdc3c7;
  margin: 4px 0 2px;
  font-size: 11px;
}
.mission-economy {
  color: #f1c40f;
  font-weight: bold;
  margin-top: 4px;
}

/* ─── Theme toggle button ────────────────────────────────────────────────────── */

.theme-switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.theme-switch-icon { font-size: 14px; line-height: 1; }

.theme-switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: #34495e;
  border-radius: 11px;
  border: 1px solid #4a6278;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}

.theme-switch-track.is-light {
  background: #3498db;
  border-color: #2980b9;
}

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transform: translateX(18px);
}

.theme-switch-track.is-light .theme-switch-knob {
  transform: translateX(0);
}

/* ─── Race cards (shared) ────────────────────────────────────────────────────── */

.races-container {
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 20px;
}

.races-title {
  font-size: 22px;
  font-weight: bold;
  color: #ecf0f1;
  margin-bottom: 20px;
}

.races-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.race-card {
  background: #2c3e50;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #3d5166;
}

.race-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.race-icon {
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}

.race-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.race-name {
  font-size: 18px;
  font-weight: bold;
  color: #ecf0f1;
}

.race-tagline {
  font-size: 12px;
  color: #95a5a6;
  font-style: italic;
}

.race-description {
  font-size: 13px;
  color: #bdc3c7;
  line-height: 1.6;
  margin-bottom: 14px;
  border-bottom: 1px solid #3d5166;
  padding-bottom: 12px;
}

.race-traits {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.race-trait {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  color: #ecf0f1;
}

.trait-icon {
  flex-shrink: 0;
  font-size: 14px;
  margin-top: 1px;
}

.trait-text strong { color: #f1c40f; }

.race-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #3d5166;
}

.race-stat-badge {
  background: #1a252f;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
  color: #95a5a6;
}

.race-stat-badge span {
  color: #3498db;
  font-weight: bold;
}

/* ─── Light Theme ────────────────────────────────────────────────────────────── */

html[data-theme="light"] body               { background: #f0f4f8; }

html[data-theme="light"] .nav-bar           { background: #dde8f5; }
html[data-theme="light"] .nav-active        { color: #1a3a52; }
html[data-theme="light"] .nav-link          { color: #2471a3; border-color: #2471a3; }
html[data-theme="light"] .nav-link:hover    { background: #2471a3; color: white; }
html[data-theme="light"] .dm-role-btn:hover { background: rgba(0,0,0,0.08); }

html[data-theme="light"] .theme-switch-track { background: #bdc3c7; border-color: #95a5a6; }
html[data-theme="light"] .theme-switch-track.is-light { background: #2471a3; border-color: #1a5e87; }

html[data-theme="light"] .sidebar          { background: #ffffff; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
html[data-theme="light"] .sidebar h2,
html[data-theme="light"] .sidebar h3       { color: #1a3a52; }
html[data-theme="light"] #unitForm input,
html[data-theme="light"] #unitForm select  { background: #f8f9fa; border-color: #c8d6e5; color: #2c3e50; }
html[data-theme="light"] .fallen-header    { color: #5d7a8c; }
html[data-theme="light"] .turn-queue-empty { color: #5d7a8c; }

html[data-theme="light"] .units-list-item       { background: #f8f9fa; color: #2c3e50; }
html[data-theme="light"] .units-list-item:hover { background: #e2eaf4; }
html[data-theme="light"] .units-list-item.corpse       { background: #e5e8ea; }
html[data-theme="light"] .units-list-item.corpse:hover { background: #e5e8ea; }

html[data-theme="light"] .turn-queue-item              { background: #f8f9fa; color: #2c3e50; }
html[data-theme="light"] .turn-queue-item.turn-queue-active { background: #fffbea; }
html[data-theme="light"] .turn-queue-init              { color: #5d7a8c; }

html[data-theme="light"] .gold-total      { background: #fff8e1; color: #b7950b; }
html[data-theme="light"] .gold-mission    { background: #fef9e7; color: #d4890a; }
html[data-theme="light"] .gold-kill-row   { color: #3d5166; }
html[data-theme="light"] .gold-kill-row:hover { background: rgba(0,0,0,0.04); }
html[data-theme="light"] .gold-kill-badge { color: #b7950b; }
html[data-theme="light"] .gold-kill-count { color: #5d7a8c; }
html[data-theme="light"] .mission-info-card { background: #f4f6f7; }
html[data-theme="light"] .mission-type-badge { background: #e8eaed; color: #555; }
html[data-theme="light"] .mission-desc { color: #555; }
html[data-theme="light"] .mission-economy { color: #b7950b; }

html[data-theme="light"] #boardViewport { scrollbar-color: #8fa8c2 transparent; }
html[data-theme="light"] #boardViewport::-webkit-scrollbar-thumb { background: #8fa8c2; }
html[data-theme="light"] .btn-viewport  { color: #5d7a8c; border-color: #5d7a8c; }
html[data-theme="light"] .btn-viewport:hover { color: #2c3e50; border-color: #2c3e50; }
html[data-theme="light"] .zoom-label   { color: #5d7a8c; border-color: #5d7a8c; }
html[data-theme="light"] .zoom-label:hover { color: #2c3e50; border-color: #2c3e50; }
html[data-theme="light"] #board        { background: #8fa8c2; }
html[data-theme="light"] .tile         { background: #f8f9fa; border-color: #c8d6e5; }
html[data-theme="light"] .tile:hover   { background: #e2eaf4; }

html[data-theme="light"] .turn-banner  { background: #dde8f5; color: #1a3a52; }

html[data-theme="light"] #spellPanel   { background: #dde8f5; }

html[data-theme="light"] #combatLog    { background: #dde8f5; }
html[data-theme="light"] .log-header   { border-bottom-color: #c8d6e5; color: #5d7a8c; }
html[data-theme="light"] .btn-clear-log        { color: #5d7a8c; border-color: #5d7a8c; }
html[data-theme="light"] .btn-clear-log:hover  { color: #2c3e50; border-color: #2c3e50; }
html[data-theme="light"] .log-entry            { color: #2c3e50; }

html[data-theme="light"] .detail-panel     { background: #ffffff; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
html[data-theme="light"] .detail-header    { border-bottom-color: #c8d6e5; color: #5d7a8c; }
html[data-theme="light"] .detail-name      { color: #1a3a52; }
html[data-theme="light"] .detail-hp-label  { color: #5d7a8c; }
html[data-theme="light"] .detail-hp-track  { background: #e2eaf4; }
html[data-theme="light"] .detail-stats     { color: #3d5166; }
html[data-theme="light"] .detail-empty     { color: #5d7a8c; }

html[data-theme="light"] .hero-form-panel    { background: #ffffff; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
html[data-theme="light"] .hero-form-panel h2 { color: #1a3a52; }
html[data-theme="light"] .hero-list-panel h2 { color: #1a3a52; }
html[data-theme="light"] .hero-card          { background: #ffffff; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
html[data-theme="light"] .hero-title strong  { color: #1a3a52; }
html[data-theme="light"] .hero-stats         { color: #2c3e50; }
html[data-theme="light"] .hero-abilities     { background: rgba(0,0,0,0.05); color: #555; }
html[data-theme="light"] .hero-notes         { background: rgba(0,0,0,0.04); color: #666; border-left-color: #bdc3c7; }
html[data-theme="light"] .form-row label     { color: #555; }
html[data-theme="light"] .form-row input,
html[data-theme="light"] .form-row select,
html[data-theme="light"] .form-row textarea  { background: #f8f9fa; border-color: #c8d6e5; color: #2c3e50; }
html[data-theme="light"] .form-section-title { color: #2c3e50; }
html[data-theme="light"] .form-divider       { border-color: #c8d6e5; }
html[data-theme="light"] .multi-select-trigger    { background: #f8f9fa; border-color: #c8d6e5; color: #2c3e50; }
html[data-theme="light"] .multi-select-dropdown   { background: #ffffff; border-color: #c8d6e5; }
html[data-theme="light"] .race-option             { color: #2c3e50; }
html[data-theme="light"] .race-option:hover       { background: #e2eaf4; }

html[data-theme="light"] #templateSelect,
html[data-theme="light"] #templateEditSelect,
html[data-theme="light"] #heroSelect         { background: #f8f9fa; border-color: #c8d6e5; color: #2c3e50; }

html[data-theme="light"] .races-title        { color: #1a3a52; }
html[data-theme="light"] .race-card          { background: #ffffff; border-color: #c8d6e5; }
html[data-theme="light"] .race-name          { color: #1a3a52; }
html[data-theme="light"] .race-tagline       { color: #5d7a8c; }
html[data-theme="light"] .race-description   { color: #3d5166; border-bottom-color: #c8d6e5; }
html[data-theme="light"] .race-trait         { color: #2c3e50; }
html[data-theme="light"] .race-stats         { border-top-color: #c8d6e5; }
html[data-theme="light"] .race-stat-badge    { background: #f0f4f8; color: #5d7a8c; }

html[data-theme="light"] #saveNameInput      { background: #f8f9fa; border-color: #c8d6e5; color: #2c3e50; }
html[data-theme="light"] .save-item          { background: #f8f9fa; }
html[data-theme="light"] .save-item-name     { color: #1a3a52; }
html[data-theme="light"] .save-item-date     { color: #5d7a8c; }

html[data-theme="light"] .classes-title      { color: #1a3a52; }
html[data-theme="light"] .class-card         { background: #ffffff; border-color: #c8d6e5; }
html[data-theme="light"] .class-name         { color: #1a3a52; }
html[data-theme="light"] .class-tagline      { color: #5d7a8c; }
html[data-theme="light"] .class-description  { color: #3d5166; }
html[data-theme="light"] .class-section-title { color: #5d7a8c; }
html[data-theme="light"] .class-trait        { color: #2c3e50; }
html[data-theme="light"] .class-upgrades     { background: #f0f4f8; }
html[data-theme="light"] .class-upgrades-title { color: #5d7a8c; }
html[data-theme="light"] .upgrade-row        { color: #2c3e50; }
html[data-theme="light"] .upgrade-name       { color: #1a3a52; }
html[data-theme="light"] .magic-tag          { background: rgba(36,113,163,0.12); color: #1a5e87; }

/* ─── Smooth theme transitions ──────────────────────────────────────────────── */
/* Enabled 50ms after page load so the initial render has no flash          */

html.transitions-enabled body,
html.transitions-enabled .nav-bar,
html.transitions-enabled .sidebar,
html.transitions-enabled .sidebar h2,
html.transitions-enabled .sidebar h3,
html.transitions-enabled .turn-banner,
html.transitions-enabled .units-list-item,
html.transitions-enabled .turn-queue-item,
html.transitions-enabled .save-item,
html.transitions-enabled .hero-card,
html.transitions-enabled .hero-form-panel,
html.transitions-enabled .hero-list-panel h2,
html.transitions-enabled .hero-title strong,
html.transitions-enabled .hero-stats,
html.transitions-enabled .hero-abilities,
html.transitions-enabled .hero-notes,
html.transitions-enabled .detail-panel,
html.transitions-enabled .detail-header,
html.transitions-enabled .detail-name,
html.transitions-enabled .detail-stats,
html.transitions-enabled .detail-empty,
html.transitions-enabled #combatLog,
html.transitions-enabled .log-entry,
html.transitions-enabled #spellPanel,
html.transitions-enabled #unitForm input,
html.transitions-enabled #unitForm select,
html.transitions-enabled .form-row input,
html.transitions-enabled .form-row select,
html.transitions-enabled .form-row textarea,
html.transitions-enabled .form-row label,
html.transitions-enabled .form-section-title,
html.transitions-enabled .form-divider,
html.transitions-enabled #templateSelect,
html.transitions-enabled #templateEditSelect,
html.transitions-enabled #heroSelect,
html.transitions-enabled #saveNameInput,
html.transitions-enabled .save-item-name,
html.transitions-enabled .multi-select-trigger,
html.transitions-enabled .multi-select-dropdown,
html.transitions-enabled .race-card,
html.transitions-enabled .race-name,
html.transitions-enabled .race-description,
html.transitions-enabled .race-stat-badge,
html.transitions-enabled .class-card,
html.transitions-enabled .class-name,
html.transitions-enabled .class-description,
html.transitions-enabled .class-upgrades,
html.transitions-enabled .magic-tag {
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.3s ease, box-shadow 0.3s ease;
}
