/* ── Gear depth (CP10): sets & curses ── */
.gear-curse { color: #ff6b6b; font-weight: bold; }
.gear-sets { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.set-row { font-size: 12px; color: var(--text-dim, #9aa); }
.set-tier { display: inline-block; margin-left: 6px; opacity: 0.5; }
.set-tier-on { opacity: 1; color: #7CFC9B; }

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

:root {
  --bg:           #0d1117;
  --bg-panel:     #161b22;
  --bg-card:      #1c2230;
  --border:       #30363d;
  --border-light: #484f58;
  --text:         #e6edf3;
  --text-muted:   #8b949e;

  --attack:       #c0392b;
  --attack-light: #e74c3c;
  --skill:        #2471a3;
  --skill-light:  #3498db;
  --power:        #9b59b6;
  --power-light:  #a66bbe;

  --common:       #8b949e;
  --uncommon:     #3fb950;
  --rare:         #e3b341;
  --epic:         #b06bff;
  --legendary:    #ff8c00;

  --energy:       #f39c12;
  --energy-low:   #e74c3c;

  --drop-idle:    rgba(255,255,255,0.04);
  --drop-active:  rgba(52, 152, 219, 0.25);
  --drop-border:  #3498db;

  --radius:       10px;
  --card-w:       120px;
  --card-h:       170px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  user-select: none;
  overflow: hidden;
}

#game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}
.hidden { display: none !important; }

.mp-net-status {
  position: fixed;
  z-index: 10000;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border: 1px solid #d7a929;
  border-radius: 5px;
  background: #17130b;
  color: #f5d66f;
  box-shadow: 0 4px 18px #000b;
  font-weight: 700;
}

.mp-reconnecting #game,
.mp-reconnecting #map-view,
.mp-reconnecting #main-menu {
  pointer-events: none;
}

/* ── Main menu + save feedback ── */
.main-menu {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 25%, rgba(155, 89, 182, 0.18), transparent 38%),
    linear-gradient(180deg, #111824, #090c11);
}
.main-menu-card {
  width: min(460px, calc(100vw - 32px));
  padding: 44px;
  text-align: center;
  background: rgba(22, 27, 34, 0.96);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.main-menu-kicker {
  color: var(--rare);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.main-menu h1 { margin-top: 8px; font-size: 40px; }
.main-menu p { margin: 10px 0 26px; color: var(--text-muted); line-height: 1.5; }
/* CP16 crawler picker on the main menu */
.char-select { display: flex; gap: 10px; justify-content: center; margin: 0 0 22px; flex-wrap: wrap; }
.char-select.hidden { display: none; }
.char-slot {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 110px; padding: 12px 8px;
  background: var(--bg-card); border: 2px solid var(--border); border-radius: 12px;
  color: var(--text); cursor: pointer; transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.char-slot:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--border-light); }
.char-slot.selected { border-color: var(--rare); background: rgba(155,89,182,0.12); }
.char-slot.char-locked { opacity: 0.55; cursor: not-allowed; }
.char-portrait { font-size: 34px; line-height: 1; }
.char-name { font-size: 14px; font-weight: bold; }
.char-hint { font-size: 10px; color: var(--text-muted); text-align: center; line-height: 1.3; min-height: 24px; }
.char-slot.selected .char-hint { color: var(--rare); }

/* Main-menu secondary links (Cookbook) + the Anarchist's Cookbook modal */
.main-menu-extras { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }
.menu-link { background: none; border: 1px solid var(--border-light); color: var(--text-muted); border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.menu-link:hover { color: var(--text); border-color: var(--rare); }
.cb-gear-locked { opacity: 0.4; filter: grayscale(1); }
/* Opened from the main menu (z-index 3000) — must sit above it. */
#cookbook-modal { z-index: 4500; }
.cookbook-box { width: 92vw; max-width: 820px; max-height: 88vh; display: flex; flex-direction: column; }
.cookbook-tabs { display: flex; gap: 6px; padding: 8px 16px 0; border-bottom: 1px solid var(--border); }
.cb-tab { background: none; border: 1px solid var(--border); border-bottom: none; color: var(--text-muted); border-radius: 8px 8px 0 0; padding: 7px 16px; cursor: pointer; font-size: 13px; }
.cb-tab.active { background: var(--bg-card); color: var(--text); border-color: var(--border-light); }
.cookbook-body { overflow-y: auto; max-height: 72vh; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: none; }
.cookbook-body::-webkit-scrollbar { display: none; }
/* Run history tab */
.cb-empty { color: var(--text-muted); text-align: center; padding: 32px 12px; }
.runs-summary { display: flex; gap: 22px; padding: 8px 4px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.runs-summary b { color: var(--text); font-size: 15px; }
.runs-list { display: flex; flex-direction: column; gap: 6px; }
.run-row { display: grid; grid-template-columns: 64px 1.4fr 1fr 1.4fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 6px; font-size: 12px; background: var(--bg-card); }
.run-row.run-win { border-left-color: var(--uncommon); }
.run-row.run-loss { border-left-color: #a23b3b; }
.run-result { font-weight: 700; }
.run-win .run-result { color: var(--uncommon); }
.run-loss .run-result { color: #e0796b; }
.run-crawler { color: var(--text); font-weight: 600; }
.run-floor, .run-meta { color: var(--text-muted); }
.run-when { color: var(--text-muted); font-size: 11px; text-align: right; }
.run-row.run-clickable { cursor: pointer; transition: background .12s, border-color .12s; }
.run-row.run-clickable:hover { background: rgba(255,255,255,0.05); border-color: var(--rare); }
.run-detail-result { font-size: 12px; font-weight: 700; margin-top: 2px; }
.run-detail-result.run-win { color: var(--uncommon); }
.run-detail-result.run-loss { color: #e0796b; }
.cb-count { color: var(--text-muted); font-size: 12px; }
.cb-entry { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.cb-entry.locked { opacity: 0.5; }
.cb-classes { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.cb-class { font-size: 12px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; }
.cb-class.locked { color: var(--text-muted); }
.cb-class-cards { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.cb-card-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-card-section { margin-top: 14px; }
.cb-section-head { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.cb-section-head .be-mini { color: var(--text-muted); font-weight: 400; }
.cookbook-footer { border-top: 1px solid var(--border); padding: 10px 16px; display: flex; justify-content: flex-end; }
.cookbook-footer .menu-danger { padding: 6px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.be-portrait { font-size: 30px; line-height: 1; }
.be-info { flex: 1; min-width: 0; }
.be-name { font-size: 15px; font-weight: bold; }
.be-mini { font-size: 11px; color: var(--text-muted); font-weight: normal; }
.be-flavor { font-size: 12px; color: var(--text-muted); margin: 4px 0; line-height: 1.4; }
.be-moves { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.be-move { font-size: 11px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.be-move.cb-hoverable { cursor: help; }
.be-move.cb-hoverable:hover { border-color: var(--rare); color: var(--text); }

.main-menu-actions { display: grid; gap: 10px; }
.main-menu-actions button {
  border-radius: 8px;
  padding: 12px 18px;
  color: white;
  font-size: 15px;
  font-weight: 750;
  cursor: pointer;
}
.main-menu-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.55);
}
.menu-primary {
  border: 1px solid #58a6ff;
  background: linear-gradient(135deg, #1f6feb, #388bfd);
}
.menu-danger {
  border: 1px solid #f85149;
  background: rgba(248, 81, 73, 0.12);
}

/* ── Co-op movement voting (CP17 / MP3 D2) ── */
.vote-status {
  display: inline-block; margin: 2px 0 6px 14px; z-index: 50;
  background: rgba(20, 26, 38, 0.92); border: 1px solid var(--rare); color: #e6edf6;
  border-radius: 8px; padding: 6px 12px; font-size: 13px; pointer-events: none;
}
.hex.vote-choice { outline: 2px solid #ffd479; outline-offset: -2px; }
.vote-badge {
  position: absolute; top: -6px; right: -6px; z-index: 4;
  background: #ffd479; color: #0d1117; font-weight: 800; font-size: 11px;
  border-radius: 10px; padding: 1px 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ── Multiplayer lobby (CP17 / MP2) ── */
.mm-view.hidden { display: none; }
.mp-field { text-align: left; margin: 4px 0 14px; }
.mp-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
#mp-name, #mp-code {
  width: 100%; box-sizing: border-box; background: #1a2230; color: #e6edf6;
  border: 1px solid #38445a; border-radius: 6px; padding: 9px 11px; font-size: 15px;
}
#mp-code { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; }
.mp-join-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.mp-join-row #mp-code { width: 120px; }
.mp-join-row button { flex: 1; border-radius: 8px; padding: 10px 16px; color: #fff; font-weight: 700; cursor: pointer; }
#mm-multi-back, #mm-single-back { margin-top: 14px; }

.mp-code-banner { margin: 2px 0 16px; color: var(--text-muted); font-size: 14px; }
.mp-code-banner .mp-code { color: #ffd479; font-family: ui-monospace, monospace; font-size: 22px; letter-spacing: 5px; font-weight: 800; }
.mp-lobby-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; text-align: left; margin-bottom: 18px; }
@media (max-width: 640px) { .mp-lobby-grid { grid-template-columns: 1fr; } }
.mp-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px; }
#mp-player-list { display: flex; flex-direction: column; gap: 6px; }
.mp-player {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.mp-player.mp-you { border-color: var(--rare); }
.mp-player.mp-empty { opacity: 0.4; font-style: italic; }
.mp-pname { font-weight: 700; }
.mp-pchar { color: var(--text-muted); }
.mp-nopick { font-style: italic; }
.mp-ready, .mp-waiting { margin-left: auto; }
.mp-ready { color: #57d38c; font-weight: 700; }
.mp-waiting { color: var(--text-muted); }
.mp-charpick .char-select { justify-content: flex-start; margin-bottom: 0; }
.main-menu-error {
  margin-top: 18px;
  padding: 10px 12px;
  color: #ffb4ae;
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.45);
  border-radius: 7px;
  line-height: 1.4;
}
.save-status {
  position: fixed;
  z-index: 4000;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 9px 13px;
  color: #b7f7c3;
  background: rgba(22, 27, 34, 0.96);
  border: 1px solid var(--uncommon);
  border-radius: 7px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.save-status.save-error {
  color: #ffb4ae;
  border-color: #f85149;
}
.save-quit-btn {
  color: var(--text);
  background: #21262d;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
}

/* ── Map view ── */
#map-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  padding: 12px;
  gap: 8px;
  position: relative;   /* anchors the floating descend prompt */
  overflow: hidden;
}
#map-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 24px;
  flex-shrink: 0;
}
.map-crawler { display: flex; align-items: center; gap: 12px; }
.map-hp-line { font-size: 13px; color: var(--text); }
.map-pets-line { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.map-status-line { display: flex; gap: 5px; margin-top: 3px; flex-wrap: wrap; }
.map-pets-line .pet-downed { color: var(--attack-light); text-decoration: line-through; }
.map-vital { cursor: help; }
.map-status-line .status-pill, .map-pet-statuses .status-pill { cursor: help; }
.map-pet-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.map-pet-statuses { display: flex; gap: 4px; flex-wrap: wrap; }
.level-badge {
  font-size: 11px;
  font-weight: bold;
  color: #000;
  background: var(--rare);
  border-radius: 5px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
/* CP18 18o: the level-up cue lives on the PORTRAIT now — glow + a "+N stat points" badge. */
.crawler-portrait.has-points {
  border-color: var(--uncommon);
  animation: badge-glow 1.2s ease-in-out infinite;
}
.crawler-portrait.has-points::after {
  content: attr(data-points);
  position: absolute; top: -7px; right: -7px;
  background: var(--uncommon); color: #000;
  font-size: 10px; font-weight: 800;
  border-radius: 9px; padding: 0 5px; line-height: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.55);
}
@keyframes badge-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(63,185,80,0); }
  50% { box-shadow: 0 0 12px rgba(63,185,80,0.8); }
}
.xp-bar {
  position: relative;
  width: 150px;
  height: 13px;
  background: #1a2233;
  border: 1px solid var(--border-light);
  border-radius: 7px;
  overflow: hidden;
  margin-top: 3px;
}
.xp-fill {
  position: absolute; inset: 0;
  width: 0%;
  background: linear-gradient(90deg, #6a4fb8, #9b59b6);
  transition: width 0.4s ease;
}
.xp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: bold; color: #e6dcf5;
  text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}
.xp-bar[data-tip] { cursor: help; }
/* Each pet gets its own (smaller) XP bar in its row — pets level independently of the crawler. */
.pet-xp-bar { width: 110px; height: 11px; margin-top: 0; }
.pet-xp-bar .xp-fill { background: linear-gradient(90deg, #138d75, #1abc9c); }
.pet-xp-bar .xp-text { font-size: 8px; color: #dffff6; }
.map-pet-hp { cursor: help; }

/* Disabled action styling (shared) */
.ca-disabled { opacity: 0.4; pointer-events: none; }

/* Desperado shop */
.shop-gold { text-align: center; font-size: 16px; color: var(--energy); margin-bottom: 8px; }
.shop-cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.shop-sold { opacity: 0.35; filter: grayscale(1); }
.shop-buy {
  background: linear-gradient(135deg, #7d5c00, #b8860b);
  color: #fff; border: 1px solid var(--energy);
  border-radius: 6px; padding: 6px 16px; font-size: 13px; font-weight: bold; cursor: pointer;
}
.shop-buy:hover { filter: brightness(1.15); }
.shop-services { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.shop-service {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-radius: 8px; padding: 10px 16px; font-size: 13px; cursor: pointer;
}
.shop-service:hover { border-color: var(--rare); }
#floor-name { font-size: 20px; font-weight: bold; color: var(--rare); letter-spacing: 0.03em; white-space: nowrap; text-align: center; padding: 0 12px; }

#turn-counter {
  text-align: center;
  background: var(--bg-card);
  border: 2px solid var(--skill);
  border-radius: 10px;
  padding: 6px 20px;
  position: relative;
}
#turn-counter span { font-size: 26px; font-weight: 800; color: var(--text); }
#turn-counter .turn-sep { font-size: 18px; opacity: 0.5; }
#turn-counter .turn-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase; }
#turn-counter.turns-critical { border-color: var(--attack-light); animation: pulse-red 0.9s infinite; }

/* CP18: Explore control + map-turn fuse readout */
#map-turn-control { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#explore-btn {
  background: var(--skill); color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: filter 0.12s, transform 0.1s;
}
#explore-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
#map-turn-control .turn-timer { font-size: 11px; color: var(--text-muted); }
#map-turn-control .turn-timer b { color: var(--skill-light); font-size: 13px; }
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 rgba(231,76,60,0); }
  50% { box-shadow: 0 0 18px rgba(231,76,60,0.6); }
}
.map-stats { display: flex; gap: 18px; align-items: center; }
#map-gold-display { font-size: 18px; font-weight: bold; color: var(--energy); }
#map-deck-display {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 8px;
  transition: color 0.15s, border-color 0.15s;
}
#map-deck-display:hover { color: var(--text); border-color: var(--border-light); }
#map-gear-display { font-size: 18px; font-weight: bold; color: var(--text-muted); cursor: pointer; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; transition: color 0.15s, border-color 0.15s; }
#map-gear-display:hover { color: var(--text); border-color: var(--border-light); }
#map-box-display { font-size: 18px; font-weight: bold; color: var(--rare); cursor: pointer; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; transition: border-color 0.15s, filter 0.15s; }
#map-box-display:hover { border-color: var(--rare); filter: brightness(1.15); }
.lootbox-readonly { cursor: default; }
.lootbox-readonly:hover { transform: none; box-shadow: none; }

/* Loot boxes */
.sr-boxes-btn {
  display: block; width: 100%; margin-bottom: 14px;
  background: linear-gradient(135deg, #5a3d1a, #b8860b);
  color: #fff; border: 2px solid var(--rare); border-radius: 8px;
  padding: 10px; font-size: 14px; font-weight: bold; cursor: pointer;
}
.sr-boxes-btn:hover { filter: brightness(1.15); }
.lootbox-grid { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.lootbox {
  width: 110px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px 8px; cursor: pointer; transition: transform 0.12s, box-shadow 0.15s;
}
.lootbox:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.5); }
.lootbox-icon { font-size: 38px; line-height: 1; }
.lootbox-tier { font-size: 13px; font-weight: bold; }
.lootbox-cat { font-size: 10px; color: var(--text-muted); }
.box-open-title { font-size: 20px; font-weight: 800; text-align: center; margin-bottom: 12px; }
.box-result-actions { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 14px; }
.stat-gear { font-size: 11px; color: var(--uncommon); margin-left: 3px; vertical-align: super; }
.stat-sub { font-size: 10px; color: var(--text-muted); }

/* Upgraded card values, highlighted in card text */
.up-val { color: var(--uncommon); font-weight: bold; }
/* Effective (buffed/weakened) damage shown on cards */
.dmg-up { color: var(--uncommon); font-weight: bold; }
.dmg-down { color: var(--attack-light); font-weight: bold; }
.blk-up { color: var(--skill-light); font-weight: bold; }
/* Gear-granted card marker in deck viewer */
.card-granted {
  position: absolute;
  top: 4px; right: 5px;
  font-size: 13px;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));
}
/* Card breakdown tooltip lines */
.tip-cost { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
/* Delivery indicator — how the card's damage/debuffs land (what shield stops them). */
.tip-delivery { font-size: 11px; margin: 0 0 6px; display: flex; flex-direction: column; gap: 1px; }
.tip-deliver { font-weight: 700; }
.tip-deliver.phys { color: #e0796b; }
.tip-deliver.magic { color: var(--skill-light); }
.tip-deliver.pierce { color: var(--rare); }
.tip-deliver-note { color: var(--text-muted); font-weight: 400; }
.tip-dmg { font-size: 12px; color: var(--text); margin-top: 4px; }
.tip-dmg b { color: var(--attack-light); }
.tip-blk { font-size: 12px; color: #acd2ff; margin-top: 4px; }
.tip-heal { font-size: 12px; color: var(--uncommon); margin-top: 4px; }
.tip-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
/* Stat tooltip */
.tip-statkey { font-size: 10px; color: var(--text-muted); margin-left: auto; letter-spacing: 0.08em; }
.tip-head { justify-content: flex-start; }
.tip-effect { font-size: 12px; color: var(--text); margin-top: 4px; line-height: 1.4; }
.tip-line { margin: 2px 0; }
.tip-line .tip-dim { color: var(--text-muted); font-size: 11px; }
.tip-placeholder { color: var(--rare); font-style: italic; }

/* ── Equipment modal ── */
.gear-modal-body { padding: 16px 20px; max-height: 70vh; overflow-y: auto; }
.gear-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 4px 0 10px; }
.gear-slots { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.gear-slot {
  width: 120px; min-height: 120px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--bg-card);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 6px; text-align: center;
}
.gear-slot-filled { border-style: solid; border-color: var(--uncommon); cursor: pointer; }
.gear-slot-filled:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.gear-slot-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.gear-icon { font-size: 28px; line-height: 1; margin-top: 2px; }
.gear-empty { opacity: 0.3; }
.gear-empty-label { color: var(--text-muted); font-size: 11px; font-style: italic; }
.gear-name { font-size: 12px; font-weight: bold; color: var(--text); }
.gear-slot-tag { font-size: 9px; color: var(--text-muted); text-transform: uppercase; }
.gear-effects { font-size: 10px; color: var(--uncommon); line-height: 1.3; }
.gear-remove { font-size: 9px; color: var(--text-muted); margin-top: auto; }

.gear-inventory { display: flex; flex-direction: column; gap: 8px; }
.gear-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left-width: 3px; border-radius: 8px; padding: 8px 12px;
}
.gear-item .gear-icon { font-size: 24px; margin: 0; }
.gear-item-info { flex: 1; }
/* Gear uses the SAME rarity tiers as cards (Bronze→Celestial). Left accent for list rows. */
.gear-rarity-bronze    { border-left-color: #cd7f32; }
.gear-rarity-silver    { border-left-color: #c0c0c0; }
.gear-rarity-gold      { border-left-color: #ffd700; }
.gear-rarity-platinum  { border-left-color: #7fdfff; }
.gear-rarity-legendary { border-left-color: #ff8c00; }
.gear-rarity-celestial { border-left-color: #b06bff; }
/* Rarity bar at the bottom of a gear card (mirrors the card-type-label bar on cards). */
.gear-rarity-bronze    .card-type-label { border-top-color: #cd7f32; color: #cd7f32; }
.gear-rarity-silver    .card-type-label { border-top-color: #c0c0c0; color: #c0c0c0; }
.gear-rarity-gold      .card-type-label { border-top-color: #ffd700; color: #ffd700; }
.gear-rarity-platinum  .card-type-label { border-top-color: #7fdfff; color: #7fdfff; }
.gear-rarity-legendary .card-type-label { border-top-color: #ff8c00; color: #ff8c00; }
.gear-rarity-celestial .card-type-label { border-top-color: #b06bff; color: #b06bff; }
/* Gear set block in the hover tooltip. */
.tip-set { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.tip-set-name { font-size: 11px; font-weight: 700; color: var(--rare); }
.tip-set-pieces { font-size: 10px; color: var(--text-muted); margin: 2px 0 4px; }
.tip-set-bonus { font-size: 10px; color: var(--text); }
/* A gear's granted card shown as its own nested context window inside the gear tooltip. */
.tip-granted-card { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.tip-granted-inner { margin-top: 4px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,0.03); }
.gear-equip-btn {
  background: var(--uncommon); color: #000; border: none; border-radius: 6px;
  padding: 6px 14px; font-size: 12px; font-weight: bold; cursor: pointer;
}
.gear-equip-btn:hover { filter: brightness(1.15); }
.gear-equip-btn.equipped { background: var(--border); color: var(--text-muted); cursor: default; }
.gear-equip-btn.equipped:hover { filter: none; }
.gear-empty-msg { color: var(--text-muted); font-style: italic; padding: 12px; text-align: center; }

/* Loot-box "equip in place" section */
.box-gear-title { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 8px; }
.box-gear-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.box-gear-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.box-gear-loadout { justify-content: center; }

/* Safe Room / choice modal */
.choice-body { padding: 20px; }
.choice-intro { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; text-align: center; }
.choice-intro b { color: var(--text); }
.choice-actions { display: flex; gap: 14px; justify-content: center; }
.choice-action {
  flex: 1;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.choice-action:hover { border-color: var(--rare); transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.4); }
.ca-icon { font-size: 30px; }
.ca-title { font-size: 15px; font-weight: bold; }
.ca-done { font-size: 11px; color: var(--rare); font-weight: normal; }
.ca-desc { font-size: 11px; color: var(--text-muted); text-align: center; line-height: 1.4; }
.choice-leave {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 12px;
  cursor: pointer;
}
.choice-leave:hover { color: var(--text); border-color: var(--border-light); }
.card-pickable { cursor: pointer; transition: transform 0.12s, box-shadow 0.15s; }
.card-pickable:hover { transform: translateY(-6px) scale(1.05) !important; box-shadow: 0 10px 26px rgba(227,179,65,0.4); z-index: 2; }

#map-banner {
  background: rgba(127,214,160,0.08);
  border-left: 3px solid #7fd6a0;
  border-radius: 4px;
  padding: 8px 14px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: #b6f0cd;
  min-height: 20px;
  flex-shrink: 0;
}
#map-banner b { color: #e6ffe6; }

/* The grid is a fixed viewport that CLIPS the (possibly larger) hex canvas. The canvas inside is
   click-dragged to pan around big floors — no scrollbars. */
#map-grid {
  flex: 1;
  min-height: 0;               /* let the flex item fill (and clip) instead of growing to content */
  position: relative;
  width: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;          /* we handle panning ourselves via pointer events */
}
#map-grid.map-dragging { cursor: grabbing; }
#map-canvas {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;       /* panned via translate() */
}

/* A mob token sliding tile→tile on the map (movement animation). The wrapper sits centered on a tile
   center; its inner icon is what actually animates (translate + fog fade), so centering stays clean. */
.map-token-fly {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;                   /* above hexes, below tooltips */
}
.map-token-icon { font-size: 30px; line-height: 1; will-change: transform, opacity; }

/* Pointy-top hexagon. The colored fill is the cell bg; we fake a "border" with an
   inner ::before so the clip-path edges still read as outlined. */
.hex {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--border);            /* acts as the hex outline */
  opacity: 0.9;
  transition: transform 0.12s, filter 0.12s, opacity 0.2s;
}
/* Hovering a tile lifts it above its neighbors (and above sliding tokens) so its full label + art
   reads clearly; it drops back to its layer on mouse-out. */
.hex.hex-hover { z-index: 40; transform: scale(1.07); opacity: 1; }
.hex::before {
  content: '';
  position: absolute;
  inset: 3px;                           /* outline thickness */
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--bg-card);
  z-index: 0;
}
.hex > * { position: relative; z-index: 1; }

.room-icon { font-size: 30px; line-height: 1; }
.room-label { font-size: 10px; color: var(--text-muted); }
.room-you {
  position: absolute;
  bottom: 16px;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.08em;
  color: #000;
  background: var(--rare);
  border-radius: 4px;
  padding: 1px 6px;
}

.room-here {
  background: var(--rare);
  opacity: 1;
  z-index: 4;
  transform: scale(1.1);
  animation: here-pulse 1.4s ease-in-out infinite;
}
/* tint the interior gold so it doesn't read like a plain rare tile */
.room-here::before { background: linear-gradient(rgba(227,179,65,0.20), rgba(227,179,65,0.20)), var(--bg-card); }
@keyframes here-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(227,179,65,0.5)); }
  50%      { filter: drop-shadow(0 0 18px rgba(227,179,65,0.95)); }
}
.room-reachable {
  cursor: pointer;
  opacity: 1;
}
.room-reachable:hover { transform: translateY(-4px) scale(1.05); filter: drop-shadow(0 8px 16px rgba(52,152,219,0.5)); }
/* Never seen — a near-black unknown. */
.room-hidden { opacity: 0.4; }
.room-hidden::before { background: #0b0e14; }
/* Explored but OUT OF VIEW — shown "from memory": the layout stays legible but is clearly desaturated,
   darkened, and given a cold blue-grey tint so it never reads the same as a currently-visible tile. */
.room-fogged { filter: grayscale(1) brightness(0.6) contrast(0.92); opacity: 0.9; }
.room-fogged::before { background: linear-gradient(rgba(64,84,116,0.45), rgba(64,84,116,0.45)), var(--bg-card); }
.room-fogged .room-label { color: #8a97ab; font-style: italic; }
.room-fog { position: absolute; bottom: 5px; right: 7px; font-size: 15px; opacity: 0.95; pointer-events: none; }
.room-cleared { opacity: 0.6; }
.room-cleared .room-icon { filter: grayscale(0.6); }
.room-cleared::after {
  content: '✓';
  position: absolute;
  top: 18px; right: 50%;
  transform: translateX(50%);
  color: var(--uncommon);
  font-weight: bold;
  font-size: 13px;
  z-index: 2;
}

/* Type accents — color the hex outline */
.room-combat   { background: var(--attack); }
.room-mob      { background: var(--attack); }   /* CP18: a tile a mob is standing on reads as danger */
.room-mob .room-icon { animation: boss-bob 1.6s ease-in-out infinite; }
.room-mob-aggro { background: var(--attack-light); animation: pulse-red 0.9s infinite; }  /* hunting you */
/* CP18 18s: a fogged neighbor hides a mob — blinking red warning so you can retreat */
.room-lurking { animation: pulse-red 0.9s infinite; }
.lurk-warning { position: absolute; top: 14px; font-size: 16px; color: var(--attack-light);
  animation: lurk-blink 0.8s steps(1) infinite; z-index: 3; }
@keyframes lurk-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0.15; } }
.room-elite    { background: var(--power); }
.room-boss     { background: var(--rare); }
.room-boss .room-icon { animation: boss-bob 1.6s ease-in-out infinite; }
@keyframes boss-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.room-treasure { background: var(--energy); }
.room-safe     { background: var(--uncommon); }
.room-desperado{ background: var(--skill); }
.room-stairs   { background: var(--text); }
/* current + reachable states win over type accent */
.room-here, .room-reachable { }
.room-here.room-combat, .room-here.room-stairs, .room-here.room-safe,
.room-here.room-treasure, .room-here.room-desperado, .room-here.room-elite { background: var(--rare); }
/* the current tile is never greyed, even after it's been visited/cleared */
.room-here.room-cleared { opacity: 1; }
.room-here.room-cleared .room-icon { filter: none; }
.room-here.room-cleared::after { content: none; }

/* Floats over the bottom of the map so it doesn't steal vertical space from the grid. */
#room-prompt { position: absolute; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; pointer-events: none; z-index: 5; }
#room-prompt > * { pointer-events: auto; }
.descend-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-panel);
  border: 2px solid var(--rare);
  border-radius: var(--radius);
  padding: 10px 20px;
}
.descend-text { font-size: 14px; color: var(--text); }
.descend-sealed { border-color: var(--attack); }
.descend-sealed .descend-text { color: #ff9a8d; }
#descend-btn {
  background: linear-gradient(135deg, #7d5c00, #b8860b);
  color: #fff;
  border: 2px solid var(--energy);
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
#descend-btn:hover { filter: brightness(1.15); }

/* ── HUD ── */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 64px;
}

/* Crawler card (left of HUD) */
#crawler-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.crawler-portrait {
  position: relative;   /* anchors the CP18 stat-points badge */
  font-size: 34px;
  line-height: 1;
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: 10px;
  padding: 4px 8px;
}
#map-portrait, .sheet-portrait { cursor: pointer; transition: border-color 0.15s, transform 0.1s; }
#map-portrait:hover, .sheet-portrait:hover { border-color: var(--rare); transform: translateY(-1px); }
.crawler-meta { display: flex; flex-direction: column; gap: 2px; }
.crawler-name { font-size: 15px; font-weight: bold; color: var(--text); }
.crawler-class { font-size: 11px; color: var(--rare); letter-spacing: 0.03em; }
.crawler-vitals { display: flex; flex-direction: column; gap: 4px; margin-left: 4px; }

.vital-bar {
  position: relative;
  width: 150px;
  height: 18px;
  background: #2a0d0d;
  border: 1px solid #5c1a1a;
  border-radius: 9px;
  overflow: hidden;
}
.vital-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(90deg, #c0392b, #e74c3c);
  transition: width 0.4s ease;
}
.vital-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  z-index: 1;
}
.block-pip {
  font-size: 12px;
  font-weight: bold;
  color: #acd2ff;
  background: rgba(52,152,219,0.15);
  border: 1px solid var(--skill-light);
  border-radius: 6px;
  padding: 1px 8px;
  align-self: flex-start;
}

#hud-center { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hud-center-top { display: flex; align-items: center; gap: 14px; }
#combat-clock {
  font-size: 14px; font-weight: bold; color: var(--skill-light);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 12px;
}
#combat-clock.clock-critical { color: var(--attack-light); border-color: var(--attack-light); animation: pulse-red 0.9s infinite; }
#hud-right { display: flex; align-items: center; gap: 20px; }

.hud-btn-row { display: flex; gap: 8px; }
.hud-btn-row button {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.hud-btn-row button:hover { color: var(--text); border-color: var(--border-light); }

/* Resource orbs (Action Points + Mana) */
.ap-orb, .mana-orb {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  transition: border-color 0.3s, background 0.3s, opacity 0.3s;
  position: relative;
}
.orb-sep { font-size: 14px; opacity: 0.7; }
.orb-label {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.05em;
}

/* Action Points — amber/energy */
.ap-orb { background: linear-gradient(135deg, #7d5c00, #b8860b); border: 2px solid var(--energy); }
.ap-orb.low   { border-color: var(--attack-light); }
.ap-orb.empty { border-color: #444; background: #222; color: #555; }

/* Mana — arcane blue */
.mana-orb { background: linear-gradient(135deg, #14375e, #2471a3); border: 2px solid var(--skill-light); }
.mana-orb.depleted { opacity: 0.55; }
.mana-orb.empty { border-color: #444; background: #222; color: #555; opacity: 0.5; }

#turn-display {
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

#end-turn-btn {
  background: linear-gradient(135deg, #1a6b3a, #27ae60);
  color: #fff;
  border: 2px solid #2ecc71;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: filter 0.15s, transform 0.1s;
}
/* Co-op: while you've ended but the party's still waiting, the button is a red "Cancel" to un-ready. */
#end-turn-btn.end-turn-cancel { background: linear-gradient(135deg, #7a1f1f, #c0392b); border-color: #e74c3c; }
#end-turn-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
#end-turn-btn:active { transform: translateY(0); }

/* Co-op combat party roster (top-left). */
.coop-roster {
  position: absolute; top: 72px; left: 12px; z-index: 40;
  background: rgba(20, 26, 38, 0.92); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; min-width: 160px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.coop-roster .cr-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.cr-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.cr-row:hover { background: rgba(255,255,255,0.06); }
.cr-row.cr-you { outline: 1px solid rgba(255,212,121,0.5); }
.cr-portrait { font-size: 16px; }
.cr-name { flex: 1; font-weight: 600; white-space: nowrap; }
.cr-ready { color: #57d38c; font-weight: 700; }
.cr-acting { color: var(--text-muted); }
.cr-down { color: #e74c3c; }
/* On the MAP the party panel replaces the vote banner: in-flow under the System banner, top-left. */
#coop-roster-map { position: static; margin: 0; width: max-content; }
#end-turn-btn:disabled {
  background: #2a2f36;
  border-color: var(--border);
  color: var(--text-muted);
  cursor: default;
  filter: none;
  transform: none;
}

/* Dim the hand during the enemy's turn */
body.enemy-phase #hand { opacity: 0.55; pointer-events: none; transition: opacity 0.2s; }
/* While a played card is resolving its beats, lock the hand so plays can't overlap (Slice 3 adds a queue). */
/* CP19: hand stays INTERACTIVE while a card resolves so you can queue the next play. */
body.resolving #hand { opacity: 0.92; transition: opacity 0.2s; }
/* A card queued to play next: bright outline + a corner badge. */
.card-queued { outline: 2px solid var(--rare); outline-offset: 2px; }
.card-queued::after {
  content: '⏳'; position: absolute; top: 2px; left: 3px; font-size: 12px;
  background: var(--rare); color: #000; border-radius: 50%; width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}

/* Discard-cost mode: highlight the hand, prompt to click */
body.discard-mode #hand .card { cursor: pointer; box-shadow: 0 0 0 2px var(--attack-light); }
body.discard-mode #hand .card:hover { transform: translateY(-20px) scale(1.06); box-shadow: 0 0 18px var(--attack-light); }
.discard-prompt {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--attack); color: #fff; font-weight: bold; font-size: 14px;
  padding: 8px 18px; border-radius: 8px; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

/* ── Board ── */
#board {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

/* ── Battlefield ── */
#battlefield {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
}
/* Targeting line overlay — sits above tiles, ignores clicks */
#target-lines {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}
/* Intent-line spotlight cycler: groups fade slowly between dim and full; the active one reads thicker. */
.intent-group { transition: opacity 0.55s ease; }
.intent-group.intent-active path { stroke-width: 3.5; }

#battlefield.battlefield-active {
  background: radial-gradient(ellipse at center, rgba(52,152,219,0.12), transparent 70%);
  border-radius: var(--radius);
}

/* Enemies */
#enemies {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
  min-height: 200px;
}

.enemy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 130px;
  padding: 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);            /* every entity gets a grey box (targeting square) */
  background: rgba(231, 76, 60, 0.05);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.3s;
  cursor: pointer;
}
.enemy.enemy-targeted {
  border-color: var(--attack-light);
  box-shadow: 0 0 26px rgba(231,76,60,0.5);
  transform: translateY(-4px);
}
.enemy.enemy-dead {
  opacity: 0.25;
  filter: grayscale(1);
  pointer-events: none;
}

.enemy-intent {
  height: 26px;
  display: flex;
  align-items: center;
}
/* Pet's telegraphed move, shown above the ally like an enemy intent. */
.ally-intent {
  min-height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2px;
}
.intent {
  font-size: 14px;
  font-weight: bold;
  padding: 2px 9px;
  border-radius: 12px;
  border: 1px solid;
}
.intent-attack { color: #ff9a8d; border-color: var(--attack); background: rgba(192,57,43,0.18); }
.intent-magic { color: #d6a8e8; border-color: var(--power); background: rgba(155,89,182,0.18); }
.intent-rider { margin-left: 2px; font-size: 11px; }
.magic-shield {
  font-size: 11px; font-weight: bold; color: #d6a8e8;
  background: rgba(155,89,182,0.15);
  border: 1px solid var(--power-light);
  border-radius: 6px; padding: 0 6px;
}
.intent-block  { color: #acd2ff; border-color: var(--skill); background: rgba(36,113,163,0.18); }
.intent-debuff { color: #d6a8e8; border-color: var(--power); background: rgba(155,89,182,0.18); }
.intent-buff   { color: #7CFC9B; border-color: var(--uncommon); background: rgba(63,185,80,0.18); }
.intent-multi  { margin-left: 1px; font-size: 11px; opacity: 0.9; }

/* Clairvoyance / Third Eye: upcoming-move queue under an enemy */
.enemy-upcoming {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  margin-top: 5px; font-size: 11px; color: #cbb9e8;
  background: rgba(155,89,182,0.12); border: 1px solid var(--power-light);
  border-radius: 6px; padding: 2px 6px;
}
.enemy-upcoming { cursor: help; }
.upcoming-label { font-size: 9px; text-transform: uppercase; letter-spacing: .04em; opacity: 0.7; margin-right: 1px; }
.upcoming-chip { font-weight: bold; }
.upcoming-sep { opacity: 0.5; }

/* Clairvoyance hover: a vertical stack of per-move tooltip boxes (each like the current-intent hover). */
.tip-upcoming-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #cbb9e8; margin-bottom: 6px; }
.tip-upcoming-box { border: 1px solid var(--power-light); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; background: rgba(155,89,182,0.08); }
.tip-upcoming-box:last-child { margin-bottom: 0; }
.tip-upcoming-idx { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: #9b8bb5; margin-bottom: 3px; }

.enemy-portrait {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}
.enemy-name { font-size: 12px; font-weight: bold; color: var(--text); text-align: center; }

.enemy-hpbar {
  position: relative;
  width: 110px;
  height: 16px;
  background: #2a0d0d;
  border: 1px solid #5c1a1a;
  border-radius: 8px;
  overflow: hidden;
}
.enemy-hpfill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #a93226, #e74c3c);
  transition: width 0.35s ease;
}
.enemy-hptext {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: bold; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.enemy-footer { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; min-height: 18px; }
.enemy-block {
  font-size: 11px; font-weight: bold; color: #acd2ff;
  background: rgba(52,152,219,0.15);
  border: 1px solid var(--skill-light);
  border-radius: 6px; padding: 0 6px;
}

/* ── Party (player entities on the field) ── */
#party {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 30px;
  margin-top: 28px;
  min-height: 150px;
}
.ally {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 130px;
  padding: 10px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: rgba(46, 204, 113, 0.04);
  position: relative;
  transition: border-color 0.15s, box-shadow 0.2s, opacity 0.3s;
}
.ally-pet { background: rgba(155, 89, 182, 0.06); }
.ally-droptarget {
  border-color: var(--uncommon);
  box-shadow: 0 0 22px rgba(63,185,80,0.5);
  transform: translateY(-4px);
}
/* A valid drop target while a card is being dragged: a STEADY glowing outline (no blink). */
.target-valid { border-color: var(--attack-light); box-shadow: 0 0 18px rgba(231,76,60,0.45); }
.pet-tag {
  position: absolute;
  top: -10px;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--power);
  border-radius: 8px;
  padding: 1px 7px;
  z-index: 3;
}
.ally-dead { opacity: 0.3; filter: grayscale(1); }
/* Co-op: a crawler who has ended their turn — dimmed with a "done" tag until the enemy phase. */
/* Co-op: label YOUR crawler + your pets at the bottom (no outline — the border is used for card targeting). */
.ally-you-tag {
  position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 800; letter-spacing: 0.06em;
  color: #0d1117; background: #ffd479; border-radius: 8px; padding: 1px 7px; z-index: 4; white-space: nowrap;
}
.ally-ended { opacity: 0.6; filter: saturate(0.7); }
.ally-ended-tag {
  position: absolute;
  top: -10px;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.08em;
  color: #0d1117;
  background: #57d38c;
  border-radius: 8px;
  padding: 1px 7px;
  z-index: 3;
}
.target-marker {
  position: absolute;
  top: -14px;
  background: var(--attack);
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  border-radius: 12px;
  padding: 1px 9px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  z-index: 3;
}
.ally-portrait {
  font-size: 46px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}
.ally-name { font-size: 13px; font-weight: bold; color: var(--text); }
.ally-hpbar {
  position: relative;
  width: 116px;
  height: 17px;
  background: #2a0d0d;
  border: 1px solid #5c1a1a;
  border-radius: 9px;
  overflow: hidden;
}
.ally-hpfill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #c0392b, #e74c3c);
  transition: width 0.35s ease;
}
.ally-hptext {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: bold; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.ally-footer { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; min-height: 18px; }
.ally-block {
  font-size: 11px; font-weight: bold; color: #acd2ff;
  background: rgba(52,152,219,0.15);
  border: 1px solid var(--skill-light);
  border-radius: 6px; padding: 0 6px;
}

/* Enemy intent target indicator */
.intent-target { margin-left: 3px; font-size: 12px; }

/* ── Entity hover tooltip ── */
.entity-tooltip {
  position: fixed;
  z-index: 9999;
  width: 240px;
  background: #0c1017;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}
.entity-tooltip.hidden { display: none; }
/* CP18 18h: current-vs-upgraded comparison tooltip (two card tooltips side by side) */
.entity-tooltip:has(.upgrade-compare) { width: auto; max-width: 620px; }
.upgrade-compare { display: flex; align-items: center; gap: 12px; }
.upgrade-compare .uc-col { width: 240px; }
.upgrade-compare .uc-arrow { color: var(--uncommon); font-size: 22px; flex-shrink: 0; }
.uc-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.uc-next .uc-label { color: var(--uncommon); }
.tip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.tip-portrait { font-size: 24px; }
.tip-name { font-size: 14px; font-weight: bold; }
.tip-hp { color: #ff9a8d; font-weight: bold; font-size: 12px; }
.tip-role { color: var(--rare); font-size: 11px; letter-spacing: 0.03em; margin-top: 2px; }
.tip-flavor { color: var(--text-muted); font-style: italic; margin-top: 6px; }
.tip-intent { margin-top: 6px; color: var(--text); }
.tip-moves { margin-top: 6px; color: var(--text-muted); font-size: 11px; }
.tip-hint { margin-top: 6px; color: var(--skill-light); font-size: 11px; }
.tip-statuses { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.tip-status { font-size: 11px; color: var(--text-muted); }
.tip-status b { color: var(--text); }

/* Status pills (shared player + enemy) */
.status-pill {
  font-size: 11px; font-weight: bold;
  color: #e8c8a0;
  background: rgba(155,89,182,0.15);
  border: 1px solid var(--power-light);
  border-radius: 6px; padding: 0 6px;
}
.player-statuses { display: flex; gap: 5px; }
.vital-row { display: flex; gap: 6px; align-items: center; }

/* Play feedback flash */
.play-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 50;
}
.play-feedback.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.feedback-art { font-size: 24px; }
.feedback-name { color: var(--text); }

/* Reshuffle notice */
.reshuffle-notice {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(52,152,219,0.9);
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.reshuffle-notice.visible { opacity: 1; }

/* ── Log panel ── */
#log-panel {
  width: 200px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.log-title {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
#log-list {
  list-style: none;
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}
#log-list li {
  font-size: 12px;
  color: var(--text-muted);
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  line-height: 1.4;
}
#log-list li:first-child { color: var(--text); }
#log-list li b { color: var(--text); font-weight: 700; }
/* The System speaks in its own color */
#log-list li.log-system {
  color: #7fd6a0;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11.5px;
}
#log-list li.log-system::before { content: '⊞ '; opacity: 0.6; }
#log-list li.log-system b { color: #b6f0cd; }
#log-list li.log-play { color: var(--text); }
#log-list li.log-play::before { content: '▸ '; color: var(--rare); }
/* A played card's name in the log — hoverable keyword: shows the full card tooltip (see Renderer._initLogCardHovers). */
.log-card { cursor: help; }
.log-card b { color: var(--skill-light); border-bottom: 1px dotted var(--skill-light); }
.log-card:hover b { color: var(--text); border-bottom-style: solid; }

/* ── Hand area ── */
#hand-area {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  padding: 16px 20px 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  height: 240px;
  position: relative;
}

/* Piles */
.pile {
  width: 80px;
  height: 110px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
}
.pile:hover { border-color: var(--border-light); transform: translateY(-2px); }

.pile-stack {
  width: 48px;
  height: 60px;
  border-radius: 6px;
  margin-bottom: 6px;
  position: relative;
}
.pile-draw .pile-stack {
  background: repeating-linear-gradient(
    135deg,
    #1e3a5f 0px, #1e3a5f 4px,
    #162a44 4px, #162a44 8px
  );
  border: 1px solid #2a5080;
}
.pile-discard .pile-stack {
  background: #1c2230;
  border: 1px dashed var(--border-light);
}
.pile-exhaust .pile-stack {
  background: repeating-linear-gradient(
    45deg,
    #2a1c2e 0px, #2a1c2e 4px,
    #1e1422 4px, #1e1422 8px
  );
  border: 1px solid #5a3a66;
}
.pile-exhaust .pile-count { color: var(--power-light); }

.pile-info { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pile-count { font-size: 20px; font-weight: bold; color: var(--text); }
.pile-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase; }

/* Hand cards container */
#hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: -8px;
  flex: 1;
  position: relative;
  height: 100%;
}

/* ── Card ── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 6px;
  cursor: grab;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  transform-origin: bottom center;
}
.card:hover {
  transform: translateY(-20px) scale(1.06);
  z-index: 10;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
}
.card:active { cursor: grabbing; }
.card.card-dragging { opacity: 0.3; transform: none !important; }

/* Type colors */
.card-type-attack { border-color: var(--attack); }
.card-type-attack:hover { box-shadow: 0 12px 32px rgba(192,57,43,0.5); border-color: var(--attack-light); }
.card-type-skill  { border-color: var(--skill); }
.card-type-skill:hover  { box-shadow: 0 12px 32px rgba(36,113,163,0.5); border-color: var(--skill-light); }
.card-type-power, .card-type-ability  { border-color: var(--power); }
.card-type-power:hover, .card-type-ability:hover  { box-shadow: 0 12px 32px rgba(155,89,182,0.5); border-color: var(--power-light); }
.card-type-ability .card-cost { background: var(--power-light); color: #fff; }
.card-type-item   { border-color: var(--item, #1abc9c); }
.card-type-item:hover   { box-shadow: 0 12px 32px rgba(26,188,156,0.45); border-color: #48d1b5; }
.card-type-item   .card-cost { background: var(--item, #1abc9c); color: #fff; }

/* Card hover: verbatim description (keywords highlighted) + keyword boxes */
.tip-desc { font-size: 12px; color: var(--text); line-height: 1.45; margin-top: 4px; }
.tip-calc { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.tip-calc b { color: var(--text); }
.kw-hl { font-weight: bold; }
.kw-hl.kw-debuff { color: var(--attack-light); }
.kw-hl.kw-buff   { color: var(--uncommon); }
.kw-hl.kw-neutral { color: var(--skill-light); }

/* "Designed by" credit at the bottom of a card's hover tooltip */
.tip-credit { margin-top: 8px; font-size: 10px; font-style: italic; color: var(--text-muted); opacity: 0.85; }
.tip-rarity { margin-top: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* Card keyword boxes (Slay-the-Spire style) under the card hover tooltip */
.tip-keywords { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.tip-keyword {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-left: 3px solid var(--skill-light);
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.35;
}
.tip-keyword.kw-debuff { border-left-color: var(--attack-light); }
.tip-keyword.kw-buff   { border-left-color: var(--uncommon); }
.kw-name { font-weight: bold; color: var(--text); }

/* Active Ability pills in the HUD */
.active-powers { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.power-pill { font-size: 10px; background: rgba(155,89,182,0.25); border: 1px solid var(--power-light); color: #e6d3f0; border-radius: 10px; padding: 1px 8px; white-space: nowrap; }

/* Rarity is shown on the divider line above the card-type label (bottom of the card).
   Tiers + colors mirror the loot boxes (data/lootboxes.js tierMeta). */
.card-rarity-bronze    .card-type-label { border-top-color: #cd7f32; }
.card-rarity-silver    .card-type-label { border-top-color: #c0c0c0; }
.card-rarity-gold      .card-type-label { border-top-color: #ffd700; }
.card-rarity-platinum  .card-type-label { border-top-color: #7fdfff; }
.card-rarity-legendary .card-type-label { border-top-color: #ff8c00; }
.card-rarity-celestial .card-type-label { border-top-color: #b06bff; }

.card-cost {
  position: absolute;
  top: 6px; left: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--energy);
  color: #000;
  font-size: 13px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.card-type-attack .card-cost { background: var(--attack-light); color: #fff; }
.card-type-skill  .card-cost { background: var(--skill-light);  color: #fff; }

/* Mana cost — a blue gem in the top-right (only on cards that cost mana) */
/* Delivery badge — sits just below the AP cost on damage cards (⚔️ physical / 🔮 magic). */
.card-delivery {
  position: absolute;
  top: 34px; left: 5px;
  padding: 1px 4px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  z-index: 2;
}
.card-delivery-phys  { border-color: #e0796b; }
.card-delivery-magic { border-color: var(--skill-light); }
.card-mini .card-delivery { top: 26px; left: 3px; font-size: 8px; padding: 0 2px; }

.card-manacost {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 22px; height: 22px;
  padding: 0 4px;
  border-radius: 6px;
  background: linear-gradient(135deg, #2471a3, #3498db);
  border: 1px solid #5dade2;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.card-mini .card-manacost { top: 4px; right: 5px; height: 18px; min-width: 18px; font-size: 10px; }

/* Item charge tracker — a third top circle, centered between the AP cost (left) and mana (right). */
.card-uses {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--item, #1abc9c);
  border: 1px solid #48d1b5;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.card-mini .card-uses { top: 4px; width: 18px; height: 18px; font-size: 8px; }
.tip-item { font-size: 11px; color: var(--item, #1abc9c); margin: 4px 0; }

.card-art {
  font-size: 30px;
  margin: 20px 0 6px;
  line-height: 1;
}
/* Inline game icons from the registry (data/icons.js) — sized to the surrounding text. */
.game-icon { width: 1.1em; height: 1.1em; object-fit: contain; vertical-align: -0.15em; }

/* ── Combat visual feedback (renderer animation layer) ── */
.float-num {
  position: fixed; transform: translate(-50%, -50%); pointer-events: none; z-index: 3000;
  font-weight: 800; font-size: 22px; text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,0.9);
  animation: float-up 0.95s ease-out forwards;
}
.float-dmg  { color: #ff6b5e; }
.float-heal { color: #7CFC9B; }
@keyframes float-up {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  18%  { opacity: 1; transform: translate(-50%, -55%) scale(1.15); }
  70%  { opacity: 1; transform: translate(-50%, -120%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(0.95); }
}
.hit-flash { animation: hit-flash 0.36s ease-out; }
@keyframes hit-flash {
  0%   { filter: brightness(2.4) saturate(1.4); transform: translateX(0); }
  20%  { transform: translateX(-3px); }
  40%  { transform: translateX(3px); }
  60%  { transform: translateX(-2px); }
  100% { filter: none; transform: translateX(0); }
}
.ally-hpfill, .enemy-hpfill { transition: width 0.35s ease; }
.status-pill.pop { animation: pill-pop 0.4s ease-out; }
@keyframes pill-pop {
  0%   { transform: scale(0.4); opacity: 0.2; }
  55%  { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); }
}

/* Optional card image (falls back to the emoji if missing). */
.card-art .art-img { width: 44px; height: 44px; object-fit: contain; vertical-align: middle; }
.card-mini .card-art .art-img { width: 34px; height: 34px; }
.tip-portrait .art-img { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; }
.card-name {
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  color: var(--text);
  line-height: 1.2;
}
/* Smith-upgraded cards get a green name (on top of the "+" marker). */
.card-upgraded .card-name { color: #5dd97a; }
.tip-name.upgraded { color: #5dd97a; }
.card-desc {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  line-height: 1.4;
  flex: 1;
  overflow: hidden;
}
.card-type-label {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 4px;
  border-top: 2px solid var(--border);
  width: 100%;
  text-align: center;
}

/* Ghost card (dragging clone) */
.card-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.9;
  transform: rotate(3deg) scale(1.05);
  box-shadow: 0 20px 50px rgba(0,0,0,0.7);
  cursor: grabbing;
}

/* Mini card (pile viewer) */
.card-mini {
  transform: none !important;
  cursor: default;
  width: 100px;
  height: 140px;
}
.card-mini:hover { transform: scale(1.05) !important; z-index: 1; }
.card-count {
  position: absolute;
  top: 4px; right: 5px;
  background: var(--rare);
  color: #000;
  font-size: 12px;
  font-weight: bold;
  min-width: 22px;
  text-align: center;
  border-radius: 11px;
  padding: 1px 5px;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.card-mini .card-art { font-size: 22px; margin: 16px 0 4px; }
.card-mini .card-name { font-size: 10px; }
.card-mini .card-desc { font-size: 9px; }

/* ── Drag error toast ── */
.drag-error {
  position: fixed;
  transform: translate(-50%, -100%);
  background: #c0392b;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  pointer-events: none;
  z-index: 2000;
  animation: fadeUp 1.2s ease forwards;
}
@keyframes fadeUp {
  0%   { opacity: 1; transform: translate(-50%, -100%); }
  70%  { opacity: 1; transform: translate(-50%, -140%); }
  100% { opacity: 0; transform: translate(-50%, -160%); }
}

/* ── Game over overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.overlay.visible { opacity: 1; pointer-events: all; }
.overlay-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 60px;
}
#gameover-title { font-size: 48px; font-weight: 800; letter-spacing: 0.04em; }
#gameover-title.go-win  { color: #2ecc71; text-shadow: 0 0 30px rgba(46,204,113,0.5); }
#gameover-title.go-lose { color: #e74c3c; text-shadow: 0 0 30px rgba(231,76,60,0.5); }
#gameover-sub { font-size: 15px; color: var(--text-muted); }
.gameover-stats {
  display: flex;
  gap: 22px;
  margin-top: 8px;
  padding: 14px 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.go-stat { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.go-stat span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.go-stat b { font-size: 16px; color: var(--text); }
#restart-btn {
  margin-top: 12px;
  background: linear-gradient(135deg, #1a6b3a, #27ae60);
  color: #fff;
  border: 2px solid #2ecc71;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}
#restart-btn:hover { filter: brightness(1.15); }

/* ── Rewards popup ── */
.rewards-box { padding: 28px 36px; gap: 14px; min-width: 320px; }

/* Floor-3 class selection overlay */
.class-box { padding: 28px 32px; gap: 8px; max-width: 860px; }
.class-overlay-title { font-size: 24px; font-weight: bold; }
.class-overlay-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.class-options { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.class-option {
  display: flex; flex-direction: column; gap: 8px; width: 240px; padding: 16px;
  background: var(--bg-card); border: 2px solid var(--border); border-radius: 12px;
  color: var(--text); cursor: pointer; text-align: left; transition: border-color 0.15s, transform 0.1s;
}
.class-option:hover { border-color: var(--rare); transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0,0,0,0.45); }
.class-name { font-size: 17px; font-weight: bold; color: var(--rare); }
.class-flavor { font-size: 12px; color: var(--text-muted); line-height: 1.4; min-height: 50px; }
.class-perks { display: flex; flex-direction: column; gap: 4px; }
.class-perk { font-size: 11px; color: var(--text); }
.class-perk.class-cards-hidden { color: var(--item, #1abc9c); font-style: italic; }
.rewards-title {
  font-size: 28px; font-weight: 800; color: var(--uncommon);
  text-shadow: 0 0 24px rgba(63,185,80,0.4); letter-spacing: 0.03em;
}
/* CP18 18m: pre-battle acknowledgement + interlude */
.battle-box { padding: 26px 34px; gap: 12px; min-width: 340px; max-width: 640px; }
.battle-title { font-size: 26px; font-weight: 800; color: var(--attack-light); letter-spacing: 0.03em; text-shadow: 0 0 22px rgba(231,76,60,0.4); }
.battle-sub { font-size: 13px; color: var(--text-muted); }
.battle-queue { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 6px 0; }
.bq-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; min-width: 96px; text-align: center; position: relative;
}
.bq-card.bq-current { border-color: var(--attack-light); box-shadow: 0 0 12px rgba(231,76,60,0.35); }
.bq-card.bq-done { opacity: 0.45; }
.bq-head { font-size: 13px; color: var(--text); margin-bottom: 4px; }
.bq-members { font-size: 18px; line-height: 1; }
.bq-tag { display: inline-block; margin-top: 6px; font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.bq-tag.bq-ambush { color: var(--attack-light); border-color: var(--attack-light); }
.bq-tag.bq-boss { color: var(--rare); border-color: var(--rare); }
.bq-tag.bq-encounter { color: #e6b95c; border-color: #e6b95c; }
#battle-go {
  background: linear-gradient(135deg, #8e1b1b, #c0392b); color: #fff; border: 2px solid #e74c3c;
  border-radius: 10px; padding: 11px 28px; font-size: 15px; font-weight: 800; cursor: pointer; margin-top: 4px;
}
#battle-go:hover { filter: brightness(1.12); }

.rewards-list { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.reward-row {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px; font-size: 14px; color: var(--text);
}
.reward-row b { color: var(--text); }
.reward-level { border-color: var(--rare); }
.reward-level b { color: var(--rare); }
.reward-gear { border-color: var(--uncommon); }
.reward-gear b { color: var(--uncommon); text-transform: capitalize; }
.reward-pet { border-color: var(--legendary, #ff8c00); }
.reward-pet b { color: var(--legendary, #ff8c00); }
.reward-note { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: -2px; }
.rewards-cards { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4px; }
.rewards-cards-title { font-size: 13px; color: var(--text); letter-spacing: 0.03em; }
.rewards-card-row { display: flex; gap: 14px; justify-content: center; }
.rewards-skip {
  background: none; border: 1px solid var(--border-light); color: var(--text-muted);
  border-radius: 6px; padding: 7px 20px; font-size: 12px; cursor: pointer;
}
/* Gear reward (Sponsor Box) cards */
.reward-gear-card {
  width: 116px; height: 168px;            /* fixed height so the rarity bar pins to the SAME bottom on every card */
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 8px; text-align: center;
  border: 2px solid var(--border); border-left-width: 4px;
}
.reward-gear-icon { font-size: 34px; line-height: 1; }
.reward-gear-slot { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.reward-gear-card .gear-effects { font-size: 10px; flex: 1; overflow: hidden; }  /* absorbs height variance; bar stays bottom */
.reward-gear-card .card-type-label { margin-top: 0; }  /* effects already flex-fill the gap */
.rewards-skip:hover { color: var(--text); border-color: var(--text-muted); }
#rewards-continue {
  margin-top: 10px;
  background: linear-gradient(135deg, #1a6b3a, #27ae60);
  color: #fff; border: 2px solid #2ecc71; border-radius: 8px;
  padding: 12px 36px; font-size: 16px; font-weight: bold; cursor: pointer;
}
#rewards-continue:hover { filter: brightness(1.15); }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal.visible { opacity: 1; pointer-events: all; }

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 80vw;
  max-width: 760px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: bold;
  font-size: 15px;
}
.modal-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-header button:hover { color: var(--text); }
.pile-modal-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
}
.init-error {
  position: fixed;
  inset: 0;
  background: #1a1a1a;
  color: #e6edf3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 16px;
  text-align: center;
  z-index: 9999;
  padding: 40px;
  line-height: 1.8;
}
.init-error code {
  background: #2d333b;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 15px;
  color: #79c0ff;
}
.hidden { display: none !important; }

.empty-pile-msg {
  color: var(--text-muted);
  padding: 20px;
  font-style: italic;
}

/* Stat block modal */
.modal-box-narrow { max-width: 360px; }

/* ── Consolidated character sheet ── */
.sheet-box { max-width: 940px; width: 92vw; max-height: 88vh; display: flex; flex-direction: column; }
.sheet-body { overflow-y: auto; padding: 16px 20px 22px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: none; -ms-overflow-style: none; }
.sheet-body::-webkit-scrollbar { display: none; }   /* scrollable, but no visible scrollbar */
.sheet-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sheet-portrait { font-size: 46px; line-height: 1; background: var(--bg-card); border: 2px solid var(--border-light); border-radius: 12px; padding: 6px 12px; }
.sheet-id { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.sheet-name { font-size: 20px; font-weight: bold; }
.sheet-lv { font-size: 13px; color: var(--rare); margin-left: 6px; }
.sheet-class { font-size: 12px; color: var(--rare); letter-spacing: 0.03em; }
.sheet-xpbar { position: relative; height: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: 220px; }
.sheet-xpfill { position: absolute; inset: 0 auto 0 0; background: var(--rare); opacity: 0.5; }
.sheet-xpbar span { position: relative; font-size: 10px; line-height: 16px; padding-left: 8px; color: var(--text); }
.sheet-vitals { display: flex; flex-direction: column; gap: 3px; font-size: 13px; margin-left: auto; }
.sheet-section { border-top: 1px solid var(--border); padding-top: 12px; }
.sheet-h { font-size: 13px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; }
.sheet-pets { display: flex; flex-wrap: wrap; gap: 12px; }
.sheet-pet { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 10px; padding: 10px 12px; min-width: 220px; flex: 1; }
.sheet-pet.pet-downed { opacity: 0.5; }
.sheet-pet-top { display: flex; align-items: center; gap: 8px; }
.sheet-pet-portrait { font-size: 24px; }
.sheet-pet-name { font-size: 14px; }
.sheet-pet-stats { font-size: 12px; color: var(--text-muted); margin: 6px 0; }
.sheet-pet-moves { display: flex; flex-direction: column; gap: 2px; }
.pet-move { font-size: 11px; color: var(--text); cursor: help; width: fit-content; }
.pet-move:hover { color: var(--rare); }
.pet-move-locked { color: var(--text-muted); opacity: 0.7; }
.sheet-deck { display: flex; flex-wrap: wrap; gap: 8px; }
.stats-modal-body { padding: 18px; }
.stat-flavor {
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.stat-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.stat-value { font-size: 20px; font-weight: bold; color: var(--text); }
.stat-cell { position: relative; }
.stat-points {
  text-align: center;
  color: var(--rare);
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 12px;
}
.stat-plus {
  position: absolute;
  top: -8px; right: -6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--uncommon);
  color: #000;
  border: none;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.stat-plus:hover { filter: brightness(1.15); transform: scale(1.1); }
.stat-resources {
  display: flex;
  justify-content: space-around;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

/* Delivery marker on a debuff intent chip (⚔️ physical / 🔮 magic) — a small dim qualifier before
   the status icon, so a glance tells you whether Block can stop the debuff. */
.intent-deliver { font-size: 0.72em; opacity: 0.75; margin-right: 1px; vertical-align: baseline; }
.intent-deliver .game-icon { width: 0.82em; height: 0.82em; vertical-align: -0.1em; }

/* ── Hand fan layout ── SYMMETRIC: rotation (--rot) and lift (--ty) are set PER CARD in JS from its
   position relative to the hand's center, so the fan is balanced for any hand size (see Renderer._renderHand). */
#hand .card { transform: rotate(var(--rot, 0deg)) translateY(var(--ty, 0px)); }
#hand .card:hover { transform: translateY(-20px) scale(1.06); }

/* A card flying between hand and a pile (draw-in / discard-out clone). */
.card-fly { position: fixed; z-index: 200; margin: 0; pointer-events: none; box-shadow: 0 12px 32px rgba(0,0,0,.6); transform-origin: center; }
/* Face-down card used for the discard→deck shuffle burst. */
.card-back { background: repeating-linear-gradient(45deg, #2b3a55, #2b3a55 6px, #22304a 6px, #22304a 12px); border: 2px solid #46608c; border-radius: var(--radius); }
/* Draw pile "shuffle" nudge. */
@keyframes pileShuffle { 0%,100% { transform: none; } 25% { transform: translateX(-4px) rotate(-4deg); } 75% { transform: translateX(4px) rotate(4deg); } }
#draw-pile.pile-shuffling .pile-stack { animation: pileShuffle .4s ease-in-out 2; }
/* A pile pulsing as it receives a card. */
@keyframes pileReceive { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.pile.pile-receiving .pile-stack { animation: pileReceive .28s ease-out; }
