/* ============================================================
   GRID QUEST RPG:THE SONG OF ADVENTURE — Global Stylesheet
   Retro RPG aesthetic: dark panels, gold accents, pixel font
   ============================================================ */

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

:root {
  --font-pixel:   'Press Start 2P', monospace;
  --font-retro:   'VT323', monospace;

  --bg-deep:      #0a0a0f;
  --bg-panel:     #0f0f1a;
  --bg-panel2:    #141428;
  --bg-overlay:   rgba(8, 8, 20, 0.88);

  --border-gold:  #c8960c;
  --border-dim:   #3a3a5a;
  --border-light: #6060a0;

  --text-white:   #e8e8f0;
  --text-gold:    #f0c830;
  --text-dim:     #8080a0;
  --text-green:   #40e060;
  --text-red:     #e84040;
  --text-blue:    #40a0e8;
  --text-purple:  #c060e8;
  --text-orange:  #e88040;
  --text-cyan:    #40d8c8;

  --hp-color:     #40e060;
  --mp-color:     #4090e8;
  --gold-color:   #f0c830;

  /* Rarity colours */
  --rarity-trash:      #888888;
  --rarity-barely:     #aaaaaa;
  --rarity-common:     #ffffff;
  --rarity-uncommon:   #40e060;
  --rarity-rare:       #4090e8;
  --rarity-superrare:  #c060e8;
  --rarity-ultrarare:  #e84040;
  --rarity-legendary:  #f0c830;
  --rarity-divine:     #40d8c8;
  --rarity-god:        #ff88ff;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg-deep);
  color: var(--text-white);
  font-family: var(--font-retro);
  font-size: 18px;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* ── Loading Screen ── */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg-deep);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px; z-index: 9999;
}

#loading-title {
  font-family: var(--font-pixel);
  font-size: clamp(12px, 3vw, 22px);
  color: var(--text-gold);
  text-shadow: 0 0 20px rgba(240,200,48,0.7);
  letter-spacing: 2px;
  text-align: center;
  line-height: 1.8;
}

#loading-bar-wrap {
  width: 320px; height: 12px;
  border: 2px solid var(--border-gold);
  background: #111;
  border-radius: 2px;
  overflow: hidden;
}
#loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c8960c, #f0c830);
  transition: width 0.3s ease;
}
#loading-text {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--text-dim);
}

/* ── Pre-Game Screens (Main Menu & Lobby) ── */
#main-menu-screen,
#lobby-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}
#main-menu-screen { background-image: url('bg/grass.webp'); }
#lobby-screen     { background-image: url('bg/town.gif'); }
#main-menu-screen.hidden,
#lobby-screen.hidden { display: none; }

/* Panel box — same look as #control-panel, used by both pre-game screens */
.pregame-panel {
  width: min(640px, 90%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--bg-overlay);
  border: 2px solid var(--border-gold);
  border-radius: 6px;
  padding: 16px 20px;
  backdrop-filter: blur(4px);
}

/* ── App Root ── */
#app {
  width: 100vw; height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: 1fr 280px;
  grid-template-areas:
    "game    log"
    "party   party";
}
#app.log-hidden {
  grid-template-columns: 1fr;
  grid-template-areas:
    "game"
    "party";
}

/* ── Party Status Panel ── */
#party-panel {
  grid-area: party;
  display: flex; flex-direction: row;
  background: var(--bg-panel);
  border-top: 2px solid var(--border-gold);
  padding: 6px 8px;
  gap: 8px;
  min-height: 96px;
}

.player-card {
  flex: 1;
  display: flex; flex-direction: row; align-items: center;
  background: var(--bg-panel2);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 6px 8px;
  gap: 8px;
  min-width: 0;
  position: relative;
  overflow: visible;
  transition: border-color 0.2s;
}
.player-card.active-turn  { border-color: var(--text-gold); box-shadow: 0 0 8px rgba(240,200,48,0.4); }
.player-card.dead         { opacity: 0.5; filter: grayscale(0.8); }

/* ── Heal animations ──────────────────────────────────────── */
.player-card.heal-cast-glow { animation: heal-cast-pulse 520ms ease-out forwards; }
@keyframes heal-cast-pulse {
  0%   { box-shadow: 0 0 0   0   rgba(80, 255, 140, 0); }
  35%  { box-shadow: 0 0 22px 8px rgba(80, 255, 140, 0.85), 0 0 40px 12px rgba(200, 255, 120, 0.4); }
  100% { box-shadow: 0 0 6px  2px rgba(80, 255, 140, 0.15); }
}
.player-card.heal-target-glow { animation: heal-target-pulse 650ms ease-out forwards; }
@keyframes heal-target-pulse {
  0%   { box-shadow: 0 0 0   0   rgba(60, 220, 100, 0); }
  30%  { box-shadow: 0 0 18px 6px rgba(60, 220, 100, 0.9); border-color: #44ff88; }
  100% { box-shadow: none; }
}
.heal-cross {
  position: fixed;
  width: 4px; height: 40px;
  margin-left: -2px; margin-top: -20px;
  background: rgba(255, 255, 210, 0.92);
  box-shadow: 0 0 8px rgba(255, 255, 160, 0.8);
  pointer-events: none;
  z-index: 8600;
  animation: heal-cross-fade 380ms ease-out forwards;
}
.heal-cross::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 32px; height: 4px;
  background: rgba(255, 255, 210, 0.92);
  box-shadow: 0 0 8px rgba(255, 255, 160, 0.8);
}
@keyframes heal-cross-fade {
  0%   { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(0.5); }
}
.heal-sparkle {
  position: fixed;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #44ff88;
  box-shadow: 0 0 6px #44ff88, 0 0 12px rgba(60, 220, 100, 0.6);
  pointer-events: none;
  z-index: 8600;
  animation: heal-sparkle-rise 720ms ease-out forwards;
}
@keyframes heal-sparkle-rise {
  0%   { transform: translateY(0)    scale(1.2); opacity: 1; }
  60%  { transform: translateY(-28px) scale(0.9); opacity: 0.8; }
  100% { transform: translateY(-52px) scale(0.3); opacity: 0; }
}

.player-card .portrait {
  width: 120px; height: 120px;
  object-fit: cover;
  border: 1px solid var(--border-dim);
  border-radius: 3px;
  flex-shrink: 0;
  image-rendering: pixelated;
}
.player-card .card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.player-card .card-name {
  font-family: var(--font-pixel);
  font-size: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-card .card-job {
  font-size: 14px;
  color: var(--text-dim);
}
.player-card .bar-row { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.player-card .bar-label { color: var(--text-dim); width: 22px; flex-shrink: 0; }
.player-card .bar-wrap {
  flex: 1; height: 8px;
  background: #222; border: 1px solid #333; border-radius: 2px; overflow: hidden;
}
.player-card .bar-fill { height: 100%; border-radius: 1px; transition: width 0.3s ease; }
.bar-fill.hp { background: var(--hp-color); }
.bar-fill.mp { background: var(--mp-color); }
.player-card .bar-val { color: var(--text-white); min-width: 60px; text-align: right; font-size: 13px; }
.player-card .card-gold { font-size: 13px; color: var(--gold-color); }

/* Empty slots when < 4 players */
.player-card.empty { opacity: 0.25; border-style: dashed; }

/* ── Game Area ── */
#game-area {
  grid-area: game;
  position: relative;
  overflow: hidden;
  background: #000;
}

#scene-bg {
  position: absolute; inset: 0;
  overflow: hidden;
}
#scene-bg-img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}

/* ── Control Panel (centred overlay) ── */
#control-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 90%);
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--bg-overlay);
  border: 2px solid var(--border-gold);
  border-radius: 6px;
  padding: 16px 20px;
  backdrop-filter: blur(4px);
  z-index: 10;
}

/* ── HUD Buttons (map / bag) ── */
.hud-btn {
  position: absolute;
  font-family: var(--font-pixel);
  font-size: 8px;
  background: var(--bg-panel2);
  border: 1px solid var(--border-gold);
  color: var(--text-gold);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  z-index: 20;
  letter-spacing: 1px;
  transition: background 0.15s, color 0.15s;
}
.hud-btn:hover { background: var(--border-gold); color: var(--bg-deep); }

/* MAP button — top-left, wide, shows current location name */
#local-map-btn {
  top: 10px; left: 10px;
  min-width: 130px; max-width: 210px;
  height: auto; padding: 6px 10px;
  text-align: center; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Second row of HUD buttons — left-aligned beneath MAP */
#world-map-btn { top: 52px; left: 10px; }
#status-btn    { top: 52px; left: 86px; }
#inventory-btn { top: 52px; left: 182px; }
#quest-log-btn { top: 52px; left: 248px; min-width: 75px; text-align: center; }
#hud-save-btn  { top: 52px; left: 356px; }

/* ── Status Window ── */
#status-window  { top: 60px; left: 10px; width: 380px; }
#status-content { padding: 10px; overflow-y: auto; max-height: 520px; }

.status-tabs { display: flex; gap: 5px; margin-bottom: 10px; flex-wrap: wrap; }
.status-tab {
  font-family: var(--font-pixel); font-size: 7px;
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  color: var(--text-dim); padding: 4px 8px; border-radius: 3px; cursor: pointer;
}
.status-tab.active { border-color: var(--border-gold); color: var(--text-gold); }

.status-header {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px;
}
.status-portrait {
  width: 52px; height: 52px; border-radius: 4px;
  border: 1px solid var(--border-dim); object-fit: cover;
  image-rendering: pixelated;
}
.status-header-info { flex: 1; }
.status-name  { font-family: var(--font-pixel); font-size: 10px; color: var(--text-white); margin-bottom: 2px; }
.status-class { font-family: var(--font-pixel); font-size: 7px; color: var(--text-gold); margin-bottom: 2px; }
.status-level { font-family: var(--font-pixel); font-size: 8px; color: var(--text-cyan); }
.status-gold  { font-size: 13px; color: var(--text-gold); margin-top: 2px; }

.status-exp-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.status-exp-label { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); white-space: nowrap; }
.status-exp-bar {
  flex: 1; height: 6px; background: var(--bg-panel2);
  border: 1px solid var(--border-dim); border-radius: 3px; overflow: hidden;
}
.status-exp-fill { height: 100%; background: var(--text-gold); border-radius: 3px; transition: width 0.3s; }

.status-vitals { margin-bottom: 10px; }
.status-vital-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.sv-label { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); width: 18px; }
.sv-bar { flex: 1; height: 7px; background: var(--bg-panel2); border: 1px solid var(--border-dim); border-radius: 3px; overflow: hidden; }
.sv-bar div { height: 100%; border-radius: 3px; }
.hp-bar div { background: var(--hp-color); }
.mp-bar div { background: var(--mp-color); }
.sv-nums { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); white-space: nowrap; }

.status-section-title {
  font-family: var(--font-pixel); font-size: 8px; color: var(--text-gold);
  border-bottom: 1px solid var(--border-dim); padding-bottom: 3px; margin: 8px 0 6px;
  display: flex; align-items: center; gap: 8px;
}
.status-pts-badge {
  font-family: var(--font-pixel); font-size: 7px; color: #f0e040;
  background: rgba(240,200,48,0.15); border: 1px solid rgba(240,200,48,0.4);
  padding: 1px 6px; border-radius: 10px;
}
.status-pts-hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
/* Active Effects section */
.status-effects-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.status-eff-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border-left: 3px solid var(--eff-color, #888);
  background: rgba(0,0,0,0.35);
  border-radius: 0 5px 5px 0;
  font-size: 12px;
}
.eff-icon  { font-size: 13px; line-height: 1; width: 16px; text-align: center; }
.eff-label { flex: 1; color: var(--eff-color, #aaa); font-weight: bold; letter-spacing: 0.3px; }
.eff-turns { font-size: 10px; color: var(--text-dim); white-space: nowrap; }

.status-def-summary { display: flex; gap: 16px; margin: 6px 0 2px; font-size: 13px; }
.def-breakdown { font-size: 10px; color: var(--text-dim); }
.stat-pending { color: #6ef06e; font-size: 11px; margin-left: 2px; }
.stat-btns { display: flex; gap: 2px; margin-left: auto; }
.stat-undo-btn { font-size: 11px; padding: 0 5px; background: #3a1a1a; border: 1px solid #884444; color: #e06060; border-radius: 3px; cursor: pointer; }
.stat-undo-btn:hover { background: #5a2a2a; }
.stat-confirm-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.stat-pts-using { font-size: 11px; color: var(--text-gold); flex: 1; }

.status-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 4px; margin-bottom: 4px;
}
.stat-row {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  border-radius: 3px; padding: 4px 6px;
}
.stat-label { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); width: 28px; }
.stat-val   { font-family: var(--font-pixel); font-size: 9px; color: var(--text-white); flex: 1; text-align: right; }
.stat-up-btn {
  font-family: var(--font-pixel); font-size: 8px; font-weight: bold;
  background: rgba(240,200,48,0.15); border: 1px solid var(--border-gold);
  color: var(--text-gold); width: 18px; height: 18px;
  border-radius: 2px; cursor: pointer; line-height: 1; padding: 0;
  flex-shrink: 0;
}
.stat-up-btn:hover { background: var(--border-gold); color: var(--bg-deep); }
.stat-up-placeholder { width: 18px; flex-shrink: 0; }

/* Skill roster */
.skill-roster { display: flex; flex-direction: column; gap: 4px; }
.skill-roster-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  border-left: 3px solid var(--text-cyan); border-radius: 3px; padding: 6px 8px;
}
.skill-locked { border-left-color: var(--border-dim); opacity: 0.55; }
.skr-left  { display: flex; align-items: flex-start; gap: 6px; flex: 1; min-width: 0; }
.skr-lock  { font-size: 11px; flex-shrink: 0; margin-top: 1px; }
.skr-info  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.skr-name  { font-family: var(--font-pixel); font-size: 8px; color: var(--text-white); }
.skr-tags  { font-family: var(--font-pixel); font-size: 6px; color: var(--text-dim); }
.skr-desc  { font-family: var(--font-retro); font-size: 13px; color: var(--text-dim); line-height: 1.35; }
.skr-unlock{ font-family: var(--font-pixel); font-size: 7px; color: var(--text-red); }
.skr-mp    { font-family: var(--font-pixel); font-size: 7px; color: var(--mp-color); flex-shrink: 0; margin-left: 6px; margin-top: 2px; }

/* ── Action Log ── */
#action-log {
  grid-area: log;
  display: flex; flex-direction: column;
  background: var(--bg-panel);
  border-left: 2px solid var(--border-gold);
  overflow: hidden;
}
#action-log-header {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--text-gold);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-dim);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: default;
}
#action-log-toggle {
  background: none;
  border: none;
  color: var(--text-gold);
  font-size: 9px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}
#action-log-toggle:hover { opacity: 1; }

#action-log-open-btn {
  position: fixed;
  right: 0;
  bottom: 50%;
  transform: translateY(50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  border-right: none;
  border-radius: 4px 0 0 4px;
  color: var(--text-gold);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 2px;
  padding: 12px 5px;
  cursor: pointer;
  z-index: 120;
  transition: background 0.15s;
}
#action-log-open-btn:hover { background: rgba(180,130,30,0.2); }
#action-log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-dim);
}
.log-filter-chip {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid currentColor;
  cursor: pointer;
  user-select: none;
  opacity: 0.9;
  transition: opacity 0.15s, background 0.15s;
}
.log-filter-chip:hover        { opacity: 1; background: rgba(255,255,255,0.05); }
.log-filter-chip.inactive     { opacity: 0.28; }
.log-filter-chip.inactive:hover { opacity: 0.45; }
.log-filter-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.log-filter-chip.inactive .log-filter-dot { opacity: 0.3; }

#action-log-entries {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-dim) transparent;
}
.log-entry {
  font-size: 15px;
  line-height: 1.4;
  border-left: 3px solid transparent;
  padding-left: 6px;
  animation: logFadeIn 0.3s ease;
}
.log-entry.move     { border-color: var(--text-blue);   color: var(--text-white); }
.log-entry.combat   { border-color: var(--text-red);    color: var(--text-white); }
.log-entry.crit     { border-color: var(--text-orange); color: var(--text-orange); font-weight: bold; }
.log-entry.loot     { border-color: var(--text-gold);   color: var(--text-gold); }
.log-entry.system   { border-color: var(--border-light);color: var(--text-dim); }
.log-entry.heal     { border-color: var(--hp-color);    color: var(--hp-color); }
.log-entry.mp       { border-color: var(--mp-color);    color: var(--mp-color); }
.log-entry.death    { border-color: var(--text-red);    color: var(--text-red); }
.log-entry.fumble   { border-color: var(--text-purple); color: var(--text-purple); }
.log-entry.vote     { border-color: var(--text-cyan);   color: var(--text-cyan); }
.log-entry.town     { border-color: var(--text-green);  color: var(--text-green); }
.log-entry.levelup  { border-color: var(--text-gold);   color: var(--text-gold); font-weight: bold; }
.log-entry.chat     { border-color: #4466cc; color: #c8d8ff; }
.log-chat-name      { color: var(--text-gold); }

/* ── Chat input row ── */
#chat-input-row {
  display: flex;
  gap: 4px;
  padding: 5px 8px;
  border-top: 1px solid var(--border-dim);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  background: var(--bg-panel2);
  border: 1px solid var(--border-dim);
  color: var(--text-white);
  padding: 4px 7px;
  font-size: 13px;
  border-radius: 3px;
  outline: none;
  min-width: 0;
}
#chat-input:focus { border-color: var(--border-gold); }
#chat-send-btn {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 0 8px;
  background: var(--bg-panel2);
  border: 1px solid var(--border-dim);
  color: var(--text-gold);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}
#chat-send-btn:hover { border-color: var(--border-gold); background: rgba(200,150,12,0.12); }

#chat-emoji-btn {
  font-size: 16px;
  padding: 0 6px;
  background: var(--bg-panel2);
  border: 1px solid var(--border-dim);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
#chat-emoji-btn:hover { border-color: var(--border-gold); background: rgba(200,150,12,0.12); }

#chat-emoji-picker {
  position: relative;
  margin: 0 8px 2px;
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: 5px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  max-height: 160px;
  overflow-y: auto;
  flex-shrink: 0;
}
#chat-emoji-picker.hidden { display: none; }
.emoji-btn {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  line-height: 1;
  text-align: center;
  transition: background 0.1s;
}
.emoji-btn:hover { background: rgba(255,255,255,0.12); }

@keyframes logFadeIn {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Menu/Button Components ── */
.menu-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 10px 16px;
  border: 2px solid var(--border-gold);
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
  text-transform: uppercase;
}
.btn-gold   { background: var(--bg-panel2); color: var(--text-gold); }
.btn-gold:hover   { background: var(--border-gold); color: var(--bg-deep); }
.btn-red    { background: var(--bg-panel2); color: var(--text-red); border-color: var(--text-red); }
.btn-red:hover    { background: var(--text-red);    color: #fff; }
.btn-blue   { background: var(--bg-panel2); color: var(--text-blue); border-color: var(--text-blue); }
.btn-blue:hover   { background: var(--text-blue);   color: var(--bg-deep); }
.btn-green  { background: var(--bg-panel2); color: var(--text-green); border-color: var(--text-green); }
.btn-green:hover  { background: var(--text-green);  color: var(--bg-deep); }
.btn-dim    { background: var(--bg-panel2); color: var(--text-dim);  border-color: var(--border-dim); }
.btn-dim:hover    { background: var(--border-dim);  color: var(--text-white); }
.btn-purple { background: var(--bg-panel2); color: var(--text-purple); border-color: var(--text-purple); }
.btn-purple:hover { background: var(--text-purple); color: #fff; }
.menu-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Control Panel Scenes ── */

/* Main Menu */
#main-menu-panel { text-align: center; padding: 10px 0; }
#main-menu-title {
  font-family: var(--font-pixel);
  font-size: clamp(10px, 2.5vw, 18px);
  color: var(--text-gold);
  text-shadow: 0 0 16px rgba(240,200,48,0.6);
  margin-bottom: 8px;
  line-height: 1.8;
}
#main-menu-subtitle {
  font-size: 20px;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.main-menu-btn { width: 280px; margin: 6px auto; display: block; }

/* Lobby */
#lobby-panel h2, #charselect-panel h2 {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--text-gold);
  margin-bottom: 14px;
  text-align: center;
}
.lobby-row { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
.lobby-label { font-family: var(--font-pixel); font-size: 9px; color: var(--text-dim); width: 80px; flex-shrink: 0; }
.lobby-input {
  flex: 1;
  font-family: var(--font-pixel); font-size: 9px;
  background: #111; border: 1px solid var(--border-dim); color: var(--text-white);
  padding: 8px 10px; border-radius: 3px;
}
.lobby-input:focus { outline: none; border-color: var(--border-gold); }
#lobby-room-id-display {
  font-family: var(--font-pixel); font-size: 12px;
  color: var(--text-cyan);
  background: #111; border: 1px solid var(--border-dim);
  padding: 8px 12px; border-radius: 3px;
  letter-spacing: 3px; cursor: pointer;
}
#player-list { margin: 10px 0; }
.lobby-player-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; 
  font-size: 16px;
}
.lobby-player-entry .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-green);
}
.lobby-player-entry .dot.host { background: var(--text-gold); }

/* Character Select */
#charselect-panel { text-align: center; }
.job-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 10px 0;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}
.job-card {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-panel2);
  border: 2px solid var(--border-dim);
  border-radius: 6px;
  padding: 8px 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.job-card:hover { border-color: var(--border-gold); background: #1e1e36; }
.job-card.selected   { border-color: var(--text-gold); background: #1e1e36; }
.job-card.confirmed  { border-color: var(--text-green); background: #0e1e16; }
.job-card.confirmed .job-name { color: var(--text-green); }
.job-card img {
  width: 90px; height: 90px; object-fit: cover;
  border-radius: 4px; image-rendering: pixelated; margin-bottom: 6px;
}
.job-card .job-name {
  font-family: var(--font-pixel); font-size: 8px;
  color: var(--text-white); text-align: center; line-height: 1.4;
}
/* Character picker */
.character-picker { margin: 8px 0 4px; }
.character-picker-label {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); margin-bottom: 6px;
}
.character-picker-row {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-start;
  max-height: 240px; overflow-y: auto; padding: 4px 2px;
}
.character-choice {
  border: 2px solid var(--border-dim);
  border-radius: 6px; cursor: pointer;
  padding: 3px; transition: border-color 0.15s;
  flex-shrink: 0; text-align: center;
}
.character-choice:hover { border-color: var(--text-gold); }
.character-choice.selected { border-color: var(--text-cyan); box-shadow: 0 0 8px rgba(64,216,200,0.5); }
.character-choice img { width: 90px; height: 90px; object-fit: cover; border-radius: 4px; display: block; image-rendering: pixelated; }
.character-choice-name {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-white); margin-top: 3px; padding: 0 2px;
}

#charselect-stats {
  font-size: 14px;
  color: var(--text-dim);
  border-top: 1px solid var(--border-dim);
  padding-top: 8px;
  text-align: left;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px;
}
#charselect-stats .stat-line { color: var(--text-white); }
#charselect-stats .stat-line span { color: var(--text-gold); }

/* Voting Panel */
#voting-panel { text-align: center; }
#voting-title {
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--text-gold); margin-bottom: 14px;
}
.vote-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 7px;
  width: clamp(260px, 38vw, 480px);
  margin: 0 auto 14px;
}
.vote-dir-btn {
  font-family: var(--font-pixel); font-size: 9px; line-height: 1.35;
  background: var(--bg-panel2); border: 2px solid var(--border-dim);
  color: var(--text-white); cursor: pointer; border-radius: 4px;
  transition: all 0.15s;
  min-height: 50px;
  padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  text-align: center;
}
.vote-dir-hint {
  flex: 1;
  font-family: var(--font-retro);
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

/* ── Combat turn-order queue (left edge) ── */
#turn-queue {
  position: fixed; left: 12px; top: 50%; transform: translateY(-50%);
  z-index: 15; display: none;
  background: var(--bg-overlay);
  border: 2px solid var(--border-gold); border-radius: 6px;
  padding: 8px;
  width: 150px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
#turn-queue .tq-title {
  font-family: var(--font-pixel); font-size: 8px; color: var(--text-gold);
  text-align: center; letter-spacing: 1px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border-gold); padding-bottom: 5px;
}
#turn-queue .tq-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 4px; margin: 3px 0;
  border: 1px solid var(--border-dim); border-radius: 4px;
  background: rgba(0,0,0,0.3);
  opacity: 0.75;
  position: relative;
}
#turn-queue .tq-row img {
  width: 26px; height: 26px; object-fit: cover;
  border-radius: 3px; image-rendering: pixelated; flex-shrink: 0;
}
#turn-queue .tq-name {
  font-family: var(--font-retro); font-size: 13px;
  color: var(--text-white);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#turn-queue .tq-monster .tq-name { color: #ff9080; }
#turn-queue .tq-current {
  opacity: 1;
  border-color: #ff4040;
  background: rgba(120,20,20,0.35);
  box-shadow: 0 0 10px rgba(255,60,60,0.7), inset 0 0 8px rgba(255,60,60,0.2);
  animation: tqPulse 0.9s ease-in-out infinite alternate;
}
@keyframes tqPulse {
  from { box-shadow: 0 0 6px rgba(255,60,60,0.5); }
  to   { box-shadow: 0 0 14px rgba(255,60,60,0.95); }
}
#turn-queue .tq-arrow {
  font-size: 10px; color: #ff5050; flex-shrink: 0;
}

/* Dice-manipulation indicator under the dice popup */
#dice-mod-text {
  margin-top: 10px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: #c08aff;
  text-shadow: 0 0 10px rgba(192,138,255,0.8);
  letter-spacing: 1px;
  animation: cardTargetPulse 0.9s ease-in-out infinite alternate;
}

/* ── Magic Cards ── */
.btn-card {
  background: linear-gradient(135deg, rgba(90,40,140,0.7), rgba(140,60,200,0.5));
  border-color: #a060e0 !important;
  color: #e0c0ff !important;
}
.btn-card:hover:not(:disabled) { background: rgba(160,80,220,0.6); color: #fff !important; }
.btn-card:disabled { opacity: 0.45; }
.card-target-glow {
  cursor: pointer;
  border-color: #c08aff !important;
  box-shadow: 0 0 14px rgba(192,138,255,0.8), inset 0 0 10px rgba(192,138,255,0.25);
  animation: cardTargetPulse 0.9s ease-in-out infinite alternate;
}
@keyframes cardTargetPulse {
  from { box-shadow: 0 0 8px rgba(192,138,255,0.5); }
  to   { box-shadow: 0 0 18px rgba(192,138,255,1); }
}

/* ── Caravan journey animation ── */
#caravan-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: none; pointer-events: none; overflow: hidden;
}
#caravan-overlay .cv-sky {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #2b1a4a 0%, #6a3a6a 45%, #c8703a 78%, #e8a050 100%);
  opacity: 0;
  animation: cvFadeIn 1.2s ease forwards;
}
@keyframes cvFadeIn { to { opacity: 1; } }
#caravan-overlay .cv-ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 22%;
  background: #140d08;
  opacity: 0;
  animation: cvFadeIn 1.2s ease forwards;
}
#caravan-overlay .cv-wagon {
  position: absolute; bottom: 18%; left: -220px;
  display: flex; align-items: flex-end; gap: 2px;
  animation: cvRoll 7.6s linear 0.5s forwards, cvBob 0.55s ease-in-out infinite;
}
@keyframes cvRoll { to { left: calc(100% + 120px); } }
@keyframes cvBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
#caravan-overlay .cv-horse {
  font-size: 44px; line-height: 1;
  transform: scaleX(-1);
  filter: brightness(0.25) sepia(1) saturate(0.6);
}
#caravan-overlay .cv-cart {
  position: relative; display: inline-block;
  width: 96px; height: 52px;
  background: #3a2414;
  border: 2px solid #1c0f06;
  border-radius: 8px 18px 4px 4px;
  box-shadow: inset 0 6px 0 rgba(255,255,255,0.05);
}
#caravan-overlay .cv-cart::before {
  content: ''; position: absolute; left: 8px; right: 8px; top: -18px; height: 22px;
  background: #6a5236; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  border: 2px solid #1c0f06; border-bottom: none;
}
#caravan-overlay .cv-wheel {
  position: absolute; bottom: -14px; width: 26px; height: 26px;
  border: 4px solid #1c0f06; border-radius: 50%;
  background: radial-gradient(circle, #574 12%, transparent 13%);
  animation: cvSpin 0.7s linear infinite;
}
#caravan-overlay .cv-wheel::before {
  content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 3px;
  margin-left: -1.5px; background: #1c0f06;
}
#caravan-overlay .cv-wheel-a { left: 8px; }
#caravan-overlay .cv-wheel-b { right: 8px; }
@keyframes cvSpin { to { transform: rotate(360deg); } }
#caravan-overlay .cv-label {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  font-family: var(--font-pixel); font-size: 12px; color: #ffe6b0;
  letter-spacing: 2px; text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  opacity: 0;
  animation: cvLabel 2.2s ease 0.8s forwards;
}
@keyframes cvLabel { to { opacity: 1; } }
#caravan-overlay .cv-black {
  position: absolute; inset: 0; background: #000;
  opacity: 0;
  animation: cvBlack 8.4s ease forwards;
}
@keyframes cvBlack {
  0%  { opacity: 0; }
  80% { opacity: 0; }
  100%{ opacity: 1; }
}

/* ── Teleport scroll warp animation ── */
#teleport-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: none; pointer-events: none;
  overflow: hidden;
}
#teleport-overlay .tp-dim {
  position: absolute; inset: 0;
  background: #060e26; opacity: 0;
  animation: tpDim 1.6s ease forwards;
}
@keyframes tpDim { to { opacity: 0.85; } }
#teleport-overlay .tp-ring {
  position: absolute; top: 50%; left: 50%;
  width: 70px; height: 70px; margin: -35px 0 0 -35px;
  border: 3px solid #7fe8ff; border-radius: 50%;
  box-shadow: 0 0 26px #7fe8ff, inset 0 0 18px #7fe8ff;
  opacity: 0;
  animation: tpRing 1.5s ease-out forwards;
}
#teleport-overlay .tp-ring2 {
  animation-delay: 0.25s;
  border-color: #b88cff;
  box-shadow: 0 0 26px #b88cff, inset 0 0 18px #b88cff;
}
#teleport-overlay .tp-ring3 { animation-delay: 0.5s; }
@keyframes tpRing {
  0%   { transform: scale(0.15) rotate(0deg);  opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: scale(16) rotate(40deg); opacity: 0; }
}
#teleport-overlay .tp-flash {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, #f2ffff 0%, #aee2ff 45%, #5d8ae8 100%);
  opacity: 0;
  animation: tpFlash 1.8s ease forwards;
}
@keyframes tpFlash {
  0%   { opacity: 0; }
  55%  { opacity: 0; }
  90%  { opacity: 1; }
  100% { opacity: 1; }
}
#teleport-overlay .tp-label {
  position: absolute; top: 56%; left: 50%; transform: translateX(-50%);
  font-family: var(--font-pixel); font-size: 13px; color: #1a3a6a;
  letter-spacing: 2px; text-shadow: 0 0 12px #ffffff;
  opacity: 0;
  animation: tpLabel 1.8s ease forwards;
}
@keyframes tpLabel {
  0%   { opacity: 0; transform: translateX(-50%) translateY(14px); }
  70%  { opacity: 0; transform: translateX(-50%) translateY(14px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.vote-dir-btn:hover:not(:disabled)  { border-color: var(--text-gold); color: var(--text-gold); }
.vote-dir-btn.voted { border-color: var(--text-cyan); background: #0a2030; }
.vote-dir-btn.locked { border-color: var(--text-red); background: #200; color: var(--text-red); }
.vote-dir-btn.winner { border-color: var(--text-green); background: #0a2010; color: var(--text-green); }
.vote-dir-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.vote-dir-btn.voted:disabled { opacity: 1; }
.vote-dir-btn.locked:disabled { opacity: 0.4; }
.vote-center { grid-column: 2; grid-row: 2; font-size: 11px; color: var(--text-dim); border: none !important; cursor: default !important; }

.vote-avatars { display: flex; gap: 6px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.vote-avatar {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 6px; border: 2px solid var(--border-dim);
  image-rendering: pixelated;
  transition: border-color 0.2s; flex-shrink: 0;
}
.vote-avatar.voted-n { border-color: #8080ff; }
.vote-avatar.voted-s { border-color: #8080ff; }
.vote-avatar.voted-e { border-color: #8080ff; }
.vote-avatar.voted-w { border-color: #8080ff; }
.vote-avatar.waiting { opacity: 0.4; }

/* Tile Event Panel */
#tile-event-panel { text-align: center; padding: 4px 0; }
.event-title {
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--text-gold); margin-bottom: 10px; letter-spacing: 1px;
}
.event-narrative {
  font-size: 15px; color: var(--text-white); line-height: 1.6;
  margin-bottom: 14px; padding: 0 8px 0 10px;
  border-left: 2px solid var(--border-dim); text-align: left;
}
.event-choices { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.event-choice-btn {
  font-family: var(--font-pixel); font-size: 8px;
  background: var(--bg-panel2); border: 2px solid var(--border-dim);
  color: var(--text-white); cursor: pointer; border-radius: 4px;
  min-height: 46px; padding: 10px 14px; text-align: left; transition: all 0.15s;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
  width: 100%; max-width: 640px;
}
.event-choice-btn:hover:not(:disabled) { border-color: var(--text-gold); color: var(--text-gold); }
.event-choice-btn.active { border-color: var(--text-cyan); background: #0a2030; color: var(--text-cyan); }
.event-choice-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.event-choice-btn.active:disabled { opacity: 1; }
.event-choice-btn.locked { border-color: var(--text-red); color: var(--text-red); opacity: 0.45; }
#dungeon-event-panel { text-align: left; }
#dungeon-item-picker { text-align: left; }
.choice-voters {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 3px; min-width: 24px; flex-shrink: 0;
}
.choice-voter-avatar {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: 6px; border: 2px solid var(--text-cyan);
  background: var(--bg-deep); image-rendering: pixelated;
  box-shadow: 0 0 6px rgba(80, 200, 255, 0.35); flex-shrink: 0;
}
.event-vote-count { color: var(--text-cyan); margin-left: 8px; }
.vote-avatar.voted-event { border-color: var(--text-cyan); }

/* Combat Panel */
/* ── Combat Monster Layer (on-map sprites) ── */
#combat-monsters-layer {
  position: absolute;
  bottom: 10%;
  height: 65%;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 48px;
  pointer-events: none;
  z-index: 8;
  padding: 0 40px;
  overflow: visible;
}

/* Skill/action notice box floats near the top during combat */
#game-area.combat-mode #control-panel {
  top: 20%;
  transform: translate(-50%, 0);
  max-height: 45%;
}

/* Action / attack overlay actor avatar sizing (larger display for 'Attack' panels) */


.map-monster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}

.map-monster-img {
  width: 100px; height: 100px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.9));
  transition: transform 0.15s, filter 0.2s;
}

.map-monster.dead .map-monster-img {
  display: none;
}

.map-monster-name {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: #fff;
  text-shadow: 1px 1px 2px #000, -1px 1px 2px #000, 1px -1px 2px #000, -1px -1px 2px #000;
  white-space: nowrap;
}

.map-monster-hp-wrap {
  width: 88px; height: 5px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}
.map-monster-hp-fill { height: 100%; border-radius: 2px; transition: width 0.35s, background 0.35s; }

.map-monster-hp-text { font-size: 11px; color: rgba(255,255,255,0.65); text-shadow: 1px 1px 2px #000; }

.monster-status-row {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  white-space: nowrap;
}

.monster-status-badge {
  font-size: 11px;
  line-height: 1;
  padding: 1px 3px;
  border: 1px solid;
  border-radius: 3px;
  background: rgba(0,0,0,0.65);
  text-shadow: 0 0 4px currentColor;
}

/* Target-selection mode */
#combat-monsters-layer.target-mode { pointer-events: auto; }

#combat-monsters-layer.target-mode .map-monster:not(.dead) { cursor: crosshair; }

#combat-monsters-layer.target-mode .map-monster:not(.dead) .map-monster-img {
  animation: targetGlow 0.9s ease-in-out infinite alternate;
}

#combat-monsters-layer.target-mode .map-monster:not(.dead):hover .map-monster-img {
  transform: scale(1.1) translateY(-6px);
  filter: brightness(1.35) drop-shadow(0 0 18px rgba(255,60,60,1));
  animation: none;
}

@keyframes targetGlow {
  from { filter: drop-shadow(0 0 4px rgba(255,80,80,0.5)) drop-shadow(0 8px 14px rgba(0,0,0,0.9)); }
  to   { filter: drop-shadow(0 0 16px rgba(255,80,80,0.95)) drop-shadow(0 8px 14px rgba(0,0,0,0.9)); }
}


#combat-title {
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--text-red); margin-bottom: 10px; text-align: center;
}
.monster-row {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 8px; background: var(--bg-panel2);
  border: 1px solid var(--border-dim); border-radius: 4px;
  margin-bottom: 6px;
}
.monster-portrait {
  width: 54px; height: 54px; object-fit: cover;
  border-radius: 3px; image-rendering: pixelated; flex-shrink: 0;
}
.monster-info { flex: 1; }
.monster-name { font-family: var(--font-pixel); font-size: 8px; color: var(--text-white); }
.monster-hp-bar-wrap { margin-top: 4px; background: #222; border: 1px solid #333; height: 8px; border-radius: 2px; overflow: hidden; }
.monster-hp-bar { height: 100%; background: var(--text-red); border-radius: 1px; transition: width 0.3s; }
.monster-hp-text { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.monster-element-badge {
  font-family: var(--font-pixel); font-size: 7px;
  padding: 2px 5px; border-radius: 2px; border: 1px solid;
}

#combat-turn-info {
  font-family: var(--font-pixel); font-size: 9px;
  text-align: center; color: var(--text-cyan);
  margin: 8px 0;
}
#combat-actions-wrap {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 6px;
}
#combat-skill-list {
  display: flex; flex-direction: column; gap: 5px;
  margin-top: 6px;
}
/* legacy skill-btn used by item menu */
.skill-btn {
  font-family: var(--font-pixel); font-size: 7px;
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  color: var(--text-white); padding: 6px 8px; border-radius: 3px;
  cursor: pointer; transition: all 0.15s; flex: 1; min-width: 120px;
}
.skill-btn:hover:not(:disabled) { border-color: var(--text-blue); color: var(--text-blue); }
.skill-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.skill-mp-cost { color: var(--mp-color); }

/* Skill card (skill menu) */
.skill-card {
  width: 100%; box-sizing: border-box;
  background: var(--bg-panel2);
  border: 1px solid var(--border-dim);
  border-left: 3px solid var(--ec, #7888a0);
  border-radius: 3px; padding: 8px 10px;
  cursor: pointer; text-align: left; display: block;
  transition: background 0.15s, border-color 0.12s;
}
.skill-card:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  border-color: var(--ec, #7888a0);
}
.skill-card-broke, .skill-card:disabled { opacity: 0.38; cursor: not-allowed; }
.skill-card-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.skill-card-name {
  font-family: var(--font-pixel); font-size: 9px; color: var(--text-white);
}
.skill-card-mp {
  font-family: var(--font-pixel); font-size: 7px; color: var(--mp-color);
  background: rgba(80,130,220,0.15); border: 1px solid rgba(80,130,220,0.35);
  padding: 1px 6px; border-radius: 10px;
}
.skill-card-tags {
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.skill-card-elem  { font-family: var(--font-pixel); font-size: 7px; font-weight: bold; }
.skill-card-sep   { color: var(--border-dim); font-size: 10px; }
.skill-card-target{ font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); }
.skill-card-power { font-family: var(--font-pixel); font-size: 7px; color: var(--text-gold); }
.skill-card-desc  { font-family: var(--font-retro); font-size: 13px; color: var(--text-dim); line-height: 1.45; }

/* Target Selector */
.target-btn {
  font-family: var(--font-pixel); font-size: 7px;
  background: #140a20; border: 2px solid var(--text-purple);
  color: var(--text-purple); padding: 6px 8px; border-radius: 3px;
  cursor: pointer; transition: all 0.15s; flex: 1;
}
.target-btn:hover { background: var(--text-purple); color: #fff; }
.target-btn.ally-target { border-color: var(--text-green); color: var(--text-green); background: #0a1a0a; }
.target-btn.ally-target:hover { background: var(--text-green); color: var(--bg-deep); }

/* ── Town Panel ── */
#town-panel h3 {
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--text-gold); margin-bottom: 12px; text-align: center;
}
.town-menu-btn { width: 100%; margin: 6px 0; font-size: 11px; padding: 12px; }

/* ── Shop Panel ── */
/* List panels (shop/craft/blacksmith) scroll only their inner list —
   the control panel's own scrollbar is disabled for them so there is
   exactly one scrollbar and nothing slides under the title bar. */
#control-panel:has(> #shop-panel),
#control-panel:has(> #craft-panel),
#control-panel:has(> #bs-panel) {
  display: flex; flex-direction: column;
  overflow-y: hidden;
  padding-top: 0;   /* title bar sits flush with the panel's top edge */
}
#shop-panel, #craft-panel, #bs-panel {
  display: flex; flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
#shop-list {
  overflow-y: auto; flex: 1; min-height: 0;
}
#shop-panel .shop-item-row {
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-dim); padding: 8px 0;
}
#shop-panel .shop-item-icon {
  width: 40px; height: 40px; object-fit: cover;
  border-radius: 3px; image-rendering: pixelated;
}
#shop-panel .shop-item-info { flex: 1; }
#shop-panel .shop-item-name { font-family: var(--font-pixel); font-size: 8px; }
#shop-panel .shop-item-rarity { font-size: 13px; }
#shop-panel .shop-item-stats { font-size: 14px; color: var(--text-dim); }
#shop-panel .shop-item-price { color: var(--gold-color); font-size: 15px; }
#shop-panel .shop-buy-btn { font-size: 9px; padding: 6px 12px; }

/* ── Craft Menu ── */
/* Header + cost note stay fixed; only the recipe list scrolls */
#craft-panel .shop-header-row { margin-bottom: 10px; }
#craft-list { overflow-y: auto; flex: 1; min-height: 0; }
.craft-group-header { font-family: var(--font-pixel); font-size: 8px; color: var(--text-gold); margin: 14px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 4px; letter-spacing: 1px; }
.craft-recipe-row   { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.craft-item-icon    { width: 48px; height: 48px; object-fit: cover; image-rendering: pixelated; border-radius: 3px; flex-shrink: 0; }
.craft-item-info    { flex: 1; min-width: 0; }
.craft-item-name    { font-family: var(--font-pixel); font-size: 9px; margin-bottom: 3px; }
.craft-job-req      { font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }
.craft-mat-list     { display: flex; flex-wrap: wrap; gap: 4px; }
.craft-mat-req      { font-family: var(--font-pixel); font-size: 8px; padding: 2px 5px; border-radius: 2px; border: 1px solid; }
.mat-ok             { color: #6f6; border-color: #3a6a3a; background: rgba(0,100,0,0.15); }
.mat-missing        { color: #f66; border-color: #6a3a3a; background: rgba(100,0,0,0.15); }
.craft-btn          { flex-shrink: 0; align-self: center; font-size: 8px; padding: 5px 10px; }
.btn-craft          { background: var(--bg-panel2); border-color: #8a6a20; color: #d4a830; }
.btn-craft:hover    { background: rgba(138,106,32,0.3); }
.btn-copper         { border-color: #a0522d; color: #cd7f32; background: rgba(100,50,10,0.25); }
.btn-copper:hover   { background: rgba(160,82,45,0.45); }

/* ── Equipment Options ── */
.ipop-options       { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.ipop-option-row    { display: flex; justify-content: space-between; font-family: var(--font-pixel); font-size: 9px; padding: 2px 4px; border-radius: 2px; background: rgba(255,255,255,0.04); }
.opt-pos            { color: #88ee88; }
.opt-neg            { color: #ee7777; }
.draft-options      { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.draft-opt          { font-family: var(--font-pixel); font-size: 8px; padding: 1px 4px; border-radius: 2px; }
.draft-opt.opt-pos  { background: rgba(0,80,0,0.25); border: 1px solid #3a6a3a; color: #88ee88; }
.draft-opt.opt-neg  { background: rgba(80,0,0,0.25); border: 1px solid #6a3a3a; color: #ee7777; }

.ipop-mat-recipes    { display: flex; flex-direction: column; gap: 6px; }
.ipop-mat-recipe-row { display: flex; align-items: center; gap: 8px; }
.ipop-mat-recipe-icon{ width: 32px; height: 32px; object-fit: cover; image-rendering: pixelated; border-radius: 2px; }
.ipop-mat-qty        { margin-left: auto; font-family: var(--font-pixel); font-size: 9px; color: var(--text-dim); }

/* ── Inn Vote Panel ── */
#inn-vote-panel { padding: 4px 0; }
.inn-cards-list  { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; }
.inn-player-card {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px;
  border: 1px solid var(--border-dim);
  background: var(--bg-panel2);
}
.inn-card-wait   { border-color: var(--border-dim); }
.inn-card-agree  { border-color: #30a030; background: rgba(30,100,30,0.2); }
.inn-card-reject { border-color: #a03030; background: rgba(100,30,30,0.2); }
.inn-card-skip   { border-color: #444; background: rgba(0,0,0,0.1); opacity: 0.55; }
.inn-avatar {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 3px; image-rendering: pixelated; flex-shrink: 0;
}
.inn-card-info {
  flex: 1; display: flex; flex-direction: column; gap: 1px;
}
.inn-card-name  { font-family: var(--font-pixel); font-size: 8px; color: var(--text-white); }
.inn-card-gold  { font-size: 11px; }
.inn-vote-icon  {
  font-size: 16px; min-width: 22px; text-align: center;
  font-family: var(--font-pixel);
}
.inn-card-agree  .inn-vote-icon { color: #50e050; }
.inn-card-reject .inn-vote-icon { color: #e05050; }
.inn-card-wait   .inn-vote-icon { color: var(--text-dim); }
.inn-vote-actions {
  display: flex; gap: 8px; margin-top: 8px; justify-content: center;
}
.inn-vote-actions .menu-btn { flex: 1; font-size: 9px; }

/* ── Inn blackout overlay ── */
#inn-blackout {
  display: none;
  position: fixed; inset: 0;
  z-index: 99999;            /* above everything including item popup */
  background: #000;
  pointer-events: all;       /* block all clicks during animation */
}

/* ── Draggable Map Windows ── */
.map-window {
  position: absolute;
  background: var(--bg-overlay);
  border: 2px solid var(--border-gold);
  border-radius: 6px;
  z-index: 30;
  backdrop-filter: blur(4px);
  min-width: 180px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.map-window-handle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: rgba(240,200,48,0.08);
  border-bottom: 1px solid var(--border-gold);
  border-radius: 4px 4px 0 0;
  cursor: grab; user-select: none;
  font-family: var(--font-pixel); font-size: 8px;
  color: var(--text-gold);
}
.map-window-handle:active { cursor: grabbing; }
.map-window-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; cursor: pointer; line-height: 1; padding: 0 2px;
}
.map-window-close:hover { color: var(--text-white); }
#local-map-window  { top: 50px; left: 10px; width: 260px; }
#world-map-window  { top: 50px; left: 290px; width: 480px; }
#minimap-local  { padding: 10px; overflow: auto; max-height: calc(100vh - 130px); }
#minimap-world  { padding: 10px; overflow: auto; max-height: 400px; }

/* Local Grid — columns set via inline style per scene */
.local-grid {
  display: grid;
  gap: 3px;
}
.local-cell {
  aspect-ratio: 1;
  background: #1a1a2a;
  border: 1px solid var(--border-dim);
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; position: relative;
}
.local-cell.current  { border-color: var(--text-gold); background: #2a2010; }
.local-cell.fog      { background: #0a0a12; }
.local-cell.boss     { border-color: var(--text-red); }
/* Dungeon layout cells */
.local-grid.dungeon-map { gap: 2px; }
.local-grid.dungeon-map .local-cell { font-size: 9px; }
.local-cell.dungeon-wall { background: #0a0a0a; border-color: transparent; pointer-events: none; }
.local-cell.dungeon-start { border-color: #44aaff; }

/* World Grid */
.world-grid-wrap { overflow: visible; }
.map-compass {
  font-family: var(--font-pixel); font-size: 8px;
  color: var(--text-dim); text-align: center; margin-bottom: 4px;
}
.world-grid {
  display: inline-grid;
  gap: 2px;
}
.world-cell {
  width: 72px; height: 46px;
  border: 1px solid #2a2a3a; border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; cursor: default; gap: 2px; padding: 2px;
  position: relative; overflow: hidden;
}
.world-cell::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  pointer-events: none;
}
.world-cell > * { position: relative; z-index: 1; }
.wc-icon { line-height: 1; }
.wc-name {
  font-family: var(--font-pixel); font-size: 6px;
  color: #fff; opacity: 0.9; line-height: 1.3;
  overflow: hidden; white-space: nowrap; max-width: 68px;
  text-overflow: ellipsis; text-align: center;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
.world-cell.grass   { background: #152410; color: #9de060; }
.world-cell.town    { background: #2a1810; color: #f0c060; }
.world-cell.dungeon { background: #160a22; color: #c080ff; }
.world-cell.fog     { background: #080810; color: #222; }
.world-cell.empty   { background: transparent; border-color: transparent; pointer-events: none; }
.world-cell.current {
  border: 2px solid var(--text-gold);
  color: var(--text-gold);
  font-size: 11px;
  box-shadow: 0 0 6px rgba(240,200,48,0.5);
}
.map-legend {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px; font-size: 11px;
}
.leg-grass   { color: #3a6020; }
.leg-dungeon { color: #804080; }
.leg-town    { color: #c08040; }
.leg-current { color: var(--text-gold); }
.leg-hinted  { color: #7a5030; font-style: italic; }

/* Hinted (rumored) macro tile — nearest town pre-revealed at game start */
.world-cell.hinted {
  background: #1a0e06;
  color: #7a5030;
  border: 1px dashed #4a2a10;
  opacity: 0.75;
}
.wc-hint {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: #7a5030;
  font-style: italic;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* ── Inventory Overlay ── */
#inventory-overlay {
  position: absolute; top: 50px; left: 100px;
  width: 420px; max-height: calc(100% - 80px);
  background: var(--bg-overlay); border: 2px solid var(--border-gold);
  border-radius: 6px;
  z-index: 30; backdrop-filter: blur(4px);
  display: flex; flex-direction: column;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.overlay-header {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-pixel); font-size: 9px; color: var(--text-gold);
  padding: 6px 10px;
  background: rgba(240,200,48,0.08);
  border-bottom: 1px solid var(--border-gold);
  border-radius: 4px 4px 0 0;
  cursor: grab; user-select: none; flex-shrink: 0;
}
.overlay-header:active { cursor: grabbing; }
.overlay-header button {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px;
}
.overlay-header button:hover { color: var(--text-white); }
#inventory-content { padding: 12px; overflow-y: auto; flex: 1; }
.inv-readonly-badge {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-dim); border-radius: 2px;
  padding: 2px 6px; margin-left: 8px; letter-spacing: 1px;
}
.inv-item-cell.readonly { cursor: default; }
.inv-item-cell.readonly:hover { border-color: var(--border-dim); }

/* Body mannequin equipment grid */
.equip-body-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto auto auto;
  gap: 6px;
  margin-bottom: 12px;
}
.equip-body-slot {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 7px 4px 6px;
  border: 1px solid var(--border-dim); border-radius: 4px;
  background: var(--bg-panel2);
  position: relative; min-height: 88px;
  text-align: center;
}
.equip-body-slot.slot-blocked { opacity: 0.38; }
.equip-body-slot.slot-clickable { cursor: pointer; }
.equip-body-slot.slot-clickable:hover { border-color: var(--text-gold); background: rgba(180,140,60,0.08); }
.equip-body-slot-label {
  font-family: var(--font-pixel); font-size: 6px;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px;
}
.equip-body-slot img {
  width: 38px; height: 38px;
  object-fit: cover; image-rendering: pixelated;
  border: 1px solid var(--border-dim); border-radius: 2px;
}
.equip-body-slot-name {
  font-family: var(--font-pixel); font-size: 6px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; padding: 0 2px; width: 100%;
  box-sizing: border-box;
}
.equip-body-slot .equip-remove-btn {
  position: absolute; top: 3px; right: 3px;
  font-size: 6px; padding: 1px 3px;
}
.slot-head       { grid-column: 2; grid-row: 1; }
.slot-lefthand   { grid-column: 1; grid-row: 2; }
.slot-body       { grid-column: 2; grid-row: 2; }
.slot-righthand  { grid-column: 3; grid-row: 2; }
.slot-legs       { grid-column: 2; grid-row: 3; }
.slot-accessory1 { grid-column: 1; grid-row: 4; }
.slot-accessory2 { grid-column: 3; grid-row: 4; }
.equip-remove-btn {
  font-family: var(--font-pixel); font-size: 7px;
  background: none; border: 1px solid var(--text-red);
  color: var(--text-red); padding: 4px 6px; border-radius: 2px;
  cursor: pointer;
}

.inv-bag-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  margin-top: 8px;
}
.inv-item-cell {
  aspect-ratio: 1;
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  border-radius: 3px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.15s; position: relative;
}
.inv-item-cell:hover { border-color: var(--border-gold); }
.inv-item-cell img { width: 32px; height: 32px; object-fit: cover; image-rendering: pixelated; }
.inv-item-cell .item-qty {
  position: absolute; bottom: 2px; right: 4px;
  font-size: 11px; color: var(--text-white);
}
/* Bag items that the current class cannot equip */
.inv-item-cell.inv-cant-equip { border-color: #4a1010; opacity: 0.7; }
.inv-item-cell.inv-cant-equip:hover { border-color: #802020; opacity: 1; }
.inv-no-use-badge {
  position: absolute; top: 2px; left: 3px;
  font-size: 8px; color: var(--text-red);
  font-family: var(--font-pixel); line-height: 1;
}

/* ── Item Detail View ── */
.ibd-back-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.ibd-header {
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 10px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-dim);
}
.ibd-icon { width: 52px; height: 52px; object-fit: cover; image-rendering: pixelated; border-radius: 3px; flex-shrink: 0; }
.ibd-title-block { flex: 1; }
.ibd-item-name  { font-family: var(--font-pixel); font-size: 9px; line-height: 1.4; }
.ibd-element-badge {
  display: inline-block; margin-top: 3px;
  font-size: 10px; color: #f0a030;
}
.ibd-twohanded-badge {
  display: inline-block; margin-top: 3px;
  font-family: var(--font-pixel); font-size: 7px;
  color: #e06020; background: rgba(224,96,32,0.15);
  border: 1px solid #e06020; border-radius: 3px; padding: 1px 4px;
}
.ibd-props-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
  margin-bottom: 10px; font-size: 12px;
}
.ibd-prop { display: flex; gap: 5px; align-items: baseline; }
.ibd-plabel {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); min-width: 46px; flex-shrink: 0;
}
.ibd-section-label {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); margin: 8px 0 4px; letter-spacing: 1px;
}
.ibd-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
  margin-bottom: 8px;
}
.ibd-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel2); border-radius: 3px; padding: 2px 5px;
}
.ibd-stat-key { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); }
.ibd-stat-val { font-family: var(--font-pixel); font-size: 8px; color: #80e080; }
.ibd-usable-list { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.ibd-cat-badge {
  font-family: var(--font-pixel); font-size: 7px;
  background: rgba(100,80,40,0.3); border: 1px solid #6a5028;
  border-radius: 3px; padding: 2px 5px; color: #c09050;
}
.ibd-cant-equip-msg {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-red); background: rgba(180,30,30,0.12);
  border: 1px solid rgba(180,30,30,0.3); border-radius: 3px;
  padding: 4px 6px; margin-bottom: 8px;
}
.ibd-can-equip-msg {
  font-family: var(--font-pixel); font-size: 7px;
  color: #60c060; background: rgba(30,120,30,0.1);
  border: 1px solid rgba(30,120,30,0.3); border-radius: 3px;
  padding: 4px 6px; margin-bottom: 8px;
}
.ibd-actions { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.ibd-action-btn { font-size: 9px !important; padding: 5px 10px !important; }
.ibd-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ibd-confirm-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 6px 8px; background: rgba(160,30,30,0.15); border: 1px solid #883333; border-radius: 4px; }
.ibd-confirm-label { font-size: 11px; color: #e08080; flex: 1 1 100%; margin-bottom: 2px; }
.btn-red {
  background: rgba(120,20,20,0.6); border-color: #802020; color: #ff8080;
}
.btn-red:hover { background: rgba(160,30,30,0.7); }

/* ── Shop enhancements ── */
/* Title bar styled like the floating-window handles (CHARACTER STATUS etc.):
   gold-tinted strip flush with the panel's top edge, gold underline. */
.shop-header-row {
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 2;
  background: rgba(240,200,48,0.08);
  margin: 0 -20px 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-gold);
  border-radius: 4px 4px 0 0;
  font-family: var(--font-pixel); font-size: 9px; color: var(--text-gold);
}
.shop-item-meta { display: flex; gap: 4px; margin-top: 2px; }
.shop-2h-badge {
  font-family: var(--font-pixel); font-size: 7px;
  background: rgba(224,96,32,0.2); border: 1px solid #e06020;
  color: #e06020; border-radius: 2px; padding: 1px 3px;
}
.shop-cat-badge {
  font-family: var(--font-pixel); font-size: 7px;
  background: rgba(100,80,40,0.2); border: 1px solid #6a5028;
  color: #c09050; border-radius: 2px; padding: 1px 3px;
}
.sell-price { color: #60c080; }
.shop-sell-btn { background: rgba(30,60,120,0.6) !important; border-color: #4060c0 !important; }

/* Shop clickable info area (icon + name, separate from BUY button) */
.shop-item-clickable {
  display: flex; align-items: center; gap: 10px; flex: 1;
  cursor: pointer; border-radius: 4px; padding: 2px 4px; margin-right: 4px;
  transition: background 0.15s;
}
.shop-item-clickable:hover { background: rgba(240,200,48,0.07); }

/* Draft item clickable wrapper */
.draft-item-clickable { border-radius: 4px; transition: background 0.15s; }
.draft-item-clickable:hover { background: rgba(240,200,48,0.07); }
.draft-detail-hint {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); align-self: flex-end; flex-shrink: 0;
}

/* Action log 🔍 item button */
.log-item-clickable {
  cursor: pointer;
  transition: filter 0.12s;
}
.log-item-clickable:hover { filter: brightness(1.35); }
.log-item-name {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-style: dotted;
}

/* ── Item Detail Popup ── */
.item-popup-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.item-popup-overlay.hidden { display: none; }

#item-popup-card {
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  padding: 18px 20px;
  min-width: 300px; max-width: 380px; width: 90%;
  box-shadow: 0 0 32px rgba(0,0,0,0.8);
  position: relative;
}

.ipop-header {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-dim);
}
.ipop-icon {
  width: 60px; height: 60px; object-fit: cover;
  image-rendering: pixelated; border-radius: 4px; flex-shrink: 0;
  border: 1px solid var(--border-dim);
}
.ipop-title-block { flex: 1; }
.ipop-name  { font-family: var(--font-pixel); font-size: 9px; line-height: 1.5; }
.ipop-element  { font-size: 12px; color: #f0a030; margin-top: 3px; }
.ipop-2h-badge {
  display: inline-block; margin-top: 4px;
  font-family: var(--font-pixel); font-size: 7px;
  color: #e06020; background: rgba(224,96,32,0.15);
  border: 1px solid #e06020; border-radius: 3px; padding: 1px 5px;
}
.ipop-refine-badge {
  display: inline-block; margin-top: 3px;
  font-family: var(--font-pixel); font-size: 8px;
  color: #f0c830; background: rgba(240,200,48,0.15);
  border: 1px solid rgba(240,200,48,0.4); border-radius: 3px; padding: 1px 6px;
}
/* Blacksmith: header + tabs stay fixed; only the item list scrolls */
#bs-panel .shop-header-row { margin-bottom: 14px; }
#bs-panel #bs-content { overflow-y: auto; flex: 1; min-height: 0; padding: 4px 2px 6px; }
.bs-tab-btn { padding: 8px 6px; }
.bs-tab-btn.active { background: rgba(240,200,48,0.15); border-color: var(--text-gold); color: var(--text-gold); }
.bs-item-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 4px; cursor: pointer; border-radius: 3px;
  transition: background 0.15s;
}
.bs-item-row:hover { background: rgba(255,255,255,0.05); }
.bs-element-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 6px;
}
.bs-elem-btn { font-family: var(--font-pixel) !important; line-height: 1.3; }

/* ── Blacksmith animations ───────────────────────────────── */
@keyframes bs-hammer-bounce {
  0%, 100% { transform: translateY(0) rotate(-15deg); }
  45%      { transform: translateY(-14px) rotate(-15deg); }
  55%      { transform: translateY(-14px) rotate(-15deg); }
}
@keyframes bs-spark-fly1 { 0% { transform:translate(0,0); opacity:1; } 100% { transform:translate(-18px,-22px); opacity:0; } }
@keyframes bs-spark-fly2 { 0% { transform:translate(0,0); opacity:1; } 100% { transform:translate(20px,-18px); opacity:0; } }
@keyframes bs-spark-fly3 { 0% { transform:translate(0,0); opacity:1; } 100% { transform:translate(-12px,-28px); opacity:0; } }
@keyframes bs-spark-fly4 { 0% { transform:translate(0,0); opacity:1; } 100% { transform:translate(16px,-24px); opacity:0; } }
@keyframes bs-forge-label-pulse {
  0%, 100% { opacity: 0.5; } 50% { opacity: 1; }
}
@keyframes bs-item-pulse {
  0%, 100% { filter: brightness(1); box-shadow: 0 0 0px #f0c830; }
  50%      { filter: brightness(1.4); box-shadow: 0 0 16px #ff8800, 0 0 32px #f0c830; }
}
@keyframes bs-success-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  65%  { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes bs-success-glow {
  0%, 100% { text-shadow: 0 0 6px #f0c830; }
  50%      { text-shadow: 0 0 22px #ffe066, 0 0 44px #fff8; }
}
@keyframes bs-panel-success-flash {
  0%   { background: transparent; }
  25%  { background: rgba(100, 255, 120, 0.12); }
  100% { background: transparent; }
}
@keyframes bs-fail-shake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-9px); }
  35%  { transform: translateX(9px); }
  55%  { transform: translateX(-6px); }
  75%  { transform: translateX(6px); }
}
@keyframes bs-fail-flash {
  0%   { background: transparent; }
  20%  { background: rgba(255, 60, 60, 0.18); }
  100% { background: transparent; }
}
@keyframes bs-fail-text-pop {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.bs-forge-anim {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 8px 0; position: relative;
}
.bs-hammer-icon {
  font-size: 28px; display: inline-block;
  animation: bs-hammer-bounce 0.45s ease-in-out infinite;
  transform-origin: bottom right;
}
.bs-anvil-icon { font-size: 24px; display: inline-block; }
.bs-sparks { position: relative; width: 20px; height: 20px; }
.bs-spark {
  position: absolute; top: 0; left: 0; font-size: 10px; color: #f0c830;
  animation-duration: 0.6s; animation-iteration-count: infinite;
  animation-timing-function: ease-out;
}
.bs-spark.s1 { animation-name: bs-spark-fly1; animation-delay: 0s; }
.bs-spark.s2 { animation-name: bs-spark-fly2; animation-delay: 0.15s; }
.bs-spark.s3 { animation-name: bs-spark-fly3; animation-delay: 0.3s; }
.bs-spark.s4 { animation-name: bs-spark-fly4; animation-delay: 0.45s; }
.bs-forge-label {
  font-family: var(--font-pixel); font-size: 11px; color: #f0c830;
  animation: bs-forge-label-pulse 0.7s ease-in-out infinite;
}
.bs-item-pulse  { animation: bs-item-pulse 0.5s ease-in-out infinite; border-radius: 4px; }
.bs-item-glow   { box-shadow: 0 0 18px #f0c830, 0 0 36px #ffe06688; border-radius: 4px; }

.bs-result-success {
  font-family: var(--font-pixel); font-size: 15px; color: #f0c830;
  text-align: center; padding: 10px 0;
  animation: bs-success-pop 0.5s ease-out forwards, bs-success-glow 1.5s ease-in-out infinite 0.5s;
}
.bs-result-fail {
  font-family: var(--font-pixel); font-size: 14px; color: #f55;
  text-align: center; padding: 10px 0;
  animation: bs-fail-text-pop 0.4s ease-out forwards;
}
.bs-success-flash { animation: bs-panel-success-flash 1.2s ease-out forwards; }
.bs-fail-shake    { animation: bs-fail-shake 0.55s ease-in-out, bs-fail-flash 1.2s ease-out; }
.ipop-close-btn {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; cursor: pointer; line-height: 1;
  padding: 2px 5px;
}
.ipop-close-btn:hover { color: var(--text-white); }

.ipop-props {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 3px 12px; margin-bottom: 10px; font-size: 12px;
}
.ipop-prop  { display: flex; gap: 5px; align-items: baseline; }
.ipop-plabel {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); min-width: 46px; flex-shrink: 0;
}
.ipop-sell-hint { font-size: 11px; color: #60c080; }

.ipop-section-label {
  font-family: var(--font-pixel); font-size: 7px;
  color: var(--text-dim); margin: 8px 0 4px; letter-spacing: 1px;
}
.ipop-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
  margin-bottom: 6px;
}
.ipop-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel2); border-radius: 3px; padding: 2px 5px;
}
.ipop-stat-key { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); }
.ipop-stat-val { font-family: var(--font-pixel); font-size: 8px; color: #80e080; }
.ipop-no-stats { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.ipop-cats  { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Fullscreen Overlays ── */
.fullscreen-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}

/* Game-area-relative overlay — centres on the bg, not the full viewport */
.game-area-overlay {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
}
.game-area-overlay.hidden { display: none; }

/* Dice popup uses game-area overlay so it sits centred on the background */
#dice-popup { background: transparent; backdrop-filter: none; }

/* Dice Popup */
#dice-popup-inner {
  text-align: center;
  background: var(--bg-panel); border: 3px solid var(--border-gold);
  border-radius: 8px; padding: 30px 40px;
  min-width: 280px;
}
#dice-label {
  font-family: var(--font-pixel); font-size: 10px;
  color: var(--text-dim); margin-bottom: 20px;
}
#dice-display {
  display: flex; gap: 20px; justify-content: center;
  margin-bottom: 16px;
}
.die {
  width: 72px; height: 72px;
  background: var(--bg-panel2); border: 3px solid var(--border-gold);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-pixel); font-size: 28px; color: var(--text-gold);
  box-shadow: 0 0 16px rgba(240,200,48,0.3);
}
.die.rolling { animation: dieRoll 0.6s ease; }
@keyframes dieRoll {
  0%,100% { transform: scale(1); }
  25%      { transform: scale(1.15) rotate(-8deg); }
  75%      { transform: scale(1.15) rotate(8deg); }
}
#dice-result-text {
  font-family: var(--font-pixel); font-size: 18px; min-height: 28px;
  letter-spacing: 1px;
}
.dice-normal  { color: var(--text-white); }
.dice-crit    { color: var(--text-orange); text-shadow: 0 0 10px rgba(232,128,64,0.8); }
.dice-supercrit { color: var(--gold-color); text-shadow: 0 0 16px rgba(240,200,48,0.9); animation: superCritPulse 0.5s ease infinite alternate; }
.dice-fumble  { color: var(--text-purple); text-shadow: 0 0 10px rgba(192,96,232,0.8); }
@keyframes superCritPulse { from { letter-spacing: 1px; } to { letter-spacing: 3px; } }

/* ── Damage Vignette (local player hit flash) ── */
#damage-vignette {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200,20,20,0.75) 100%);
  pointer-events: none;
  z-index: 300;
  opacity: 0;
}
#damage-vignette.flashing { animation: vignetteFlash 0.65s ease-out forwards; }
@keyframes vignetteFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Battle Start Banner ─────────────────────────────────────── */
#battle-start-overlay {
  position: absolute; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
}

/* Normal battle — sky blue */
.battle-banner-bg-normal {
  background: linear-gradient(180deg,
    rgba(20,100,220,0.0)   0%,
    rgba(20,100,220,0.82) 30%,
    rgba(10, 50,140,0.88) 60%,
    rgba(5,  20, 70,0.0) 100%);
  animation: battleBannerFade 2.0s ease forwards;
}
.battle-banner-text-normal {
  font-family: var(--font-pixel); font-size: 26px; letter-spacing: 4px;
  color: #e0f4ff;
  text-shadow: 0 0 18px rgba(80,180,255,0.95), 0 0 40px rgba(40,140,255,0.6);
  animation: battleTextPop 1.95s ease forwards;
}

/* Boss battle — crimson red, same animation style */
.battle-banner-bg-boss {
  background: linear-gradient(180deg,
    rgba(180,10,10,0.0)   0%,
    rgba(180,10,10,0.88) 30%,
    rgba( 90, 0, 0,0.92) 60%,
    rgba( 30, 0, 0,0.0) 100%);
  animation: battleBannerFade 2.6s ease forwards;
}
.battle-banner-text-boss {
  font-family: var(--font-pixel); font-size: 34px; letter-spacing: 6px;
  color: #ffe0e0;
  text-shadow: 0 0 22px rgba(255,60,60,1), 0 0 55px rgba(220,0,0,0.75), 0 0 90px rgba(160,0,0,0.5);
  animation: battleTextPop 2.5s ease forwards;
}
.battle-banner-sub {
  font-family: var(--font-pixel); font-size: 11px; letter-spacing: 5px;
  color: #ffaaaa; margin-top: 12px; opacity: 0;
  animation: battleTextPop 2.5s ease 0.18s forwards;
}

@keyframes battleBannerFade {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  65%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes battleTextPop {
  0%   { transform: scale(0.15); opacity: 0; }
  18%  { transform: scale(1.15); opacity: 1; }
  28%  { transform: scale(0.97); }
  35%  { transform: scale(1.0); }
  68%  { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(1.05); opacity: 0; }
}

/* ── Treasure Chest Popup ── */
.tr-wrap {
  position: absolute;
  left: 50%; top: 52%;
  transform: translate(-50%, -50%);
  z-index: 200;
  pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
}
.tr-chest {
  animation: trChestPop 0.5s cubic-bezier(0.34,1.6,0.64,1) forwards,
             trChestShake 0.35s ease-in-out 0.5s forwards;
  transform-origin: bottom center;
  filter: drop-shadow(0 0 14px rgba(240,200,48,0.9));
}
.tr-chest img {
  width: 80px; height: 80px;
  image-rendering: pixelated; display: block;
}
@keyframes trChestPop {
  0%   { transform: scale(0) rotate(-12deg); opacity: 0; }
  55%  { transform: scale(1.4) rotate(5deg);  opacity: 1; }
  75%  { transform: scale(0.9) rotate(-2deg); }
  100% { transform: scale(1.0) rotate(0deg); opacity: 1; }
}
@keyframes trChestShake {
  0%   { transform: scale(1.0) rotate(0deg); }
  20%  { transform: scale(1.05) rotate(-8deg); }
  40%  { transform: scale(1.08) rotate(8deg); }
  60%  { transform: scale(1.05) rotate(-5deg); }
  80%  { transform: scale(1.03) rotate(3deg); }
  100% { transform: scale(1.0) rotate(0deg); }
}
.tr-particle {
  position: absolute;
  top: 0; left: 0;
  animation: trParticleBurst 1.1s ease-out forwards;
  animation-fill-mode: both;
  opacity: 0;
}
@keyframes trParticleBurst {
  0%   { transform: translate(0,0) scale(0.4); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(var(--px), var(--py)) scale(0.6); opacity: 0; }
}
.tr-coin {
  font-size: 20px;
  color: #f0c820;
  text-shadow: 0 0 8px rgba(240,200,32,0.9);
}
.tr-item-particle img {
  width: 30px; height: 30px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(180,120,255,0.9));
}
.tr-label {
  margin-top: 8px;
  font-family: var(--font-pixel); font-size: 14px;
  letter-spacing: 2px;
  animation: trLabelRise 1.8s ease-out forwards;
  animation-delay: 0.25s;
  opacity: 0;
}
.tr-label-gold { color: #f0c820; text-shadow: 0 0 12px rgba(240,200,32,0.8); }
.tr-label-item { color: #60b8ff; text-shadow: 0 0 12px rgba(80,160,255,0.8); }
@keyframes trLabelRise {
  0%   { transform: translateY(10px); opacity: 0; }
  20%  { opacity: 1; }
  75%  { transform: translateY(-18px); opacity: 1; }
  100% { transform: translateY(-28px); opacity: 0; }
}

/* ── Player avatar hit flash (all players see) ── */
.player-card.hit .portrait {
  animation: avatarHitFlash 0.5s ease-out forwards;
}
@keyframes avatarHitFlash {
  0%, 25% { filter: brightness(3) sepia(1) saturate(3) hue-rotate(-30deg);
             box-shadow: 0 0 14px rgba(255,40,40,0.9); }
  60%     { filter: brightness(1.6) sepia(0.4); box-shadow: 0 0 6px rgba(255,40,40,0.4); }
  100%    { filter: none; box-shadow: none; }
}

/* ── Monster hit react (shake + red flash) ── */
.map-monster.hit .map-monster-img {
  animation: monsterHitFlash 0.45s ease-out forwards;
}
@keyframes monsterHitFlash {
  0%   { filter: brightness(3) sepia(1) saturate(3) hue-rotate(-30deg)
                 drop-shadow(0 0 14px rgba(255,30,30,1));
         transform: translateX(-7px) scale(1.1); }
  30%  { filter: brightness(3) sepia(1) saturate(3) hue-rotate(-30deg)
                 drop-shadow(0 0 12px rgba(255,30,30,0.8));
         transform: translateX(7px) scale(1.12); }
  60%  { filter: brightness(1.6) sepia(0.3) drop-shadow(0 0 6px rgba(255,30,30,0.4));
         transform: translateX(-3px) scale(1.04); }
  100% { filter: drop-shadow(0 8px 14px rgba(0,0,0,0.9));
         transform: translateX(0) scale(1); }
}

/* ── Monster attack lunge ── */
.map-monster.attacking .map-monster-img {
  animation: monsterAttack 0.55s ease-out forwards;
}
@keyframes monsterAttack {
  0%   { transform: translateX(0)     scale(1);    }
  28%  { transform: translateX(-38px) scale(1.18); filter: brightness(1.25) drop-shadow(0 8px 14px rgba(0,0,0,0.9)); }
  65%  { transform: translateX(-10px) scale(1.06); }
  100% { transform: translateX(0)     scale(1);    filter: drop-shadow(0 8px 14px rgba(0,0,0,0.9)); }
}

/* Multi-roll loot contest layout */
#multi-roll-grid { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.roll-entry {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border-dim);
}
.roll-entry.winner {
  border-color: var(--border-gold);
  background: rgba(240,200,48,0.08);
  box-shadow: 0 0 10px rgba(240,200,48,0.3);
}
.roll-player-name { font-family: var(--font-pixel); font-size: 8px; color: var(--text-dim); }
.roll-dice-pair { display: flex; gap: 8px; }
.roll-dice-pair .die { width: 54px; height: 54px; font-size: 22px; }
.roll-total { font-family: var(--font-pixel); font-size: 14px; color: var(--text-white); min-height: 18px; }
.roll-winner-text {
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--text-gold); margin-top: 12px;
  text-shadow: 0 0 10px rgba(240,200,48,0.7);
}

/* Draft Overlay */
#draft-inner {
  background: var(--bg-panel); border: 3px solid var(--border-gold);
  border-radius: 8px; padding: 24px 32px;
  min-width: 340px; text-align: center;
}
#draft-header {
  font-family: var(--font-pixel); font-size: 12px;
  color: var(--text-gold); margin-bottom: 16px;
}
#draft-item-display {
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  border-radius: 4px; padding: 14px; margin-bottom: 12px;
}
.draft-item-name {
  font-family: var(--font-pixel); font-size: 10px; margin-bottom: 6px;
}
.draft-item-stats { font-size: 15px; color: var(--text-dim); }
#draft-answer-line { font-size: 13px; color: var(--text-dim); margin: 6px 0 12px; }
#draft-actions { display: flex; gap: 16px; justify-content: center; min-height: 40px; align-items: center; }
.draft-my-choice { font-size: 14px; color: var(--text-cyan); }

#draft-response-row {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap; margin: 12px 0 4px;
}
.draft-player-resp {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 2px solid var(--border-dim); border-radius: 4px;
  padding: 6px 10px; min-width: 60px;
  transition: border-color 0.2s;
}
.draft-resp-want  { border-color: var(--text-gold); }
.draft-resp-pass  { border-color: var(--border-dim); opacity: 0.5; }
.draft-resp-wait  { border-color: var(--border-dim); }
.draft-resp-avatar { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; image-rendering: pixelated; }

/* Monster target avatar (when a monster shows which player they're targeting) */
.map-monster .target-avatar {
  width: 56px; height: 56px; object-fit: cover; border-radius: 6px;
  border: 2px solid var(--border-gold); image-rendering: pixelated;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
.draft-resp-name   { font-size: 11px; color: var(--text-dim); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-resp-icon   { font-family: var(--font-pixel); font-size: 12px; color: var(--text-gold); }

/* Modal */
#modal-box {
  background: var(--bg-panel); border: 2px solid var(--border-gold);
  border-radius: 6px; padding: 24px 28px;
  max-width: 480px; width: 90%; text-align: center;
}
#modal-title {
  font-family: var(--font-pixel); font-size: 11px;
  color: var(--text-gold); margin-bottom: 14px;
}
#modal-body { font-size: 17px; line-height: 1.7; margin-bottom: 18px; color: var(--text-white); }
#modal-actions { display: flex; gap: 12px; justify-content: center; }

/* Level-Up */
#levelup-inner {
  background: var(--bg-panel); border: 3px solid var(--border-gold);
  border-radius: 8px; padding: 24px 32px;
  min-width: 360px; text-align: center;
}
#levelup-header {
  font-family: var(--font-pixel); font-size: 14px;
  color: var(--text-gold); margin-bottom: 6px;
  animation: levelupGlow 0.8s ease infinite alternate;
}
@keyframes levelupGlow {
  from { text-shadow: 0 0 8px rgba(240,200,48,0.4); }
  to   { text-shadow: 0 0 24px rgba(240,200,48,0.9); }
}
#levelup-player-name { font-size: 20px; color: var(--text-white); margin-bottom: 14px; }
#levelup-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  text-align: left; margin-bottom: 10px;
}
.levelup-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel2); border: 1px solid var(--border-dim);
  padding: 6px 10px; border-radius: 3px;
}
.levelup-stat-name { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); }
.levelup-stat-val  { font-size: 16px; color: var(--text-white); }
.levelup-stat-btn  {
  font-family: var(--font-pixel); font-size: 8px;
  background: none; border: 1px solid var(--border-gold);
  color: var(--text-gold); padding: 2px 6px; border-radius: 2px;
  cursor: pointer; margin-left: 6px;
}
.levelup-stat-btn:disabled { opacity: 0.3; cursor: not-allowed; }
#levelup-points-left {
  font-size: 16px; color: var(--text-cyan); margin-bottom: 12px;
}

/* ── Rarity Colours ── */
.rarity-trash       { color: var(--rarity-trash); }
.rarity-barely      { color: var(--rarity-barely); }
.rarity-common      { color: var(--rarity-common); }
.rarity-uncommon    { color: var(--rarity-uncommon); }
.rarity-rare        { color: var(--rarity-rare); }
.rarity-superrare   { color: var(--rarity-superrare); }
.rarity-ultrarare   { color: var(--rarity-ultrarare); }
.rarity-legendary   { color: var(--rarity-legendary); }
.rarity-divine      { color: var(--rarity-divine); }
.rarity-god         { color: var(--rarity-god); animation: godShimmer 2s linear infinite; }

@keyframes godShimmer {
  0%   { text-shadow: 0 0 6px #ff88ff; }
  33%  { text-shadow: 0 0 6px #ffff88; }
  66%  { text-shadow: 0 0 6px #88ffff; }
  100% { text-shadow: 0 0 6px #ff88ff; }
}

/* ── Element Colours ── */
.elem-fire      { color: #e85020; }
.elem-ice       { color: #60c0e8; }
.elem-lightning { color: #e8d040; }
.elem-earth     { color: #a06040; }
.elem-light     { color: #f8f0a0; }
.elem-dark      { color: #c060e8; }
.elem-neutral   { color: #aaaaaa; }

/* ── Status Effect Badges ── */
.status-poison  { color: var(--text-green); font-family: var(--font-pixel); font-size: 8px; }
.status-silence { color: var(--mp-color);   font-family: var(--font-pixel); font-size: 8px; }
.status-blind   { color: var(--text-dim);   font-family: var(--font-pixel); font-size: 8px; }
.status-bleed      { color: #cc2222; font-family: var(--font-pixel); font-size: 8px; }
.status-leg_broken { color: #a05030; font-family: var(--font-pixel); font-size: 8px; }

/* ── Damage Pop Numbers ── */
.damage-pop {
  position: absolute;
  font-family: var(--font-pixel); font-size: 14px;
  pointer-events: none; z-index: 50;
  animation: popFloat 1.4s ease forwards;
}
.damage-pop.phys  { color: var(--text-white); }
.damage-pop.magic { color: var(--text-blue); }
.damage-pop.heal  { color: var(--hp-color); }
.damage-pop.crit  { color: var(--text-orange); font-size: 18px; }
.damage-pop.miss  { color: var(--text-dim); }
@keyframes popFloat {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Floating Sound Widget ── */
#sound-widget {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  user-select: none;
}

/* The toggle button (speaker icon) */
#sound-toggle-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-panel2);
  border: 2px solid var(--border-gold);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
#sound-toggle-btn:hover { background: var(--border-gold); transform: scale(1.08); }

/* The expandable panel */
#sound-panel {
  position: absolute;
  bottom: 52px;
  right: 0;
  width: 270px;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
}

.sound-panel-title {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--text-gold);
  letter-spacing: 2px;
  margin-bottom: 12px;
  text-align: center;
}

.sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sound-row:last-child { margin-bottom: 0; }

.sound-label {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-dim);
  width: 34px;
  flex-shrink: 0;
}

/* Range slider */
.vol-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border-dim);
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-gold);
  border: 2px solid var(--bg-deep);
  cursor: pointer;
  transition: background 0.15s;
}
.vol-slider::-webkit-slider-thumb:hover { background: #fff; }

.sound-val {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-white);
  width: 28px;
  flex-shrink: 0;
  text-align: right;
}

.sound-mute-btn {
  background: none;
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.sound-mute-btn:hover { border-color: var(--text-gold); color: var(--text-gold); }
.sound-mute-btn.muted { color: var(--text-red); border-color: var(--text-red); }

/* ── Quest Log Panel ── */
#quest-log-window {
  min-width: 260px; max-width: 320px;
  top: 120px; right: 10px; left: auto;
}
#quest-log-content {
  max-height: 420px; overflow-y: auto;
  padding: 6px;
}
/* Tab bar */
.ql-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border-dim);
  margin-bottom: 6px;
}
.ql-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  padding: 6px 4px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: color 0.15s, border-color 0.15s;
}
.ql-tab.active { color: var(--text-gold); border-bottom-color: var(--text-gold); }
.ql-tab:hover:not(.active) { color: var(--text-white); }

.ql-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.quest-log-card {
  background: var(--bg-panel2);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
}
.quest-log-title {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--text-gold);
  margin-bottom: 4px;
}
.quest-type-badge {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 7px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 6px;
  border: 1px solid currentColor;
}
.quest-badge-gather         { color: #66cc66; }
.quest-badge-combat_local   { color: #ff9900; }
.quest-badge-combat_regional{ color: #cc44ff; }
.quest-badge-hunt_list      { color: #ffcc33; }
.quest-badge-airship        { color: #44ccff; }
.quest-log-narrative {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 5px 0 6px;
  font-style: italic;
}
.quest-log-progress { margin: 4px 0; }
.ql-locations { margin: 5px 0 3px; display: flex; flex-direction: column; gap: 2px; }
.ql-location-row { display: flex; align-items: baseline; gap: 5px; font-size: 12px; }
.ql-loc-label { font-family: var(--font-pixel); font-size: 7px; color: var(--text-dim); white-space: nowrap; }
.ql-loc-name  { color: var(--text-white); }
.quest-log-status {
  font-family: var(--font-pixel);
  font-size: 7px;
  margin: 4px 0;
}
.quest-log-reward {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}
.ql-mat-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 1px 0;
  color: var(--text-dim);
}
.ql-mat-row.fulfilled { color: var(--text-green); }

/* ── Boss death animation ────────────────────────────────────── */
.boss-dying-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  animation:
    boss-death-shake 0.35s ease-in-out infinite,
    boss-death-fade  6s ease-in forwards;
}
@keyframes boss-death-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}
@keyframes boss-death-fade {
  0%   { opacity: 1; }
  40%  { opacity: 0.8; }
  100% { opacity: 0; }
}

/* ── Monster speech bubble ───────────────────────────────────── */
.monster-speech-bubble {
  position: fixed;
  transform: translateX(-50%);
  background: rgba(15, 8, 4, 0.96);
  border: 2px solid #c88c44;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--font-main);
  font-size: 13px;
  color: #ffe8c0;
  max-width: 260px;
  text-align: center;
  pointer-events: none;
  z-index: 160;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.85);
  animation: speech-bubble-show 2.8s ease forwards;
}
.monster-speech-bubble::after {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
  border-bottom-color: #c88c44;
  border-top: none;
}
@keyframes speech-bubble-show {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  10%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}

/* ── Quest NPC Panel (in control panel) ── */
#quest-npc-panel { padding: 4px 0; }
.quest-npc-section {
  margin: 8px 0;
}
.quest-mat-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 3px 0;
  border-bottom: 1px solid var(--border-dim);
}
.quest-mat-row.fulfilled .quest-mat-name,
.quest-mat-row.fulfilled .quest-mat-count { color: var(--text-green); }
.quest-mat-name { color: var(--text-white); }
.quest-mat-count { color: var(--text-dim); font-size: 11px; }
.quest-contribute-btn { font-size: 11px; padding: 4px 8px; }
.quest-vote-row {
  display: flex; align-items: center; gap: 8px; margin: 6px 0;
}
.quest-vote-count {
  font-family: var(--font-pixel);
  font-size: 8px; color: var(--text-dim);
}
.quest-voters { display: flex; gap: 4px; margin-top: 4px; }
.quest-reward-line {
  font-size: 11px;
  color: var(--text-gold);
  font-family: var(--font-pixel);
  font-size: 8px;
  margin-top: 6px;
}
.quest-target-label {
  font-family: var(--font-pixel); font-size: 8px;
  color: var(--text-dim); margin-bottom: 3px;
}
.quest-target-loc { font-size: 12px; color: var(--text-white); }
.quest-back-btn { font-size: 11px; }

/* ── Local map quest markers ── */
.local-cell.quest-npc    { border-color: #ffcc00; background: #2a2000; }
.local-cell.quest-target { border-color: #ff6600; background: #2a1000; }

/* ── World map quest target ── */
.wc-quest-target {
  position: absolute; bottom: 2px; right: 2px;
  font-size: 9px; color: #ff9900;
}

/* ── Responsive ── */
/* Responsive / mobile rules live in src/styles/mobile.css */

/* ── Abyssal Singularity In-Battle Effects ── */

/* Full-screen dark overlay during build-up */
.singularity-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 0, 30, 0.55);
  pointer-events: none;
  z-index: 155;
  animation: sing-overlay-fade 1.5s ease-out forwards;
}
@keyframes sing-overlay-fade {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  75%  { opacity: 0.85; }
  100% { opacity: 0; }
}

/* Inward-spiraling energy particle during charge phase */
.singularity-pull-particle {
  position: fixed;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #cc00ff;
  box-shadow: 0 0 7px 2px rgba(200, 0, 255, 0.9);
  pointer-events: none;
  z-index: 157;
  animation: sing-pull var(--sing-dur, 580ms) ease-in forwards;
}
@keyframes sing-pull {
  0%   { opacity: 1;   transform: translate(0, 0) scale(1.2); }
  100% { opacity: 0;   transform: translate(var(--pull-dx), var(--pull-dy)) scale(0.1); }
}

/* Orbiting charge ring that collapses inward before detonation */
.singularity-charge-ring {
  position: fixed;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 159;
  border: 2px solid rgba(190, 0, 255, 0.85);
  box-shadow: 0 0 12px 4px rgba(180, 0, 255, 0.55),
              inset 0 0 8px rgba(230, 100, 255, 0.3);
  animation: sing-charge-spin 0.95s ease-in-out forwards;
}
@keyframes sing-charge-spin {
  0%   { transform: translate(-50%,-50%) scale(0.2)  rotate(0deg);   opacity: 0.9; }
  55%  { transform: translate(-50%,-50%) scale(1.55) rotate(265deg); opacity: 0.7; }
  100% { transform: translate(-50%,-50%) scale(0.8)  rotate(445deg); opacity: 0; }
}

/* Void orb — dark core, pulsing purple ring, bright outer glow */
.singularity-orb {
  position: fixed;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 160;
  overflow: hidden;
  background: radial-gradient(circle,
    #000000 0%,
    #1a0030 22%,
    #44007a 42%,
    #8800cc 58%,
    #cc44ff 72%,
    #ff88ff 83%,
    transparent 92%
  );
  box-shadow:
    0 0 0 2px rgba(220, 0, 255, 0.9),
    0 0 20px 7px rgba(180, 0, 255, 0.85),
    0 0 55px 22px rgba(110, 0, 200, 0.65),
    0 0 115px 48px rgba(70, 0, 150, 0.3),
    inset 0 0 28px rgba(0, 0, 0, 1);
  animation: sing-orb-pulse 1.7s ease-out forwards;
}
@keyframes sing-orb-pulse {
  0%   { transform: translate(-50%,-50%) scale(0.1);  opacity: 0; }
  12%  { transform: translate(-50%,-50%) scale(1.1);  opacity: 1; }
  35%  { transform: translate(-50%,-50%) scale(0.9);  opacity: 1; }
  55%  { transform: translate(-50%,-50%) scale(1.15); opacity: 1;
         box-shadow: 0 0 0 3px rgba(255,120,255,1), 0 0 35px 14px rgba(210,0,255,1),
                     0 0 90px 40px rgba(140,0,220,0.75), 0 0 150px 65px rgba(80,0,160,0.4),
                     inset 0 0 32px rgba(0,0,0,1); }
  75%  { transform: translate(-50%,-50%) scale(4.8);  opacity: 0.55; }
  100% { transform: translate(-50%,-50%) scale(7.5);  opacity: 0; }
}

/* Vein/crack lines radiating from center, clipped to the orb's circle via overflow:hidden */
.singularity-vein {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 1.5px;
  transform-origin: left center;
  background: linear-gradient(90deg,
    rgba(255, 120, 255, 0.05) 0%,
    rgba(255, 160, 255, 0.9)  28%,
    rgba(255, 210, 255, 1.0)  50%,
    rgba(255, 160, 255, 0.9)  72%,
    transparent 100%
  );
  animation: sing-vein-pulse 0.65s ease-in-out infinite alternate;
}
@keyframes sing-vein-pulse {
  0%   { opacity: 0.3; filter: blur(0.9px); }
  100% { opacity: 1.0; filter: blur(0px); }
}

/* Energy tendril from orb toward a monster */
.singularity-tendril {
  position: fixed;
  height: 2px;
  transform-origin: left center;
  pointer-events: none;
  z-index: 158;
  background: linear-gradient(90deg,
    rgba(210, 0, 255, 0.95) 0%,
    rgba(255, 120, 255, 0.7) 40%,
    rgba(255, 190, 255, 0.35) 75%,
    transparent 100%
  );
  filter: blur(0.7px);
  animation: sing-tendril-flash 0.88s ease-out forwards;
}
@keyframes sing-tendril-flash {
  0%   { opacity: 0; transform: rotate(var(--tend-angle)) scaleX(0); }
  22%  { opacity: 1; transform: rotate(var(--tend-angle)) scaleX(1); }
  100% { opacity: 0; transform: rotate(var(--tend-angle)) scaleX(1.25); }
}

/* Full-screen purple flash at detonation */
.singularity-detonation-flash {
  position: fixed;
  inset: 0;
  background: rgba(210, 0, 255, 0.42);
  pointer-events: none;
  z-index: 163;
  animation: sing-det-flash 380ms ease-out forwards;
}
@keyframes sing-det-flash {
  0%   { opacity: 0; }
  14%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Expanding burst ring on detonation */
.singularity-burst-ring {
  position: fixed;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 162;
  border: 3px solid rgba(210, 0, 255, 0.9);
  box-shadow: 0 0 16px 6px rgba(180, 0, 255, 0.65),
              inset 0 0 10px rgba(255, 110, 255, 0.3);
  animation: sing-burst-expand var(--ring-dur, 570ms) ease-out forwards;
}
@keyframes sing-burst-expand {
  0%   { transform: translate(-50%,-50%) scale(0.3);              opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(var(--ring-max, 10)); opacity: 0; }
}

/* Electric impact pop on each individual monster */
.singularity-impact {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 161;
  background: radial-gradient(circle, #ffffff 0%, #aa44ff 30%, #6600cc 55%, transparent 75%);
  box-shadow: 0 0 12px 4px rgba(180, 80, 255, 0.9);
  animation: singularity-impact-pop 0.55s ease-out forwards;
}

@keyframes singularity-impact-pop {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
  70%  { transform: translate(-50%, -50%) scale(1.0); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

/* ── Vow of Genesis — holy ray beam from skill to portrait ── */
.vow-ray-beam {
  position: fixed;
  height: 3px;
  transform-origin: left center;
  background: linear-gradient(to right,
    rgba(255,255,180,0.0) 0%,
    rgba(255,230,80,0.8)  18%,
    rgba(255,255,255,1.0) 52%,
    rgba(255,230,80,0.8)  82%,
    rgba(255,255,180,0.0) 100%
  );
  border-radius: 2px;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 0 7px 3px rgba(255,215,0,0.65);
  animation: vow-beam-shoot 0.7s ease-out forwards;
}
@keyframes vow-beam-shoot {
  0%   { clip-path: inset(0 100% 0 0 round 2px); opacity: 1; }
  52%  { clip-path: inset(0 0%   0 0 round 2px); opacity: 1; }
  100% { clip-path: inset(0 0%   0 0 round 2px); opacity: 0; }
}

/* Traveling orb along the beam */
.vow-ray-orb {
  position: fixed;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 201;
  background: radial-gradient(circle, #ffffff 0%, #fff580 38%, rgba(255,210,0,0) 72%);
  box-shadow: 0 0 14px 6px rgba(255,220,0,0.9), 0 0 4px 2px #fff;
}

/* ── Vow of Genesis — golden orb burst on player card ── */
.vow-genesis-orb {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 160;
  background: radial-gradient(circle, #ffffff 0%, #ffd700 30%, #e0a000 55%, transparent 75%);
  box-shadow: 0 0 24px 10px rgba(255, 215, 0, 0.85),
              0 0 60px 24px rgba(200, 160, 0, 0.5);
  animation: vow-genesis-burst 1.3s ease-out forwards;
}

@keyframes vow-genesis-burst {
  0%   { transform: translate(-50%, -50%) scale(0.15); opacity: 1; }
  25%  { transform: translate(-50%, -50%) scale(2.0);  opacity: 1; box-shadow: 0 0 40px 18px rgba(255,220,0,0.9); }
  55%  { transform: translate(-50%, -50%) scale(3.5);  opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(5.5);  opacity: 0; }
}

/* ── Titan's Onslaught — fiery golden ground impact ── */

/* Central impact burst — white-hot core fading to fiery gold */
.titans-burst {
  position: fixed;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 162;
  background: radial-gradient(circle,
    #ffffff   0%,
    #fff200  18%,
    #ff8800  40%,
    #ff4400  62%,
    rgba(255, 68, 0, 0) 80%
  );
  box-shadow: 0 0 40px 18px rgba(255, 140, 0, 0.85),
              0 0 80px 36px rgba(255, 68, 0, 0.45);
  animation: titans-burst-anim 0.65s ease-out forwards;
}

@keyframes titans-burst-anim {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  25%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1;
         box-shadow: 0 0 60px 28px rgba(255, 160, 0, 0.9); }
  55%  { transform: translate(-50%, -50%) scale(2.0); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(3.0); opacity: 0; }
}

/* Expanding shockwave ring */
.titans-ring {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  pointer-events: none;
  z-index: 161;
  border: 5px solid rgba(255, 180, 0, 0.9);
  box-shadow: 0 0 18px 6px rgba(255, 130, 0, 0.7),
              inset 0 0 10px rgba(255, 200, 0, 0.3);
  animation: titans-ring-anim 0.55s ease-out forwards;
}

@keyframes titans-ring-anim {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 1; border-width: 5px; }
  70%  { opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(4.0); opacity: 0; border-width: 1px; }
}

/* Ember particles radiating outward */
.titans-ember {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 163;
  background: radial-gradient(circle, #ffffff 0%, #ffcc00 50%, #ff6600 100%);
  box-shadow: 0 0 6px 3px rgba(255, 140, 0, 0.8);
  animation: titans-ember-fly 0.55s ease-out forwards;
}

@keyframes titans-ember-fly {
  0%   { transform: translate(-50%, -50%) translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--tdx, 60px), var(--tdy, -40px)) scale(0); opacity: 0; }
}

/* ── Titan's Onslaught — Earth Crack Effect ─────────────────── */

/* Full-viewport container — fades out as a unit */
.titans-crack-container {
  position: fixed;
  left: 0; top: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 10000;
  animation: titans-crack-fade 0.35s ease-in 0.52s forwards;
}
@keyframes titans-crack-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Dark central pit — depth hole in the ground */
.titans-crack-pit {
  position: absolute;
  width: 52px; height: 26px;
  background: radial-gradient(ellipse at 50% 35%, #000 0%, #111 28%, #2a2a2a 55%, #555 80%, transparent 100%);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0,0,0,0.9), 0 1px 4px rgba(0,0,0,0.7);
  transform: translate(-50%, -50%) scale(0);
  animation: titans-crack-pit-grow 0.11s cubic-bezier(0.1,0,0.3,1) 0.05s forwards;
  pointer-events: none;
  z-index: 10001;
}
@keyframes titans-crack-pit-grow {
  0%   { transform: translate(-50%,-50%) scale(0); }
  60%  { transform: translate(-50%,-50%) scale(1.12); }
  100% { transform: translate(-50%,-50%) scale(1); }
}

/* Crack-arm wrapper — sets the radial angle, children animate scaleX */
.titans-crack-wrapper {
  position: absolute;
  transform-origin: 0 0;
  pointer-events: none;
}

/* Each crack line radiating outward from the pit */
.titans-crack-arm {
  position: absolute;
  height: var(--arm-h, 5px);
  width: var(--arm-w, 120px);
  top: 0; left: 0;
  /* dark base → mid gray → light → fade to transparent */
  background: linear-gradient(to right, #1a1a1a 0%, #3a3a3a 18%, #666 45%, #999 72%, #bbb 88%, transparent 100%);
  /* taper: full-width base, narrowing to ~40% at tip, with slight zigzag for crack realism */
  clip-path: polygon(0 0, 88% 12%, 100% 28%, 96% 72%, 100% 88%, 88% 100%, 0 100%);
  transform-origin: 0 50%;
  transform: translateY(-50%) scaleX(0);
  animation: titans-arm-spread var(--arm-dur, 0.16s) cubic-bezier(0.05, 0, 0.25, 1) var(--arm-delay, 0ms) forwards;
  pointer-events: none;
}
@keyframes titans-arm-spread {
  0%   { transform: translateY(-50%) scaleX(0); }
  65%  { transform: translateY(-50%) scaleX(1.04); }
  100% { transform: translateY(-50%) scaleX(1); }
}

/* ── Titan's Onslaught — Anticipation phase ─────────────────── */

/* Battlefield dims while the titan power gathers */
.titans-dim {
  position: fixed; inset: 0;
  z-index: 159; pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.55) 100%);
  opacity: 0;
  animation: titans-dim-anim 0.95s ease-out forwards;
}
@keyframes titans-dim-anim {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Looming shadow growing under the target — something huge is coming */
.titans-shadow {
  position: fixed;
  width: 110px; height: 34px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.35) 55%, transparent 75%);
  transform: translate(-50%, -50%) scale(0.1);
  z-index: 160; pointer-events: none;
  animation: titans-shadow-grow 0.5s ease-in forwards;
}
@keyframes titans-shadow-grow {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 0.2; }
  100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* Colossal energy pillar crashing down from the sky */
.titans-pillar {
  position: fixed; top: 0;
  width: 72px;
  transform: translateX(-50%) translateY(-105%);
  z-index: 161; pointer-events: none;
  background: linear-gradient(to right,
    transparent 0%, rgba(255,140,0,0.35) 15%,
    rgba(255,190,60,0.85) 35%, #ffffff 50%,
    rgba(255,190,60,0.85) 65%, rgba(255,140,0,0.35) 85%, transparent 100%);
  box-shadow: 0 0 30px 10px rgba(255,150,0,0.45);
  animation: titans-pillar-drop   0.15s cubic-bezier(0.7, 0, 1, 0.6) 0.39s forwards,
             titans-pillar-vanish 0.28s ease-out 0.6s forwards;
}
@keyframes titans-pillar-drop {
  0%   { transform: translateX(-50%) translateY(-105%); opacity: 0.9; }
  100% { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
@keyframes titans-pillar-vanish {
  0%   { transform: translateX(-50%) translateY(0) scaleX(1);   opacity: 1; }
  100% { transform: translateX(-50%) translateY(0) scaleX(0.15); opacity: 0; }
}

/* ── Titan's Onslaught — Impact & aftermath ─────────────────── */

/* White impact flash frame */
.titans-flash {
  position: fixed; inset: 0;
  background: #fff;
  z-index: 9999; pointer-events: none;
  animation: titans-flash-fade 0.2s ease-out forwards;
}
@keyframes titans-flash-fade {
  0%   { opacity: 0.85; }
  100% { opacity: 0; }
}

/* Rock debris launched skyward, falls back with gravity + spin */
.titans-debris {
  position: fixed;
  width: var(--dsz, 10px); height: var(--dsz, 10px);
  background: linear-gradient(135deg, #6b5a48 0%, #3d342a 60%, #241f18 100%);
  clip-path: polygon(30% 0, 100% 25%, 85% 90%, 15% 100%, 0 40%);
  transform: translate(-50%, -50%);
  z-index: 164; pointer-events: none;
  animation: titans-debris-arc 0.75s cubic-bezier(0.3, 0.4, 0.6, 1) forwards;
}
@keyframes titans-debris-arc {
  0%   { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg); opacity: 1; }
  45%  { transform: translate(-50%, -50%) translate(calc(var(--ddx, 60px) * 0.55), var(--dpeak, -90px)) rotate(200deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--ddx, 60px), 44px) rotate(420deg); opacity: 0; }
}

/* Dust clouds billowing up from the impact */
.titans-dust {
  position: fixed;
  width: 46px; height: 30px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(150,130,110,0.5) 0%, rgba(120,105,90,0.3) 50%, transparent 75%);
  transform: translate(-50%, -50%) scale(0.4);
  z-index: 160; pointer-events: none;
  filter: blur(2px);
  animation: titans-dust-rise 0.9s ease-out forwards;
}
@keyframes titans-dust-rise {
  0%   { transform: translate(-50%, -50%) translate(0, 0) scale(0.4); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) translate(var(--dux, 0px), -34px) scale(1.6); opacity: 0; }
}

/* Stun stars orbiting the target's head */
.titans-stun-wrap {
  position: fixed; width: 0; height: 0;
  z-index: 165; pointer-events: none;
  animation: titans-stun-spin 1.25s linear forwards;
}
.titans-stun-star {
  position: absolute;
  font-size: 15px; color: #ffe066;
  text-shadow: 0 0 6px rgba(255,210,60,0.9), 0 0 12px rgba(255,170,0,0.5);
  line-height: 0;
}
@keyframes titans-stun-spin {
  0%   { transform: rotate(0deg);   opacity: 0; }
  12%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { transform: rotate(360deg); opacity: 0; }
}

/* ── Absolute Zero — frost screen + ice blocks + snow ── */

/* Full-screen frost overlay — icy blue-white flash covering the whole viewport */
.az-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 170;
  background: radial-gradient(ellipse at center,
    rgba(220, 248, 255, 0.82) 0%,
    rgba(160, 220, 255, 0.65) 45%,
    rgba(100, 180, 240, 0.40) 75%,
    rgba(60,  140, 210, 0.15) 100%
  );
  animation: az-frost-flash 1.5s ease-out forwards;
}

@keyframes az-frost-flash {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  55%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Ice block encasing a monster — translucent crystal with sharp edges */
.az-ice-block {
  position: fixed;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 164;
  border-radius: 4px;
  background: linear-gradient(135deg,
    rgba(200, 240, 255, 0.75) 0%,
    rgba(140, 210, 255, 0.55) 40%,
    rgba(100, 180, 240, 0.35) 70%,
    rgba(180, 230, 255, 0.60) 100%
  );
  border: 2px solid rgba(160, 220, 255, 0.9);
  box-shadow: 0 0 18px 6px rgba(100, 200, 255, 0.6),
              inset 0 0 20px rgba(200, 245, 255, 0.4);
  animation: az-ice-form 2.2s ease-out forwards;
}

@keyframes az-ice-form {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  30%  { transform: translate(-50%, -50%) scale(1.0); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.0); }
}

/* Snow particles drifting downward with a slight horizontal drift */
.az-snow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 171;
  background: rgba(220, 245, 255, 0.9);
  box-shadow: 0 0 4px 2px rgba(180, 230, 255, 0.7);
  animation: az-snow-fall linear forwards;
}

@keyframes az-snow-fall {
  0%   { transform: translate(0, 0); opacity: 1; }
  80%  { opacity: 0.8; }
  100% { transform: translate(var(--az-drift, 20px), var(--az-fall, 600px)); opacity: 0; }
}

/* ── Celestial Rebirth — holy light, halo, pillars ── */

/* Full-screen divine blessing flash */
.cr-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 170;
  background: radial-gradient(ellipse at center,
    rgba(255, 255, 240, 0.95) 0%,
    rgba(255, 240, 160, 0.78) 30%,
    rgba(255, 210, 60,  0.50) 60%,
    rgba(255, 180, 0,   0.15) 100%
  );
  animation: cr-bless-flash 2.2s ease-out forwards;
}

@keyframes cr-bless-flash {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Radiant halo ring behind Miri */
.cr-halo {
  position: fixed;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  pointer-events: none;
  z-index: 160;
  border: 10px solid rgba(255, 220, 60, 0.95);
  box-shadow: 0 0 40px 16px rgba(255, 210, 0, 0.75),
              0 0 80px 32px rgba(255, 180, 0, 0.40),
              inset 0 0 30px rgba(255, 245, 180, 0.30);
  animation: cr-halo-appear 2.8s ease-out forwards;
}

@keyframes cr-halo-appear {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(0deg);   opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.1) rotate(20deg);  opacity: 1; }
  45%  { transform: translate(-50%, -50%) scale(1.0) rotate(45deg);  opacity: 1; }
  80%  { transform: translate(-50%, -50%) scale(1.0) rotate(80deg);  opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.15) rotate(100deg);opacity: 0; }
}

/* Golden light pillar descending from top of screen to player card */
.cr-pillar {
  position: fixed;
  width: 56px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 169;
  background: linear-gradient(to bottom,
    rgba(255, 255, 200, 0.0)  0%,
    rgba(255, 240, 120, 0.55) 30%,
    rgba(255, 215, 60,  0.85) 70%,
    rgba(255, 255, 255, 1.0)  100%
  );
  box-shadow: 0 0 24px 10px rgba(255, 220, 80, 0.45);
  animation: cr-pillar-descend 1.5s ease-in-out forwards;
}

@keyframes cr-pillar-descend {
  0%   { clip-path: inset(0 0 100% 0 round 2px); opacity: 1; }
  45%  { clip-path: inset(0 0 0%   0 round 2px); opacity: 1; }
  80%  { clip-path: inset(0 0 0%   0 round 2px); opacity: 0.9; }
  100% { clip-path: inset(0 0 0%   0 round 2px); opacity: 0; }
}

/* Small radiant burst at the base of each pillar when it hits the card */
.cr-burst {
  position: fixed;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.1);
  pointer-events: none;
  z-index: 168;
  background: radial-gradient(circle,
    #ffffff   0%,
    #ffffa0  25%,
    #ffd700  55%,
    rgba(255, 200, 0, 0) 80%
  );
  box-shadow: 0 0 20px 8px rgba(255, 220, 0, 0.8);
  animation: cr-burst-pop 0.9s ease-out forwards;
}

@keyframes cr-burst-pop {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  40%  { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
  70%  { transform: translate(-50%, -50%) scale(2.0); opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(2.8); opacity: 0; }
}

/* ── Heavenly Grace — white blessing, halo, cascading particles, aura ── */

/* Full-screen white divine flash */
.hg-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 170;
  background: radial-gradient(ellipse at center,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(235, 248, 255, 0.72) 35%,
    rgba(200, 230, 255, 0.42) 65%,
    rgba(180, 210, 255, 0.10) 100%
  );
  animation: hg-white-flash 2.0s ease-out forwards;
}

@keyframes hg-white-flash {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Radiant white halo behind Grace */
.hg-halo {
  position: fixed;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  pointer-events: none;
  z-index: 160;
  border: 10px solid rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 40px 18px rgba(210, 240, 255, 0.80),
              0 0 80px 36px rgba(180, 220, 255, 0.45),
              inset 0 0 30px rgba(255, 255, 255, 0.45);
  animation: hg-halo-appear 2.8s ease-out forwards;
}

@keyframes hg-halo-appear {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(0deg);    opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.1) rotate(20deg);   opacity: 1; }
  45%  { transform: translate(-50%, -50%) scale(1.0) rotate(45deg);   opacity: 1; }
  80%  { transform: translate(-50%, -50%) scale(1.0) rotate(80deg);   opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1.15) rotate(100deg); opacity: 0; }
}

/* White light particles cascading down onto ally cards */
.hg-particle {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 172;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 6px 3px rgba(200, 235, 255, 0.85);
  animation: hg-particle-fall linear forwards;
}

@keyframes hg-particle-fall {
  0%   { transform: translateY(0) scale(1);   opacity: 1; }
  75%  { opacity: 0.8; }
  100% { transform: translateY(var(--hg-fall, 80px)) scale(0); opacity: 0; }
}

/* Shimmering aura enveloping each ally card */
.hg-aura {
  position: fixed;
  border-radius: 4px;
  pointer-events: none;
  z-index: 158;
  background: rgba(220, 245, 255, 0.16);
  border: 2px solid rgba(200, 235, 255, 0.75);
  box-shadow: 0 0 18px 7px rgba(200, 230, 255, 0.55),
              inset 0 0 14px rgba(255, 255, 255, 0.28);
  animation: hg-aura-shimmer 1.5s ease-out forwards;
}

@keyframes hg-aura-shimmer {
  0%   { opacity: 0; transform: scale(0.94); }
  22%  { opacity: 1; transform: scale(1.03); }
  60%  { opacity: 1; transform: scale(1.0);  }
  100% { opacity: 0; transform: scale(1.06); }
}

/* ── Apex Bolt of the Primal Runes — rune/wind cast + arrow impact ── */

/* Turn 1: full-screen teal/green wind + rune flash */
.apb-cast-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 170;
  background: radial-gradient(ellipse at center,
    rgba(100, 255, 180, 0.55) 0%,
    rgba(40,  200, 140, 0.40) 40%,
    rgba(20,  160, 100, 0.20) 70%,
    rgba(0,   120,  80, 0.05) 100%
  );
  animation: apb-cast-flash 1.8s ease-out forwards;
}

@keyframes apb-cast-flash {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  55%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Floating rune characters drifting upward */
.apb-rune {
  position: fixed;
  pointer-events: none;
  z-index: 172;
  font-size: 18px;
  color: rgba(80, 255, 160, 0.95);
  text-shadow: 0 0 8px rgba(60, 220, 130, 0.9), 0 0 18px rgba(40, 180, 100, 0.6);
  animation: apb-rune-rise linear forwards;
}

@keyframes apb-rune-rise {
  0%   { transform: translateY(0)                    scale(1);    opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translateY(var(--apb-rise, -80px)) scale(0.4); opacity: 0; }
}

/* Radial glow pulsing on Rowan's portrait */
.apb-portrait-glow {
  position: fixed;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 160;
  background: radial-gradient(circle,
    rgba(160, 255, 200, 0.70) 0%,
    rgba(60,  220, 140, 0.45) 45%,
    rgba(20,  180, 100, 0.00) 75%
  );
  box-shadow: 0 0 30px 12px rgba(60, 220, 130, 0.65);
  animation: apb-portrait-pulse 1.6s ease-out forwards;
}

@keyframes apb-portrait-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  60%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* Turn 2: wind impact burst at monster */
.apb-impact {
  position: fixed;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 162;
  background: radial-gradient(circle,
    #ffffff   0%,
    #afffda  18%,
    #22cc88  42%,
    rgba(20, 160, 90, 0) 75%
  );
  box-shadow: 0 0 40px 16px rgba(40, 210, 130, 0.80),
              0 0 80px 32px rgba(20, 160, 90,  0.40);
  animation: apb-impact-burst 0.65s ease-out forwards;
}

@keyframes apb-impact-burst {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  30%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  60%  { transform: translate(-50%, -50%) scale(2.0); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(3.0); opacity: 0; }
}

/* Expanding wind shockwave ring */
.apb-wind-ring {
  position: fixed;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  pointer-events: none;
  z-index: 161;
  border: 4px solid rgba(60, 220, 140, 0.90);
  box-shadow: 0 0 16px 6px rgba(40, 200, 120, 0.65);
  animation: apb-ring-expand 0.58s ease-out forwards;
}

@keyframes apb-ring-expand {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 1; border-width: 4px; }
  70%  { opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(4.2); opacity: 0; border-width: 1px; }
}

/* Rune particle bursting outward on impact */
.apb-particle {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 163;
  background: radial-gradient(circle, #ffffff 0%, #66ffcc 50%, #22aa77 100%);
  box-shadow: 0 0 5px 2px rgba(40, 200, 130, 0.8);
  animation: titans-ember-fly 0.55s ease-out forwards;
}

/* Persistent golden glow on player card while Vow of Genesis is active */
.player-card.vow-glow {
  box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.65), inset 0 0 8px rgba(255, 200, 0, 0.15);
  border-color: #e0b800 !important;
  animation: vow-glow-pulse 1.6s ease-in-out infinite;
}

@keyframes vow-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(255, 215, 0, 0.5), inset 0 0 6px rgba(255,200,0,0.1); }
  50%       { box-shadow: 0 0 16px 6px rgba(255, 230, 0, 0.8), inset 0 0 12px rgba(255,220,0,0.2); }
}

/* Persistent white glow on player card while Heavenly Grace buff is active */
.player-card.grace-glow {
  box-shadow: 0 0 10px 4px rgba(210, 235, 255, 0.7), inset 0 0 8px rgba(255, 255, 255, 0.18);
  border-color: rgba(200, 230, 255, 0.9) !important;
  animation: grace-glow-pulse 1.8s ease-in-out infinite;
}

@keyframes grace-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px 3px rgba(200, 225, 255, 0.5), inset 0 0 6px rgba(255,255,255,0.12); }
  50%       { box-shadow: 0 0 18px 7px rgba(220, 242, 255, 0.85), inset 0 0 14px rgba(255,255,255,0.28); }
}

/* ── Phantom Clone — persistent shadow glow + cast/echo effects ── */

.player-card.phantom-glow {
  box-shadow: 0 0 10px 4px rgba(120, 40, 200, 0.7), inset 0 0 8px rgba(80, 0, 160, 0.25);
  border-color: rgba(150, 60, 220, 0.9) !important;
  animation: phantom-glow-pulse 1.6s ease-in-out infinite;
}

.phantom-clone-img {
  position: absolute;
  object-fit: cover;
  border-radius: 3px;
  pointer-events: none;
  z-index: 2;
  opacity: 0.5;
  filter: brightness(0.55) saturate(0.35) hue-rotate(240deg);
  animation: phantom-clone-float 2.2s ease-in-out infinite;
}

@keyframes phantom-clone-float {
  0%, 100% { opacity: 0.5;  transform: translateX(-1px); }
  50%       { opacity: 0.38; transform: translateX(-3px); }
}

@keyframes phantom-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px 3px rgba(100, 30, 180, 0.55), inset 0 0 6px rgba(60, 0, 130, 0.18); }
  50%       { box-shadow: 0 0 18px 7px rgba(160, 60, 240, 0.85), inset 0 0 14px rgba(100, 0, 200, 0.35); }
}

.pc-cast-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 170;
  background: radial-gradient(ellipse at center, rgba(80, 0, 160, 0.6) 0%, rgba(20, 0, 50, 0.3) 50%, transparent 75%);
  animation: pc-cast-flash 1.6s ease-out forwards;
}

@keyframes pc-cast-flash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  70%  { opacity: 0.7; }
  100% { opacity: 0; }
}

.pc-clone-silhouette {
  position: fixed;
  border-radius: 4px;
  pointer-events: none;
  z-index: 162;
  background: rgba(80, 0, 160, 0.38);
  filter: blur(3px);
  animation: pc-clone-appear 1.4s ease-out forwards;
}

@keyframes pc-clone-appear {
  0%   { opacity: 0;   transform: translate(-8px, -4px); }
  25%  { opacity: 0.75; }
  75%  { opacity: 0.4; transform: translate(-12px, -6px); }
  100% { opacity: 0;   transform: translate(-16px, -10px); }
}

.pc-cast-particle {
  position: fixed;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 171;
  background: rgba(140, 40, 220, 0.95);
  box-shadow: 0 0 6px 3px rgba(100, 0, 200, 0.75);
  animation: pc-particle-rise linear forwards;
}

@keyframes pc-particle-rise {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(var(--pc-rise, -60px)) scale(0.2); }
}

.pc-echo-ripple {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 160;
  border: 3px solid rgba(150, 40, 230, 0.9);
  box-shadow: 0 0 10px 3px rgba(120, 0, 200, 0.5);
  transform: translate(-50%, -50%) scale(0.1);
  animation: pc-ring-expand 0.7s ease-out forwards;
}

@keyframes pc-ring-expand {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}

.pc-echo-flash {
  position: fixed;
  border-radius: 4px;
  pointer-events: none;
  z-index: 163;
  background: rgba(120, 0, 200, 0.4);
  animation: pc-echo-flash-anim 0.45s ease-out forwards;
}

@keyframes pc-echo-flash-anim {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Elemental Prismatic Magic Circle (Ida overdrive) ──────── */

.player-card.prismatic-glow {
  box-shadow: 0 0 10px 4px rgba(160, 80, 255, 0.6), inset 0 0 8px rgba(80, 200, 255, 0.15);
  border-color: rgba(180, 120, 255, 0.9) !important;
  animation: prismatic-glow-pulse 1.4s ease-in-out infinite;
}
@keyframes prismatic-glow-pulse {
  0%   { box-shadow: 0 0 8px 3px rgba(255, 80, 80, 0.5),  inset 0 0 6px rgba(80, 200, 255, 0.1); border-color: rgba(255, 80, 80, 0.8) !important; }
  16%  { box-shadow: 0 0 8px 3px rgba(255, 160, 40, 0.5), inset 0 0 6px rgba(80, 200, 255, 0.1); border-color: rgba(255, 160, 40, 0.8) !important; }
  33%  { box-shadow: 0 0 8px 3px rgba(220, 220, 40, 0.5), inset 0 0 6px rgba(80, 200, 255, 0.1); border-color: rgba(220, 220, 40, 0.8) !important; }
  50%  { box-shadow: 0 0 14px 6px rgba(40, 200, 80, 0.6), inset 0 0 10px rgba(40, 200, 80, 0.2); border-color: rgba(40, 200, 80, 0.9) !important; }
  66%  { box-shadow: 0 0 14px 6px rgba(40, 140, 255, 0.6),inset 0 0 10px rgba(40, 140, 255, 0.2); border-color: rgba(40, 140, 255, 0.9) !important; }
  83%  { box-shadow: 0 0 8px 3px rgba(160, 60, 255, 0.5), inset 0 0 6px rgba(160, 60, 255, 0.1); border-color: rgba(160, 60, 255, 0.8) !important; }
  100% { box-shadow: 0 0 8px 3px rgba(255, 80, 80, 0.5),  inset 0 0 6px rgba(80, 200, 255, 0.1); border-color: rgba(255, 80, 80, 0.8) !important; }
}

/* ── Magic circle floating over Ida's portrait ─────────────── */

/* Float wrapper — positioned absolutely, centered on portrait */
.prismatic-hexagram-wrap {
  position: absolute;
  pointer-events: none;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: prism-hex-float 2.8s ease-in-out infinite;
}

/* Outer runic ring — rotates CW slowly */
.prism-ring-outer {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1.5px dashed rgba(80, 200, 255, 0.75);
  box-shadow: 0 0 6px rgba(60, 180, 255, 0.5), inset 0 0 6px rgba(60, 180, 255, 0.2);
  animation: prism-outer-rotate 8s linear infinite;
}

/* Middle solid ring — rotates CCW */
.prism-ring-mid {
  position: absolute;
  width: 75%;
  height: 75%;
  border-radius: 50%;
  border: 1.5px solid rgba(60, 160, 240, 0.85);
  box-shadow: 0 0 8px rgba(40, 160, 255, 0.6), inset 0 0 4px rgba(40, 160, 255, 0.25);
  animation: prism-outer-rotate 5s linear infinite reverse;
}

/* Inner ring — rotates CW, brightest */
.prism-ring-inner {
  position: absolute;
  width: 50%;
  height: 50%;
  border-radius: 50%;
  border: 1px solid rgba(120, 220, 255, 0.7);
  box-shadow: 0 0 5px rgba(100, 220, 255, 0.5), inset 0 0 3px rgba(100, 220, 255, 0.2);
  animation: prism-outer-rotate 3s linear infinite;
}

/* Hexagram symbol centered in the circle */
.prism-hex-symbol {
  position: relative;
  z-index: 1;
  font-size: 30px;
  line-height: 1;
  color: rgba(130, 220, 255, 0.95);
  filter: drop-shadow(0 0 6px rgba(60, 180, 255, 1.0)) drop-shadow(0 0 12px rgba(60, 180, 255, 0.5));
  animation: prism-sym-pulse 2s ease-in-out infinite;
}

@keyframes prism-hex-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-5px); }
}
@keyframes prism-outer-rotate {
  to { transform: rotate(360deg); }
}
@keyframes prism-sym-pulse {
  0%, 100% { opacity: 0.8;  filter: drop-shadow(0 0 5px rgba(60, 180, 255, 0.8)); }
  50%       { opacity: 1.0; filter: drop-shadow(0 0 10px rgba(100, 220, 255, 1.0)) drop-shadow(0 0 18px rgba(60, 160, 255, 0.5)); }
}

/* Element picker grid */
.prismatic-element-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 6px;
}
.prismatic-elem-btn {
  background: rgba(20, 20, 40, 0.85);
  border: 1px solid rgba(80, 140, 200, 0.5);
  border-radius: 4px;
  color: #ddd;
  font-size: 11px;
  padding: 5px 3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background 0.15s, border-color 0.15s;
}
.prismatic-elem-btn:hover {
  background: rgba(60, 120, 200, 0.25);
  border-color: rgba(100, 180, 255, 0.8);
}
.prism-elem-emoji {
  font-size: 16px;
  line-height: 1;
}

/* Cast overlay */
.prism-cast-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 170;
  background: conic-gradient(rgba(255,80,80,0.12), rgba(255,160,40,0.12), rgba(220,220,40,0.12), rgba(40,200,80,0.12), rgba(40,140,255,0.12), rgba(160,60,255,0.12), rgba(255,80,80,0.12));
  animation: prism-overlay-flash 1.8s ease-out forwards;
}
@keyframes prism-overlay-flash {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  60%  { opacity: 0.6; }
  100% { opacity: 0; }
}

/* Expanding arcane rings */
.prism-ring {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 160;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  background: transparent;
  border-image: conic-gradient(#ff6060, #ffe040, #40c0ff, #a040ff, #ff6060) 1;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.1);
  animation: prism-ring-expand 0.9s ease-out forwards;
}
@keyframes prism-ring-expand {
  0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(5);   opacity: 0; }
}

/* Hexagram burst on cast */
.prism-hex-burst {
  position: fixed;
  pointer-events: none;
  z-index: 162;
  font-size: 48px;
  line-height: 1;
  color: transparent;
  background: conic-gradient(#ff6060, #ffaa40, #ffe040, #60e060, #40c0ff, #a040ff, #ff60c0, #ff6060);
  -webkit-background-clip: text;
  background-clip: text;
  transform: translate(-50%, -50%);
  animation: prism-hex-burst-anim 1.6s ease-out forwards;
}
.prism-hex-burst::before { content: '✡'; }
@keyframes prism-hex-burst-anim {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(0deg); filter: drop-shadow(0 0 6px #fff); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.4) rotate(30deg); }
  60%  { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1) rotate(80deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6) rotate(120deg); }
}

/* Prismatic particles */
.prism-particle {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 171;
  animation: prism-particle-burst linear forwards;
}
@keyframes prism-particle-burst {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--pdx, 60px), var(--pdy, -40px)) scale(0); }
}

/* Brief golden flash when regen ticks */
.player-card.vow-flash .portrait {
  animation: vow-flash-anim 0.65s ease-out;
}

@keyframes vow-flash-anim {
  0%   { filter: brightness(1) sepia(0); }
  20%  { filter: brightness(2.5) sepia(0.8) hue-rotate(10deg); }
  100% { filter: brightness(1) sepia(0); }
}

/* Holy-style overdrive announcement (golden instead of red) */
.overdrive-announce.oa-style-holy {
  background: rgba(0, 12, 0, 0.75);
}

.overdrive-announce.oa-style-holy .oa-icon {
  border-color: #ffd700;
  box-shadow: 0 0 24px rgba(255, 215, 0, 1), 0 0 60px rgba(200, 160, 0, 0.7);
}

.overdrive-announce.oa-style-holy .oa-name {
  color: #ffd700;
  text-shadow: 0 0 12px rgba(255, 220, 0, 1), 0 0 30px rgba(200, 160, 0, 0.9);
}

.overdrive-announce.oa-style-holy .oa-actor {
  color: #ffe080;
}

/* Arcane-style overdrive announcement (purple/violet — Vivian) */
.overdrive-announce.oa-style-arcane {
  background: rgba(8, 0, 20, 0.80);
}

.overdrive-announce.oa-style-arcane .oa-icon {
  border-color: #aa66ff;
  box-shadow: 0 0 24px rgba(160, 80, 255, 1), 0 0 60px rgba(100, 40, 200, 0.7);
}

.overdrive-announce.oa-style-arcane .oa-name {
  color: #cc88ff;
  text-shadow: 0 0 12px rgba(180, 100, 255, 1), 0 0 30px rgba(120, 50, 220, 0.9);
  animation: oa-arcane-pulse 0.5s infinite alternate;
}

.overdrive-announce.oa-style-arcane .oa-actor {
  color: #bb99ee;
}

@keyframes oa-arcane-pulse {
  from { text-shadow: 0 0 10px rgba(160, 80, 255, 0.8), 0 0 24px rgba(100, 40, 200, 0.6); }
  to   { text-shadow: 0 0 18px rgba(200, 120, 255, 1),  0 0 40px rgba(140, 60, 240, 0.9); }
}

/* Fire-style overdrive announcement (orange/red — Rufus) */
.overdrive-announce.oa-style-fire {
  background: rgba(20, 4, 0, 0.80);
}

.overdrive-announce.oa-style-fire .oa-icon {
  border-color: #ff4400;
  box-shadow: 0 0 24px rgba(255, 80, 0, 1), 0 0 60px rgba(200, 40, 0, 0.7),
              0 0 100px rgba(255, 120, 0, 0.4);
}

.overdrive-announce.oa-style-fire .oa-name {
  color: #ff8800;
  text-shadow: 0 0 12px rgba(255, 120, 0, 1), 0 0 30px rgba(220, 60, 0, 0.9);
  animation: oa-fire-pulse 0.4s infinite alternate;
}

.overdrive-announce.oa-style-fire .oa-actor {
  color: #ffaa55;
}

@keyframes oa-fire-pulse {
  from { text-shadow: 0 0 10px rgba(255, 100, 0, 0.9), 0 0 22px rgba(200, 50, 0, 0.7); }
  to   { text-shadow: 0 0 20px rgba(255, 160, 0, 1),   0 0 42px rgba(220, 80, 0, 1);   }
}

/* Prismatic-style overdrive announcement (rainbow — Julian) */
.overdrive-announce.oa-style-prismatic {
  background: rgba(4, 0, 18, 0.82);
}
.overdrive-announce.oa-style-prismatic .oa-icon {
  border-color: #cc88ff;
  box-shadow: 0 0 20px rgba(160, 80, 255, 0.9), 0 0 50px rgba(255, 120, 60, 0.5),
              0 0 80px rgba(60, 160, 255, 0.4);
  animation: oa-prismatic-icon-spin 1s linear infinite;
}
.overdrive-announce.oa-style-prismatic .oa-name {
  background: linear-gradient(90deg, #ff6060, #ffcc00, #60ff80, #60ccff, #cc60ff, #ff6060);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: oa-prismatic-shift 0.6s linear infinite;
}
.overdrive-announce.oa-style-prismatic .oa-actor {
  color: #ccaaff;
}
@keyframes oa-prismatic-shift {
  from { background-position: 0% 50%; }
  to   { background-position: 200% 50%; }
}
@keyframes oa-prismatic-icon-spin {
  0%   { filter: hue-rotate(0deg)   brightness(1.2); }
  100% { filter: hue-rotate(360deg) brightness(1.2); }
}

/* Prismatic Arcane Execution — card flash during activation */
.player-card.prismatic-sweep-glow {
  animation: prismatic-card-sweep 0.85s ease-out forwards;
}
@keyframes prismatic-card-sweep {
  0%   { box-shadow: none; filter: brightness(1); }
  25%  { box-shadow: 0 0 18px 4px rgba(200, 100, 255, 0.7); filter: brightness(1.18) hue-rotate(0deg); }
  60%  { box-shadow: 0 0 28px 6px rgba(60, 180, 255, 0.6);  filter: brightness(1.22) hue-rotate(120deg); }
  85%  { box-shadow: 0 0 12px 2px rgba(255, 180, 60, 0.4);  filter: brightness(1.10) hue-rotate(240deg); }
  100% { box-shadow: none; filter: brightness(1); }
}

/* ── Prismatic Arcane Execution animation elements ─────────── */

/* Phase 1: charge particles from Julian's card */
.pae-charge-particle {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tint, #cc88ff);
  box-shadow: 0 0 8px var(--tint, #cc88ff), 0 0 16px var(--tint, #cc88ff);
  pointer-events: none;
  z-index: 8700;
  animation: pae-charge-drift 750ms ease-in forwards;
}
@keyframes pae-charge-drift {
  0%   { transform: translate(var(--dx), var(--dy)) scale(1.4); opacity: 0.9; }
  60%  { opacity: 0.7; }
  100% { transform: translate(0, 0) scale(0); opacity: 0; }
}

/* Phase 2: screen flash at the cut */
.pae-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%,
    rgba(255,255,255,0.75) 0%,
    rgba(200,120,255,0.45) 40%,
    rgba(60,100,255,0.12) 100%);
  pointer-events: none;
  z-index: 8820;
  animation: pae-flash-fade 350ms ease-out forwards;
}
@keyframes pae-flash-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Phase 2: big diagonal sword slash */
.pae-slash {
  position: fixed;
  left: -20vw;
  width: 0;
  pointer-events: none;
  z-index: 8810;
  animation: pae-slash-sweep 440ms cubic-bezier(0.05, 0, 0.28, 1) forwards;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(180, 80, 255, 0.55) 8%,
    rgba(255, 255, 255, 0.96) 28%,
    var(--tint, #cc88ff) 52%,
    rgba(60, 180, 255, 0.5) 72%,
    transparent 100%);
  clip-path: polygon(0% 10%, 78% 0%, 100% 50%, 78% 100%, 0% 90%);
  filter: drop-shadow(0 0 14px var(--tint, #cc88ff)) drop-shadow(0 0 28px rgba(180, 80, 255, 0.6));
}
@keyframes pae-slash-sweep {
  from { left: -20vw; width: 45vw; }
  to   { left: 118vw; width: 55vw; opacity: 0; }
}

/* Phase 3: central arcane burst */
.pae-arcane-burst {
  position: fixed;
  width: 130px;
  height: 130px;
  margin-left: -65px;
  margin-top: -65px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,255,255,1) 0%,
    var(--tint, #cc88ff) 30%,
    rgba(100, 30, 200, 0.45) 65%,
    transparent 100%);
  pointer-events: none;
  z-index: 8820;
  animation: pae-burst-expand 900ms ease-out forwards;
  box-shadow: 0 0 40px var(--tint, #cc88ff), 0 0 80px rgba(150, 50, 255, 0.55);
}
.pae-arcane-burst.pae-arcane-burst-b {
  width: 75px;
  height: 75px;
  margin-left: -37px;
  margin-top: -37px;
  animation-duration: 720ms;
  background: radial-gradient(circle,
    rgba(255,255,255,1) 0%,
    rgba(255,255,255,0.9) 25%,
    var(--tint, #cc88ff) 55%,
    transparent 100%);
}
@keyframes pae-burst-expand {
  0%   { transform: scale(0.08); opacity: 1; }
  35%  { transform: scale(1.3);  opacity: 0.95; }
  100% { transform: scale(2.4);  opacity: 0; }
}

/* Phase 3: expanding arcane rings */
.pae-arcane-ring {
  position: fixed;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border: 3px solid var(--tint, #cc88ff);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--tint, #cc88ff), inset 0 0 10px rgba(150, 50, 255, 0.25);
  pointer-events: none;
  z-index: 8815;
  animation: pae-ring-expand 680ms ease-out forwards;
}
@keyframes pae-ring-expand {
  from { transform: scale(0.15); opacity: 1; }
  to   { transform: scale(8);    opacity: 0; }
}

/* Phase 3: arcane energy orbs */
.pae-arcane-orb {
  position: fixed;
  width: 13px;
  height: 13px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, white 0%, var(--tint, #cc88ff) 55%, transparent 100%);
  box-shadow: 0 0 10px var(--tint, #cc88ff);
  pointer-events: none;
  z-index: 8815;
  animation: pae-orb-fly 780ms ease-out forwards;
}
@keyframes pae-orb-fly {
  0%   { transform: translate(0, 0) scale(1.6); opacity: 1; }
  100% { transform: translate(var(--ox, 0), var(--oy, 0)) scale(0.1); opacity: 0; }
}

/* Phoenix Wrath — card glows while active (flames injected by JS do the heavy lifting) */
.player-card.phoenix-wrath-glow {
  border-color: #ff4400 !important;
  box-shadow: 0 0 10px 3px rgba(255, 80, 0, 0.55), inset 0 0 10px rgba(255, 30, 0, 0.15);
}

.player-card.phoenix-wrath-glow .portrait {
  filter: sepia(0.3) hue-rotate(-20deg) saturate(1.6) brightness(1.07);
}

/* Individual injected flame element on the card */
.pw-flame {
  pointer-events: none;
}

/* Flame flicker — organic random movement on each element */
@keyframes pw-flame-flicker {
  0%   { transform: scaleY(0.78) scaleX(1.14) rotate(-3deg);  opacity: 0.82; }
  30%  { transform: scaleY(1.18) scaleX(0.88) rotate( 2deg);  opacity: 1.00; }
  65%  { transform: scaleY(1.05) scaleX(0.96) rotate(-1deg);  opacity: 0.90; }
  100% { transform: scaleY(0.85) scaleX(1.08) rotate( 3deg);  opacity: 0.76; }
}

/* Activation: tall column rising then fading */
@keyframes pw-col-rise {
  0%   { opacity: 0;    transform: scaleY(0.15) scaleX(1.3);               }
  18%  { opacity: 0.95; transform: scaleY(1.00) scaleX(1.0);               }
  65%  { opacity: 0.80; transform: scaleY(1.08) scaleX(0.92);              }
  100% { opacity: 0;    transform: scaleY(1.25) scaleX(0.80) translateY(-18px); }
}

/* Activation: bright fire flash that expands then fades */
@keyframes pw-flash {
  0%   { opacity: 1;   transform: scale(1.0); }
  25%  { opacity: 0.9; transform: scale(1.12); }
  100% { opacity: 0;   transform: scale(1.45); }
}

/* ── Overdrive — Status Menu Section ── */
.status-overdrive-section {
  padding: 4px 0 8px;
}
.sod-gauge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.sod-gauge-wrap {
  flex: 1;
  height: 8px;
  background: rgba(180, 20, 0, 0.25);
  border: 1px solid #882020;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
.sod-gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, #cc0000, #ff4400);
  border-radius: 3px;
  transition: width 0.3s;
}
.sod-gauge-fill.sod-full {
  background: linear-gradient(90deg, #ff0000, #ff8800);
  box-shadow: 0 0 5px rgba(255, 80, 0, 0.8);
  animation: overdrive-pulse 0.5s infinite alternate;
}
.sod-pct {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}
.sod-pct.sod-full-text {
  color: #ff4400;
  text-shadow: 0 0 6px rgba(255, 80, 0, 0.8);
  animation: oa-name-pulse 0.5s infinite alternate;
}
.sod-skill-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(100, 10, 0, 0.15);
  border: 1px solid #440010;
  border-radius: 4px;
  padding: 8px;
}
.sod-icon {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  border: 2px solid #aa2200;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(200, 50, 0, 0.4);
}
.sod-info { flex: 1; }
.sod-name {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: #ff4400;
  margin-bottom: 4px;
}
.sod-tags {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.sod-desc {
  font-size: 13px;
  color: var(--text-white);
  line-height: 1.4;
}

/* ── Overdrive System ── */

/* Overdrive gauge in player card (thin bar, no label/value) */
.overdrive-bar-row {
  margin: 2px 0 1px;
  padding: 0;
  width: 100%;
}
.overdrive-wrap {
  flex: 1;
  height: 4px;
  background: rgba(160, 15, 0, 0.35);
  border: 1px solid #772010;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}
.overdrive-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #cc0000, #ff4400);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.overdrive-fill.overdrive-fill-full {
  background: linear-gradient(90deg, #ff0000, #ff8800);
  box-shadow: 0 0 4px rgba(255, 80, 0, 0.9);
  animation: overdrive-pulse 0.5s infinite alternate;
}

@keyframes overdrive-pulse {
  from { box-shadow: 0 0 4px rgba(255,80,0,0.7); }
  to   { box-shadow: 0 0 10px rgba(255,140,0,1), 0 0 3px rgba(255,60,0,0.8); }
}

/* OVERDRIVE! action button */
.overdrive-btn {
  grid-column: 1 / -1;
  width: 100% !important;
  background: linear-gradient(135deg, #1a0000, #2a0500) !important;
  color: #ff4400 !important;
  border: 2px solid #cc2200 !important;
  font-family: var(--font-pixel) !important;
  font-size: 9px !important;
  letter-spacing: 1px !important;
  animation: overdrive-btn-glow 0.6s infinite alternate !important;
  text-shadow: 0 0 6px rgba(255, 80, 0, 0.8) !important;
}
.overdrive-btn:hover {
  background: linear-gradient(135deg, #2a0000, #440800) !important;
  border-color: #ff4400 !important;
}

@keyframes overdrive-btn-glow {
  from {
    box-shadow: 0 0 6px rgba(255, 50, 0, 0.6), inset 0 0 4px rgba(100, 0, 0, 0.4);
    border-color: #cc2200;
  }
  to {
    box-shadow: 0 0 14px rgba(255, 120, 0, 0.9), inset 0 0 8px rgba(180, 30, 0, 0.5);
    border-color: #ff6600;
  }
}

/* Overdrive activation announcement overlay */
.overdrive-announce {
  position: fixed;
  inset: -12%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  background: rgba(20, 0, 0, 0.72);
  animation: oa-in 0.25s ease-out;
  pointer-events: none;
}
.overdrive-announce.oa-fadeout {
  animation: oa-out 0.3s ease-in forwards;
}
.oa-icon-wrap {
  margin-bottom: 14px;
  animation: oa-icon-spin 1.8s ease-out;
}
.oa-icon {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 3px solid #ff4400;
  box-shadow: 0 0 24px rgba(255, 80, 0, 1), 0 0 60px rgba(200, 40, 0, 0.6);
  object-fit: cover;
}
.oa-name {
  font-family: var(--font-pixel);
  font-size: 13px;
  color: #ff4400;
  text-shadow: 0 0 12px rgba(255, 100, 0, 1), 0 0 30px rgba(255, 50, 0, 0.8);
  letter-spacing: 2px;
  margin-bottom: 6px;
  animation: oa-name-pulse 0.5s infinite alternate;
}
.oa-actor {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: #ff8844;
  opacity: 0.9;
}

@keyframes oa-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes oa-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes oa-icon-spin {
  0%   { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  30%  { transform: scale(1.15) rotate(3deg);  opacity: 1; }
  60%  { transform: scale(0.97) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes oa-name-pulse {
  from { text-shadow: 0 0 8px rgba(255,100,0,0.8); }
  to   { text-shadow: 0 0 20px rgba(255,140,0,1), 0 0 40px rgba(255,60,0,0.8); }
}
