/* ═══════════════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES
   Change these to retheme the entire game.
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg:         #0d1117;   /* page background — deep night */
  --surface:    #161b22;   /* card / panel background */
  --surface2:   #21262d;   /* slightly lighter surface */
  --accent:     #58a6ff;   /* elf-blue magic — primary interactive colour */
  --accent2:    #7ee787;   /* pale green — Frieren's robe trim, positive events */
  --danger:     #f85149;   /* demon red — boss glow, low HP */
  --text:       #e6edf3;   /* main text */
  --text-muted: #8b949e;   /* secondary text, labels */
  --border:     #30363d;   /* subtle borders */
  --glow:       #79c0ff;   /* magic glow effect */
  --hp-high:    #3fb950;   /* HP bar colour above 60% */
  --hp-mid:     #d29922;   /* HP bar colour 25–60% */
  --hp-low:     #f85149;   /* HP bar colour below 25% */
  --player-hp:  #7c6bff;
  --gold:       #d4a843;
  --item-common:   #8b949e;
  --item-uncommon: #58a6ff;
  --item-rare:     #d4a843;

  /* Rest spot */
  --rest-bg:       #140b04;
  --rest-surface:  #1e1008;
  --rest-surface2: #2a1810;
  --rest-accent:   #e8840a;
  --rest-accent2:  #f5c842;
  --rest-text:     #f5deb3;
  --rest-muted:    #a08060;
  --rest-border:   #3d2010;
}

/* ═══════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════ */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#header-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#header-floor {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   MAIN LAYOUT — single column
   ═══════════════════════════════════════════════════════════ */
#game {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#game.hidden { display: none; }

/* ═══════════════════════════════════════════════════════════
   COMBAT PANEL (left column)
   ═══════════════════════════════════════════════════════════ */
#combat-panel {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.1rem;
  padding-top: 9rem;   /* clears the story notification banner */
  overflow-y: auto;
}

#zone-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent2);
}

#zone-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

/* Enemy Area */
#enemy-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  user-select: none;
}

#enemy-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
  color: var(--text);
  transition: color 0.2s;
}

#enemy-hp-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#hp-bar-container {
  flex: 1;
  background: var(--surface2);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

#hp-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--hp-high);
  border-radius: 99px;
  transition: width 0.15s ease-out, background 0.3s;
}

#hp-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 55px;
  text-align: right;
}

/* ── Focus / Combo Bar (inside Zoltraak button) ────────────────── */
#focus-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.3rem 0 0;
  border-top: 1px solid var(--border);
}

.focus-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 36px;
}

#focus-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#focus-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.1s ease-out;
}

#focus-bar-fill.focus-full {
  background: var(--gold);
  animation: focus-pulse 0.7s ease-in-out infinite;
}

@keyframes focus-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

#focus-stack-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════
   ANALYSIS / BREAK / RECOVERY PHASE UI
   ═══════════════════════════════════════════════════════════ */
#phase-indicator {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0 0;
}

#phase-indicator.phase-break #phase-label {
  color: var(--gold);
  font-weight: 700;
}

#analysis-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0 0;
}

#analysis-container.hidden { display: none; }

.analysis-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 80px;
}

#analysis-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#analysis-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent2);
  border-radius: 99px;
  transition: width 0.15s ease-out;
}

#analysis-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: right;
}

#break-timer {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
  padding: 0.25rem 0 0;
  animation: break-pulse 0.8s ease-in-out infinite;
}

#break-timer.hidden { display: none; }

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

/* Locked state for Zoltraak and Blase Flamme during analysis/recovery */
#click-zone.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
}

#click-zone.is-locked:hover {
  background: var(--surface);
  box-shadow: none;
}

#click-zone.is-locked:active {
  transform: none;
}

#click-zone.is-locked .click-label {
  color: var(--text-muted);
}

#blase-flamme-btn.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
}

#blase-flamme-btn.is-locked:hover {
  background: var(--surface);
  box-shadow: none;
}

/* Click Zone (the big attack button) */
#click-zone {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 1.1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
  color: var(--text);
  width: 100%;
}

#click-zone:hover {
  background: var(--surface2);
  box-shadow: 0 0 18px rgba(88, 166, 255, 0.25);
}

#click-zone:active {
  transform: scale(0.97);
}

.click-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
}

.click-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Boss state — pulsing danger glow */
#click-zone.is-boss {
  border-color: var(--danger);
  animation: boss-pulse 1.8s ease-in-out infinite;
}

#click-zone.is-boss .click-label {
  color: var(--danger);
}

@keyframes boss-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(248, 81, 73, 0.35); }
  50%       { box-shadow: 0 0 26px rgba(248, 81, 73, 0.65); }
}

/* Elite encounter — gold accent */
#enemy-area.is-elite {
  border-color: var(--gold);
  animation: elite-pulse 2.2s ease-in-out infinite;
}
#enemy-area.is-elite #enemy-name { color: var(--gold); }
#enemy-area.is-elite #hp-bar-fill { background: var(--gold) !important; }

@keyframes elite-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(212, 168, 67, 0.30); }
  50%       { box-shadow: 0 0 18px rgba(212, 168, 67, 0.60); }
}

/* ── Blase Flamme (secondary spell button) ───────────────────── */
#blase-flamme-btn {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--accent2, #7ee787);
  border-radius: 10px;
  padding: 0.8rem 1.1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: var(--text);
  width: 100%;
  overflow: hidden;
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
}

#blase-flamme-btn:hover:not(:disabled) {
  background: var(--surface2);
  box-shadow: 0 0 14px rgba(126, 231, 135, 0.2);
}

#blase-flamme-btn:active:not(:disabled) {
  transform: scale(0.97);
}

#blase-flamme-btn:disabled {
  cursor: not-allowed;
  border-color: var(--border);
  opacity: 0.65;
}

#blase-flamme-btn .click-label {
  color: var(--accent2, #7ee787);
}

#blase-flamme-cd-overlay {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 0%;
  background: rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: width 0.25s linear;
}

/* Burst float text */
.float-text--burst {
  color: var(--gold);
  font-size: 1.4rem;
  font-weight: 800;
}

/* Party auto-attack float text (smaller, muted) */
.float-text--party {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.85;
}

/* Player Stats */
#player-stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.stat-label { color: var(--text-muted); }
.stat-value { color: var(--text); font-weight: 500; }

/* Mana Counter */
#mana-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  letter-spacing: -0.01em;
}

.mana-label {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Floor Progress */
#floor-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Upgrade Cards */
.upgrade-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  transition: border-color 0.15s, opacity 0.15s;
  user-select: none;
}

.upgrade-card:not(.upgrade-card--locked) {
  border-color: rgba(88, 166, 255, 0.3);
}

.upgrade-card--locked {
  opacity: 0.5;
}

.upgrade-card[data-id],
.upgrade-card[data-prestige-id] {
  cursor: pointer;
}

.upgrade-card[data-id]:hover,
.upgrade-card[data-prestige-id]:hover {
  background: var(--surface2);
  border-color: rgba(88, 166, 255, 0.5);
}

#rest-page .upgrade-card[data-id]:hover,
#rest-page .upgrade-card[data-prestige-id]:hover {
  background: var(--rest-surface2);
  border-color: rgba(232, 132, 10, 0.6);
}

.upgrade-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.upgrade-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.upgrade-level {
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(88, 166, 255, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
  white-space: nowrap;
}

.upgrade-desc {
  font-size: 0.78rem;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.upgrade-current {
  font-size: 0.72rem;
  color: var(--accent2);
  margin-bottom: 0.15rem;
}

.upgrade-lore {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.upgrade-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upgrade-cost {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   GENERIC BUTTON
   ═══════════════════════════════════════════════════════════ */
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 0.22rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Rest button — sits in the combat panel below the attack button */
.btn-rest {
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-rest:hover {
  background: var(--surface2);
  border-color: var(--text-muted);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   JOURNAL MODAL
   ═══════════════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem;
  min-width: 320px;
  max-width: 90vw;
}

.journal-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

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

.journal-row span:last-child {
  color: var(--text);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   FLOATING DAMAGE NUMBERS
   ═══════════════════════════════════════════════════════════ */
#float-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.float-text {
  position: absolute;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  animation: float-up 1.1s ease-out forwards;
  user-select: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

.float-text--crit {
  color: var(--glow);
  font-size: 1.35rem;
  text-shadow: 0 0 10px var(--glow);
}

.float-text--execute {
  color: var(--danger);
  font-size: 1.2rem;
  text-shadow: 0 0 10px var(--danger);
}

@keyframes float-up {
  0%   { opacity: 1;   transform: translateY(0)     scale(1); }
  20%  { opacity: 1;   transform: translateY(-12px) scale(1.1); }
  100% { opacity: 0;   transform: translateY(-55px) scale(0.9); }
}

/* ═══════════════════════════════════════════════════════════
   NOTIFICATION TOASTS
   ═══════════════════════════════════════════════════════════ */
.notification {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  padding: 0.45rem 1.1rem;
  border-radius: 99px;
  font-size: 0.8rem;
  z-index: 300;
  white-space: nowrap;
  animation: notif-in 0.3s ease, notif-out 0.3s ease 2.1s forwards;
}

@keyframes notif-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes notif-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR STYLING
   ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Player HP Bar ───────────────────────────────────────────── */
#player-area {
  margin: 0;
}

.player-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

#player-hp-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#player-hp-bar-container {
  flex: 1;
  background: var(--surface2);
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#player-hp-bar-fill {
  height: 100%;
  background: var(--player-hp);
  transition: width 0.3s ease, background 0.3s ease;
}

#player-hp-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 55px;
  text-align: right;
}

/* ── Memories Display ────────────────────────────────────────── */
#memories-display {
  background: var(--surface2);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
}

.prestige-preview-text {
  color: var(--accent2);
  font-size: 0.9rem;
  background: var(--surface2);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border-left: 3px solid var(--accent2);
}

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}

.btn-danger {
  padding: 0.6rem 1.2rem;
  background: var(--danger);
  color: white;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  align-self: center;
  transition: opacity 0.2s;
}

.btn-danger:hover { opacity: 0.85; }

/* ── Camp Screen Modal ───────────────────────────────────────── */
.camp-modal {
  align-items: flex-start;
  padding-top: 27rem;
}

.camp-modal-content {
  width: min(600px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.camp-title {
  text-align: center;
  color: var(--gold);
  margin: 0;
  font-size: 1.2rem;
}

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

.item-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.item-card[data-rarity="common"]   { border-left: 3px solid var(--item-common); }
.item-card[data-rarity="uncommon"] { border-left: 3px solid var(--item-uncommon); }
.item-card[data-rarity="rare"]     { border-left: 3px solid var(--item-rare); }

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

.item-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.item-lore {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.item-qty {
  font-size: 0.75rem;
  color: var(--accent2);
  font-weight: 600;
}

.item-use-btn {
  margin-top: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.15s;
  align-self: flex-start;
}

.item-use-btn:hover { background: var(--surface2); }
.item-use-btn:disabled { opacity: 0.4; cursor: default; border-color: var(--border); color: var(--text-muted); }

.fragment-display {
  font-size: 0.82rem;
  color: var(--gold);
  padding: 0.4rem 0;
}

.buff-entry {
  font-size: 0.82rem;
  color: var(--accent2);
  padding: 0.2rem 0;
}

.btn-continue {
  width: 100%;
  padding: 0.8rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 0.5rem;
}

.btn-continue:hover { opacity: 0.85; }

/* ── Story Notification ──────────────────────────────────────── */
.notification--story {
  position: fixed;
  top: 3.2rem;        /* sits just below the header */
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid rgba(210, 160, 60, 0.45);
  border-left: 3px solid rgba(210, 160, 60, 0.85);
  color: var(--text);
  padding: 0.8rem 1.4rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-style: italic;
  max-width: 500px;
  width: 92vw;
  line-height: 1.6;
  z-index: 900;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  animation: story-fadein 0.5s ease, story-fadeout 0.6s ease 9.4s forwards;
}

.notification--story div + div {
  margin-top: 0.35rem;
}

@keyframes story-fadein {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes story-fadeout {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════
   REST SPOT PAGE
   ═══════════════════════════════════════════════════════════ */
#rest-page {
  background: var(--rest-bg);
  color: var(--rest-text);
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#rest-page.hidden { display: none; }

#rest-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.2rem;
  background: var(--rest-surface);
  border-bottom: 1px solid var(--rest-border);
  flex-shrink: 0;
}

#fireplace-art { font-size: 1.5rem; }

#fireplace-quote {
  flex: 1;
  font-size: 0.82rem;
  color: var(--rest-muted);
  font-style: italic;
  line-height: 1.4;
}

#rest-tabs {
  display: flex;
  border-bottom: 1px solid var(--rest-border);
  background: var(--rest-surface);
  flex-shrink: 0;
}

.rest-tab-btn {
  flex: 1;
  padding: 0.65rem 0.4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--rest-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.rest-tab-btn:hover  { color: var(--rest-text); }
.rest-tab-btn.active { color: var(--rest-accent); border-bottom-color: var(--rest-accent); }

#rest-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.7rem;
  min-height: 0;
}

#rest-upgrade-list,
#rest-memories-tab,
#rest-inventory-tab,
#rest-journal-tab {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

#rest-upgrade-list.hidden,
#rest-memories-tab.hidden,
#rest-inventory-tab.hidden,
#rest-journal-tab.hidden { display: none; }

/* Warm card overrides scoped to rest page */
#rest-page .upgrade-card             { background: var(--rest-surface); border-color: var(--rest-border); }
#rest-page .upgrade-card:not(.upgrade-card--locked) { border-color: rgba(232,132,10,0.4); }
#rest-page .upgrade-name             { color: var(--rest-text); }
#rest-page .upgrade-desc             { color: var(--rest-text); }
#rest-page .upgrade-lore             { color: var(--rest-muted); }
#rest-page .upgrade-current          { color: var(--rest-muted); }
#rest-page .upgrade-level            { color: var(--rest-accent); background: rgba(232,132,10,0.12); }
#rest-page .upgrade-cost             { color: var(--rest-accent); }
#rest-page .upgrade-buy-btn          { background: var(--rest-accent); color: #1a0800; }
#rest-page .upgrade-buy-btn:disabled { background: var(--rest-surface2); color: var(--rest-muted); }
#rest-page .prestige-preview-text    { border-left-color: var(--rest-accent2); color: var(--rest-accent2); background: var(--rest-surface2); }
#rest-page .section-label            { color: var(--rest-muted); }
#rest-page .item-card                { background: var(--rest-surface2); border-color: var(--rest-border); }
#rest-page .item-name                { color: var(--rest-text); }
#rest-page .item-desc,
#rest-page .item-lore                { color: var(--rest-muted); }
#rest-page .item-use-btn             { color: var(--rest-accent); border-color: var(--rest-accent); background: var(--rest-surface); }
#rest-page .fragment-display         { color: var(--rest-accent2); }
#rest-page .buff-entry               { color: var(--rest-accent2); }
#rest-page .journal-row              { border-bottom-color: var(--rest-border); color: var(--rest-muted); }
#rest-page .journal-row span:last-child { color: var(--rest-text); }

/* ═══════════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════════ */
#settings-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
  color: var(--text);
}

#settings-page.hidden { display: none; }

#settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#settings-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

#settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.settings-action-btn {
  padding: 0.55rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.settings-action-btn:hover { background: var(--surface2); border-color: var(--text-muted); }

.settings-action-btn--danger { border-color: var(--danger); color: var(--danger); }
.settings-action-btn--danger:hover { background: rgba(248, 81, 73, 0.1); }

.settings-debug-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.debug-btn {
  padding: 0.5rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.debug-btn:hover { background: rgba(88, 166, 255, 0.12); border-color: var(--accent); }

.debug-btn--danger { color: var(--danger); }
.debug-btn--danger:hover { background: rgba(248, 81, 73, 0.1); border-color: var(--danger); }

.debug-floor-row {
  display: flex;
  gap: 0.4rem;
  grid-column: span 2;
}

.debug-input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.8rem;
}

.debug-input::placeholder { color: var(--text-muted); }

/* Toggle switches */
.debug-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.debug-toggle input[type="checkbox"] { display: none; }

.debug-toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.debug-toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.debug-toggle input:checked + .debug-toggle-slider {
  background: var(--accent);
}

.debug-toggle input:checked + .debug-toggle-slider::after {
  transform: translateX(16px);
  background: #fff;
}

.debug-toggle-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

/* Rest stats bar */
#rest-stats-bar {
  display: flex;
  gap: 1.5rem;
  padding: 0.45rem 1.2rem;
  background: var(--rest-surface);
  border-bottom: 1px solid var(--rest-border);
  font-size: 0.8rem;
  color: var(--rest-muted);
  flex-shrink: 0;
}

#rest-stats-bar span { font-weight: 600; color: var(--rest-text); }

/* ═══════════════════════════════════════════════════════════
   BOSS FIGHT UI
   ═══════════════════════════════════════════════════════════ */
#boss-fight-ui { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
#boss-fight-ui.hidden { display: none; }

#boss-attack-name {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--danger);
  text-align: center;
}

#boss-telegraph-track {
  position: relative;
  height: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, height 0.15s;
}

#boss-telegraph-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--danger);
  border-radius: 6px;
}

#boss-telegraph-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.75);
  pointer-events: none;
  user-select: none;
}

@keyframes boss-telegraph-fill {
  from { width: 0%; }
  to   { width: 100%; }
}

/* Parry window — track becomes the click target */
#boss-telegraph-track.parry-ready {
  cursor: pointer;
  border-color: var(--gold);
  animation: parry-track-glow 0.35s ease-in-out infinite alternate;
}

@keyframes parry-track-glow {
  from { box-shadow: 0 0 8px rgba(212, 168, 67, 0.45); }
  to   { box-shadow: 0 0 22px rgba(212, 168, 67, 0.85); }
}

#boss-attack-window-label {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.05em;
  padding: 0.3rem 0;
}

#boss-attack-window-label.hidden { display: none; }

/* Parry success/fail flashes on #enemy-area */
#enemy-area.parry-success {
  animation: parry-success-flash 0.6s ease-out !important;
}

#enemy-area.parry-fail {
  animation: parry-fail-flash 0.6s ease-out !important;
}

@keyframes parry-success-flash {
  0%   { border-color: var(--border); box-shadow: none; }
  40%  { border-color: var(--accent2); box-shadow: 0 0 20px rgba(126, 231, 135, 0.60); }
  100% { border-color: var(--border); box-shadow: none; }
}

@keyframes parry-fail-flash {
  0%   { border-color: var(--border); box-shadow: none; }
  40%  { border-color: var(--danger); box-shadow: 0 0 20px rgba(248, 81, 73, 0.60); }
  100% { border-color: var(--border); box-shadow: none; }
}

/* ── Spiegel: Projectile Orbs ──────────────────────────────────────────────── */

.projectile-orb {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c8d8ff, #4466ff 55%, #1a0066);
  box-shadow: 0 0 14px 5px rgba(80, 120, 255, 0.65);
  cursor: pointer;
  animation: orb-fly linear forwards;
  z-index: 10;
  transform: translateY(-50%);  /* centre on the top% value */
  user-select: none;
}

.projectile-orb:hover {
  box-shadow: 0 0 20px 8px rgba(120, 160, 255, 0.9);
  transform: translateY(-50%) scale(1.18);
}

@keyframes orb-fly {
  from { left: -50px; }
  to   { left: calc(100% + 12px); }
}

/* Boss countdown overlay */
#boss-countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  z-index: 20;
  pointer-events: none;
}
#boss-countdown-overlay.hidden { display: none; }

#boss-countdown-number {
  font-size: 4rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 24px rgba(200, 160, 255, 0.9), 0 2px 8px rgba(0,0,0,0.8);
  line-height: 1;
}
#boss-countdown-number.countdown-animate {
  animation: countdown-pop 0.75s ease-out forwards;
}
@keyframes countdown-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  25%  { transform: scale(1.25); opacity: 1; }
  60%  { transform: scale(1.0);  opacity: 1; }
  100% { transform: scale(0.85); opacity: 0; }
}

/* Alpha disclaimer */
#alpha-disclaimer {
  position: fixed;
  bottom: 0.5rem;
  left: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  z-index: 999;
}

/* ── Tutorial Page ─────────────────────────────────────────────────────────── */
#tutorial-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
  color: var(--text);
}
#tutorial-page.hidden { display: none; }

#tutorial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#tutorial-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

#tutorial-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.tutorial-tab-btn {
  flex: 1;
  padding: 0.65rem 0.4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tutorial-tab-btn:hover  { color: var(--text); }
.tutorial-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

#tutorial-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  min-height: 0;
}

.tutorial-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.tutorial-section.hidden { display: none; }

.tutorial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.tutorial-card h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
}
.tutorial-card p,
.tutorial-card li {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
.tutorial-card ul {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.tutorial-card strong { color: var(--text); }
