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

:root {
  --bg-deep:      #080a12;
  --bg-base:      #0d0f1a;
  --bg-card:      #131625;
  --bg-card-alt:  #181b2e;
  --bg-hover:     #1e2138;
  --bg-input:     #0d0f1a;
  --border:       #232640;
  --border-focus: #4ecdc4;

  --text:         #d4d8e4;
  --text-dim:     #8e94b0;
  --text-muted:   #6b7194;

  --gold:         #f0c060;
  --gold-dim:     #8a6a20;
  --cyan:         #4ecdc4;
  --cyan-dim:     #1e5a56;
  --green:        #2ecc71;
  --green-dim:    #1a5e3a;
  --red:          #e74c3c;
  --red-dim:      #6b2020;
  --orange:       #f39c12;
  --purple:       #9b59b6;

  --rank-F: #7a7a8a;
  --rank-E: #27ae60;
  --rank-D: #3498db;
  --rank-C: #9b59b6;
  --rank-B: #e67e22;
  --rank-A: #e74c3c;
  --rank-S: #f0c060;
  --rank-Sp: #ff6b35;
  --rank-Spp: #00e5c8;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --shadow: 0 2px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.7);
}

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

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

/* ── Typography ────────────────────────────────────────────────────────── */
h2 { font-size: 1rem; font-weight: 600; color: var(--text); }
h3 { font-size: 0.875rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card-alt);
  color: var(--text); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
  line-height: 1;
}
.btn:hover { border-color: var(--border-focus); color: var(--cyan); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan);
}
.btn-primary:hover { background: #264f4c; }

.btn-success {
  background: var(--green-dim); border-color: var(--green); color: var(--green);
}
.btn-success:hover { background: #224a30; }

.btn-danger {
  background: var(--red-dim); border-color: var(--red); color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: #5a1a1a; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { border-color: var(--cyan); background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 10px 24px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 0.875rem; color: var(--text-dim); font-weight: 500; }

input[type="text"] {
  padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 1rem;
  outline: none; transition: border-color 0.15s;
}
input[type="text"]:focus { border-color: var(--border-focus); }
input[type="text"]::placeholder { color: var(--text-muted); }

/* ── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 10, 18, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.new-game-box { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 20px; }

.modal-header-art { font-size: 3rem; text-align: center; }
.modal-title { font-size: 1.75rem; font-weight: 700; color: var(--gold); text-align: center; letter-spacing: 0.04em; }
.modal-flavor { font-size: 0.875rem; color: var(--text-dim); text-align: center; line-height: 1.7; font-style: italic; }

.results-box { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 20px; }
#results-content { display: flex; flex-direction: column; gap: 12px; }

/* ── Class Picker ──────────────────────────────────────────────────────── */
.class-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.class-card {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card-alt);
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 4px;
}
.class-card:hover { border-color: var(--cyan); background: var(--bg-hover); }
.class-card.selected { border-color: var(--cyan); background: var(--cyan-dim); }

.class-card-name { font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.class-card-sigil { font-size: 0.7rem; color: var(--cyan); background: rgba(78,205,196,0.1); padding: 1px 5px; border-radius: 3px; font-family: monospace; letter-spacing: 0.5px; }
.class-card-desc { font-size: 0.78rem; color: var(--text-dim); }
.class-card-stats { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Game Layout ───────────────────────────────────────────────────────── */
#game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px; flex-shrink: 0;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-icon { font-size: 1.25rem; }
.game-title { font-size: 1.1rem; font-weight: 700; color: var(--gold); letter-spacing: 0.04em; }
.header-right { display: flex; align-items: center; gap: 14px; }

.gold-display {
  font-size: 1rem; font-weight: 600; color: var(--gold);
  display: flex; align-items: center; gap: 5px;
}
.gold-icon { font-size: 0.8rem; opacity: 0.8; }

.rank-badge {
  padding: 3px 10px; border-radius: 20px; font-weight: 700; font-size: 0.8rem;
  border: 1px solid currentColor; letter-spacing: 0.06em;
}
.rank-F { color: var(--rank-F); border-color: var(--rank-F); }
.rank-E { color: var(--rank-E); border-color: var(--rank-E); }
.rank-D { color: var(--rank-D); border-color: var(--rank-D); }
.rank-C { color: var(--rank-C); border-color: var(--rank-C); }
.rank-B { color: var(--rank-B); border-color: var(--rank-B); }
.rank-A { color: var(--rank-A); border-color: var(--rank-A); }
.rank-S { color: var(--rank-S); border-color: var(--rank-S); box-shadow: 0 0 8px rgba(240,192,96,0.3); }
.rank-Sp { color: var(--rank-Sp); border-color: var(--rank-Sp); box-shadow: 0 0 10px rgba(255,107,53,0.4); }
.rank-Spp { color: var(--rank-Spp); border-color: var(--rank-Spp); box-shadow: 0 0 12px rgba(0,229,200,0.4); animation: celestialShimmer 1.8s ease-in-out infinite; }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 2px; padding: 8px 16px; flex-shrink: 0;
  background: var(--bg-base); border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 7px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--text-dim); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
.tab-btn.active { color: var(--cyan); background: var(--cyan-dim); border-color: var(--cyan); }

.game-main { flex: 1; overflow: hidden; position: relative; }
.tab-content { display: none; height: 100%; overflow-y: auto; padding: 20px; }
.tab-content.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-title {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 12px;
}

/* ── Progress Bars ─────────────────────────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress-bar {
  flex: 1; height: 8px; background: var(--bg-deep);
  border-radius: 4px; overflow: hidden;
}
.progress-bar.thick { height: 14px; border-radius: 4px; }
.progress-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.4s ease;
  background: var(--cyan);
}
.progress-fill.hp-high  { background: var(--green); }
.progress-fill.hp-med   { background: var(--orange); }
.progress-fill.hp-low   { background: var(--red); }
.progress-fill.rank-bar { background: var(--purple); }
.progress-fill.exp-bar  { background: var(--cyan); }
.progress-label { font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; min-width: 60px; text-align: right; }

/* ── Guild Hall ────────────────────────────────────────────────────────── */
.hall-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 12px; }
.hall-wide { grid-column: 1 / -1; }

.active-quest-empty {
  text-align: center; padding: 24px; color: var(--text-dim);
  font-style: italic;
}
.active-quest-name {
  font-size: 1.1rem; font-weight: 600; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.active-quest-meta {
  font-size: 0.8rem; color: var(--text-dim); margin-bottom: 12px;
}
.quest-timer {
  font-size: 1.5rem; font-weight: 700; color: var(--cyan);
  font-variant-numeric: tabular-nums; margin-bottom: 8px;
}

.party-overview { display: flex; flex-direction: column; gap: 8px; }
.party-member-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px; align-items: center;
}
.member-name-cls { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; }
.member-sigil { font-size: 0.65rem; color: var(--cyan); background: rgba(78,205,196,0.1); padding: 1px 5px; border-radius: 3px; font-family: monospace; letter-spacing: 0.5px; }
.member-level { font-size: 0.75rem; color: var(--text-dim); }
.member-hp-text { font-size: 0.75rem; color: var(--text-dim); text-align: right; white-space: nowrap; }

.rank-progress-section { display: flex; flex-direction: column; gap: 8px; }
.rank-progress-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-dim); }

.event-log { display: flex; flex-direction: column; gap: 6px; }
.event-row { display: flex; gap: 10px; font-size: 0.8rem; }
.event-time { color: var(--text-muted); flex-shrink: 0; min-width: 50px; }
.event-text { color: var(--text-dim); }
.event-empty { color: var(--text-muted); font-style: italic; font-size: 0.8rem; }

/* ── Tutorial System ──────────────────────────────────────────────────── */
.tutorial-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  pointer-events: none;
}
.tutorial-spotlight {
  position: fixed;
  border-radius: var(--radius);
  box-shadow: 0 0 16px 6px rgba(0, 229, 200, 0.35), inset 0 0 8px rgba(0, 229, 200, 0.1);
  border: 2px solid rgba(0, 229, 200, 0.5);
  background: rgba(0, 229, 200, 0.04);
  z-index: 10000;
  pointer-events: none;
  display: none;
  transition: top 0.3s ease, left 0.3s ease, width 0.3s ease, height 0.3s ease;
  animation: tutorialPulse 2s ease-in-out infinite;
}
@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 16px 6px rgba(0, 229, 200, 0.35), inset 0 0 8px rgba(0, 229, 200, 0.1); }
  50% { box-shadow: 0 0 24px 10px rgba(0, 229, 200, 0.55), inset 0 0 12px rgba(0, 229, 200, 0.15); }
}
.tutorial-tooltip {
  position: fixed;
  z-index: 10001;
  width: 320px;
  background: var(--bg-card);
  border: 2px solid var(--cyan);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 229, 200, 0.15);
  pointer-events: auto;
  animation: tutorialFadeIn 0.3s ease;
}
.tutorial-tooltip.tutorial-centered {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
@keyframes tutorialFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tutorial-centered { animation-name: tutorialFadeInCenter; }
@keyframes tutorialFadeInCenter {
  from { opacity: 0; }
  to { opacity: 1; }
}
.tutorial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tutorial-step-count {
  font-size: 0.7rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.tutorial-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 2px 6px;
  transition: color 0.15s;
}
.tutorial-skip:hover { color: var(--text); }
.tutorial-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.tutorial-body {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 14px;
}
.tutorial-body strong { color: var(--cyan); }
.tutorial-footer {
  display: flex;
  justify-content: flex-end;
}
.tutorial-next {
  background: var(--cyan) !important;
  color: #000 !important;
  font-weight: 800;
  font-size: 0.85rem;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
  text-shadow: none;
  letter-spacing: 0.3px;
}
.tutorial-next:hover { opacity: 0.85; }
.tutorial-next-waiting {
  background: var(--bg-card-alt) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
  cursor: not-allowed;
  opacity: 0.6;
}
.tutorial-next-waiting:hover { opacity: 0.6; }
.tutorial-done-msg {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(46,204,113,0.1);
  border: 1px solid rgba(46,204,113,0.25);
  border-radius: var(--radius-sm);
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 600;
  animation: tutorialFadeIn 0.3s ease;
}

/* ── Save Management ──────────────────────────────────────────────────── */
.save-mgmt-card { }
.save-mgmt-info { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
.save-mgmt-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.save-mgmt-hint { font-size: 0.72rem; color: var(--text-muted); font-style: italic; }

/* ── Quest Board ───────────────────────────────────────────────────────── */
.rank-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.rank-filter-btn {
  padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-card-alt); color: var(--text-dim);
  cursor: pointer; font-size: 0.8rem; font-weight: 600;
  transition: all 0.15s;
}
.rank-filter-btn:hover { color: var(--text); border-color: var(--border-focus); }
.rank-filter-btn.active { color: white; border-color: transparent; }
.rank-filter-btn.locked { opacity: 0.3; cursor: not-allowed; }
.rank-filter-btn[data-rank="F"].active  { background: var(--rank-F); }
.rank-filter-btn[data-rank="E"].active  { background: var(--rank-E); }
.rank-filter-btn[data-rank="D"].active  { background: var(--rank-D); }
.rank-filter-btn[data-rank="C"].active  { background: var(--rank-C); }
.rank-filter-btn[data-rank="B"].active  { background: var(--rank-B); }
.rank-filter-btn[data-rank="A"].active  { background: var(--rank-A); }
.rank-filter-btn[data-rank="S"].active  { background: var(--rank-S); color: #000; }
.rank-filter-btn[data-rank="S+"].active  { background: var(--rank-Sp); color: #000; }
.rank-filter-btn[data-rank="S++"].active  { background: var(--rank-Spp); color: #000; }

.quest-list { display: flex; flex-direction: column; gap: 8px; }

.quest-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color 0.15s;
}
.quest-card:hover { border-color: #3a3f5c; }
.quest-card.selected { border-color: var(--cyan); }
.quest-card.locked { opacity: 0.5; }
.quest-card.done .quest-header { opacity: 0.6; }

.quest-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer; user-select: none;
}
.quest-rank-tag {
  padding: 2px 8px; border-radius: 4px; font-size: 0.72rem;
  font-weight: 700; flex-shrink: 0; border: 1px solid currentColor;
}
.quest-title { font-weight: 600; flex: 1; font-size: 0.9rem; }
.quest-meta { font-size: 0.78rem; color: var(--text-dim); display: flex; gap: 8px; flex-shrink: 0; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.quest-done-badge {
  font-size: 0.7rem; color: var(--text-muted); background: var(--bg-deep);
  padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border);
}
.difficulty-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

.quest-detail {
  padding: 0 14px 14px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
}
.quest-description { font-size: 0.875rem; color: var(--text-dim); font-style: italic; }
.quest-rewards { display: flex; gap: 20px; flex-wrap: wrap; }
.quest-reward-item { display: flex; flex-direction: column; gap: 2px; }
.quest-reward-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.quest-reward-value { font-size: 0.875rem; font-weight: 600; }
.quest-power-row { display: flex; flex-direction: column; gap: 6px; }
.quest-power-label { font-size: 0.78rem; color: var(--text-dim); display: flex; justify-content: space-between; }
.quest-loot { font-size: 0.8rem; color: var(--text-dim); }
.quest-loot span { color: var(--cyan); }
.quest-actions { display: flex; align-items: center; gap: 10px; }
.quest-block-reason { font-size: 0.8rem; color: var(--red); }

/* ── Party Screen ──────────────────────────────────────────────────────── */
.party-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; min-height: 100%; }
.party-main { display: flex; flex-direction: column; gap: 12px; }
.party-sidebar { display: flex; flex-direction: column; gap: 12px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.slot-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }

.active-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.slot-card {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 10px; min-height: 80px; cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 4px;
}
.slot-card.filled { border-style: solid; }
.slot-card:hover { border-color: var(--cyan-dim); background: var(--bg-hover); }
.slot-card.selected { border-color: var(--cyan); background: var(--bg-hover); }
.slot-empty-text { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin: auto; }
.slot-name { font-size: 0.8rem; font-weight: 600; }
.slot-cls { font-size: 0.7rem; color: var(--cyan); }
.slot-hp { margin-top: 4px; flex: 0 0 8px; }

/* Party Expansion Panel */
.party-expand-panel {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 12px;
}
.party-expand-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.party-expand-title {
  font-weight: 700; font-size: 0.88rem; color: var(--text);
}
.party-expand-maxed {
  font-weight: 700; font-size: 0.8rem; color: var(--green);
  background: rgba(46,204,113,0.1); border: 1px solid var(--green);
  border-radius: 4px; padding: 2px 10px; letter-spacing: 0.05em;
}
.btn-expand {
  background: rgba(46,204,113,0.12) !important; border-color: var(--green) !important;
  color: var(--green) !important; font-weight: 600;
}
.btn-expand:hover { background: rgba(46,204,113,0.22) !important; }
.party-expand-pips {
  display: flex; gap: 4px;
}
.party-expand-pip {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--bg-hover); border: 1px solid var(--border);
  transition: background 0.3s;
}
.party-expand-pip.filled {
  background: var(--green); border-color: var(--green);
}

.roster-grid { display: flex; flex-direction: column; gap: 6px; }
.roster-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-card-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.roster-row:hover { border-color: #3a3f5c; background: var(--bg-hover); }
.roster-row.selected { border-color: var(--cyan); }
.roster-row.in-active { border-color: var(--green-dim); }
.roster-info { flex: 1; }
.roster-name { font-size: 0.875rem; font-weight: 600; }
.roster-sub { font-size: 0.75rem; color: var(--text-dim); }
.roster-hp { width: 80px; }
.roster-status { font-size: 0.7rem; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.status-active { color: var(--green); background: var(--green-dim); }
.status-reserve { color: var(--text-muted); background: var(--bg-deep); border: 1px solid var(--border); }
.status-injured { color: var(--orange); background: rgba(243,156,18,0.1); }

/* Member detail sidebar */
.member-detail { display: flex; flex-direction: column; gap: 12px; }
.member-detail-header { display: flex; flex-direction: column; gap: 4px; }
.member-detail-name { font-size: 1.1rem; font-weight: 700; }
.member-detail-sub { font-size: 0.8rem; color: var(--text-dim); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-item { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); }
.stat-label { font-size: 0.78rem; color: var(--text-dim); }
.stat-value { font-size: 0.8rem; font-weight: 600; }
.equip-slots { display: flex; flex-direction: column; gap: 6px; }
.equip-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--bg-deep); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.equip-slot-label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); width: 60px; flex-shrink: 0; }
.equip-item-name { flex: 1; font-size: 0.8rem; }
.equip-item-empty { color: var(--text-muted); font-style: italic; }
.equip-btn { font-size: 0.7rem; padding: 2px 6px; }

.member-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Recruit panel */
.recruit-list { display: flex; flex-direction: column; gap: 6px; }
.recruit-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg-card-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.recruit-row:hover { border-color: var(--cyan); background: var(--bg-hover); }
.recruit-row.cant-afford { opacity: 0.4; cursor: not-allowed; }
.recruit-info { flex: 1; }
.recruit-name { font-size: 0.875rem; font-weight: 600; }
.recruit-desc { font-size: 0.75rem; color: var(--text-dim); }
.recruit-cost { font-weight: 700; color: var(--gold); font-size: 0.875rem; }
.recruit-cost.too-pricey { color: var(--red); }

/* Equip item list */
.equip-item-list { display: flex; flex-direction: column; gap: 6px; }
.equip-item-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-card-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.equip-item-row:hover { border-color: var(--cyan); background: var(--bg-hover); }
.equip-item-row-name { flex: 1; font-size: 0.875rem; }
.equip-item-bonus { font-size: 0.75rem; }
.equip-item-qty { font-size: 0.75rem; color: var(--text-dim); }

/* ── Shop Screen ───────────────────────────────────────────────────────── */
.shop-toggle { display: flex; gap: 6px; margin-bottom: 16px; }
.shop-toggle .btn.active { background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan); }

.shop-grid { display: flex; flex-direction: column; gap: 8px; }
.shop-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-card-alt); border: 1px solid var(--border);
  border-radius: var(--radius); transition: all 0.15s;
}
.shop-item:hover { border-color: #3a3f5c; background: var(--bg-hover); }
.shop-item-info { flex: 1; }
.shop-item-name { font-weight: 600; font-size: 0.9rem; }
.shop-item-desc { font-size: 0.78rem; color: var(--text-dim); }
.shop-item-bonus { font-size: 0.78rem; }
.shop-item-slot { font-size: 0.7rem; color: var(--cyan); text-transform: uppercase; }
.shop-item-meta { display: flex; gap: 10px; align-items: center; }
.shop-item-class-req { font-size: 0.7rem; color: var(--text-dim); }
.shop-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.shop-price { font-weight: 700; color: var(--gold); font-size: 0.9rem; }
.shop-price.cant-afford { color: var(--red); }

/* Keep / lock toggle */
.shop-item-kept {
  border-color: var(--gold) !important;
  background: linear-gradient(135deg, rgba(218,165,32,0.06) 0%, transparent 60%);
}
.kept-icon { font-size: 0.82rem; }
.kept-note { color: var(--gold); font-size: 0.78rem; font-weight: 400; }
.btn-keep-toggle {
  font-size: 0.72rem; padding: 3px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card-alt);
  color: var(--text-muted); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-keep-toggle:hover { border-color: var(--gold); color: var(--gold); }
.btn-keep-toggle.btn-kept {
  border-color: var(--gold); color: var(--gold); background: rgba(218,165,32,0.12);
  font-weight: 600;
}
.shop-stock { font-size: 0.72rem; color: var(--text-muted); }
.shop-refresh { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 12px; }
.shop-refresh-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; padding: 8px 12px;
  background: var(--bg-card-alt); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.82rem;
}
.shop-refresh-info { color: var(--text-muted); }
.shop-refresh-info strong { color: var(--text); }
.btn-rush {
  background: linear-gradient(135deg, #b8860b 0%, #daa520 100%);
  color: #fff; border: none; font-weight: 600; white-space: nowrap;
  padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: opacity 0.15s;
}
.btn-rush:hover:not(:disabled) { opacity: 0.85; }
.btn-rush.disabled, .btn-rush:disabled { opacity: 0.4; cursor: not-allowed; }
.shop-sell-all-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; padding: 8px 12px;
  background: var(--bg-card-alt); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.82rem; color: var(--text-muted);
}
.shop-sell-all-bar strong { color: var(--text); }
.btn-sell-all-items {
  background: #c0392b; color: #fff; border: none; font-weight: 600;
  white-space: nowrap; padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: opacity 0.15s;
}
.btn-sell-all-items:hover { opacity: 0.85; }

/* Shop Upgrade Panel */
.shop-upgrade-panel {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.shop-upgrade-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.shop-upgrade-title {
  font-weight: 700; font-size: 0.95rem; color: var(--text);
}
.shop-upgrade-maxed {
  font-weight: 700; font-size: 0.8rem; color: var(--gold);
  background: rgba(255,215,0,0.1); border: 1px solid var(--gold);
  border-radius: 4px; padding: 2px 10px; letter-spacing: 0.05em;
}
.btn-upgrade {
  background: rgba(255,215,0,0.12) !important; border-color: var(--gold) !important;
  color: var(--gold) !important; font-weight: 600;
}
.btn-upgrade:hover { background: rgba(255,215,0,0.22) !important; }
.shop-upgrade-pips {
  display: flex; gap: 4px; margin-bottom: 10px;
}
.shop-upgrade-pip {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--bg-hover); border: 1px solid var(--border);
  transition: background 0.3s;
}
.shop-upgrade-pip.filled {
  background: var(--gold); border-color: var(--gold);
}
.shop-rarity-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  margin-bottom: 6px; background: var(--bg-hover);
}
.shop-rarity-bar-seg { transition: width 0.4s ease; }
.shop-rarity-labels {
  display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.7rem; font-weight: 600;
}
.shop-rarity-label { opacity: 0.85; }
.shop-milestone {
  font-size: 0.78rem; font-weight: 600; color: var(--gold);
  margin-bottom: 8px; text-align: center;
}
.shop-next-milestone {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 6px;
  font-style: italic; text-align: center;
}
.shop-rank-locked {
  font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 10px;
}
.shop-locked-rarities {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 6px;
  text-align: center;
}

/* ── Results Modal ─────────────────────────────────────────────────────── */
.result-outcome {
  text-align: center; padding: 20px 0 12px;
  font-size: 1.5rem; font-weight: 700;
}
.result-outcome.success { color: var(--green); }
.result-outcome.failure { color: var(--red); }
.result-quest-name { text-align: center; color: var(--gold); font-size: 1rem; margin-bottom: 4px; }
.result-narrative {
  font-size: 0.875rem; color: var(--text-dim); font-style: italic;
  background: var(--bg-deep); border-radius: var(--radius-sm);
  padding: 12px 14px; line-height: 1.7;
  border-left: 3px solid var(--border);
}
.result-section { display: flex; flex-direction: column; gap: 6px; }
.result-section-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.result-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem; padding: 4px 0; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: none; }
.result-row-label { color: var(--text-dim); }
.result-row-value { font-weight: 600; }
.result-gold { color: var(--gold); }
.result-exp { color: var(--cyan); }
.result-rank { color: var(--purple); }
.result-loot { color: var(--green); }
.result-loot-section { padding: 4px 0; }
.result-loot-section .result-row-label { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 4px; }
.result-loot-entry { font-size: 0.82rem; padding: 2px 0; }
.result-loot-class-req { font-size: 0.68rem; color: var(--text-muted); }
.result-injury { color: var(--red); }
.result-levelup-section {
  background: rgba(240,192,96,0.08); border: 1px solid rgba(240,192,96,0.15);
  border-radius: var(--radius); padding: 12px 16px; margin: 8px 0;
  animation: levelup 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.levelup-title {
  font-size: 1rem; font-weight: 700; color: var(--gold);
  text-align: center; margin-bottom: 8px; letter-spacing: 1px;
}
.result-levelup-entry {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; font-size: 0.88rem;
}
.result-levelup-entry + .result-levelup-entry { border-top: 1px solid rgba(240,192,96,0.10); }
.levelup-name { color: var(--gold); font-weight: 600; }
.levelup-levels { color: var(--text); font-weight: 700; font-size: 0.9rem; }

/* Skill gain banner */
.result-skill-gain {
  color: var(--cyan, #4ecdc4); font-weight: 700; text-align: center; font-size: 0.9rem;
  padding: 8px; margin-top: 4px;
  background: rgba(78,205,196,0.08); border-radius: var(--radius-sm);
  animation: fadeSlideIn 0.5s ease-out;
}

/* Combat stats section */
.cs-header {
  display: flex; justify-content: space-between; font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim);
  padding: 0 2px 4px; border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}
.cs-row {
  display: flex; align-items: center; gap: 6px; padding: 3px 2px;
  font-size: 0.78rem;
}
.cs-name {
  width: 80px; flex-shrink: 0; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-weight: 600;
}
.cs-bar-wrap {
  flex: 1; position: relative; height: 16px; background: rgba(255,255,255,0.04);
  border-radius: 3px; overflow: hidden;
}
.cs-bar {
  position: absolute; top: 0; left: 0; height: 100%;
  background: linear-gradient(90deg, var(--red, #e74c3c), var(--orange, #e0a050));
  border-radius: 3px; min-width: 2px; transition: width 0.3s ease;
}
.cs-dmg-val {
  position: absolute; right: 4px; top: 0; height: 100%;
  display: flex; align-items: center; font-size: 0.7rem; font-weight: 700;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
/* Defense, Healing & Support table */
.ds-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; margin-top: 4px; }
.ds-table th { padding: 5px 8px; text-align: right; font-weight: 600; font-size: 0.7rem; color: var(--gold, #ffd700); border-bottom: 1px solid rgba(255,255,255,0.08); white-space: nowrap; }
.ds-table th:first-child { text-align: left; }
.ds-table td { padding: 4px 8px; text-align: right; color: rgba(255,255,255,0.6); border-bottom: 1px solid rgba(255,255,255,0.03); }
.ds-table td:first-child { text-align: left; }
.ds-table .ds-name { color: rgba(255,255,255,0.85); font-weight: 500; }
.ds-table .ds-best { color: var(--gold, #ffd700); font-weight: 600; }
.ds-table .ds-total { color: rgba(255,255,255,0.9); font-weight: 600; border-left: 1px solid rgba(255,255,255,0.06); }
.ds-table tr:hover td { background: rgba(255,255,255,0.03); }
.ds-mvp { background: var(--gold, #ffd700); color: #1a1a2e; font-size: 0.6rem; font-weight: bold; padding: 1px 5px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }
.ds-taken { color: rgba(255,100,100,0.8); border-left: 1px solid rgba(255,255,255,0.06); }

/* Synergy unlock banner */
.result-synergy-unlocks {
  margin-top: 8px; padding: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(147,130,220,0.10), rgba(78,205,196,0.06));
  border: 1px solid rgba(147,130,220,0.25);
  animation: fadeSlideIn 0.5s ease-out;
}
.synergy-unlock-title {
  font-weight: 700; font-size: 0.85rem; text-align: center;
  color: var(--purple, #9382dc); margin-bottom: 6px; letter-spacing: 0.5px;
}
.synergy-unlock-entry {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; font-size: 0.82rem;
}
.synergy-unlock-label { font-weight: 600; color: var(--text); }
.synergy-unlock-desc { color: var(--text-dim); font-style: italic; }

/* Copy Fight Log button */
.result-copy-log {
  display: flex; justify-content: center; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.btn-copy-fight-log {
  font-size: 0.72rem; padding: 5px 14px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06); color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08); cursor: pointer;
  transition: all 0.2s ease;
}
.btn-copy-fight-log:hover {
  background: rgba(255,255,255,0.1); color: var(--text);
  border-color: rgba(255,255,255,0.15);
}
.btn-copy-fight-log.copied {
  background: rgba(46,204,113,0.15); color: var(--green);
  border-color: rgba(46,204,113,0.3);
}


@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Rank-up celebration */
.result-rank-up {
  text-align: center; padding: 16px; margin: -16px -16px 16px;
  background: linear-gradient(135deg, rgba(240,192,96,0.15), rgba(78,205,196,0.10));
  border-bottom: 2px solid var(--gold);
  animation: rankUpPulse 1.5s ease-in-out;
}
.rank-up-stars {
  font-size: 1.4rem; color: var(--gold); letter-spacing: 8px;
  animation: rankUpStars 1s ease-out;
}
.rank-up-title {
  font-size: 1.5rem; font-weight: 800; color: var(--gold);
  text-transform: uppercase; letter-spacing: 2px; margin: 4px 0 12px;
  text-shadow: 0 0 20px rgba(240,192,96,0.4);
}
.rank-up-badges {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 8px 0;
}
.rank-up-arrow {
  font-size: 1.6rem; color: var(--gold); font-weight: 700;
  animation: rankUpArrow 0.8s ease-out 0.3s both;
}
.rank-up-subtitle {
  font-size: 0.8rem; color: var(--text-dim); margin-top: 8px; font-style: italic;
}
@keyframes rankUpPulse {
  0% { opacity: 0; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes rankUpStars {
  0% { opacity: 0; transform: translateY(-10px) scale(0.5); }
  60% { opacity: 1; transform: translateY(0) scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes rankUpArrow {
  0% { opacity: 0; transform: translateX(-10px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Rank-up full-screen flash */
.rank-up-flash {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, rgba(240,192,96,0.3), transparent 70%);
  pointer-events: none; z-index: 10000;
  animation: rankFlash 1.5s ease-out forwards;
}
@keyframes rankFlash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}

/* Dead party member in combat */
.aq-member-dead {
  opacity: 0.4; filter: grayscale(0.7);
}
.aq-member-dead .aq-party-sigil {
  color: var(--red); background: rgba(231,76,60,0.15);
}

/* ── Misc Utilities ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-gold    { color: var(--gold); }
.text-cyan    { color: var(--cyan); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-dim     { color: var(--text-dim); }
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.fw-600       { font-weight: 600; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-8        { gap: 8px; }

.empty-state {
  text-align: center; padding: 32px 16px;
  color: var(--text-muted); font-style: italic; font-size: 0.875rem;
}

/* ── Animations ────────────────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(78, 205, 196, 0.3); }
  50% { box-shadow: 0 0 16px rgba(78, 205, 196, 0.6); }
}

@keyframes sparkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; transform: scale(1.1); }
}

@keyframes levelup {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes countUp {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-pulse {
  animation: pulse 0.6s ease-in-out;
}

.animate-glow {
  animation: glow 0.8s ease-in-out;
}

.animate-sparkle {
  animation: sparkle 1s ease-in-out;
}

.animate-levelup {
  animation: levelup 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-content {
  animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
  animation: fadeIn 0.3s ease-in-out;
}

.card {
  animation: slideUp 0.4s ease-out;
}

.progress-fill {
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#toast {
  animation: slideUpFade 0.3s ease-out;
}

.result-levelup-section {
  animation: levelup 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-box {
  animation: slideUp 0.3s ease-out;
}

/* ── Character Sheet ──────────────────────────────────────────────────── */

.char-sheet {
  display: flex; flex-direction: column; gap: 16px;
  animation: fadeIn 0.25s ease-out;
}

.char-sheet-topbar {
  display: flex; justify-content: space-between; align-items: center;
}

.char-sheet-actions {
  display: flex; gap: 6px;
}

.char-header {
  display: flex; gap: 20px; align-items: flex-start;
  padding: 20px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}

.char-portrait {
  width: 72px; height: 72px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep); border: 2px solid var(--cyan-dim);
  border-radius: var(--radius); font-size: 1.8rem;
}

.char-portrait-sigil {
  color: var(--cyan); font-weight: 700; font-family: monospace;
}

.char-header-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.char-name { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.char-class { font-size: 0.85rem; color: var(--text-dim); }
.char-power { font-size: 0.8rem; color: var(--text-dim); }
.char-power strong { color: var(--gold); }

.char-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.char-bar-row {
  display: flex; align-items: center; gap: 8px;
}
.char-bar-label {
  font-size: 0.7rem; font-weight: 600; color: var(--text-dim);
  width: 28px; text-align: right;
}
.char-bar-value {
  font-size: 0.72rem; color: var(--text-dim); min-width: 80px; text-align: right;
}

.char-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

.char-col-left, .char-col-right {
  display: flex; flex-direction: column; gap: 16px;
}

.char-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}

.char-section-title {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 12px;
}

/* ── Equipment Panel ──────────────────────────────────────────────────── */

.equip-panel { display: flex; flex-direction: column; gap: 8px; }

.equip-slot-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; transition: border-color 0.15s;
}

.equip-slot-card:hover { border-color: var(--cyan-dim); }
.equip-slot-card.open { border-color: var(--cyan); }

.equip-slot-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; cursor: pointer; transition: background 0.15s;
}

.equip-slot-header:hover { background: var(--bg-hover); }

.equip-slot-icon { font-size: 1.1rem; flex-shrink: 0; }

.equip-slot-info { flex: 1; min-width: 0; }

.equip-slot-type {
  display: block; font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim);
}

.equip-slot-item-name {
  display: block; font-size: 0.85rem; font-weight: 600; color: var(--text);
}

.equip-slot-empty {
  font-size: 0.8rem; color: var(--text-dim); font-style: italic;
}

.equip-slot-bonus {
  font-size: 0.72rem; white-space: nowrap;
}

.equip-unequip-btn {
  font-size: 0.75rem; padding: 2px 8px; color: var(--red); border-color: transparent;
}
.equip-unequip-btn:hover { border-color: var(--red); background: var(--red-dim); }

.equip-slot-class-req {
  font-size: 0.7rem; color: var(--text-dim); padding: 0 12px 4px 38px;
}

.equip-skill-grant {
  font-size: 0.72rem; color: var(--purple); padding: 4px 12px 8px 38px;
}

/* ── Equipment Picker (inline dropdown) ──────────────────────────────── */

.equip-picker {
  border-top: 1px solid var(--border); padding: 8px;
  background: var(--bg-deep);
  animation: slideUp 0.2s ease-out;
}

.equip-picker-empty {
  text-align: center; padding: 12px; color: var(--text-muted);
  font-style: italic; font-size: 0.8rem;
}

.equip-picker-item {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  cursor: pointer; transition: all 0.12s;
}

.equip-picker-item:last-child { margin-bottom: 0; }

.equip-picker-item:hover {
  border-color: var(--cyan); background: var(--bg-hover);
}

.equip-picker-item-main {
  display: flex; justify-content: space-between; align-items: center;
}

.equip-picker-item-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.equip-picker-qty { color: var(--text-dim); font-weight: 400; }
.equip-picker-item-bonus { font-size: 0.75rem; }
.equip-picker-item-skill { font-size: 0.72rem; color: var(--purple); margin-top: 3px; }
.equip-picker-item-desc { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

.equip-picker-item.class-locked {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
  border-left: 2px solid var(--red);
}
.equip-picker-class-warn {
  font-size: 0.7rem; color: var(--red); margin-top: 2px; font-style: italic;
}
.equip-picker-dual-wield {
  font-size: 0.7rem; color: var(--cyan); margin-top: 2px; font-weight: 600;
}
.equip-picker-two-handed {
  font-size: 0.7rem; color: var(--orange); margin-top: 2px; font-weight: 600;
}

/* ── Item Rarity Badge ─────────────────────────────────────────────────── */
.item-rarity-badge {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 1px 5px;
  border: 1px solid; border-radius: 3px;
  vertical-align: middle; white-space: nowrap;
}

/* ── Stats Panel ─────────────────────────────────────────────────────── */

.stats-panel { display: flex; flex-direction: column; gap: 4px; }

.stat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}

.stat-row:last-child { border-bottom: none; }

.stat-row-label {
  font-size: 0.78rem; font-weight: 600; color: var(--text-dim);
  width: 50px;
}

.stat-row-base {
  font-size: 0.8rem; color: var(--text-dim); width: 40px; text-align: right;
}

.stat-row-arrow {
  font-size: 0.7rem; color: var(--text-dim);
}

.stat-row-final {
  font-size: 0.85rem; font-weight: 700; color: var(--text); width: 40px; text-align: right;
}

.stat-bonus {
  color: var(--green); font-weight: 600;
}

.stat-penalty {
  color: var(--red); font-weight: 600;
}

/* ── Skills Panel ────────────────────────────────────────────────────── */

.skills-panel { display: flex; flex-direction: column; gap: 6px; }

.skills-category-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--cyan); padding: 2px 0;
}

.skills-category-sub {
  color: var(--text-dim); font-weight: 400; text-transform: none; letter-spacing: 0;
}

.skill-empty-note {
  font-size: 0.78rem; color: var(--text-dim); font-style: italic; padding: 4px 0;
}

.skill-row {
  display: flex; gap: 8px; padding: 8px 10px;
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: border-color 0.15s;
}

.skill-row:hover:not(.locked) {
  border-color: var(--cyan-dim); background: var(--bg-hover);
}

.skill-row.locked {
  opacity: 0.45;
}

.skill-row-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.3; filter: brightness(1.4) drop-shadow(0 0 1px rgba(255,255,255,0.3)); }
.skill-row-info { flex: 1; min-width: 0; }

.skill-row-top {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

.skill-row-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text);
}

.skill-row-source {
  font-size: 0.65rem; color: var(--purple); font-style: italic;
}

.skill-row-lock {
  font-size: 0.72rem; color: var(--text-dim); margin-top: 2px;
}

.skill-row-desc {
  font-size: 0.75rem; color: var(--text-dim); margin-top: 3px; line-height: 1.4;
}

.skill-row-effects {
  font-size: 0.7rem; color: var(--green); margin-top: 3px; font-weight: 500;
}

.skill-badge {
  font-size: 0.6rem; padding: 1px 5px;
  border-radius: 2px; font-weight: 600; flex-shrink: 0;
}

.skill-active {
  background: rgba(46, 204, 113, 0.15); color: var(--green);
}

.skill-passive {
  background: rgba(155, 89, 182, 0.15); color: var(--purple);
}

/* ── Specialization Picker ─────────────────────────────────────────── */
.spec-picker {
  display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
}
.spec-card {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; padding: 10px 12px; cursor: default;
  transition: border-color 0.2s;
}
.spec-card:hover { border-color: var(--cyan); }
.spec-card-header {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 0.95rem; margin-bottom: 4px;
}
.spec-card-icon { font-size: 1.1rem; }
.spec-card-name { color: var(--text-primary); }
.spec-card-desc {
  font-size: 0.78rem; color: var(--text-dim); margin-bottom: 6px; line-height: 1.3;
}
.spec-card-skills {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
}
.spec-skill-preview {
  font-size: 0.7rem; padding: 2px 6px; border-radius: 3px;
  background: rgba(255,255,255,0.06); color: var(--text-secondary);
}
.btn-choose-spec {
  width: 100%; padding: 5px 0; font-size: 0.78rem;
}
.spec-respec-bar {
  display: flex; justify-content: flex-end; margin: 4px 0 8px;
}
.btn-roster {
  font-size: 0.75rem; padding: 4px 12px;
  color: var(--cyan); border: 1px solid rgba(0,245,255,0.3);
  background: rgba(0,245,255,0.08); border-radius: 4px;
  cursor: pointer; transition: all 0.2s;
}
.btn-roster:hover { background: rgba(0,245,255,0.18); border-color: rgba(0,245,255,0.5); }
.btn-respec {
  font-size: 0.75rem; padding: 4px 12px;
  color: var(--gold); border: 1px solid rgba(255,215,0,0.3);
  background: rgba(255,215,0,0.08); border-radius: 4px;
  cursor: pointer; transition: all 0.2s;
}
.btn-respec:hover { background: rgba(255,215,0,0.18); border-color: rgba(255,215,0,0.5); }
.btn-xs {
  font-size: 0.65rem; padding: 1px 6px; border-radius: 3px;
}

.result-skill-activation {
  font-size: 0.85rem; color: var(--cyan);
  padding: 4px 0; margin: 2px 0;
}

/* ── Battle Highlights ──────────────────────────────────────────────── */
.highlight-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; margin: 2px 0;
  border-radius: 6px; font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.03);
}
.highlight-row:nth-child(even) { background: rgba(255, 255, 255, 0.06); }
.highlight-icon { font-size: 1.1rem; flex-shrink: 0; width: 22px; text-align: center; }
.highlight-label {
  color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.04em; width: 100px; flex-shrink: 0;
}
.highlight-value { color: var(--text); flex: 1; }
.highlight-value strong { color: var(--gold); }

/* ── Active Quest Scene ──────────────────────────────────────────────── */

.aq-scene {
  display: flex; flex-direction: column; gap: 0;
  animation: fadeIn 0.3s ease-out;
}

.aq-scene-header {
  padding: 20px 24px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  position: relative;
  overflow: hidden;
}

/* Mood-based gradient backgrounds */
.aq-scene-header.mood-pastoral   { background: linear-gradient(135deg, #1a2a15 0%, var(--bg-card) 60%); }
.aq-scene-header.mood-dungeon    { background: linear-gradient(135deg, #1a1520 0%, var(--bg-card) 60%); }
.aq-scene-header.mood-wilderness { background: linear-gradient(135deg, #15201a 0%, var(--bg-card) 60%); }
.aq-scene-header.mood-haunted    { background: linear-gradient(135deg, #1a1528 0%, var(--bg-card) 60%); }
.aq-scene-header.mood-fortress   { background: linear-gradient(135deg, #201a15 0%, var(--bg-card) 60%); }
.aq-scene-header.mood-mountain   { background: linear-gradient(135deg, #151a25 0%, var(--bg-card) 60%); }
.aq-scene-header.mood-demonic    { background: linear-gradient(135deg, #2a1015 0%, var(--bg-card) 60%); }

.aq-scene-env {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px;
}
.aq-scene-icon { font-size: 1.2rem; }
.aq-scene-name { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

.aq-scene-quest {
  display: flex; align-items: center; gap: 10px;
}
.aq-scene-title {
  font-size: 1.3rem; font-weight: 700; color: var(--text);
}

/* Phase tracker */
.aq-phase-tracker {
  display: flex; align-items: center; justify-content: center;
  gap: 0; padding: 14px 24px;
  background: var(--bg-card); border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.aq-phase-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0;
}

.aq-phase-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-deep); border: 2px solid var(--border);
  transition: all 0.3s ease;
}
.aq-phase-dot.active {
  background: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(78, 205, 196, 0.5);
}
.aq-phase-dot.done {
  background: var(--green); border-color: var(--green);
}

.aq-phase-name {
  font-size: 0.68rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.aq-phase-name.active { color: var(--cyan); font-weight: 600; }

.aq-phase-line {
  flex: 1; height: 2px; background: var(--border);
  margin: 0 8px; margin-bottom: 18px;
  min-width: 30px;
}

/* Main content: 2-column layout */
.aq-main-content {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.aq-left-col {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px; background: var(--bg-card);
  border-right: 1px solid var(--border);
}

.aq-right-col {
  display: flex; flex-direction: column;
  background: var(--bg-deep);
}

.aq-section-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 8px;
}

/* Timer block */
.aq-phase-status { text-align: center; margin-bottom: 8px; }
.aq-phase-current {
  font-size: 0.9rem; color: var(--cyan); font-weight: 600;
}

/* Party strip with HP bars */
.aq-party-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.aq-party-member {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px 10px; background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 100px; max-width: 140px;
  transition: border-color 0.3s ease;
}
.aq-party-header {
  display: flex; align-items: center; gap: 6px;
}
.aq-party-sigil {
  font-size: 0.85rem; font-weight: 700; color: var(--cyan);
  background: rgba(78,205,196,0.1); padding: 2px 6px; border-radius: 3px;
  font-family: monospace; flex-shrink: 0;
}
.aq-party-info { display: flex; flex-direction: column; min-width: 0; }
.aq-party-name { font-size: 0.75rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aq-party-level { font-size: 0.6rem; color: var(--text-muted); white-space: nowrap; }

/* Buff/cooldown indicators on hero cards */
.aq-buff-row {
  display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px;
}
.aq-buff-pip {
  font-size: 0.7rem; padding: 1px 4px; border-radius: 3px;
  background: rgba(78,205,196,0.12); border: 1px solid rgba(78,205,196,0.25);
  cursor: default; line-height: 1.1; transition: all 0.3s ease;
  filter: brightness(1.4) drop-shadow(0 0 1px rgba(255,255,255,0.3));
}
.aq-buff-pip.buff-cd {
  background: rgba(127,127,140,0.12); border-color: rgba(127,127,140,0.3);
  opacity: 0.6; filter: grayscale(0.4);
}

/* Live HP bars (shared between party and enemy) */
.aq-hp-bar {
  width: 100%; height: 5px; background: var(--bg); border-radius: 3px;
  overflow: hidden; margin-top: 3px;
}
.aq-hp-bar.enemy { height: 4px; }
.aq-hp-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.5s ease, background 0.5s ease;
}
.aq-hp-text {
  font-size: 0.6rem; color: var(--text-muted); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Enemy cards with HP */
.aq-enemy-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.aq-enemy-card {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--red-dim); border: 1px solid rgba(231,76,60,0.3);
  border-radius: var(--radius-sm); font-size: 0.8rem;
  transition: opacity 0.4s ease, filter 0.4s ease;
}
.aq-enemy-card.defeated {
  opacity: 0.35; filter: grayscale(0.8);
  border-color: var(--border);
}
.aq-enemy-card.reinforcement {
  border-color: rgba(243,156,18,0.5); background: rgba(243,156,18,0.06);
}
.aq-enemy-icon { font-size: 1rem; flex-shrink: 0; }
.aq-enemy-info { display: flex; flex-direction: column; gap: 2px; min-width: 60px; }
.aq-enemy-name { color: var(--text); font-weight: 500; font-size: 0.78rem; }
.aq-reinforce-tag {
  font-size: 0.6rem; font-weight: 700; color: var(--orange);
  text-transform: uppercase; letter-spacing: 0.5px;
}
/* Enemy debuff state */
.aq-enemy-card.debuffed {
  border-color: rgba(243,156,18,0.5);
  box-shadow: 0 0 6px rgba(243,156,18,0.15);
}
.aq-debuff-row {
  display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle;
}
.aq-debuff-pip {
  font-size: 0.65rem; padding: 0px 3px; border-radius: 3px;
  background: rgba(231,76,60,0.15); border: 1px solid rgba(231,76,60,0.3);
  color: var(--red); cursor: default; line-height: 1.2;
  animation: debuffPulse 1.5s ease-in-out infinite;
}
.aq-debuff-rounds {
  font-size: 0.55rem; font-weight: 700; margin-left: 1px;
  font-variant-numeric: tabular-nums;
}
@keyframes debuffPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════════════════
   COMBAT LOG — Standardized Visual System (v2)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Damage / heal NUMBER chips ────────────────────────────────────── */
.dmg-num {
  font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 0 3px; border-radius: 2px; font-size: 0.85em;
}
.dmg-phys  { color: #ffffff; background: rgba(255,255,255,0.08); }
.dmg-mag   { color: #c882ff; background: rgba(168,100,255,0.12); }
.dmg-skill { color: var(--gold); background: rgba(240,192,96,0.12); }
.dmg-aoe   { color: #f5a623; background: rgba(245,166,35,0.12); }
.dmg-equip {
  color: #c882ff; background: rgba(168,100,255,0.15);
  font-size: 0.9em; font-weight: 800;
  text-shadow: 0 0 3px rgba(168,100,255,0.3);
  animation: equipFlare 0.5s ease-out;
}
@keyframes equipFlare {
  0%   { background: rgba(168,100,255,0.35); text-shadow: 0 0 8px rgba(168,100,255,0.7); }
  100% { background: rgba(168,100,255,0.15); text-shadow: 0 0 3px rgba(168,100,255,0.3); }
}
.dmg-heal  { color: var(--green); background: rgba(46,204,113,0.10); }
.dmg-block { color: var(--text-dim); background: rgba(255,255,255,0.06); }
.dmg-enemy { color: var(--red); background: rgba(231,76,60,0.10); }
.dmg-dot   { color: #e67e22; background: rgba(230,126,34,0.12); }
.dmg-crit {
  color: #fff; background: rgba(255,200,60,0.20);
  font-size: 1.0em; text-shadow: 0 0 4px rgba(255,200,60,0.5);
  animation: critPop 0.4s ease-out;
}
@keyframes critPop {
  0%   { transform: scale(1.0); }
  30%  { transform: scale(1.35); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1.0); }
}
.dmg-celestial {
  color: #00e5c8; background: rgba(0,229,200,0.12);
  font-size: 1.0em; font-weight: 800;
  text-shadow: 0 0 6px rgba(0,229,200,0.5), 0 0 14px rgba(0,229,200,0.25);
  animation: celestialShimmer 1.8s ease-in-out infinite;
}
@keyframes celestialShimmer {
  0%, 100% { text-shadow: 0 0 6px rgba(0,229,200,0.5), 0 0 14px rgba(0,229,200,0.25); }
  50%      { text-shadow: 0 0 10px rgba(0,229,200,0.8), 0 0 20px rgba(0,229,200,0.4); }
}
.dmg-ko {
  color: #ff4444; background: rgba(255,68,68,0.15);
  font-weight: 800;
}
.dmg-dodge {
  color: var(--text-muted); background: rgba(255,255,255,0.04);
  font-style: italic; opacity: 0.7;
}

/* ── Inline skill / ability NAME highlights ─────────────────────────── */
.sk-atk    { color: #e0e0e0; font-weight: 600; }
.sk-skill  { color: var(--gold); font-weight: 600; }
.sk-aoe    { color: #f5a623; font-weight: 600; }
.sk-magic  { color: #c882ff; font-weight: 600; }
.sk-heal   { color: #5dde8e; font-weight: 600; }
.sk-buff   { color: #64b5f6; font-weight: 600; }
.sk-debuff { color: var(--orange); font-weight: 600; }
.sk-equip  { color: #c882ff; font-weight: 600; }
.sk-divine { color: #ffd866; font-weight: 700; }
.sk-dot    { color: #e67e22; font-weight: 600; }
.sk-react  { color: #80deea; font-weight: 600; }
.sk-enemy  { color: #ff7675; font-weight: 600; }
.sk-crit   { color: #ffd866; font-weight: 700; }
.sk-celest { color: #00e5c8; font-weight: 700; text-shadow: 0 0 6px rgba(0,229,200,0.4); }

/* Rewards preview */
.aq-rewards-row {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.aq-reward {
  font-size: 0.8rem; color: var(--text-dim);
  display: flex; align-items: center; gap: 4px;
}
.aq-reward-icon { font-size: 0.9rem; }

/* Combat log */
.aq-combat-log-section {
  display: flex; flex-direction: column; height: 100%;
  padding: 16px;
}

.aq-combat-log {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 3px; max-height: 400px; min-height: 200px;
  padding: 8px;
  scrollbar-width: thin;
}

.combat-log-entry {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  font-size: 0.8rem; line-height: 1.4;
  border-left: 3px solid transparent;
  animation: slideUp 0.3s ease-out;
}

.log-icon {
  flex-shrink: 0; font-size: 0.85rem; width: 20px; text-align: center;
}

.log-text { color: #c8cce0; }

/* ── Log entry type backgrounds + accents ────────────────────────────
   Standard: 3px left-border accent + subtle tinted background.
   Body text stays uniform #c8cce0 — only skill names & numbers get color.
   ──────────────────────────────────────────────────────────────────── */

/* Travel / narrative — barely visible, low priority */
.combat-log-entry.log-travel   { background: rgba(78,205,196,0.03); border-left-color: transparent; }
.combat-log-entry.log-travel .log-text { color: var(--text-muted); font-style: italic; }

/* Encounter — amber alert */
.combat-log-entry.log-encounter { background: rgba(243,156,18,0.08); border-left-color: var(--orange); }

/* Party basic attack — clean neutral */
.combat-log-entry.log-attack   { background: rgba(200,210,230,0.04); border-left-color: rgba(200,210,230,0.2); }

/* Defend — subtle steel */
.combat-log-entry.log-defend   { background: rgba(200,210,230,0.04); border-left-color: rgba(200,210,230,0.15); }

/* Party skill attack — gold accent */
.combat-log-entry.log-skill    { background: rgba(240,192,96,0.06); border-left-color: var(--gold); }

/* Party crit — punchy gold */
.combat-log-entry.log-crit {
  background: rgba(255,216,102,0.10); border-left-color: #ffd866;
}
.combat-log-entry.log-crit .log-text { font-weight: 600; }

/* Magic (Shadow Bolt, Raise Dead, minion attacks) — purple */
.combat-log-entry.log-magic    { background: rgba(155,89,182,0.07); border-left-color: var(--purple); }

/* Equipment proc — deeper purple with flash */
.combat-log-entry.log-equip {
  background: rgba(168,100,255,0.08); border-left-color: #a864ff;
  animation: slideUp 0.3s ease-out, equipEntryFlash 0.6s ease-out;
}
@keyframes equipEntryFlash {
  0%   { background: rgba(168,100,255,0.2); }
  100% { background: rgba(168,100,255,0.08); }
}

/* Celestial proc — teal glow + shimmer */
.combat-log-entry.log-celestial {
  background: rgba(0,229,200,0.08); border-left-color: #00e5c8;
  animation: slideUp 0.3s ease-out, celestialEntryGlow 2.5s ease-in-out infinite;
}
.combat-log-entry.log-celestial .log-text { font-weight: 700; }
@keyframes celestialEntryGlow {
  0%, 100% { background: rgba(0,229,200,0.06); box-shadow: none; }
  50%      { background: rgba(0,229,200,0.12); box-shadow: inset 0 0 12px rgba(0,229,200,0.08); }
}

/* Heal — green */
.combat-log-entry.log-heal     { background: rgba(46,204,113,0.06); border-left-color: var(--green); }

/* Buff (party buff applied) — cool blue */
.combat-log-entry.log-buff     { background: rgba(100,181,246,0.06); border-left-color: #64b5f6; }

/* Debuff (applied to enemies / DoT ticks) — amber */
.combat-log-entry.log-debuff   { background: rgba(243,156,18,0.06); border-left-color: #e67e22; }

/* Enemy attack — red threat */
.combat-log-entry.log-enemy    { background: rgba(231,76,60,0.07); border-left-color: var(--red); }

/* Enemy defeat — victorious green */
.combat-log-entry.log-defeat   { background: rgba(46,204,113,0.08); border-left-color: var(--green); }
.combat-log-entry.log-defeat .log-text { font-weight: 600; }

/* KO (party member down) — alarming red flash */
.combat-log-entry.log-ko {
  background: rgba(255,68,68,0.10); border-left-color: #ff4444;
  animation: slideUp 0.3s ease-out, koFlash 0.6s ease-out;
}
.combat-log-entry.log-ko .log-text { font-weight: 600; }
@keyframes koFlash {
  0%   { background: rgba(255,68,68,0.25); }
  100% { background: rgba(255,68,68,0.10); }
}

/* Dodge / miss — barely there */
.combat-log-entry.log-dodge    { background: rgba(255,255,255,0.02); border-left-color: transparent; }
.combat-log-entry.log-dodge .log-text { color: var(--text-muted); font-style: italic; }

/* Divine (DI, cheat-death, resurrection) — holy gold */
.combat-log-entry.log-divine   { background: rgba(255,216,102,0.08); border-left-color: #ffd866; }
.combat-log-entry.log-divine .log-text { font-weight: 600; }

/* Cover (Vanguard intercept, Bulwark) — steel blue */
.combat-log-entry.log-cover    { background: rgba(100,181,246,0.06); border-left-color: #90caf9; }

/* Reinforce (new enemies arrive) — warning orange */
.combat-log-entry.log-reinforce { background: rgba(243,156,18,0.10); border-left-color: var(--orange); }
.combat-log-entry.log-reinforce .log-text { font-weight: 600; }

/* Resolve (battle end flavor) — subtle cyan */
.combat-log-entry.log-resolve  { background: rgba(78,205,196,0.06); border-left-color: var(--cyan); }
.combat-log-entry.log-resolve .log-text { font-style: italic; }

/* ── Quest Board Enhancements ────────────────────────────────────────── */

.qb-header {
  margin-bottom: 16px;
}
.qb-title {
  font-size: 1.2rem; font-weight: 700; color: var(--text);
}
.qb-subtitle {
  font-size: 0.8rem; color: var(--text-muted); margin-top: 2px;
}

/* Difficulty badges (replace the old dot) */
.difficulty-badge {
  font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
  border-radius: 3px; text-transform: uppercase; letter-spacing: 0.04em;
}
.diff-easy   { background: rgba(46,204,113,0.15); color: var(--green); }
.diff-fair   { background: rgba(243,156,18,0.15); color: var(--orange); }
.diff-hard   { background: rgba(231,76,60,0.15); color: var(--red); }
.diff-danger { background: rgba(231,76,60,0.25); color: #ff6b6b; }

.qc-env-icon {
  font-size: 1rem; flex-shrink: 0;
}

.qc-stat {
  font-size: 0.73rem; font-weight: 500; white-space: nowrap;
}
.qc-gold { color: var(--gold); }
.qc-exp { color: var(--cyan); }
.qc-rp { color: var(--purple); }
.qc-rec { color: var(--text-dim); }
.qc-duration { color: var(--text-muted); }

/* Quest detail expanded */
.qd-flavor {
  display: flex; gap: 12px; align-items: flex-start;
  padding-top: 12px;
}
.qd-env-icon { font-size: 1.5rem; flex-shrink: 0; margin-top: 2px; }
.qd-env-name {
  font-size: 0.78rem; color: var(--cyan); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600; margin-bottom: 4px;
}

.qd-enemies {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; padding: 8px 12px;
  background: rgba(231,76,60,0.05); border: 1px solid rgba(231,76,60,0.15);
  border-radius: var(--radius-sm);
}
.qd-enemies-label { color: var(--red); font-weight: 600; flex-shrink: 0; }
.qd-enemies-list { color: var(--text-dim); }

.qd-rewards-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.qd-reward-box {
  text-align: center; padding: 10px 8px;
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.qd-reward-val { font-size: 0.95rem; font-weight: 700; }
.qd-reward-label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-top: 2px;
}

.qd-power-section { display: flex; flex-direction: column; gap: 6px; }
.qd-power-header {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; color: var(--text-dim);
}

.qd-loot {
  font-size: 0.8rem; color: var(--text-dim);
}
.qd-loot-label { font-weight: 600; }
.qd-loot-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.qd-loot-entry { font-size: 0.8rem; }
.qd-loot-class-req { font-size: 0.68rem; color: var(--text-muted); }

.qd-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.qd-repeatable {
  font-size: 0.72rem; color: var(--green); background: rgba(46,204,113,0.1);
  padding: 3px 10px; border-radius: 3px; font-weight: 600;
}
.qd-one-time {
  font-size: 0.72rem; color: var(--text-muted); background: var(--bg-deep);
  padding: 3px 10px; border-radius: 3px; border: 1px solid var(--border);
}

/* Hall quest top row */
.hall-quest-top {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.hall-quest-phase {
  font-size: 0.78rem; color: var(--cyan); font-weight: 600;
  white-space: nowrap;
}

/* ── Quest Sub-tabs ─────────────────────────────────────────────────── */

.quest-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.quest-tab-btn {
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--text-dim); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.quest-tab-btn:hover { color: var(--text); background: var(--bg-hover); }
.quest-tab-btn.active { color: var(--cyan); background: var(--cyan-dim); border-color: var(--cyan); }

/* ── Quest Board Header ─────────────────────────────────────────────── */

.qb-header-row {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.qb-party-strength {
  text-align: right; padding: 8px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.qb-ps-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.qb-ps-value { font-size: 1.1rem; font-weight: 700; color: var(--gold); }

.qb-refresh-timer {
  font-size: 0.78rem; color: var(--text-muted); margin-top: 8px;
  font-style: italic;
}

/* ── Rarity Badges ──────────────────────────────────────────────────── */

.rarity-badge {
  font-size: 0.62rem; font-weight: 700; padding: 1px 6px;
  border-radius: 3px; text-transform: uppercase; letter-spacing: 0.04em;
}
.rarity-badge.rarity-common    { display: none; }
.rarity-badge.rarity-uncommon  { background: rgba(46,204,113,0.15); color: var(--green); }
.rarity-badge.rarity-rare      { background: rgba(155,89,182,0.15); color: var(--purple); }
.rarity-badge.rarity-legendary { background: rgba(240,192,96,0.15); color: var(--gold); }

/* ── Special Quest Card Effects ─────────────────────────────────────── */

.quest-card.quest-boss {
  border: 1px solid rgba(231, 76, 60, 0.5);
  animation: bossGlow 2s ease-in-out infinite;
}
.quest-card.quest-boss .quest-title { color: #e74c3c; font-weight: 700; }

/* Raid boss — celestial-themed glow, stronger than regular boss */
.quest-card.quest-raid {
  border: 2px solid rgba(0, 229, 200, 0.6);
  animation: raidGlow 1.8s ease-in-out infinite;
  background: linear-gradient(135deg, rgba(0,229,200,0.05) 0%, rgba(0,0,0,0) 50%, rgba(0,229,200,0.03) 100%);
}
.quest-card.quest-raid .quest-title { color: #00e5c8; font-weight: 800; text-shadow: 0 0 8px rgba(0,229,200,0.4); }

.quest-card.quest-gem-mining {
  border: 1px solid rgba(240, 192, 96, 0.5);
  animation: gemGlow 2.5s ease-in-out infinite;
}
.quest-card.quest-gem-mining .quest-title { color: #f0c060; font-weight: 600; }

@keyframes bossGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(231, 76, 60, 0.2), inset 0 0 4px rgba(231, 76, 60, 0.05); border-color: rgba(231, 76, 60, 0.3); }
  50% { box-shadow: 0 0 12px rgba(231, 76, 60, 0.5), inset 0 0 8px rgba(231, 76, 60, 0.1); border-color: rgba(231, 76, 60, 0.7); }
}

@keyframes raidGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 229, 200, 0.3), inset 0 0 6px rgba(0, 229, 200, 0.05); border-color: rgba(0, 229, 200, 0.4); }
  50% { box-shadow: 0 0 20px rgba(0, 229, 200, 0.6), inset 0 0 12px rgba(0, 229, 200, 0.1); border-color: rgba(0, 229, 200, 0.8); }
}

@keyframes gemGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(240, 192, 96, 0.2), inset 0 0 4px rgba(240, 192, 96, 0.05); border-color: rgba(240, 192, 96, 0.3); }
  50% { box-shadow: 0 0 12px rgba(240, 192, 96, 0.5), inset 0 0 8px rgba(240, 192, 96, 0.1); border-color: rgba(240, 192, 96, 0.7); }
}

.quest-type-tag {
  font-size: 0.6rem; font-weight: 700; padding: 1px 6px;
  border-radius: 3px; text-transform: uppercase; letter-spacing: 0.05em;
  margin-left: 4px;
}
.quest-type-tag.tag-boss {
  background: rgba(231, 76, 60, 0.2); color: #e74c3c;
}
.quest-type-tag.tag-gem-mining {
  background: rgba(240, 192, 96, 0.2); color: #f0c060;
}

/* ── Quest Detail Additions ─────────────────────────────────────────── */

.qd-tier-label {
  font-size: 0.75rem; font-weight: 600; text-align: center; margin-top: 4px;
}

.qd-synergy-bonuses {
  font-size: 0.78rem; color: var(--cyan); padding: 6px 10px;
  background: rgba(78,205,196,0.08); border-radius: var(--radius-sm);
  border: 1px solid rgba(78,205,196,0.15); text-align: center;
}

/* ── Auto-Run Strategy Picker ──────────────────────────────────────── */

.ar-picker {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 14px;
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ar-picker.ar-active {
  border-color: var(--cyan-dim);
  background: rgba(78,205,196,0.06);
}
.ar-label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
.ar-strategies {
  display: flex; gap: 6px;
}
.ar-counts {
  display: flex; gap: 4px; margin-left: auto;
}
.btn-ar-strategy {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); font-size: 0.78rem; padding: 5px 12px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s;
}
.btn-ar-strategy:hover {
  border-color: var(--cyan); color: var(--cyan);
  background: rgba(78,205,196,0.1);
}
.btn-ar-count {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.75rem; padding: 4px 10px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s;
}
.btn-ar-count.selected {
  border-color: var(--cyan); color: var(--cyan);
  background: rgba(78,205,196,0.15);
}
.btn-ar-count:hover {
  border-color: var(--cyan-dim); color: var(--text);
}

/* Active auto-run status */
.ar-status {
  display: flex; align-items: center; gap: 8px; flex: 1;
}
.ar-status-icon { font-size: 1.1rem; }
.ar-status-text {
  font-size: 0.85rem; color: var(--cyan); font-weight: 500;
}
.btn-ar-stop {
  background: rgba(255,82,82,0.15); border-color: var(--red);
  color: var(--red); font-size: 0.78rem; padding: 4px 12px;
}
.btn-ar-stop:hover {
  background: rgba(255,82,82,0.3);
}

/* ── Auto-run indicator on active quest ─────────────────────────────── */

.aq-auto-run {
  font-size: 0.8rem; color: var(--cyan); margin-top: 6px;
  padding: 4px 10px; background: rgba(78,205,196,0.1);
  border-radius: var(--radius-sm); display: inline-block;
}

/* ── Quest History ──────────────────────────────────────────────────── */

/* ── Quest History ──────────────────────────────────────────────────── */
.qh-container { display: flex; flex-direction: column; gap: 12px; }
.qh-title-bar { margin-bottom: 4px; }
.qh-list { display: flex; flex-direction: column; gap: 6px; }

.qh-entry {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  border-left: 3px solid var(--border);
  transition: border-color 0.2s;
}
.qh-entry.success { border-left-color: var(--green); }
.qh-entry.failure { border-left-color: var(--red); }
.qh-entry.expanded { border-color: var(--border-focus, rgba(100,160,255,0.3)); }

.qh-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg-card-alt);
  cursor: pointer; user-select: none;
  transition: background 0.15s;
}
.qh-header:hover { background: rgba(255,255,255,0.04); }

.qh-title { display: flex; align-items: center; gap: 8px; }
.qh-chevron { font-size: 0.75rem; color: var(--text-muted); width: 12px; }
.qh-quest-name { font-weight: 600; font-size: 0.9rem; }
.qh-outcome { font-size: 0.85rem; font-weight: 700; }
.qh-outcome.success { color: var(--green); }
.qh-outcome.failure { color: var(--red); }

.qh-header-right {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.qh-stats { display: flex; gap: 10px; font-size: 0.8rem; font-weight: 600; }
.qh-stat { display: inline; white-space: nowrap; }
.qh-hints { font-size: 0.72rem; color: var(--cyan); white-space: nowrap; }
.qh-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

/* Expanded detail area */
.qh-detail {
  padding: 12px 16px; display: flex; flex-direction: column; gap: 12px;
  border-top: 1px solid var(--border);
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 1000px; }
}

.qh-detail-narrative {
  font-size: 0.82rem; color: var(--text-dim); font-style: italic;
  line-height: 1.5; padding: 8px 12px;
  background: rgba(0,0,0,0.15); border-radius: var(--radius-sm);
}

.qh-detail-grid {
  display: flex; flex-direction: column; gap: 4px;
}
.qh-detail-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text-body);
}
.qh-detail-label {
  font-weight: 600; color: var(--text-muted); min-width: 80px;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.qh-detail-sub { font-size: 0.72rem; color: var(--text-muted); }

.qh-detail-section {
  display: flex; flex-direction: column; gap: 6px;
}
.qh-detail-section-title {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}

/* Party health in history */
.qh-party-member {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; padding: 3px 0;
}
.qh-pm-sigil { font-size: 0.8rem; width: 36px; text-align: center; font-family: monospace; }
.qh-pm-name { width: 80px; font-weight: 500; }
.qh-pm-level { font-size: 0.72rem; color: var(--text-muted); width: 40px; }
.qh-pm-hp { display: flex; align-items: center; gap: 6px; flex: 1; }
.qh-hp-bar {
  flex: 1; height: 6px; background: rgba(255,255,255,0.07);
  border-radius: 3px; overflow: hidden; max-width: 120px;
}
.qh-hp-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.qh-hp-text { font-size: 0.72rem; color: var(--text-dim); min-width: 60px; }
.qh-hp-change { font-size: 0.72rem; font-weight: 600; }

/* Loot, skills, level ups in history detail */
.qh-loot-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.qh-loot-item {
  font-size: 0.8rem; padding: 3px 8px; border-radius: var(--radius-sm);
  background: rgba(46,204,113,0.1);
  border: 1px solid rgba(46,204,113,0.15);
}
.qh-loot-class-req { font-size: 0.68rem; color: var(--text-muted); }
.qh-skills-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qh-skill-item {
  font-size: 0.8rem; padding: 3px 8px; border-radius: var(--radius-sm);
  background: rgba(52,152,219,0.1); color: var(--cyan);
  border: 1px solid rgba(52,152,219,0.15);
}
.qh-levelup-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qh-levelup-item {
  font-size: 0.8rem; padding: 3px 8px; border-radius: var(--radius-sm);
  background: rgba(240,192,96,0.1); border: 1px solid rgba(240,192,96,0.15);
}

.qh-secret-boss {
  font-size: 0.82rem; padding: 8px 12px; border-radius: var(--radius-sm);
  font-weight: 600; line-height: 1.5;
}
.qh-secret-boss.success { background: rgba(240,192,96,0.1); color: var(--gold); border: 1px solid rgba(240,192,96,0.2); }
.qh-secret-boss.failure { background: rgba(231,76,60,0.08); color: var(--red); border: 1px solid rgba(231,76,60,0.15); }

/* ── Party Synergy ──────────────────────────────────────────────────── */

.syn-container { display: flex; flex-direction: column; gap: 16px; }

.syn-stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.syn-stat-box {
  text-align: center; padding: 14px 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.syn-stat-val { font-size: 1.3rem; font-weight: 700; color: var(--cyan); }
.syn-stat-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-top: 4px;
}

.syn-bonus-list { display: flex; flex-direction: column; gap: 8px; }

.syn-bonus {
  padding: 12px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.syn-bonus.unlocked { border-color: var(--green-dim); }
.syn-bonus.locked { opacity: 0.7; }

.syn-bonus-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.syn-bonus-name { font-weight: 600; font-size: 0.9rem; }
.syn-bonus.unlocked .syn-bonus-name { color: var(--green); }
.syn-bonus-req { font-size: 0.78rem; color: var(--text-muted); }
.syn-bonus-desc { font-size: 0.8rem; color: var(--text-dim); }

/* ── Compendium ────────────────────────────────────────────────────────── */
.compendium-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  min-height: 70vh;
  background: var(--bg-base);
  border-radius: var(--radius-lg);
  overflow: visible;
  border: 1px solid var(--border);
}
.comp-sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.comp-sidebar-title {
  padding: 8px 16px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.5px;
}
.comp-nav-divider {
  padding: 12px 16px 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
  pointer-events: none;
}
.comp-nav-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  text-align: left;
  padding: 10px 16px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.comp-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.comp-nav-btn.active {
  background: var(--bg-hover);
  color: var(--cyan);
  border-left-color: var(--cyan);
  font-weight: 600;
}
.comp-body {
  padding: 24px 32px;
  overflow-y: visible;
}
.comp-section { max-width: 800px; }
.comp-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
}
.comp-subtitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--cyan);
  margin: 20px 0 8px;
}
.comp-text {
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: 10px;
  font-size: 0.92rem;
}
.comp-text strong { color: var(--text); }

/* Stats Guide */
.comp-stat-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.comp-stat-row:last-child { border-bottom: none; }
.comp-stat-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
}
.comp-stat-desc {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Class Cards */
.comp-class-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.comp-class-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.comp-class-sigil {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.comp-class-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.comp-class-role {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.comp-class-desc {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 12px;
}
.comp-class-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
  background: var(--bg-card-alt);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.comp-class-stats span { white-space: nowrap; }
.comp-class-stats em {
  color: var(--text-muted);
  font-style: normal;
  font-size: 0.78rem;
}

/* Skills in class cards */
.comp-skill-section { margin-top: 8px; }
.comp-skill-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.comp-skill-row {
  display: grid;
  grid-template-columns: 24px 130px 80px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.83rem;
  align-items: start;
  border-bottom: 1px solid var(--border);
}
.comp-skill-row:last-child { border-bottom: none; }
.comp-skill-row.comp-mastery { opacity: 0.85; }
.comp-skill-icon {
  width: 24px; height: 24px; line-height: 24px;
  text-align: center; font-size: 0.85rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50%;
  filter: brightness(1.4) drop-shadow(0 0 1px rgba(255,255,255,0.3));
}
.comp-skill-name {
  font-weight: 600;
  color: var(--text);
}
.comp-skill-type {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}
.comp-skill-desc {
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* Rarity rows */
.comp-rarity-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.comp-rarity-row:last-child { border-bottom: none; }
.comp-rarity-badge {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 10px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  min-width: 80px;
  text-align: center;
}
.comp-rarity-desc {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Loot drops by rank table */
.comp-loot-table {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.comp-loot-header,
.comp-loot-row {
  display: grid;
  grid-template-columns: 50px 1fr 1fr;
  gap: 8px;
  padding: 6px 12px;
  align-items: center;
  font-size: 0.8rem;
}
.comp-loot-header {
  background: var(--bg-card-alt);
  font-weight: 600;
  color: var(--text);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.comp-loot-row { border-top: 1px solid var(--border); color: var(--text-dim); }
.comp-loot-row:nth-child(even) { background: var(--bg-card-alt); }

/* Step-by-step guide */
.comp-steps {
  display: flex; flex-direction: column; gap: 8px;
  margin: 10px 0 16px;
}
.comp-step {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.comp-step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--cyan);
  color: var(--bg);
  font-weight: 700; font-size: 0.78rem;
}
.comp-step-text {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.comp-step-text strong { color: var(--text); }
.comp-step-text code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.78rem;
  color: var(--cyan);
}

/* ── Combat Log Guide (Compendium) ──────────────────────────── */
/* Chip-legend: flex-wrap row of color swatches + labels */
.clg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 8px 0 18px;
}
.clg-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.clg-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
/* Sample combat sequence — real log entries in context */
.clg-sample {
  background: var(--bg-card, #131625);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0 18px;
}
.clg-sample .combat-log-entry {
  font-size: 0.82rem;
}
/* Design principles box */
.clg-principles {
  background: var(--bg-card, #131625);
  border-radius: 8px;
  padding: 16px;
  margin: 8px 0 18px;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.7;
}
.clg-principles p { margin-bottom: 10px; }
.clg-principles p:last-child { margin-bottom: 0; }
.clg-principles strong { color: var(--text); }
/* Scaling data tables (Difficulty & Scaling compendium page) */
.comp-scale-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 18px;
  font-size: 0.82rem;
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.comp-scale-table thead {
  background: rgba(255,255,255,0.04);
}
.comp-scale-table th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.comp-scale-table td {
  padding: 6px 10px;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.comp-scale-table tbody tr:nth-child(odd) {
  background: rgba(255,255,255,0.015);
}
.comp-scale-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

/* Item proc table */
.comp-item-table {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.comp-item-header,
.comp-item-row {
  display: grid;
  grid-template-columns: 145px 55px 85px 135px 50px 1fr 95px;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  align-items: start;
}
.comp-item-header {
  background: var(--bg-card-alt);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}
.comp-item-row {
  border-top: 1px solid var(--border);
}
.comp-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.comp-item-slot { color: var(--text-muted); text-transform: capitalize; }
.comp-item-class { color: var(--text-dim); font-size: 0.78rem; }
.comp-item-skill { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.comp-item-proc { text-align: center; }
.comp-proc-chance { color: var(--cyan); font-weight: 600; }
.comp-proc-passive { color: var(--text-muted); font-style: italic; font-size: 0.78rem; }
.comp-aoe-badge { display: inline-block; background: var(--orange, #e8a044); color: #000; font-size: 0.65rem; font-weight: 700; padding: 1px 5px; border-radius: 3px; vertical-align: middle; margin-left: 4px; letter-spacing: 0.03em; }
.comp-item-effects { color: var(--text-dim); font-size: 0.8rem; }
.comp-item-duration { color: var(--text-muted); font-size: 0.78rem; }

/* Synergy table */
.comp-synergy-table {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.comp-synergy-header,
.comp-synergy-row {
  display: grid;
  grid-template-columns: 90px 160px 1fr 60px;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.83rem;
  align-items: center;
}
.comp-synergy-header {
  background: var(--bg-card-alt);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}
.comp-synergy-row {
  border-top: 1px solid var(--border);
}
.comp-synergy-row.unlocked {
  background: rgba(78, 205, 196, 0.06);
}
.comp-synergy-quests { color: var(--gold); font-weight: 600; }
.comp-synergy-label { color: var(--text); font-weight: 500; }
.comp-synergy-desc { color: var(--text-dim); font-size: 0.82rem; }
.comp-synergy-status { text-align: center; font-size: 1rem; }
.comp-synergy-row.unlocked .comp-synergy-status { color: var(--green); }

/* Rank rows */
.comp-rank-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.comp-rank-row:last-child { border-bottom: none; }
.comp-rank-row.current {
  background: rgba(78, 205, 196, 0.06);
  border-radius: var(--radius-sm);
}
.comp-rank-desc {
  color: var(--text-dim);
  font-size: 0.88rem;
  flex: 1;
}
.comp-rank-current {
  font-size: 0.82rem;
  color: var(--cyan);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Responsive: Tablet (≤800px) ──────────────────────────────────────── */
@media (max-width: 800px) {
  .char-body { grid-template-columns: 1fr; }
  .char-header { flex-direction: column; align-items: center; text-align: center; }
  .char-bar-label { text-align: center; }
  .active-slots { grid-template-columns: repeat(2, 1fr) !important; }
  .hall-grid { grid-template-columns: 1fr; }
  .hall-wide { grid-column: 1; }
  .game-title { font-size: 0.9rem; }
  .tab-btn { padding: 6px 10px; font-size: 0.8rem; }
  .aq-main-content { grid-template-columns: 1fr; }
  .aq-left-col { border-right: none; border-bottom: 1px solid var(--border); }
  .qd-rewards-grid { grid-template-columns: repeat(2, 1fr); }
  .syn-stats-row { grid-template-columns: repeat(2, 1fr); }
  .quest-tabs { flex-wrap: wrap; }
  .party-layout { grid-template-columns: 1fr; }
  .compendium-layout { grid-template-columns: 1fr; }
  .comp-sidebar { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding: 8px; gap: 4px; }
  .comp-sidebar-title { display: none; }
  .comp-nav-divider { display: none; }
  .comp-nav-btn { padding: 6px 10px; font-size: 0.78rem; border-left: none; border-bottom: 2px solid transparent; }
  .comp-nav-btn.active { border-left-color: transparent; border-bottom-color: var(--cyan); }
  .comp-body { padding: 16px; max-height: none; }
  .comp-skill-row { grid-template-columns: 24px 100px 75px 1fr; }
  .comp-item-header, .comp-item-row { grid-template-columns: 120px 45px 75px 110px 45px 1fr 80px; font-size: 0.78rem; }
}

/* ── Responsive: Phone (≤480px) ───────────────────────────────────────── */
@media (max-width: 480px) {

  /* ── Global spacing ── */
  .tab-content { padding: 10px; }
  .modal-overlay { padding: 8px; }
  .modal-box { padding: 16px; border-radius: var(--radius); }
  .new-game-box, .results-box { gap: 14px; }
  .modal-title { font-size: 1.3rem; }
  .modal-flavor { font-size: 0.8rem; }
  .modal-header-art { font-size: 2rem; }

  /* ── Header ── */
  .game-header { padding: 0 10px; height: 44px; }
  .header-left { gap: 6px; }
  .header-icon { font-size: 1rem; }
  .game-title { font-size: 0.75rem; }
  .header-right { gap: 8px; }
  .gold-display { font-size: 0.85rem; }
  .rank-badge { padding: 2px 7px; font-size: 0.7rem; }
  .btn-sm { padding: 6px 10px; font-size: 0.75rem; }

  /* ── Tab bar: scrollable horizontal strip ── */
  .tab-bar {
    padding: 6px 8px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn {
    padding: 8px 10px;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 36px;
  }

  /* ── Guild Hall ── */
  .hall-grid { grid-template-columns: 1fr; gap: 10px; }
  .hall-wide { grid-column: 1; }

  /* ── Quest Board ── */
  .quest-tabs { flex-wrap: wrap; gap: 4px; }
  .quest-tab-btn { padding: 8px 10px; font-size: 0.78rem; min-height: 36px; }
  .rank-filter { gap: 4px; }
  .rank-filter-btn { padding: 6px 10px; font-size: 0.78rem; min-height: 36px; }
  .qd-rewards-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }

  /* ── Active Quest ── */
  .aq-main-content { grid-template-columns: 1fr; }
  .aq-left-col { border-right: none; border-bottom: 1px solid var(--border); }
  .aq-combat-log { max-height: 250px; min-height: 120px; }
  .aq-combat-log-section { padding: 10px; }
  .combat-log-entry { padding: 4px 6px; font-size: 0.8rem; }

  /* ── Party ── */
  .party-layout { grid-template-columns: 1fr; }
  .active-slots { grid-template-columns: repeat(2, 1fr) !important; }
  .char-body { grid-template-columns: 1fr; }
  .char-header { flex-direction: column; align-items: center; text-align: center; }

  /* ── Shop ── */
  .shop-grid { grid-template-columns: 1fr !important; }

  /* ── Compendium ── */
  .compendium-layout { grid-template-columns: 1fr; min-height: auto; }
  .comp-sidebar {
    flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 6px; gap: 4px;
  }
  .comp-sidebar::-webkit-scrollbar { display: none; }
  .comp-sidebar-title { display: none; }
  .comp-nav-divider { display: none; }
  .comp-nav-btn {
    padding: 8px 10px; font-size: 0.72rem; white-space: nowrap; flex-shrink: 0;
    border-left: none; border-bottom: 2px solid transparent; min-height: 36px;
  }
  .comp-nav-btn.active { border-left-color: transparent; border-bottom-color: var(--cyan); }
  .comp-body { padding: 12px; max-height: none; }
  .comp-title { font-size: 1.1rem; }
  .comp-subtitle { font-size: 0.95rem; }
  .comp-text { font-size: 0.85rem; }

  /* Compendium: Stats */
  .comp-stat-row { grid-template-columns: 1fr; gap: 4px; padding: 8px 0; }
  .comp-stat-name { font-size: 0.85rem; }
  .comp-stat-desc { font-size: 0.82rem; }

  /* Compendium: Class cards */
  .comp-class-card { padding: 12px; }
  .comp-class-sigil { font-size: 1.5rem; width: 40px; height: 40px; }
  .comp-class-name { font-size: 1rem; }
  .comp-class-stats { font-size: 0.75rem; gap: 4px 10px; padding: 6px 8px; }
  .comp-skill-row {
    grid-template-columns: 22px 1fr;
    gap: 2px 6px;
  }
  .comp-skill-name { grid-column: 2; font-size: 0.82rem; }
  .comp-skill-type { grid-column: 2; font-size: 0.72rem; }
  .comp-skill-desc { grid-column: 1 / -1; font-size: 0.78rem; padding-left: 28px; }

  /* Compendium: Equipment table → card layout */
  .comp-item-table { border: none; }
  .comp-item-header { display: none; }
  .comp-item-row {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px; margin-bottom: 6px;
    background: var(--bg-card-alt); border-radius: var(--radius-sm);
    border: 1px solid var(--border); font-size: 0.82rem;
  }
  .comp-item-name { font-size: 0.88rem; }
  .comp-item-slot::before { content: 'Slot: '; color: var(--text-muted); }
  .comp-item-class::before { content: 'Class: '; color: var(--text-muted); }
  .comp-item-proc { text-align: left; }
  .comp-item-proc::before { content: 'Proc: '; color: var(--text-muted); font-style: normal; font-weight: 400; }
  .comp-item-effects::before { content: 'Effects: '; color: var(--text-muted); }
  .comp-item-duration::before { content: 'Duration: '; color: var(--text-muted); }

  /* Compendium: Synergy table → card layout */
  .comp-synergy-table { border: none; }
  .comp-synergy-header { display: none; }
  .comp-synergy-row {
    display: flex; flex-wrap: wrap; gap: 4px 12px;
    padding: 10px; margin-bottom: 6px;
    background: var(--bg-card-alt); border-radius: var(--radius-sm);
    border: 1px solid var(--border); font-size: 0.82rem;
  }
  .comp-synergy-quests { min-width: 80px; }
  .comp-synergy-desc { flex-basis: 100%; }
  .comp-synergy-status { position: absolute; right: 10px; top: 10px; }
  .comp-synergy-row { position: relative; }

  /* Compendium: Rank rows */
  .comp-rank-row { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .comp-rank-desc { font-size: 0.82rem; flex-basis: 100%; }

  /* ── Battle Highlights (results screen) ── */
  .highlight-row { font-size: 0.82rem; }

  /* ── Synergy stats ── */
  .syn-stats-row { grid-template-columns: 1fr; }

  /* ── General touch target fixes ── */
  button, .btn, [role="button"] { min-height: 36px; }
}

/* ── iOS safe area + viewport fixes ───────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .tab-bar { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .game-header { padding-top: env(safe-area-inset-top); }
  .tab-content { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .modal-overlay { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
}

/* iOS Safari: extra scroll padding so last content isn't hidden behind toolbar */
@supports (-webkit-touch-callout: none) {
  .tab-content { padding-bottom: 80px; }
  .comp-body { padding-bottom: 80px; }
  .modal-box { padding-bottom: 24px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   TOWER CLIMB
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Tower Locked ── */
.tower-locked {
  text-align: center;
  padding: 60px 20px;
  max-width: 420px;
  margin: 0 auto;
}
.tower-locked .tower-icon { font-size: 3rem; margin-bottom: 12px; }
.tower-locked h2 { color: var(--gold); margin-bottom: 8px; }
.tower-locked .tower-flavor { color: var(--text-dim); font-size: 0.85rem; line-height: 1.5; margin-bottom: 16px; }
.tower-locked .tower-requirement {
  color: var(--orange);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
  background: rgba(255,165,0,0.08);
  border: 1px solid rgba(255,165,0,0.2);
  border-radius: 8px;
  display: inline-block;
}

/* ── Tower Lobby ── */
.tower-lobby {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 16px;
}
.tower-header { text-align: center; margin-bottom: 24px; }
.tower-icon-large { font-size: 2.5rem; margin-bottom: 8px; }
.tower-header h2 { color: var(--gold); margin-bottom: 6px; }
.tower-header .tower-flavor {
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 400px;
  margin: 0 auto;
}

.tower-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 20px;
}
.tower-stat { text-align: center; }
.tower-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.tower-stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.tower-best-party {
  text-align: center;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255,215,0,0.04);
  border: 1px solid rgba(255,215,0,0.1);
  border-radius: 8px;
}
.tower-party-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.tower-party-member {
  font-size: 0.82rem;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.tower-member-sigil { margin-right: 2px; }

.tower-rewards-info {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.tower-rewards-info h3 {
  color: var(--gold);
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.tower-rewards-info p {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.tower-reward-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tower-reward-list li {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.tower-reward-list li:last-child { border-bottom: none; }
.tower-reward-list li strong { color: var(--text-primary); }

.tower-enter-btn {
  display: block;
  width: 100%;
  font-size: 1rem;
  padding: 14px;
}

/* ── Active Climb ── */
.tower-active {
  max-width: 480px;
  margin: 0 auto;
  padding: 30px 16px;
  text-align: center;
}
.tower-floor-display { margin-bottom: 20px; }
.tower-icon-small { font-size: 1.5rem; margin-bottom: 4px; }
.tower-floor-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}
.tower-floor-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.tower-progress-bar {
  position: relative;
  height: 28px;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.tower-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #ff9800);
  border-radius: 14px;
  transition: width 0.5s ease;
}
.tower-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.tower-combat-status { margin-bottom: 20px; }
.tower-fighting {
  color: var(--orange);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px;
  background: rgba(255,165,0,0.06);
  border: 1px solid rgba(255,165,0,0.15);
  border-radius: 8px;
}
.tower-waiting {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.tower-exit-btn {
  margin-top: 12px;
  opacity: 0.7;
}
.tower-exit-btn:hover { opacity: 1; }

/* ── Rest Room ── */
.tower-rest {
  max-width: 500px;
  margin: 0 auto;
  padding: 24px 16px;
}
.tower-rest-header { text-align: center; margin-bottom: 20px; }
.tower-rest-header h2 { color: var(--gold); margin-bottom: 6px; }
.tower-rest-header .tower-flavor {
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 380px;
  margin: 0 auto;
}

.tower-rest-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.tower-rest-info strong { color: var(--gold); }

.tower-reward-preview {
  padding: 16px;
  background: rgba(255,215,0,0.04);
  border: 1px solid rgba(255,215,0,0.12);
  border-radius: 10px;
  text-align: center;
  margin-bottom: 24px;
}
.tower-reward-preview h3 {
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 10px;
}
.tower-preview-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.tower-preview-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 8px;
}

.tower-rest-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tower-rest-actions .btn { font-size: 0.95rem; padding: 14px; }

/* ── Tower Results Recap ── */
.tower-recap-header {
  text-align: center;
  margin-bottom: 16px;
}
.tower-recap-header .tower-icon-large { font-size: 2rem; }
.tower-recap-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
}
.tower-recap-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.tower-recap-floor {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin: 12px 0;
}
.tower-recap-floor-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}
.tower-recap-record {
  text-align: center;
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 600;
  margin-top: 6px;
}
.tower-recap-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.tower-recap-stat {
  text-align: center;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tower-recap-stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.tower-recap-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ── Compendium Tower Guide ── */
.comp-tower-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 12px;
  margin-bottom: 16px;
  background: rgba(255,215,0,0.04);
  border: 1px solid rgba(255,215,0,0.1);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.comp-tower-items {
  margin: 10px 0 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.comp-tower-item-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.comp-tower-item-row:last-child { border-bottom: none; }
.comp-tower-item-sell { color: var(--gold); font-size: 0.8rem; }

/* ── Compendium Skill Badges ── */
.comp-skill-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.comp-skill-badge.active {
  color: var(--orange);
  background: rgba(255,165,0,0.1);
  border: 1px solid rgba(255,165,0,0.25);
}
.comp-skill-badge.passive {
  color: var(--cyan);
  background: rgba(0,200,220,0.08);
  border: 1px solid rgba(0,200,220,0.2);
}
.comp-skill-badge.reactive {
  color: var(--purple, #a78bfa);
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.25);
}
.comp-skill-lvl {
  font-size: 0.72rem;
  opacity: 0.5;
  font-style: normal;
  margin-left: 4px;
}

/* ── Guild Legacy + Talents ────────────────────────────────────────────── */
.legacy-card { background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255,215,0,0.03) 100%); }
.legacy-overview { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.legacy-bonuses { flex: 1; min-width: 200px; }
.legacy-bonus-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.82rem; color: var(--text-dim); }
.legacy-bonus-val { color: var(--gold); font-weight: 600; }
.legacy-talents-summary { flex: 1; min-width: 180px; }
.talent-points-display { font-size: 1.1rem; margin-bottom: 8px; }
.tp-available { color: var(--gold); font-weight: 700; font-size: 1.3rem; }
.tp-total { color: var(--text-dim); }
.btn-sm { padding: 4px 12px; font-size: 0.75rem; }
.btn-danger { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); cursor: pointer; border-radius: 4px; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.talent-tree { display: flex; flex-wrap: wrap; gap: 12px; }
.talent-class-group { flex: 1 1 280px; min-width: 260px; background: rgba(0,0,0,0.15); border-radius: 8px; padding: 10px; }
.talent-class-header { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.talent-nodes { display: flex; flex-direction: column; gap: 6px; }

.talent-node {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 6px; border: 1px solid var(--border);
  transition: all 0.2s; position: relative;
}
.talent-node.talent-locked { opacity: 0.4; cursor: default; background: rgba(0,0,0,0.1); }
.talent-node.talent-available { cursor: pointer; border-color: var(--gold); background: rgba(255,215,0,0.05); }
.talent-node.talent-available:hover { background: rgba(255,215,0,0.12); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(255,215,0,0.15); }
.talent-node.talent-owned { border-color: var(--gold); background: rgba(255,215,0,0.1); box-shadow: inset 0 0 12px rgba(255,215,0,0.08); }
.talent-node.talent-owned .talent-icon { filter: drop-shadow(0 0 4px rgba(255,215,0,0.4)); }

.talent-icon { font-size: 1.3rem; flex-shrink: 0; width: 28px; text-align: center; }
.talent-info { flex: 1; min-width: 0; }
.talent-name { font-size: 0.82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talent-tier { font-size: 0.68rem; color: var(--text-dim); font-weight: 400; margin-left: 4px; }
.talent-desc { font-size: 0.72rem; color: var(--text-dim); line-height: 1.3; margin-top: 2px; }
.talent-cost { display: flex; gap: 3px; align-items: center; flex-shrink: 0; }
.tp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--gold); }
.talent-owned .tp-dot { background: var(--gold); }
.talent-available .tp-dot { background: rgba(255,215,0,0.3); }
.talent-req { font-size: 0.65rem; color: var(--text-dim); margin-left: 4px; }

/* ── Compendium Legacy Section ─────────────────────────────────────────── */
.comp-legacy-tree { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.comp-legacy-group { flex: 1 1 280px; min-width: 260px; background: rgba(0,0,0,0.15); border-radius: 8px; padding: 10px; }
.comp-legacy-class { font-size: 0.85rem; font-weight: 600; color: var(--gold); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.comp-legacy-talent { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.comp-legacy-talent:last-child { border-bottom: none; }
.comp-legacy-icon { font-size: 1.1rem; flex-shrink: 0; width: 24px; text-align: center; margin-top: 2px; }
.comp-legacy-info { flex: 1; }
.comp-legacy-name { font-size: 0.82rem; font-weight: 600; color: var(--text); display: block; }
.comp-legacy-tier { font-size: 0.68rem; color: var(--text-dim); font-weight: 400; margin-left: 4px; }
.comp-legacy-desc { font-size: 0.72rem; color: var(--text-dim); line-height: 1.3; display: block; margin-top: 2px; }

/* ── Hero Specialization Badges ────────────────────────────────────────── */
.hero-spec-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 600;
  padding: 1px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle;
  background: rgba(99,179,237,0.12); color: #63b3ed; border: 1px solid rgba(99,179,237,0.25);
}
.hero-spec-tag {
  font-size: 0.68rem; font-weight: 600; margin-left: 4px;
  color: #63b3ed;
}
.hero-spec-warn {
  background: rgba(245,158,11,0.15); color: #f59e0b; border-color: rgba(245,158,11,0.3);
  animation: specPulse 1.8s ease-in-out infinite;
}
.hero-spec-tag.hero-spec-warn {
  color: #f59e0b;
  animation: specPulse 1.8s ease-in-out infinite;
}
@keyframes specPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Level-cap "MAX" tag ─────────────────────────────────────────────── */
.lvl-max-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 3px;
  vertical-align: middle;
  color: #1a1108;
  background: linear-gradient(90deg, #f5d76e, #f0c040);
  border: 1px solid rgba(240, 192, 64, 0.6);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 6px rgba(245, 215, 110, 0.35);
}
.progress-fill.lvl-max-bar {
  box-shadow: 0 0 8px rgba(245, 215, 110, 0.5);
}

/* ── Rarity Visual System ─────────────────────────────────────────────── */

/* Rarity border glow for item containers (.shop-item, .equip-slot-card, .equip-picker-item, etc) */
.rarity-common { border-left: 3px solid #9a9aaa; }
.rarity-magic { border-left: 3px solid #3498db; box-shadow: inset 0 0 12px rgba(52,152,219,0.06); }
.rarity-rare { border-left: 3px solid #f0c060; box-shadow: inset 0 0 12px rgba(240,192,96,0.08); }
.rarity-epic { border-left: 3px solid #9b59b6; box-shadow: inset 0 0 16px rgba(155,89,182,0.08); }
.rarity-legendary { border-left: 3px solid #e74c3c; box-shadow: inset 0 0 16px rgba(231,76,60,0.08), 0 0 6px rgba(231,76,60,0.1); }
.rarity-celestial {
  border-left: 3px solid #00e5c8;
  box-shadow: inset 0 0 20px rgba(0,229,200,0.08), 0 0 8px rgba(0,229,200,0.12);
  animation: celestialItemPulse 3s ease-in-out infinite;
}

@keyframes celestialItemPulse {
  0%, 100% { box-shadow: inset 0 0 20px rgba(0,229,200,0.08), 0 0 8px rgba(0,229,200,0.12); }
  50% { box-shadow: inset 0 0 24px rgba(0,229,200,0.14), 0 0 14px rgba(0,229,200,0.2); }
}

/* Loot drop shimmer for results modal items */
.loot-drop-magic { animation: lootDropMagic 0.6s ease-out; }
.loot-drop-rare { animation: lootDropRare 0.8s ease-out; }
.loot-drop-epic { animation: lootDropEpic 0.8s ease-out; }
.loot-drop-legendary { animation: lootDropLegendary 1s ease-out; }
.loot-drop-celestial { animation: lootDropCelestial 1.2s ease-out; }

@keyframes lootDropMagic {
  0% { background: rgba(52,152,219,0.3); transform: scale(1.02); }
  100% { background: transparent; transform: scale(1); }
}
@keyframes lootDropRare {
  0% { background: rgba(240,192,96,0.35); transform: scale(1.03); }
  100% { background: transparent; transform: scale(1); }
}
@keyframes lootDropEpic {
  0% { background: rgba(155,89,182,0.35); transform: scale(1.04); }
  50% { background: rgba(155,89,182,0.1); }
  100% { background: transparent; transform: scale(1); }
}
@keyframes lootDropLegendary {
  0% { background: rgba(231,76,60,0.4); transform: scale(1.05); text-shadow: 0 0 10px rgba(231,76,60,0.5); }
  50% { background: rgba(231,76,60,0.1); }
  100% { background: transparent; transform: scale(1); text-shadow: none; }
}
@keyframes lootDropCelestial {
  0% { background: rgba(0,229,200,0.4); transform: scale(1.06); text-shadow: 0 0 12px rgba(0,229,200,0.7); }
  30% { transform: scale(1.08); }
  60% { background: rgba(0,229,200,0.1); }
  100% { background: transparent; transform: scale(1); text-shadow: none; }
}

/* Equipment slot glow based on equipped item rarity */
.equip-slot-card.equip-rarity-magic { border-color: rgba(52,152,219,0.4); }
.equip-slot-card.equip-rarity-rare { border-color: rgba(240,192,96,0.5); }
.equip-slot-card.equip-rarity-epic { border-color: rgba(155,89,182,0.5); box-shadow: 0 0 6px rgba(155,89,182,0.1); }
.equip-slot-card.equip-rarity-legendary { border-color: rgba(231,76,60,0.5); box-shadow: 0 0 8px rgba(231,76,60,0.12); }
.equip-slot-card.equip-rarity-celestial { border-color: rgba(0,229,200,0.5); box-shadow: 0 0 10px rgba(0,229,200,0.15); animation: celestialItemPulse 3s ease-in-out infinite; }

/* Rarity glow on item names (text glow for high-tier items) */
.item-name-epic { text-shadow: 0 0 8px rgba(155,89,182,0.3); }
.item-name-legendary { text-shadow: 0 0 10px rgba(231,76,60,0.4); }
.item-name-celestial { text-shadow: 0 0 12px rgba(0,229,200,0.5); animation: celestialShimmer 1.8s ease-in-out infinite; }

/* ── Floating Text Numbers ────────────────────────────────────────────── */
.float-text {
  position: fixed;
  z-index: 9998;
  pointer-events: none;
  font-size: 1rem;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  white-space: nowrap;
  transform: translateX(-50%);
  animation: floatUp 1.2s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  60% { opacity: 1; transform: translateX(-50%) translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-50px) scale(0.8); }
}

/* ── Particle System ──────────────────────────────────────────────────── */
.fx-particle {
  position: fixed;
  z-index: 9998;
  pointer-events: none;
  border-radius: 50%;
  animation: particleFly ease-out forwards;
}
@keyframes particleFly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  70% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); }
}

/* ── Screen Flash ─────────────────────────────────────────────────────── */
.fx-screen-flash {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  pointer-events: none;
  animation: fxFlash ease-out forwards;
}
@keyframes fxFlash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Shake ────────────────────────────────────────────────────────────── */
.fx-shake {
  animation: fxShake 0.4s ease-out !important;
}
@keyframes fxShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(calc(-1 * var(--shake-px, 3px))); }
  30% { transform: translateX(var(--shake-px, 3px)); }
  45% { transform: translateX(calc(-0.7 * var(--shake-px, 3px))); }
  60% { transform: translateX(calc(0.5 * var(--shake-px, 3px))); }
  75% { transform: translateX(calc(-0.3 * var(--shake-px, 3px))); }
}

/* ── Tab Transition ───────────────────────────────────────────────────── */
.tab-content.active {
  animation: tabSlideIn 0.25s ease-out;
}
@keyframes tabSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Crit shake handled in main combat log section above */

/* ── UI Polish: Card Hover Effects ────────────────────────────────────── */
.card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: #2a2d48;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* Quest card hover lift */
.quest-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.quest-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Shop item hover glow */
.shop-item {
  transition: all 0.2s ease;
}
.shop-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* Roster row hover highlight */
.roster-row {
  transition: all 0.2s ease;
}
.roster-row:hover {
  transform: translateX(2px);
}

/* Slot card hover pop */
.slot-card {
  transition: all 0.2s ease;
}
.slot-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* ── XP Bar Glow ──────────────────────────────────────────────────────── */
.progress-fill.exp-bar {
  background: linear-gradient(90deg, #4ecdc4, #45b8b0);
  box-shadow: 0 0 6px rgba(78,205,196,0.3);
}
.progress-fill.rank-bar {
  background: linear-gradient(90deg, #9b59b6, #8e44ad);
  box-shadow: 0 0 6px rgba(155,89,182,0.3);
}

/* ── Gold Display Pulse on Change ─────────────────────────────────────── */
.gold-display.gold-changed {
  animation: goldPulse 0.5s ease-out;
}
@keyframes goldPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); color: #ffe066; }
  100% { transform: scale(1); }
}

/* ── Difficulty Dot Colors ────────────────────────────────────────────── */
.difficulty-dot.diff-trivial { background: #7a7a8a; }
.difficulty-dot.diff-easy { background: #2ecc71; }
.difficulty-dot.diff-moderate { background: #3498db; }
.difficulty-dot.diff-hard { background: #f39c12; }
.difficulty-dot.diff-brutal { background: #e74c3c; }
.difficulty-dot.diff-suicide { background: #9b59b6; box-shadow: 0 0 6px rgba(155,89,182,0.5); }

/* ── Rank Badge Improvements ──────────────────────────────────────────── */
.rank-badge {
  transition: all 0.3s ease;
}
.rank-S, .rank-Sp, .rank-Spp {
  font-weight: 800;
}

/* ── Boss Quest Indicator ─────────────────────────────────────────────── */
.quest-card.quest-boss {
  border-left: 3px solid var(--red);
  background: linear-gradient(135deg, rgba(231,76,60,0.04) 0%, transparent 40%);
}
.quest-card.quest-boss:hover {
  border-left-color: var(--red);
  box-shadow: 0 4px 20px rgba(231,76,60,0.15);
}

/* ── Gem Quest Indicator ──────────────────────────────────────────────── */
.quest-card.quest-gem-mining {
  border-left: 3px solid var(--cyan);
  background: linear-gradient(135deg, rgba(78,205,196,0.04) 0%, transparent 40%);
}

/* ── Stat Bonus Colors ────────────────────────────────────────────────── */
.stat-bonus { color: #2ecc71; font-weight: 600; }
.stat-penalty { color: #e74c3c; font-weight: 600; }

/* ── Toast Improvements ───────────────────────────────────────────────── */
#toast {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── Member Card Hover on Active Quest ────────────────────────────────── */
.aq-party-member {
  transition: all 0.2s ease;
}
.aq-party-member:hover:not(.aq-member-dead) {
  border-color: var(--cyan-dim);
  transform: translateY(-1px);
}

/* ── Enemy Card Hover ─────────────────────────────────────────────────── */
.aq-enemy-card {
  transition: all 0.3s ease;
}
.aq-enemy-card:hover:not(.defeated) {
  border-color: rgba(231,76,60,0.5);
  transform: translateY(-1px);
}

/* ── Smooth HP Bar Transitions ────────────────────────────────────────── */
.aq-hp-fill {
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background 0.5s ease;
}

/* ── Empty State Polish ───────────────────────────────────────────────── */
.empty-state {
  opacity: 0.7;
  animation: fadeIn 0.5s ease-out;
}

/* ── Header Gold Icon Spin on Gain ────────────────────────────────────── */
.gold-icon.spinning {
  animation: coinSpin 0.6s ease-out;
}
@keyframes coinSpin {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}

/* ── Recruit Row Stagger Animation ────────────────────────────────────── */
.recruit-grid .recruit-row:nth-child(1) { animation: slideUp 0.3s ease-out 0.0s both; }
.recruit-grid .recruit-row:nth-child(2) { animation: slideUp 0.3s ease-out 0.05s both; }
.recruit-grid .recruit-row:nth-child(3) { animation: slideUp 0.3s ease-out 0.1s both; }
.recruit-grid .recruit-row:nth-child(4) { animation: slideUp 0.3s ease-out 0.15s both; }
.recruit-grid .recruit-row:nth-child(5) { animation: slideUp 0.3s ease-out 0.2s both; }
.recruit-grid .recruit-row:nth-child(6) { animation: slideUp 0.3s ease-out 0.25s both; }
.recruit-grid .recruit-row:nth-child(7) { animation: slideUp 0.3s ease-out 0.3s both; }
.recruit-grid .recruit-row:nth-child(8) { animation: slideUp 0.3s ease-out 0.35s both; }
.recruit-grid .recruit-row:nth-child(9) { animation: slideUp 0.3s ease-out 0.4s both; }
