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

/* ---- Theme variables (mirrors ShiroNexus portal) ---- */
[data-theme="dark"] {
  --bg:          #07060f;
  --surface:     #0f0e1a;
  --surface-hov: #16152a;
  --inset:       rgba(167,139,250,0.04);
  --border:      rgba(139,92,246,0.12);
  --border-hov:  rgba(139,92,246,0.28);
  --text:        #eeeef5;
  --muted:       #6e6a94;
  --accent:      #a78bfa;
  --shadow:      rgba(0, 0, 0, 0.6);
  --panel-glow:  rgba(139,92,246,0.06);
}

[data-theme="light"] {
  --bg:          #f0ece8;
  --surface:     #ffffff;
  --surface-hov: #f7f5ff;
  --inset:       rgba(0, 0, 0, 0.03);
  --border:      rgba(0, 0, 0, 0.08);
  --border-hov:  rgba(0, 0, 0, 0.18);
  --text:        #1b1020;
  --muted:       #706080;
  --accent:      #7c3aed;
  --shadow:      rgba(0, 0, 0, 0.12);
}

:root {
  --mana:   #38bdf8;
  --gold:   #f59e0b;
  --insight:#34d399;
  --essence:#c084fc;
  --green:  #22c55e;
  --cores:  #f43f5e;
  --header-h: 54px;
  --nav-h:  40px;
}

/* ---- Base ---- */
html { font-family: 'Cabin', -apple-system, sans-serif; font-size: 15px; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(88,28,220,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,0.07) 0%, transparent 55%);
}

/* ---- Header ---- */
.header {
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  background: rgba(10,9,20,0.92);
  border-bottom: 1px solid rgba(139,92,246,0.18);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 24px rgba(88,28,220,0.12);
}

.header-left  { display: flex; align-items: center; gap: 0.875rem; }
.header-right { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }

.back-btn {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.back-btn:hover { color: var(--text); border-color: var(--border-hov); }

.game-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
#sigil {
  -webkit-text-fill-color: initial;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}

.hbadge {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.22rem 0.75rem;
  border-radius: 12px;
  white-space: nowrap;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  transition: transform 0.15s, box-shadow 0.15s;
}
.hbadge:hover { transform: translateY(-1px); }
.hbadge-main { display: inline-flex; gap: 0.1rem; }
.hrate { font-size: 0.64em; font-weight: 600; opacity: 0.7; }
.mana-badge    { color: var(--mana);    background: rgba(56,189,248,0.08);  border: 1px solid rgba(56,189,248,0.22);  box-shadow: 0 0 12px rgba(56,189,248,0.08); }
.gold-badge    { color: var(--gold);    background: rgba(245,158,11,0.08);  border: 1px solid rgba(245,158,11,0.22);  box-shadow: 0 0 12px rgba(245,158,11,0.08); }
.insight-badge { color: var(--insight); background: rgba(52,211,153,0.08);  border: 1px solid rgba(52,211,153,0.22);  box-shadow: 0 0 12px rgba(52,211,153,0.08); }
.essence-badge { color: var(--essence); background: rgba(192,132,252,0.08); border: 1px solid rgba(192,132,252,0.22); box-shadow: 0 0 12px rgba(192,132,252,0.10); }
.cores-badge   { color: var(--cores);   background: rgba(244,63,94,0.08);   border: 1px solid rgba(244,63,94,0.22);   box-shadow: 0 0 12px rgba(244,63,94,0.08); }
.essence-badges { display: inline-flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }

/* ── Essence combined badge (mobile only — replaces 4 element badges) ── */
.essence-combined-badge {
  display: none;
  cursor: pointer;
  font-family: inherit;
  border: none;
  color: var(--essence);
  background: rgba(192,132,252,0.08);
  border: 1px solid rgba(192,132,252,0.22);
  box-shadow: 0 0 12px rgba(192,132,252,0.10);
}
.essence-popover {
  position: fixed;
  z-index: 300;
  background: var(--surface);
  border: 1px solid rgba(192,132,252,0.35);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  display: none;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 148px;
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 0.75rem;
}
.essence-popover.open { display: flex; }
.ess-pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.ess-pop-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.ess-pop-rate { font-size: 0.62em; opacity: 0.7; }

.theme-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--border-hov); transform: rotate(18deg); }

/* ── Dev button ── */
.dev-header-btn {
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.dev-header-btn:hover { border-color: var(--border-hov); color: var(--text); }

/* ── Dev modal ── */
.dev-modal-box {
  background: var(--surface);
  border: 1px solid var(--border-hov);
  border-radius: 14px;
  max-width: 780px;
  width: 96%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dev-modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--inset);
  flex-shrink: 0;
}
.dev-modal-title { font-weight: 700; font-size: 1rem; letter-spacing: 0.01em; }
.dev-modal-close {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.45rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.dev-modal-close:hover { color: var(--text); border-color: var(--border-hov); }
.dev-body { overflow-y: auto; flex: 1; min-height: 0; }
.dev-grid { padding: 0.75rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; align-items: start; }
.dev-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  align-self: start;
}
.dev-section.dev-span { grid-column: span 2; }
.dev-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.5rem 0.85rem 0.45rem;
  background: var(--inset);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.dev-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.5rem 0.85rem;
  transition: background 0.12s;
}
.dev-row + .dev-row { border-top: 1px solid var(--border); }
.dev-row:hover { background: var(--surface-hov); }
.dev-row-info { flex: 1; min-width: 0; }
.dev-row-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.dev-row-desc { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.dev-action-btn {
  padding: 4px 14px;
  border-radius: 7px;
  border: 1px solid var(--border-hov);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.dev-action-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(139,92,246,0.08); }
.dev-action-btn.dev-on { border-color: #f59e0b; background: rgba(245,158,11,0.12); color: #f59e0b; }
.dev-action-btn.dev-danger { border-color: rgba(239,68,68,0.4); color: #f87171; }
.dev-action-btn.dev-danger:hover { border-color: #ef4444; background: rgba(239,68,68,0.1); color: #fca5a5; }
.dev-btn-group {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--border-hov);
  border-radius: 7px;
  overflow: hidden;
}
.dev-btn-group .dev-action-btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border-hov);
  padding: 4px 11px;
}
.dev-btn-group .dev-action-btn:last-child { border-right: none; }
.dev-btn-group .dev-action-btn:hover { background: rgba(139,92,246,0.1); color: var(--accent); }
.dev-btn-group .dev-action-btn.dev-on { background: rgba(245,158,11,0.12); color: #f59e0b; border-color: transparent; }
.dev-omen-search {
  margin: 0.5rem 1rem 0;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  outline: none;
}
.dev-omen-search:focus { border-color: var(--border-hov); }
.dev-omen-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-height: 0;
  padding: 0.5rem 1rem 0.75rem;
}
.dev-omen-entry {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.5rem;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.dev-omen-entry-ico { font-size: 1rem; flex-shrink: 0; }
.dev-omen-entry-info { flex: 1; min-width: 0; }
.dev-omen-entry-name { font-weight: 700; font-size: 0.78rem; color: var(--text); }
.dev-omen-entry-desc { font-size: 0.68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-omen-fire-btn {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(139,92,246,0.12);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--accent);
  font-family: inherit;
  transition: background 0.15s;
}
.dev-omen-fire-btn:hover { background: rgba(139,92,246,0.22); }

/* ---- Layout ---- */
/* ---- Screen nav ---- */
.screen-nav {
  display: flex;
  gap: 0;
  flex: 0 0 40px !important;
  min-height: 0 !important;
  height: 40px !important;
  max-height: 40px !important;
  overflow: hidden !important;
  background: rgba(10,9,20,0.88);
  border-bottom: 1px solid rgba(139,92,246,0.14);
  padding: 0 0.75rem;
  align-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.nav-icon { font-size: 1rem; line-height: 1; }

.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 1rem;
  height: 100%;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.18s, border-color 0.18s, text-shadow 0.18s;
  position: relative;
  flex-shrink: 0;
  white-space: nowrap;
}

.nav-btn:hover { color: var(--text); }

.nav-btn--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 14px rgba(167,139,250,0.55);
}

/* ════════ GRIMOIRE SUBNAV (mobile panel switcher) ════════ */
.grimoire-subnav {
  display: none;
  height: 36px;
  align-items: center;
  background: rgba(10,9,20,0.82);
  border-bottom: 1px solid rgba(139,92,246,0.10);
  padding: 0 0.75rem;
  gap: 0;
  flex-shrink: 0;
}
.gsub-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0 0.9rem;
  height: 100%;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.gsub-btn:hover { color: var(--text); }
.gsub-btn--active { color: var(--accent); border-bottom-color: var(--accent); }
/* Grimoire subnav spans all grid columns (display:contents makes it a game-layout grid item) */
#grimoire-subnav { grid-column: 1 / -1; order: -2; }
/* Frontier subnav spans all frontier-screen columns */
#frontier-subnav { grid-column: 1 / -1; }

/* ---- Screens ---- */
/* Grimoire uses display:contents so its panels participate in the parent grid */
.screen { display: none; }
.screen[data-screen="grimoire"].screen--active { display: contents; }
/* Non-grimoire screens span the full grid row */
.frontier-screen.screen--active {
  display: grid;
  grid-column: 1 / -1;
  min-height: 0;
  overflow: hidden;
}
.inventory-screen.screen--active {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  min-height: 0;
  overflow: hidden;
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
  align-self: stretch;
  padding: 0.875rem;
}

/* ---- Layout ---- */
.game-layout {
  display: grid;
  grid-template-columns: 270px 1fr 320px;
  grid-template-rows: minmax(0, 1fr);
  gap: 0.875rem;
  padding: 0.875rem;
  height: calc(100dvh - var(--header-h) - var(--nav-h));
  min-height: 0;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════
   FRONTIER SCREEN
═══════════════════════════════════════════════════════════════════ */

.frontier-screen {
  grid-template-columns: 1fr 260px 220px;
  gap: 0.875rem;
  padding: 0.875rem;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  overflow: hidden;
  align-self: stretch;
}

.frontier-wrap {
  background: linear-gradient(160deg, var(--surface) 0%, rgba(12,10,24,0.95) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  overflow-y: auto;
  min-height: 0;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(167,139,250,0.06);
}

.frontier-log-wrap {
  background: linear-gradient(160deg, var(--surface) 0%, rgba(12,10,24,0.95) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(167,139,250,0.06);
}

.frontier-log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.73rem;
}

/* Dungeon list */
.frontier-page-hdr {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0 0.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.875rem;
}
.frontier-page-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.dungeon-list { display: flex; flex-direction: column; gap: 0.75rem; }

.dungeon-card {
  background: rgba(167,139,250,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.dungeon-card:hover {
  border-color: var(--border-hov);
  background: rgba(167,139,250,0.07);
  box-shadow: 0 2px 16px rgba(139,92,246,0.12);
}

.dungeon-card--locked { opacity: 0.45; pointer-events: none; }

.dungeon-card-hdr {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dungeon-icon { font-size: 1.6rem; flex-shrink: 0; }

.dungeon-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dungeon-name { font-weight: 700; font-size: 0.95rem; }

.dungeon-meta { font-size: 0.75rem; color: var(--muted); }

.dungeon-first-clear { color: #4ade80; }

.dungeon-relic-hint { font-size: 0.72rem; color: var(--accent); }

.dungeon-locked-hint { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }

.enter-btn {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 1.1rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
}

.enter-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124,58,237,0.5);
}

/* Abyss portal (Frontier — Descend button area) */
.abyss-portal {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem 1.1rem;
  background: rgba(20, 0, 0, 0.55);
  border: 1px solid rgba(180, 30, 50, 0.50);
  border-radius: 10px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6) inset, 0 0 14px rgba(140, 10, 30, 0.40);
}

.abyss-portal-text {
  font-size: 0.78rem;
  color: #c07080;
  text-align: center;
  font-style: italic;
}

.descend-btn {
  background: linear-gradient(135deg, #2a0010, #550015);
  color: #f87171;
  border: 1px solid rgba(200, 40, 60, 0.65);
  border-radius: 8px;
  padding: 0.55rem 1.4rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
  box-shadow: 0 2px 18px rgba(160, 0, 30, 0.50);
}

.descend-btn:hover {
  background: linear-gradient(135deg, #3d0018, #720020);
  border-color: rgba(240, 60, 80, 0.85);
  color: #fca5a5;
  box-shadow: 0 4px 24px rgba(200, 0, 40, 0.70);
}

.abyss-action-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.surface-btn {
  background: linear-gradient(135deg, #001a2e, #002a44);
  color: #7dd3fc;
  border: 1px solid rgba(56, 140, 200, 0.5);
  border-radius: 8px;
  padding: 0.55rem 1.4rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
  box-shadow: 0 2px 14px rgba(0, 80, 140, 0.4);
}

.surface-btn:hover {
  background: linear-gradient(135deg, #002a44, #003a60);
  border-color: rgba(90, 180, 255, 0.7);
  color: #bae6fd;
  box-shadow: 0 4px 20px rgba(0, 120, 200, 0.55);
}

/* Abyss placeholder (inside Frontier content when currentDepth > 0) */
.abyss-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2.5rem 1.25rem;
  text-align: center;
}

.abyss-placeholder-icon { font-size: 3rem; opacity: 0.7; }

.abyss-placeholder-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f87171;
}

.abyss-placeholder-desc {
  font-size: 0.8rem;
  color: #c07080;
}

.abyss-placeholder-hint {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  max-width: 280px;
}

/* Abyss depth HUD — small label at top of combat panel when in Abyss */
.abyss-depth-hud {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem;
  margin-bottom: 0.875rem;
  background: rgba(160,0,30,0.22);
  border: 1px solid rgba(220,40,60,0.40);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ff8090;
  letter-spacing: 0.04em;
}
.abyss-depth-hud-icon { opacity: 0.85; }

/* ══════════════════════════════════════════════════════
   Abyss global theme — body.abyss-active
   Override CSS variables so everything using them shifts
   automatically; target hardcoded colors individually.
   ══════════════════════════════════════════════════════ */

html[data-theme="dark"] body.abyss-active {
  --bg:          #0c0204;
  --surface:     #140307;
  --surface-hov: #1e040b;
  --inset:       rgba(220,30,50,0.05);
  --border:      rgba(200,30,50,0.28);
  --border-hov:  rgba(240,50,70,0.55);
  --accent:      #f87171;
  --muted:       #8a5060;
  --panel-glow:  rgba(200,30,50,0.09);
}

html[data-theme="light"] body.abyss-active {
  --bg:          #f5e8e8;
  --surface:     #fff0f0;
  --surface-hov: #ffe0e0;
  --inset:       rgba(180,0,20,0.04);
  --border:      rgba(180,0,20,0.18);
  --border-hov:  rgba(200,20,40,0.35);
  --accent:      #dc2626;
  --muted:       #9a6060;
  --panel-glow:  rgba(200,30,50,0.06);
}

/* Page background gradient */
body.abyss-active {
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 0%,  rgba(180,10,20,0.20) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(120,0,10,0.14) 0%, transparent 55%);
}

/* Header — hardcoded bg + purple border/shadow */
body.abyss-active .header {
  background: rgba(14,2,4,0.95);
  border-bottom-color: rgba(200,30,50,0.35);
  box-shadow: 0 1px 24px rgba(160,0,20,0.22);
}

/* Nav bar */
body.abyss-active .screen-nav {
  background: rgba(14,2,4,0.94);
  border-bottom-color: rgba(200,30,50,0.30);
}

body.abyss-active .nav-btn--active {
  color: #f87171;
  border-bottom-color: #dc2626;
  text-shadow: 0 0 14px rgba(220,30,50,0.65);
}

body.abyss-active .nav-btn:hover { color: #fca5a5; }

/* Grimoire subnav */
body.abyss-active .grimoire-subnav {
  background: rgba(14,2,4,0.90);
  border-bottom-color: rgba(200,30,50,0.22);
}

/* Panels */
body.abyss-active .panel {
  background: linear-gradient(160deg, #140307 0%, #1a040a 100%);
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), inset 0 1px 0 rgba(220,30,60,0.10);
}

/* Scrollbar */
body.abyss-active ::-webkit-scrollbar-thumb {
  background: rgba(180,20,30,0.55);
}
body.abyss-active ::-webkit-scrollbar-thumb:hover {
  background: rgba(220,30,50,0.75);
}

/* Frontier panels (kept scoped for specificity) */
.abyss-active .frontier-wrap {
  background: linear-gradient(160deg, #0f0205 0%, #160306 100%);
  border-color: rgba(200,30,50,0.35);
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), inset 0 1px 0 rgba(220,30,60,0.10);
}

.abyss-active .frontier-log-wrap {
  background: linear-gradient(160deg, #0f0205 0%, #160306 100%);
  border-color: rgba(200,30,50,0.35);
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), inset 0 1px 0 rgba(220,30,60,0.10);
}

.abyss-active .hp-bar-fill        { background: #dc2626; }
.abyss-active .hp-bar-fill--low   { background: #b91c1c; }
.abyss-active .hp-bar-fill--crit  { background: #991b1b; }

.abyss-active .enemy-wrap {
  background: rgba(180,20,40,0.14);
  border-color: rgba(220,40,60,0.32);
}

[data-theme="dark"] .abyss-active .enemy-wrap {
  background: rgba(180,20,40,0.18);
  border-color: rgba(220,40,60,0.38);
}

/* ── Elite modifier chips (Abyss enemies) ── */
.elite-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.2rem;
}
.elite-chip {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: rgba(130,10,20,0.70);
  border: 1px solid rgba(230,40,65,0.65);
  color: #ff8090;
  white-space: nowrap;
}
.elite-chip--shielded  { color: #93c5fd; background: rgba(10,30,80,0.65);  border-color: rgba(50,100,220,0.55); }
.elite-chip--frenzied  { color: #fca5a5; background: rgba(120,10,10,0.70); border-color: rgba(230,40,40,0.65); }
.elite-chip--hexed     { color: #c4b5fd; background: rgba(60,10,100,0.65); border-color: rgba(140,60,220,0.55); }
.elite-chip--voidborn  { color: #ff8090; background: rgba(130,10,20,0.70); border-color: rgba(230,40,65,0.65); }

.elite-tag {
  background: rgba(180,15,35,0.80);
  border: 1px solid rgba(240,50,75,0.70);
  color: #fca5a5;
}

/* ── Abyss depth navigation ── */
.abyss-depth-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.6rem;
  background: rgba(10,0,0,0.35);
  border: 1px solid rgba(200,30,50,0.40);
  border-radius: 8px;
}
.abyss-nav-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ff8090;
  text-align: center;
  flex: 1;
}
.abyss-nav-btn {
  background: rgba(140,20,30,0.35);
  border: 1px solid rgba(210,40,60,0.50);
  border-radius: 6px;
  color: #fca5a5;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.abyss-nav-btn:hover { background: rgba(180,25,40,0.55); border-color: rgba(240,60,80,0.75); }
.abyss-nav-btn--locked { opacity: 0.5; cursor: not-allowed; }
.abyss-nav-btn--locked:hover { background: rgba(140,20,30,0.35); border-color: rgba(210,40,60,0.50); }

.abyss-boss-hint {
  font-size: 0.72rem;
  color: #f87171;
  background: rgba(200,30,30,0.12);
  border: 1px solid rgba(200,30,30,0.3);
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  margin-top: 0.35rem;
  text-align: center;
}
.abyss-boss-hint--slain {
  color: #4ade80;
  background: rgba(30,180,30,0.10);
  border-color: rgba(30,180,30,0.25);
}

/* ── Abyssal Essence HUD badge (in depth HUD) ── */
.abyss-ae-hud {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: #c084fc;
  background: rgba(120,30,180,0.18);
  border: 1px solid rgba(160,60,240,0.30);
  border-radius: 5px;
  padding: 0.12rem 0.5rem;
  letter-spacing: 0.03em;
}

/* Abyssal Essence gain log highlight */
.ae-gain { color: #c084fc; font-weight: 700; }

/* ── Abyssal Upgrades panel ── */
.abyss-upgrades-panel {
  margin-top: 1rem;
  border: 1px solid rgba(120,30,180,0.30);
  border-radius: 10px;
  background: rgba(20,5,40,0.55);
  overflow: hidden;
}
.abyss-upgrades-hdr {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #c084fc;
  background: rgba(80,15,130,0.35);
  border-bottom: 1px solid rgba(120,30,180,0.28);
  letter-spacing: 0.04em;
}
.abyss-upgrades-ae {
  font-weight: 400;
  font-size: 0.75rem;
  color: #a78bfa;
  margin-left: 0.4rem;
}
.abyss-upgrade-node {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(80,30,120,0.20);
  transition: background 0.12s;
}
.abyss-upgrade-node:last-child { border-bottom: none; }
.abyss-upgrade-node--owned   { opacity: 0.6; }
.abyss-upgrade-node--locked  { opacity: 0.45; }
.abyss-upgrade-node--avail:hover { background: rgba(100,40,160,0.14); }
.au-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 0.1rem; }
.au-body { flex: 1; min-width: 0; }
.au-name { font-size: 0.82rem; font-weight: 700; color: #e2d9f3; }
.au-desc { font-size: 0.74rem; color: #a78bfa; margin-top: 0.1rem; }
.au-cost {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #c084fc;
  background: rgba(120,30,180,0.18);
  border: 1px solid rgba(160,60,240,0.28);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}
.au-cost--short { color: #f87171; border-color: rgba(248,113,113,0.45); background: rgba(120,10,10,0.18); }
.au-req { font-size: 0.7rem; color: var(--muted); margin-top: 0.15rem; font-style: italic; }

/* ── Boss fight UI ── */
.abyss-boss-label {
  color: #f87171;
  font-weight: 700;
  letter-spacing: 0.06em;
  animation: boss-pulse 1.4s ease-in-out infinite;
}

@keyframes boss-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.boss-fight-wrap {
  background: rgba(80,10,10,0.22);
  border: 1px solid rgba(220,40,60,0.35);
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 0 20px rgba(200,20,40,0.12) inset;
}

.boss-name-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.boss-banner-icon { font-size: 1.8rem; flex-shrink: 0; }
.boss-banner-info { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.boss-banner-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fca5a5;
  letter-spacing: -0.01em;
}
.boss-phase-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c084fc;
  background: rgba(140,50,220,0.2);
  border: 1px solid rgba(140,50,220,0.45);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  margin-top: 0.1rem;
  width: fit-content;
}
.boss-enrage-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fbbf24;
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.4);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  margin-top: 0.1rem;
  width: fit-content;
  animation: boss-pulse 0.9s ease-in-out infinite;
}
.boss-immune-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #93c5fd;
  background: rgba(10,40,100,0.5);
  border: 1px solid rgba(50,100,220,0.6);
  border-radius: 5px;
  padding: 0.15rem 0.55rem;
  flex-shrink: 0;
  animation: boss-pulse 0.8s ease-in-out infinite;
}

.boss-hp-track {
  height: 14px;
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(220,40,60,0.4);
}
.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #b91c1c, #ef4444);
  border-radius: 8px;
  transition: width 0.12s linear;
}
.boss-hp-fill--immune {
  background: linear-gradient(90deg, #1e3a8a, #3b82f6);
}

/* Bleed indicator */
.bleed-indicator {
  font-size: 0.65em;
  font-weight: 700;
  color: #f87171;
  background: rgba(200,20,20,0.18);
  border: 1px solid rgba(200,20,20,0.4);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
  animation: boss-pulse 1s ease-in-out infinite;
}

/* Adds section (Void Tendrils / Void Cores) */
.abyss-adds-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(80,40,120,0.35);
}
.abyss-adds-hdr {
  font-size: 0.68rem;
  font-weight: 700;
  color: #f87171;
  letter-spacing: 0.04em;
}
.abyss-add-card {
  background: rgba(60,10,60,0.35);
  border: 1px solid rgba(140,50,220,0.35);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.abyss-add-card:hover { border-color: rgba(192,132,252,0.6); background: rgba(80,20,80,0.4); }
.abyss-add-card--targeted {
  border-color: rgba(192,132,252,0.75);
  background: rgba(80,20,80,0.5);
  box-shadow: 0 0 0 1px rgba(192,132,252,0.3);
}
.abyss-add-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}
.abyss-add-name { font-size: 0.8rem; font-weight: 700; color: #e879f9; }
.abyss-add-target-tag {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4ade80;
  background: rgba(30,180,80,0.15);
  border: 1px solid rgba(30,180,80,0.4);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}
.abyss-add-hp-fill { background: #a855f7; }

/* ── Shield HP bar (Abyss Shielded modifier) ── */
.shield-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.15rem;
}
.shield-bar-label {
  font-size: 0.68rem;
  color: #93c5fd;
  font-weight: 600;
}
.shield-bar-track { border-color: rgba(50,100,220,0.3); }
.shield-bar-fill  { background: #3b82f6; }

/* Combat view */
.combat-view { display: flex; flex-direction: column; gap: 1rem; }

.combat-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.combat-dungeon-name { font-weight: 700; font-size: 1rem; }
.combat-floor { font-size: 0.82rem; color: var(--muted); }

/* HP bars */
.hp-bar-track {
  height: 10px;
  background: var(--inset);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.hp-bar-fill {
  height: 100%;
  background: #4ade80;
  border-radius: 6px;
  transition: width 0.1s linear;
}

.hp-bar-fill--low  { background: #facc15; }
.hp-bar-fill--crit { background: #f87171; }

.player-hp-wrap { display: flex; flex-direction: column; gap: 0.25rem; }
.player-hp-label { font-size: 0.82rem; font-weight: 600; }
.hp-cur { color: #4ade80; }
.hp-max { color: var(--muted); }

.enemy-wrap {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.enemy-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.enemy-name { font-weight: 700; font-size: 0.95rem; }
.enemy-meta { font-size: 0.72rem; color: var(--muted); }
.enemy-hp-label { font-size: 0.72rem; color: var(--muted); }
.enemy-hp-track { margin-top: 0.1rem; }
.enemy-hp-fill { background: #f87171; }

.boss-tag {
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  vertical-align: middle;
}

/* Combat spells */
.combat-spells { display: flex; flex-direction: column; gap: 0.4rem; }

.combat-spell-btn {
  position: relative;
  background: var(--inset);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem 0.45rem 0.55rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
  width: 100%;
  text-align: left;
}
.combat-spell-btn:hover:not(.combat-spell-btn--cd) {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(167,139,250,0.1);
}
.combat-spell-btn--cd { opacity: 0.55; cursor: default; }

.combat-spell-btn[data-element="fire"]   { border-left-color: #f97316; }
.combat-spell-btn[data-element="water"]  { border-left-color: #38bdf8; }
.combat-spell-btn[data-element="wind"]   { border-left-color: #a3e635; }
.combat-spell-btn[data-element="earth"]  { border-left-color: #92400e; }
.combat-spell-btn[data-element="arcane"] { border-left-color: var(--accent); }
.combat-spell-btn[data-element="life"]   { border-left-color: #4ade80; }

.cs-icon { font-size: 1.2rem; flex-shrink: 0; width: 1.4rem; text-align: center; }
.cs-body { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.cs-name { font-weight: 600; font-size: 0.78rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-stat { font-size: 0.68rem; line-height: 1; }
.cs-stat--dmg  { color: #fb923c; }
.cs-stat--heal { color: #4ade80; }

.cs-cost {
  flex-shrink: 0;
  background: rgba(139,92,246,0.12);
  border: 1px solid rgba(139,92,246,0.22);
  border-radius: 5px;
  padding: 0.15rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.cs-cost.cut { color: var(--green); background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.28); }

.cs-cd-bar {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
  transition: width 0.1s linear;
}

.cs-cd-label {
  position: absolute;
  bottom: 3px; right: 6px;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--muted);
}

/* Run loot panel */
.run-loot {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.run-loot-title { font-weight: 700; font-size: 0.82rem; color: var(--muted); }

.run-loot-gold  { font-size: 0.9rem; font-weight: 600; color: var(--gold); }
.run-loot-cores { font-size: 0.9rem; font-weight: 600; color: var(--cores); }
.run-loot-ae    { font-size: 0.9rem; font-weight: 600; color: #c084fc; }

.run-loot-items { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.2rem; }

.run-loot-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  cursor: default;
}

.flee-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  align-self: flex-start;
  transition: border-color 0.15s, color 0.15s;
}

.flee-btn:hover { border-color: #f87171; color: #f87171; }

/* ---- Combat stats panel ---- */
.combat-stats-wrap {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-top: 0.75rem;
}

.combat-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 0.5rem;
  margin-top: 0.3rem;
}

.cstat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  padding: 0.15rem 0;
}

.cstat-label { color: var(--muted); }
.cstat-val   { font-weight: 700; color: var(--text); }

/* ---- Combat research panel ---- */
.frontier-research-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  min-height: 0;
}

.frontier-research-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}


/* ═══════════════════════════════════════════════════════════════════
   INVENTORY SCREEN
═══════════════════════════════════════════════════════════════════ */

.inventory-screen {
  padding: 0.875rem;
}

#inventory-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Page header */
.inv-page-hdr {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0 0.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.875rem;
}
.inv-page-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.inv-page-sub   { font-size: 0.72rem; color: var(--muted); }
.flux-counter {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.85em; color: #a5b4fc;
  background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.25);
  border-radius: 12px; padding: 2px 10px; margin-left: auto;
}
.cores-counter  { font-size: 0.72rem; color: var(--muted); margin-left: 0.4rem; }
.cores-counter span { color: #f87171; font-weight: 600; }
.inv-count { font-size: 0.8em; color: #64748b; }
.inv-count.inv-warn { color: #fbbf24; }
.inv-count.inv-full { color: #f87171; font-weight: 700; }

.inv-sell-btn {
  background: none;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  color: #fbbf24;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s;
}
.inv-sell-btn:hover { background: rgba(251,191,36,0.12); }

.inv-scrap-btn {
  background: none;
  border: 1px solid #a78bfa;
  border-radius: 6px;
  color: #a78bfa;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s;
}
.inv-scrap-btn:hover { background: rgba(167,139,250,0.12); }

.inv-layout {
  display: grid;
  grid-template-columns: 300px 1fr 260px;
  gap: 1rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.inv-equipped,
.inv-bag,
.inv-bestiary {
  max-height: 100%;
  min-height: 0;
}

.inv-equipped,
.inv-bag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inv-equipped { padding: 1rem; overflow-y: auto; gap: 0.5rem; }

.inv-bag-header {
  flex-shrink: 0;
  padding: 1rem 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inv-bag-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  min-height: 0;
}

.inv-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.1rem;
}
.inv-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.inv-section-count {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.22);
  border-radius: 99px;
  padding: 0.05rem 0.45rem;
}

.inv-slot {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.inv-slot-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.inv-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 7px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  cursor: default;
  transition: border-color 0.15s;
}

.inv-item:hover { border-color: var(--border-hov); }
.inv-item--equipped { cursor: pointer; }
.inv-item--equipped.selected { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(167,139,250,0.2); }

/* Rarity left-border colors */
.inv-item.common    { border-left-color: var(--muted); }
.inv-item.uncommon  { border-left-color: #34d399; }
.inv-item.rare      { border-left-color: #38bdf8; }
.inv-item.epic      { border-left-color: var(--accent); }
.inv-item.legendary { border-left-color: #f59e0b; }
.inv-item.unique    { border-left-color: #ef4444; }

.inv-item-icon { font-size: 1.1rem; flex-shrink: 0; }

.inv-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.08rem; }
.inv-item-name { font-weight: 700; line-height: 1.2; }
.inv-level-badge {
  font-size: 0.7em; font-weight: 700;
  background: rgba(251,191,36,0.15); color: #fbbf24;
  border-radius: 4px; padding: 1px 5px; margin-left: 3px;
  vertical-align: middle;
}
.inv-item-stats { font-size: 0.62rem; color: var(--green); opacity: 0.9; }
.inv-item-passive { font-size: 0.6rem; color: var(--muted); opacity: 0.8; }

.inv-item-perm { font-size: 0.7rem; color: var(--accent); flex-shrink: 0; }

/* Rarity chips */
.inv-rarity-chip {
  font-size: 0.58rem; font-weight: 700;
  padding: 0.06rem 0.38rem; border-radius: 4px;
  text-transform: capitalize; white-space: nowrap; flex-shrink: 0;
}
.inv-rarity-chip.common    { color: var(--muted);   background: rgba(120,120,160,0.08); border: 1px solid rgba(120,120,160,0.2); }
.inv-rarity-chip.uncommon  { color: #34d399; background: rgba(52,211,153,0.09);   border: 1px solid rgba(52,211,153,0.22); }
.inv-rarity-chip.rare      { color: #38bdf8; background: rgba(56,189,248,0.09);   border: 1px solid rgba(56,189,248,0.22); }
.inv-rarity-chip.epic      { color: var(--accent); background: rgba(167,139,250,0.09); border: 1px solid rgba(167,139,250,0.22); }
.inv-rarity-chip.legendary { color: #f59e0b; background: rgba(245,158,11,0.09);   border: 1px solid rgba(245,158,11,0.25); }
.inv-rarity-chip.unique    { color: #ef4444; background: rgba(239,68,68,0.09);    border: 1px solid rgba(239,68,68,0.25); }

.inv-abyss-mod-chip {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid;
  background: rgba(0,0,0,0.35);
  letter-spacing: 0.03em;
}

.inv-slot-empty {
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0.35rem 0.5rem;
  font-style: italic;
  border: 1px dashed var(--border);
  border-radius: 7px;
  opacity: 0.6;
}

.inv-unequip-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.inv-unequip-btn:hover { border-color: #f87171; color: #f87171; }

/* Sort controls */
.inv-sort-row { display: flex; gap: 0.3rem; }
.inv-sort-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.6rem;
  font-family: inherit;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.inv-sort-btn.active { border-color: var(--accent); color: var(--accent); }
.inv-sort-btn:hover:not(.active) { border-color: var(--border-hov); color: var(--text); }

.inv-select-toggle {
  font-size: 0.65rem; font-weight: 700;
  background: none; border: 1px solid var(--border);
  border-radius: 4px; color: var(--muted);
  padding: 0.1rem 0.45rem; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-left: 0.3rem;
}
.inv-select-toggle:hover { border-color: var(--border-hov); color: var(--text); }
.inv-select-toggle.active {
  border-color: #4ade80; color: #4ade80;
  background: rgba(74,222,128,0.08);
}

/* Bulk select bar */
.inv-select-bar {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.6rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  margin-top: 0.5rem;
}
.inv-select-bar-top { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.inv-select-count { font-size: 0.75rem; color: var(--muted); margin-left: auto; }
.inv-rsel-common:hover    { color: #9ca3af; border-color: rgba(156,163,175,0.55); }
.inv-rsel-uncommon:hover  { color: #34d399; border-color: rgba(52,211,153,0.55);  }
.inv-rsel-rare:hover      { color: #38bdf8; border-color: rgba(56,189,248,0.55);  }
.inv-rsel-epic:hover      { color: var(--accent); border-color: rgba(167,139,250,0.55); }
.inv-rsel-legendary:hover { color: #f59e0b; border-color: rgba(245,158,11,0.55);  }
.inv-rsel-unique:hover    { color: #ef4444; border-color: rgba(239,68,68,0.55);   }
.inv-select-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.inv-select-hint { font-size: 0.72rem; color: var(--muted); font-style: italic; }

/* Lock button in detail card */
.inv-lock-btn {
  align-self: flex-start;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted);
  font-size: 0.7rem; padding: 2px 7px;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
  margin-bottom: 0.35rem;
}
.inv-lock-btn:hover { border-color: var(--border-hov); color: var(--text); }
.inv-lock-btn.locked { border-color: rgba(251,191,36,0.45); color: #fbbf24; }
.inv-lock-btn.locked:hover { border-color: #fbbf24; }

/* Cell overlays */
.inv-cell-lock {
  position: absolute; top: 2px; left: 3px;
  font-size: 0.5rem; line-height: 1;
  pointer-events: none; opacity: 0.85;
}
.inv-cell.select-mode { cursor: crosshair; opacity: 0.75; }
.inv-cell.select-mode.locked-cell { cursor: not-allowed; opacity: 0.4; }
.inv-cell.bulk-selected {
  box-shadow: 0 0 0 2px #4ade80;
  background: rgba(74,222,128,0.1);
  opacity: 1;
}

/* Item detail card */
.inv-detail-card {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.inv-detail-name { font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.inv-detail-meta { display: flex; align-items: center; gap: 0.4rem; font-size: 0.62rem; color: var(--muted); }
.inv-detail-perm { color: var(--accent); }
.inv-detail-desc { font-size: 0.7rem; color: var(--muted); line-height: 1.4; }
.inv-detail-stats { font-size: 0.68rem; color: var(--green); }
.inv-detail-passive { font-size: 0.65rem; color: var(--muted); }
.inv-detail-drops { font-size: 0.62rem; color: var(--muted); }
.inv-drop-boss { color: #ef4444; font-weight: 700; }
.inv-detail-actions { display: flex; gap: 0.45rem; margin-top: 0.1rem; }

.inv-cmp-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  padding: 0.3rem 0;
}
.inv-cmp-row {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-size: 0.68rem;
}
.inv-cmp-label   { color: var(--muted); }
.inv-cmp-val     { font-weight: 600; color: var(--muted); }
.inv-cmp-better  { color: #4ade80; }
.inv-cmp-same    { color: #facc15; }
.inv-cmp-worse   { color: #f87171; }

.inv-equip-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.22rem 0.65rem;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.inv-equip-btn:hover { opacity: 0.85; }

.inv-destroy-btn {
  background: none;
  border: 1px solid #f87171;
  border-radius: 6px;
  color: #f87171;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s;
}
.inv-destroy-btn:hover { background: rgba(248,113,113,0.12); }

.inv-upgrade-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  min-height: 2rem;
}

.inv-upgrade-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid #34d399;
  border-radius: 6px;
  color: #34d399;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.inv-upgrade-btn:hover:not(:disabled) { background: rgba(52,211,153,0.12); }
.inv-upgrade-btn:disabled { opacity: 0.4; cursor: default; }

.inv-upg-label { flex-shrink: 0; }
.inv-upg-cost  { display: flex; gap: 0.35rem; opacity: 0.85; }
.inv-upg-gold  { color: #fbbf24; }
.inv-upg-flux  { color: #a78bfa; }

.inv-max-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #facc15;
  background: rgba(250,204,21,0.1);
  border: 1px solid rgba(250,204,21,0.35);
  border-radius: 5px;
  padding: 0.2rem 0.6rem;
}

.inv-dupe-note {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Icon grid */
.inv-bag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.1rem;
  align-content: flex-start;
}
.inv-grid-label {
  width: 100%;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0.3rem 0 0.05rem;
  border-top: 1px solid var(--border);
  margin-top: 0.1rem;
}
.inv-grid-label:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.inv-cell {
  width: 50px;
  height: 50px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  background: var(--inset);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
}
.inv-cell:hover { transform: scale(1.1); }
.inv-cell.selected { box-shadow: 0 0 0 2px var(--accent); }

.inv-cell.common    { border-color: rgba(120,120,160,0.25); border-bottom: 3px solid rgba(120,120,160,0.55); }
.inv-cell.uncommon  { border-color: rgba(52,211,153,0.35);  border-bottom: 3px solid #34d399; }
.inv-cell.rare      { border-color: rgba(56,189,248,0.35);  border-bottom: 3px solid #38bdf8; }
.inv-cell.epic      { border-color: rgba(167,139,250,0.35); border-bottom: 3px solid var(--accent); }
.inv-cell.legendary { border-color: rgba(245,158,11,0.35);  border-bottom: 3px solid #f59e0b; }
.inv-cell.unique    { border-color: rgba(239,68,68,0.35);   border-bottom: 3px solid #ef4444; }

.inv-cell-badge {
  position: absolute; bottom: 2px; right: 3px;
  font-size: 0.52rem; font-weight: 800; line-height: 1;
  background: rgba(251,191,36,0.2); color: #fbbf24;
  border-radius: 3px; padding: 1px 3px;
  pointer-events: none;
}
.inv-cell-badge.inv-cell-max {
  background: rgba(248,113,113,0.2); color: #f87171;
}

.inv-empty-hint { color: var(--muted); font-size: 0.8rem; font-style: italic; padding: 0.5rem 0; }

/* ---- Bestiary ---- */
.inv-bestiary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bestiary-progress {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.4rem 0.1rem 0.1rem;
}
.bestiary-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
}
.bestiary-progress-label strong { color: var(--text); font-variant-numeric: tabular-nums; }
.bestiary-progress-track {
  height: 5px;
  background: var(--inset);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bestiary-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #34d399, #38bdf8);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.bestiary-list { display: flex; flex-direction: column; gap: 0.3rem; }

.bestiary-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.35rem 0.6rem;
  transition: border-color 0.12s;
}

.bestiary-row:hover { border-color: var(--border-hov); }
.bestiary-row--boss { border-left: 3px solid #ef4444; }

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

.bestiary-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.bestiary-name { font-size: 0.8rem; font-weight: 600; }
.bestiary-meta { font-size: 0.68rem; color: var(--muted); }
.bestiary-kills { font-size: 0.78rem; font-weight: 700; color: var(--muted); flex-shrink: 0; }

/* ---- Inventory tab bar (mobile only) ---- */
.inv-tab-bar { display: none; }
.inv-tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.25rem 0.4rem;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.inv-tab-btn:hover:not(.active) { color: var(--text); }
.inv-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Detail card close button (mobile only) */
.inv-detail-close { display: none; }
/* Needed so absolute close btn positions against the card */
.inv-detail-card { position: relative; }

@media (max-width: 640px) {
  .inventory-screen { padding: 0; }

  .inv-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
  }

  .inv-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  /* Hide all panels; show only the active tab */
  .inv-equipped, .inv-bag, .inv-bestiary { display: none !important; }
  .inv-layout[data-tab="equipped"] .inv-equipped { display: flex !important; }
  .inv-layout[data-tab="bag"]      .inv-bag      { display: flex !important; }
  .inv-layout[data-tab="bestiary"] .inv-bestiary { display: flex !important; }

  /* Detail card slides up as a fixed bottom sheet */
  .inv-detail-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    border-radius: 14px 14px 0 0;
    border: 1px solid var(--border-hov);
    border-bottom: none;
    background: var(--surface);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
    padding: 1rem 1rem 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
  }

  .inv-detail-close {
    display: block;
    position: absolute;
    top: 0.55rem;
    right: 0.65rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
    transition: color 0.15s;
  }
  .inv-detail-close:hover { color: var(--text); }

  .inv-detail-actions { gap: 0.5rem; }

  .inv-equip-btn,
  .inv-destroy-btn {
    flex: 1;
    padding: 0.65rem 0.5rem;
    font-size: 0.82rem;
  }
}

/* ---- Monster Cores badge ---- */
.cores-badge .hbadge-main { color: var(--cores); }

.panel {
  background: linear-gradient(160deg, var(--surface) 0%, rgba(12,10,24,0.95) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(167,139,250,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  min-height: 0;
}

.panel-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  opacity: 0.65;
}

.divider { height: 1px; background: var(--border); }

/* ---- Bars ---- */
.bar-track { height: 7px; background: var(--inset); border-radius: 99px; overflow: hidden; }
.bar-track.big-bar { height: 16px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.1s linear; }
.mana-fill { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }

/* ════════ GRIMOIRE PANEL ════════ */
.mana-wrap { display: flex; flex-direction: column; gap: 0.3rem; }
.mana-regen { font-size: 0.66rem; color: var(--muted); text-align: right; }
.orb-mana-wrap { padding: 0 0.5rem 0.25rem; }

.spell-list { display: flex; flex-direction: column; gap: 0.45rem; max-height: 16rem; overflow-y: auto; padding-right: 0.15rem; flex-shrink: 0; }

.spell-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.spell-row:hover { border-color: var(--accent); background: var(--surface-hov); }
.spell-row:active { transform: scale(0.985); }
.spell-row.cant { opacity: 0.5; }
.spell-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; width: 1.7rem; text-align: center; }
.spell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.spell-name { font-size: 0.82rem; font-weight: 700; }
.spell-desc { font-size: 0.64rem; color: var(--muted); line-height: 1.3; }
.spell-cost { flex-shrink: 0; font-size: 0.72rem; font-weight: 700; color: var(--mana); white-space: nowrap; }
.spell-locked-hint { font-size: 0.68rem; color: var(--muted); font-style: italic; padding: 0.2rem 0.25rem; opacity: 0.7; }

/* ── Hover tooltip (body-level, matches the site's surface/accent) ── */
.tip {
  position: fixed;
  z-index: 400;
  max-width: 230px;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 10px;
  box-shadow: 0 12px 32px var(--shadow), 0 0 0 1px rgba(167, 139, 250, 0.06);
  font-family: inherit;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.13s ease, transform 0.13s ease;
}
.tip.show { opacity: 1; transform: translateY(0); }
.tip-title  { font-weight: 700; color: var(--accent); margin-bottom: 0.1rem; }
.tip-cost   { color: var(--mana); font-weight: 700; font-size: 0.66rem; }
.tip-yield  { margin-top: 0.15rem; }
.tip-g { color: var(--gold); }
.tip-i { color: var(--insight); }
.tip-e { color: var(--essence); }
.tip-flavor { color: var(--muted); font-style: italic; font-size: 0.66rem; margin-top: 0.3rem; }

/* ── Advanced calc breakdown (inside the spell tooltip) ── */
.tip-calc { margin-top: 0.45rem; padding-top: 0.4rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.4rem; }
.tip-calc-block { display: flex; flex-direction: column; gap: 0.08rem; }
.tip-calc-row { display: flex; justify-content: space-between; gap: 0.9rem; font-size: 0.64rem; color: var(--muted); }
.tip-calc-row > span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.tip-calc-row.total { margin-top: 0.12rem; padding-top: 0.16rem; border-top: 1px dashed var(--border-hov); }
.tip-calc-row.total > span:first-child { color: var(--text); font-weight: 700; }
.tip-calc-row.tip-sub { padding-left: 0.75rem; opacity: 0.75; font-size: 0.62rem; }
.tip-calc-note { font-size: 0.6rem; color: var(--muted); font-style: italic; line-height: 1.35; }
.tip-section { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); opacity: 0.75; margin: 0.45rem 0 0.2rem; }
.tip-scholars { font-size: 0.65rem; color: var(--muted); margin-top: 0.35rem; }

/* ── Element Mastery (v0.4) ── */
.mastery { display: flex; flex-direction: column; gap: 0.45rem; }
.mastery-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
}
.mastery-ico { font-size: 1.35rem; line-height: 1; flex-shrink: 0; width: 1.6rem; text-align: center; }
.mastery-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.22rem; }
.mastery-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; }
.mastery-name { font-size: 0.8rem; font-weight: 700; }
.mastery-lvl { font-size: 0.66rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.mastery-track { height: 6px; background: var(--inset); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.mastery-fill { height: 100%; width: 0%; border-radius: 99px; transition: width 0.2s linear; }
.mastery-sub { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; }
.mastery-bonus { font-size: 0.62rem; color: var(--green); font-weight: 600; }
.mastery-xp { font-size: 0.6rem; color: var(--muted); white-space: nowrap; }
.mastery-ess { font-size: 0.6rem; color: var(--essence); font-weight: 600; margin-top: 0.1rem; }

/* primary-element pick (v0.5 — locked) */
.mastery-row.primary { border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.07); }
.mastery-tag {
  font-size: 0.52rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gold); background: rgba(245,158,11,0.14);
  border-radius: 4px; padding: 0.05rem 0.3rem; margin-left: 0.25rem; vertical-align: middle;
}

/* primary spell markers (v0.5) */
.spell-row.primary { border-color: rgba(245,158,11,0.35); }
.spell-star { color: var(--gold); font-size: 0.7rem; }
.spell-cost.cut { color: var(--green); }
.tip-cut { color: var(--muted); text-decoration: line-through; opacity: 0.8; }
.tip-primary { color: var(--gold); font-weight: 700; }

/* Spells header + locked-primary chip */
.spells-hdr { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.primary-chip {
  display: inline-flex; align-items: center; gap: 0.15rem;
  font-size: 0.62rem; font-weight: 700; white-space: nowrap;
  color: var(--gold); background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.3); border-radius: 99px;
  padding: 0.12rem 0.5rem;
}

/* ════════ PRIMARY-ELEMENT MODAL ════════ */
.primary-box { max-width: 420px; }
.primary-intro { font-size: 0.82rem; color: var(--muted); line-height: 1.5; margin: -0.2rem 0 0.2rem; }
.primary-intro b { color: var(--gold); }
.primary-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.primary-choice {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 0.85rem 0.5rem;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--inset); color: var(--text);
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.primary-choice:hover {
  border-color: rgba(245,158,11,0.6); background: rgba(245,158,11,0.1);
  transform: translateY(-2px);
}
.pc-ico  { font-size: 1.9rem; line-height: 1; }
.pc-name { font-size: 0.9rem; font-weight: 700; }
.pc-desc { font-size: 0.64rem; color: var(--muted); }

.arcane-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid rgba(192,132,252,0.3);
  background: rgba(192,132,252,0.08);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.arcane-ico { font-size: 1.35rem; }
.arcane-val   { display: block; font-size: 0.9rem; font-weight: 700; color: var(--essence); }
.arcane-bonus { display: block; font-size: 0.66rem; color: var(--muted); }

.transcend-btn {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem;
  border: 1px solid rgba(192,132,252,0.4);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(192,132,252,0.18), rgba(124,58,237,0.12));
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.transcend-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,0.3); }
.transcend-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.transcend-top { font-size: 0.85rem; font-weight: 700; }
.transcend-sub { font-size: 0.64rem; color: var(--muted); }
.transcend-pending { font-size: 0.62rem; font-weight: 700; color: var(--gold); margin-top: 0.15rem; }

.info-rows { display: flex; flex-direction: column; gap: 0.35rem; }
.info-row { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }
.info-row span:last-child { color: var(--text); font-weight: 600; }
.info-row--sub { padding-left: 1rem; font-size: 0.7rem; opacity: 0.8; }

.reset-row { margin-top: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.reset-btn {
  flex: 1 1 0;
  padding: 0.38rem 0.6rem;
  font-size: 0.7rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
  text-align: center;
  white-space: nowrap;
}
.adv-toggle {
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  width: 100%;
  padding: 0.42rem 0.6rem;
  font-family: inherit; font-size: 0.7rem; font-weight: 700;
  color: var(--muted); background: var(--inset);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.adv-toggle:hover { color: var(--text); border-color: var(--border-hov); }
.adv-toggle.on { color: var(--accent); border-color: rgba(167,139,250,0.5); background: rgba(167,139,250,0.1); }
.adv-toggle.on #adv-state { color: var(--accent); }
.adv-toggle:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
/* Allow disabled buttons with data-tip to still receive mouse events for tooltip */
button[disabled][data-tip] { pointer-events: auto; cursor: not-allowed; }

.reset-run-btn:hover { color: var(--accent); border-color: rgba(167,139,250,0.5); }
.reset-all-btn:hover { color: #ef4444;        border-color: rgba(239,68,68,0.5); }

/* ── Attunement screen ── */
.attunement-screen.screen--active {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 260px 1fr;
  gap: 0.875rem;
  padding: 0.875rem;
  min-height: 0;
  overflow: hidden;
}
.attunement-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
}
.attunement-panel .transcend-btn { width: 100%; }

/* Sticky top bar inside left panel (button + AP summary) */
.attune-sticky-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  padding-bottom: 0.5rem;
}

.ap-tree-wrap {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 0;
  overflow: hidden;
}
.ap-tree-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.875rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ap-tree-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.ap-tree-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ap-zoom-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  flex-shrink: 0;
}
.ap-zoom-btn:hover { border-color: var(--accent); color: var(--accent); }
.ap-available {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--essence);
}
.ap-tree {
  flex: 1;
  min-height: 320px;
  overflow: hidden;
}

@media (max-width: 640px) {
  .attunement-screen.screen--active {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
  }

  .attunement-panel {
    overflow-y: visible;
  }

  /* On mobile the sticky bar background needs to match the page bg */
  .attune-sticky-bar {
    background: var(--bg);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
  }

  .ap-tree-wrap {
    min-height: 420px;
  }

  /* Bigger zoom buttons for touch */
  .ap-zoom-btn {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }
}

/* ── AP Effects Summary (left panel) ── */
.ap-effects-summary {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--bg);
}
.ap-effects-hdr {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.ap-effects-list {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}
.ap-effect-line {
  font-size: 0.73rem;
  color: var(--accent);
  font-weight: 500;
}
.ap-effects-empty {
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Nav locked tabs ── */
.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.nav-btn:disabled:hover { color: var(--muted); }

/* ── Ritual screen ── */
.ritual-screen.screen--active {
  display: flex;
  grid-column: 1 / -1;
  align-items: stretch;
  justify-content: center;
  padding: 0.875rem;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.ritual-main {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(167,139,250,0.06);
}

/* Drifting ambient blobs */
.ritual-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.ritual-atmosphere::before,
.ritual-atmosphere::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.ritual-atmosphere::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(88,28,220,0.18), transparent 70%);
  top: -160px; left: -120px;
  animation: ritualAtmosDrift 14s ease-in-out infinite alternate;
}
.ritual-atmosphere::after {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(139,92,246,0.12), transparent 70%);
  bottom: -120px; right: -100px;
  animation: ritualAtmosDrift 18s ease-in-out infinite alternate-reverse;
}
@keyframes ritualAtmosDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(50px, 35px) scale(1.18); }
}

/* Header */
.ritual-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid rgba(139,92,246,0.12);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.ritual-header-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.35), transparent);
}
.ritual-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(192,132,252,0.6);
  white-space: nowrap;
}

/* Body */
.ritual-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
}

/* Side panels */
.ritual-info-panel,
.ritual-lore-panel {
  width: 190px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.ritual-info-panel { border-right: 1px solid var(--border); }
.ritual-lore-panel { border-left:  1px solid var(--border); }

/* Panel content wrapper — carries padding/gap on desktop */
.ritual-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem 1.1rem;
  flex: 1;
  overflow-y: auto;
}

/* Accordion header — hidden on desktop, tappable on mobile */
.ritual-accordion-hdr { display: none; }
.ritual-acc-chevron { transition: transform 0.2s; }

@media (max-width: 640px) {
  /* Screen scrolls; flex-start so .ritual-main shrink-wraps content
     instead of stretching to the screen height */
  .ritual-screen.screen--active {
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Keep overflow:hidden — clips animated blobs and spinning rings so
     their animated bounds never inflate the scroll area */
  .ritual-main {
    min-height: 100%;
  }

  /* Stack body vertically; natural height */
  .ritual-body {
    flex-direction: column;
    flex: none;
    height: auto;
  }

  /* Circle full width, sandwiched between panels */
  .ritual-circle-area {
    flex: none;
    width: 100%;
    border-left: none;
    border-right: none;
    border-top: 1px solid rgba(139,92,246,0.12);
    border-bottom: 1px solid rgba(139,92,246,0.12);
    padding: 1rem;
  }

  /* Frame ring: no vh cap on mobile */
  .ritual-frame-ring {
    width: min(100%, 480px);
  }

  /* Side panels full-width with opaque background so canvas never bleeds through */
  .ritual-info-panel,
  .ritual-lore-panel {
    width: 100%;
    flex-shrink: 0;
    overflow-y: visible;
    background: var(--surface);
    border-right: none;
    border-left: none;
    border-top: 1px solid rgba(139,92,246,0.12);
  }

  .ritual-accordion-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    color: rgba(192,132,252,0.7);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.7rem 1.1rem;
    cursor: pointer;
  }

  .ritual-panel-body { display: none; padding-top: 0; }

  .ritual-info-panel.open .ritual-panel-body,
  .ritual-lore-panel.open  .ritual-panel-body { display: flex; }

  .ritual-info-panel.open .ritual-acc-chevron,
  .ritual-lore-panel.open  .ritual-acc-chevron { transform: rotate(180deg); }
}

.ritual-section-hdr {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(139,92,246,0.5);
}

.ritual-panel-div {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.18), transparent);
}

/* AP display */
.ritual-ap-block { text-align: center; padding: 0.25rem 0; }
.ritual-ap-val {
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
  color: #c084fc;
  text-shadow: 0 0 24px rgba(192,132,252,0.45), 0 0 60px rgba(139,92,246,0.2);
  animation: ritualApPulse 4s ease-in-out infinite;
}
.ritual-ap-lbl {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(139,92,246,0.45);
  margin-top: 0.3rem;
}
@keyframes ritualApPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(192,132,252,0.4), 0 0 50px rgba(139,92,246,0.15); }
  50%       { text-shadow: 0 0 32px rgba(192,132,252,0.65), 0 0 80px rgba(139,92,246,0.3); }
}

/* Elements list */
.ritual-elements-list { display: flex; flex-direction: column; gap: 0.6rem; }
.ritual-el-row { display: flex; align-items: center; gap: 0.55rem; }
.ritual-el-icon { font-size: 1.05rem; flex-shrink: 0; }
.ritual-el-right { flex: 1; display: flex; flex-direction: column; gap: 0.22rem; min-width: 0; }
.ritual-el-track {
  height: 3px;
  border-radius: 99px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}
.ritual-el-fill { height: 100%; border-radius: 99px; transition: width 0.18s; }
.ritual-el-amount { font-size: 0.67rem; font-weight: 600; }
.ritual-no-els { font-size: 0.68rem; color: rgba(139,92,246,0.35); }

/* Cost block */
.ritual-cost-block { display: flex; flex-direction: column; gap: 0.12rem; }
.ritual-cost-val { font-size: 1.2rem; font-weight: 700; color: rgba(216,180,254,0.85); }
.ritual-cost-lbl { font-size: 0.6rem; color: rgba(139,92,246,0.45); }

/* Circle area — always dark so the canvas content reads correctly */
.ritual-circle-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-width: 0;
  min-height: 0;
  background: #04020e;
  border-left:  1px solid rgba(139,92,246,0.12);
  border-right: 1px solid rgba(139,92,246,0.12);
}

/* Decorative spinning rings around canvas */
.ritual-frame-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Constrain to fit both width and height of the area */
  width: min(100%, calc(100dvh - 200px), 480px);
  aspect-ratio: 1 / 1;
  animation: ritualFramePulse 5s ease-in-out infinite;
}
.ritual-frame-ring::before {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color:   rgba(192,132,252,0.55);
  border-right-color: rgba(139,92,246,0.22);
  animation: ritualRingSpin 10s linear infinite;
  pointer-events: none;
}
.ritual-frame-ring::after {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px solid transparent;
  border-bottom-color: rgba(167,139,250,0.42);
  border-left-color:   rgba(88,28,220,0.22);
  animation: ritualRingSpin 7s linear infinite reverse;
  pointer-events: none;
}
@keyframes ritualRingSpin { to { transform: rotate(360deg); } }
@keyframes ritualFramePulse {
  0%, 100% { filter: drop-shadow(0 0 22px rgba(88,28,220,0.38)); }
  50%       { filter: drop-shadow(0 0 44px rgba(139,92,246,0.58)); }
}

/* Canvas */
.ritual-circle-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ritual-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  border-radius: 50%;
}

/* Lore panel */
.ritual-lore-text {
  font-size: 0.7rem;
  line-height: 1.7;
  color: rgba(167,139,250,0.38);
  font-style: italic;
}
.ritual-hints-list { display: flex; flex-direction: column; gap: 0.55rem; }
.ritual-hint-item {
  font-size: 0.67rem;
  color: rgba(139,92,246,0.5);
  line-height: 1.55;
}
.ritual-hint-key {
  display: inline-block;
  color: rgba(192,132,252,0.82);
  font-weight: 700;
  font-style: normal;
}
.ritual-rune-display {
  font-size: 0.88rem;
  letter-spacing: 0.3em;
  color: rgba(139,92,246,0.22);
  text-align: center;
  padding: 0.4rem 0;
  animation: ritualRuneGlow 6s ease-in-out infinite;
}
@keyframes ritualRuneGlow {
  0%, 100% { color: rgba(139,92,246,0.22); }
  50%       { color: rgba(192,132,252,0.42); }
}

/* Light mode — fix dark screen/canvas areas */
[data-theme="light"] .ritual-screen.screen--active {
  background: transparent;
}
[data-theme="light"] .ritual-circle-area {
  background: transparent;
  border: none;
}
[data-theme="light"] .ritual-frame-ring {
  filter: none;
  animation: none;
}
[data-theme="light"] .ritual-atmosphere::before,
[data-theme="light"] .ritual-atmosphere::after { display: none; }

/* Light mode overrides for ritual side panels */
[data-theme="light"] .ritual-info-panel    { border-right: none; }
[data-theme="light"] .ritual-lore-panel    { border-left: none; }
[data-theme="light"] .ritual-header        { border-bottom: none; }
[data-theme="light"] .ritual-section-hdr   { color: rgba(109,40,217,0.65); }
[data-theme="light"] .ritual-ap-val        { color: #7c3aed; text-shadow: none; animation: none; }
[data-theme="light"] .ritual-ap-lbl        { color: rgba(109,40,217,0.5); }
[data-theme="light"] .ritual-cost-val      { color: #6d28d9; }
[data-theme="light"] .ritual-cost-lbl      { color: rgba(109,40,217,0.5); }
[data-theme="light"] .ritual-lore-text     { color: rgba(109,40,217,0.55); }
[data-theme="light"] .ritual-hint-item     { color: rgba(109,40,217,0.6); }
[data-theme="light"] .ritual-hint-key      { color: #7c3aed; }
[data-theme="light"] .ritual-rune-display  { color: rgba(109,40,217,0.3); animation: none; }
[data-theme="light"] .ritual-panel-div     { background: linear-gradient(90deg, transparent, rgba(109,40,217,0.12), transparent); }
[data-theme="light"] .ritual-header-line   { background: linear-gradient(90deg, transparent, rgba(109,40,217,0.25), transparent); }
[data-theme="light"] .ritual-title         { color: rgba(109,40,217,0.55); }
[data-theme="light"] .ritual-el-track      { background: rgba(0,0,0,0.08); }
[data-theme="light"] .ritual-no-els        { color: rgba(109,40,217,0.4); }

/* ── Chronicle screen ── */
.chronicle-screen.screen--active {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  min-height: 0;
  overflow-y: auto;
}

.chronicle-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

/* ── Chronicle tab bar ── */
.chr-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.chr-tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.55rem 0.5rem 0.45rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.chr-tab-btn:hover { color: var(--text); }
.chr-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Feats grid ── */
.feats-summary {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.5rem 0.1rem 0.75rem;
}
.feats-summary-count {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.feats-summary-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.feats-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.feats-section { display: flex; flex-direction: column; gap: 0.5rem; }
.feats-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.feats-section-hdr:hover { background: var(--surface); }
.feats-section-title { font-size: 0.78rem; font-weight: 700; color: var(--text); }
.feats-section-count { font-weight: 400; color: var(--muted); }
.feats-section-chevron {
  font-size: 1rem;
  color: var(--muted);
  transition: transform 0.2s;
}
.feats-section-hdr.collapsed .feats-section-chevron { transform: rotate(-90deg); }
.feats-section-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}
.feats-section-body.collapsed { display: none; }

.feat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  transition: background 0.1s;
}
.feat-card:hover { background: var(--inset); }
.feat-card.feat-locked {
  opacity: 0.8;
  filter: grayscale(0.2);
}
.feat-card.feat-earned {
  border-color: rgba(167,139,250,0.35);
  background: rgba(167,139,250,0.06);
}
.feat-progress {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  margin-top: 0.35rem;
  overflow: hidden;
}
.feat-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s;
}
.feat-reward {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 0.2rem;
  letter-spacing: 0.03em;
}
.feat-reward--earned {
  color: rgba(251,191,36,0.85);
}
.feat-progress-label {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

/* ── Feat reward box (modal) ── */
.feat-modal-reward-box {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.feat-modal-reward-box--earned {
  border-color: rgba(251,191,36,0.35);
  background: rgba(251,191,36,0.05);
}
.feat-modal-reward-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.feat-modal-reward-val {
  font-weight: 700;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.feat-bonus-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.22rem 0.45rem;
  border-radius: 5px;
  background: rgba(255,255,255,0.04);
}
.fbs-label { font-size: 0.75rem; color: var(--muted); }
.fbs-val   { font-size: 0.8rem; font-weight: 700; }
.fbs-fallback { font-size: 0.82rem; color: var(--muted); font-weight: 700; }
.fbs-gold     .fbs-val { color: #fbbf24; }
.fbs-insight  .fbs-val { color: #60a5fa; }
.fbs-essence  .fbs-val { color: #a78bfa; }
.fbs-research .fbs-val { color: #34d399; }
.fbs-mana     .fbs-val { color: #38bdf8; }
.fbs-hp       .fbs-val { color: #f87171; }
.fbs-combat   .fbs-val { color: #fb923c; }
.feat-modal-reward-box--earned .feat-modal-reward-label { color: rgba(251,191,36,0.65); }

/* ── Feat detail modal ── */
.feat-modal-status {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  margin-top: -0.5rem;
}
.feat-modal-earned {
  background: rgba(167,139,250,0.15);
  color: var(--accent);
  border: 1px solid rgba(167,139,250,0.3);
}
.feat-modal-locked {
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  border: 1px solid var(--border);
}
.feat-modal-desc {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
}
.feat-modal-flavor {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin: 0;
  line-height: 1.55;
}
.feat-modal-progress-wrap { width: 100%; display: flex; flex-direction: column; gap: 0.3rem; }
.feat-modal-progress-bar-track { height: 5px; margin-top: 0; }
.feat-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}
.feat-info { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }
.feat-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feat-desc {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 400px) {
  .feats-section-body { grid-template-columns: 1fr; }
}

/* Page header */
.chr-header {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.chr-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.chr-subtitle {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Sticky column labels */
.chr-col-hdrs {
  display: grid;
  grid-template-columns: 1fr 130px 130px;
  padding: 0 0.9rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.chr-col-hdr-label { font-size: 0.7rem; color: transparent; }
.chr-col-hdr-val {
  text-align: right;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0.3rem 0.5rem;
  border-radius: 20px;
  justify-self: end;
}
.chr-col-hdr-val:first-of-type {
  background: rgba(167,139,250,0.12);
  color: var(--accent);
  border: 1px solid rgba(167,139,250,0.25);
}
.chr-col-hdr-val:last-of-type {
  background: rgba(56,189,248,0.1);
  color: var(--mana);
  border: 1px solid rgba(56,189,248,0.2);
}

/* Category cards */
.chr-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chr-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  border-left-width: 3px;
}
.chr-group--general  { border-left-color: var(--muted); }
.chr-group--casting  { border-left-color: var(--mana); }
.chr-group--research { border-left-color: var(--insight); }
.chr-group--resources{ border-left-color: var(--gold); }
.chr-group--omens    { border-left-color: var(--accent); }
.chr-group--frontier { border-left-color: var(--cores); }

.chr-group-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  background: var(--inset);
  border-bottom: 1px solid var(--border);
}

/* Stat rows */
.chr-row {
  display: grid;
  grid-template-columns: 1fr 130px 130px;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.chr-row:last-child { border-bottom: none; }
.chr-row:hover { background: var(--inset); }
.chr-row > span:first-child {
  font-size: 0.78rem;
  color: var(--muted);
}
.chr-row > span:nth-child(2) {
  text-align: right;
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.chr-row > span:nth-child(3) {
  text-align: right;
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--mana);
}

/* Sub-rows (per-element essence, etc.) */
.chr-row--sub {
  padding-left: 1.75rem;
  background: rgba(0,0,0,0.03);
}
.chr-row--sub > span:first-child { font-size: 0.72rem; }
.chr-row--sub > span:nth-child(2),
.chr-row--sub > span:nth-child(3) {
  font-size: 0.78rem;
  opacity: 0.75;
}

/* Rows where "This Run" is not applicable */
.chr-row--lifetime > span:nth-child(2) {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.75rem;
  opacity: 0.5;
}

@media (max-width: 520px) {
  /* Narrow stat columns so the label column doesn't get crushed */
  .chr-col-hdrs,
  .chr-row { grid-template-columns: 1fr 80px 80px; }

  /* Swap long header text for short abbreviations via data-short */
  .chr-col-hdr-val { font-size: 0; }
  .chr-col-hdr-val::before { font-size: 0.65rem; content: attr(data-short); }

  /* Tighten chronicle page padding */
  .chronicle-page { padding-left: 0.75rem; padding-right: 0.75rem; }

  /* Save slots: wrap buttons to a second row */
  .save-slot { flex-wrap: wrap; padding: 0.45rem 0.55rem; gap: 0.35rem; }
  .save-slot-btns { width: 100%; flex-wrap: wrap; gap: 0.28rem; }
  .ss-btn { padding: 0.22rem 0.45rem; font-size: 0.63rem; }
}

/* Footer */
.chr-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  border-top: 1px solid var(--border);
}

/* ════════ STUDY PANEL ════════ */
.study-panel {
  background:
    radial-gradient(circle at 50% 22%, rgba(167,139,250,0.1) 0%, transparent 55%),
    var(--surface);
}

.orb-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.4rem 0 1rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}
.orb-float-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 3; }

.orb-core {
  font-size: 5rem;
  line-height: 1;
  filter: drop-shadow(0 0 28px rgba(167,139,250,0.55));
  transition: transform 0.09s ease;
  animation: orb-bob 4s ease-in-out infinite;
}
.orb-stage.pulse .orb-core { transform: scale(0.9); }
@keyframes orb-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.orb-hint { font-size: 0.7rem; color: var(--muted); opacity: 0.7; animation: hint-pulse 2.4s ease-in-out infinite; }
@keyframes hint-pulse { 0%,100% { opacity: 0.35; } 50% { opacity: 0.8; } }

.study-section { display: flex; flex-direction: column; gap: 0.5rem; }
.study-hdr { display: flex; align-items: center; justify-content: space-between; }
.slot-count { font-size: 0.7rem; font-weight: 700; color: var(--accent); }

.research-slots { display: flex; flex-direction: column; gap: 0.5rem; }
.slot {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  padding: 0.55rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.slot-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.slot-name { font-size: 0.78rem; font-weight: 700; }
.slot-eta { font-size: 0.7rem; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.slot-track { height: 8px; background: var(--inset); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.slot-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #7c3aed, #a78bfa); transition: width 0.15s linear; }
.slot-empty { font-size: 0.74rem; color: var(--muted); font-style: italic; padding: 0.5rem 0.2rem; }

/* ── The Study: scholars (v0.6) ── */
.scholar-summary { font-size: 0.7rem; font-weight: 700; color: var(--accent); }
.scholar-subhdr {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-top: 0.2rem;
}
.scholar-sub-note { font-size: 0.6rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); opacity: 0.8; }
.hire-btn {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-family: inherit; font-size: 0.74rem; font-weight: 700;
  color: var(--gold); background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.35); border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, opacity 0.15s;
}
.hire-btn:not(:disabled):hover { background: rgba(245,158,11,0.18); transform: translateY(-1px); }
.hire-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.hire-btn b { color: var(--gold); }

.scholar-rows { display: flex; flex-direction: column; gap: 0.35rem; }
.scholar-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border); border-radius: 9px; background: var(--inset);
}
.scholar-ico { font-size: 1.2rem; line-height: 1; flex-shrink: 0; width: 1.5rem; text-align: center; }
.scholar-name { font-size: 0.76rem; font-weight: 700; flex: 1; min-width: 0; }
.scholar-rate { font-size: 0.62rem; color: var(--green); font-weight: 600; white-space: nowrap; cursor: help; }
.scholar-ctrl { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.sch-btn {
  width: 1.4rem; height: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 0.9rem; font-weight: 700; line-height: 1;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.sch-btn:hover { border-color: var(--accent); color: var(--accent); }
.sch-count { min-width: 1.1rem; text-align: center; font-size: 0.78rem; font-weight: 700; }

.scholar-auto { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.scholar-auto-label { font-size: 0.64rem; color: var(--muted); }
.sch-auto-btn {
  flex: 1 1 0;
  padding: 0.3rem 0.4rem;
  font-family: inherit; font-size: 0.66rem; font-weight: 700;
  color: var(--muted); background: var(--inset);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.sch-auto-btn:hover { color: var(--accent); border-color: rgba(167,139,250,0.5); background: rgba(167,139,250,0.08); }

.log-wrap { flex: 1; min-height: 0; }
.log-hdr { display: flex; align-items: center; cursor: pointer; user-select: none; -webkit-user-select: none; }
.log-hdr:hover .panel-label { color: var(--text); }
.log-wrap.collapsed { flex: 0 0 auto; min-height: 0; }
.log-wrap.collapsed .event-log { display: none; }
/* Frontier combat log collapsible */
.frontier-log-wrap.collapsed .event-log { display: none; }

/* ── Generic collapsible panels (Spells / Mastery / Studying / Casting) ── */
.col-section { display: flex; flex-direction: column; gap: 0.5rem; }
.col-hdr { cursor: pointer; user-select: none; -webkit-user-select: none; }
.col-hdr:hover .panel-label,
.panel-label.col-hdr:hover,
.scholar-subhdr.col-hdr:hover { color: var(--text); }
.col-section.collapsed > :not(.col-hdr) { display: none; }
.event-log {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.log-line { font-size: 0.74rem; line-height: 1.4; color: var(--muted); padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.log-line:last-child { border-bottom: none; padding-bottom: 0; }
.log-line b { color: var(--text); font-weight: 700; }
.log-discovery { color: var(--text); }
.log-discovery b { color: var(--accent); }
.log-start b { color: var(--mana); }
.log-transcend { color: var(--essence); }
.log-transcend b { color: var(--essence); }
.log-combat { color: var(--muted); }
.log-combat b { color: var(--text); }
.log-loot   { color: var(--gold); }
.log-warn   { color: #f87171; }

/* ════════ RESEARCH PANEL ════════ */
.research-panel { overflow: hidden; }
.research-panel-hdr { display: flex; align-items: center; justify-content: space-between; padding: 0.1rem 0 0.4rem; }
.res-speed-stat { font-size: 0.72rem; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 4px; padding: 0.1rem 0.45rem; cursor: help; }
.research-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Explicit, self-contained height bound (Pokébrowse-style) so the list
     always scrolls inside its column, independent of grid/flex context. */
  max-height: calc(100dvh - var(--header-h) - 6rem);
  padding-right: 0.15rem;
}

.chapter-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-top: 0.5rem;
  padding: 0.25rem 0.1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.15s;
}
.chapter-hdr:hover { color: var(--text); }
.chapter-hdr:first-child { margin-top: 0; }
.chapter-title { display: flex; align-items: center; gap: 0.3rem; }
.chapter-chevron { display: inline-block; width: 0.7rem; font-size: 0.7rem; text-align: center; }
.chapter-prog { color: var(--muted); }

.res-node {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
}
.res-node.locked { opacity: 0.5; }
.res-node.done   { opacity: 0.62; }
.res-node.active { border-color: rgba(167,139,250,0.45); background: rgba(167,139,250,0.07); }
.res-node--clickable { cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.res-node--clickable:hover { border-color: var(--border-hov); background: var(--surface-hov); }

/* Research detail modal */
.res-modal-desc { font-size: 0.86rem; color: var(--muted); line-height: 1.55; text-align: left; margin: -0.25rem 0 0; }
.res-modal-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; justify-content: center; margin-top: 0.35rem; }
.res-modal-req { font-size: 0.78rem; color: #f59e0b; }

/* Spell info modal (touch long-press) */
.spell-info-box { max-width: 340px; text-align: left; }
.spell-info-inner { padding: 0.25rem; display: flex; flex-direction: column; gap: 0.3rem; }
.spell-info-inner .tip-title { font-size: 0.88rem; font-weight: 700; }
.spell-info-inner .tip-cost,
.spell-info-inner .tip-yield,
.spell-info-inner .tip-flavor,
.spell-info-inner .tip-primary { font-size: 0.8rem; }
.spell-info-inner .tip-calc { font-size: 0.72rem; }
.spell-info-inner .tip-section { border-top: 1px solid var(--border); padding-top: 0.3rem; }

.res-ico { font-size: 1.3rem; line-height: 1; flex-shrink: 0; width: 1.6rem; text-align: center; }
.res-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.18rem; }
.res-name { font-size: 0.8rem; font-weight: 700; }
.res-check { color: var(--green); }
.res-desc { font-size: 0.66rem; color: var(--muted); }
.res-desc.req { color: #f59e0b; opacity: 0.85; }

.res-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-top: 0.15rem; }
.chip {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
.chip.short { color: #ef4444; border-color: rgba(239,68,68,0.4); }
.res-time { font-size: 0.62rem; color: var(--muted); }
.res-time[data-res-id] { cursor: help; }
.res-pips { font-size: 0.7rem; letter-spacing: 0.12em; color: var(--accent);
  margin-top: 4px; opacity: 0.85; }
.slot-tier { font-size: 0.62rem; font-weight: 600; color: var(--accent); opacity: 0.8; }

.begin-btn {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.begin-btn:not(:disabled):hover { background: var(--accent); color: #fff; transform: translateY(-1px); }
.begin-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: var(--border); }

/* ════════ FLOATING NUMBERS ════════ */
.float-num {
  position: absolute;
  font-weight: 700;
  font-size: 0.92rem;
  color: #fde68a;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, 0);
  animation: floatUp 0.85s ease-out forwards;
}
.float-num.tap { color: var(--mana); }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  15%  { opacity: 1; transform: translate(-50%, -10px) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

/* ════════ TOAST ════════ */
.achievement-container {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 600;
  align-items: center;
  pointer-events: none;
}
.achievement-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(160deg, #0f0e1a 0%, #130f1e 100%);
  border: 1px solid rgba(251,191,36,0.4);
  border-top: 2px solid rgba(251,191,36,0.65);
  padding: 0.8rem 1.75rem 0.9rem;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 30px rgba(251,191,36,0.12);
  backdrop-filter: blur(10px);
  text-align: center;
  min-width: 200px;
  animation: achieveIn 0.4s cubic-bezier(0.34,1.56,0.64,1), achieveOut 0.35s ease 4.15s forwards;
}
.achievement-banner-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(251,191,36,0.85);
}
.achievement-banner-icon { font-size: 2rem; line-height: 1; margin: 0.2rem 0; }
.achievement-banner-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.achievement-banner-desc {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.achievement-banner-reward {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(251,191,36,0.9);
  letter-spacing: 0.04em;
}
@keyframes achieveIn  { from { opacity:0; transform: translateY(-16px) scale(0.92); } to { opacity:1; transform: translateY(0) scale(1); } }
@keyframes achieveOut { to   { opacity:0; transform: translateY(-10px); } }

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(15,13,28,0.95);
  border: 1px solid rgba(139,92,246,0.35);
  color: var(--text);
  padding: 0.6rem 1.2rem;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(139,92,246,0.15);
  backdrop-filter: blur(8px);
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1), toastOut 0.3s ease 2.7s forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px); } }

/* ════════ ATTUNEMENT MODAL ════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4,2,14,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1rem;
}

.modal-box {
  background: linear-gradient(160deg, #0f0e1a 0%, #0a0818 100%);
  border: 1px solid rgba(192,132,252,0.35);
  box-shadow: 0 0 60px rgba(88,28,220,0.25), 0 24px 48px rgba(0,0,0,0.6);
  border-radius: 20px;
  padding: 2rem 2.25rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(192,132,252,0.1);
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.86) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}
@keyframes modalInSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-glow  { font-size: 2.4rem; line-height: 1; }
.modal-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; margin-top: -0.3rem; }

.modal-souls-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(192,132,252,0.3);
  background: rgba(192,132,252,0.08);
}
.modal-big   { font-size: 2.8rem; font-weight: 700; color: var(--essence); line-height: 1; }
.modal-label { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.modal-gain {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green);
  background: rgba(34,197,94,0.1);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
}

.modal-lines { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; }
.modal-line { font-size: 0.75rem; padding: 0.3rem 0.6rem; border-radius: 7px; }
.modal-warn { background: rgba(239,68,68,0.08); color: #f87171; }
.modal-keep { background: rgba(163,230,53,0.07); color: #a3e635; }

.modal-tip { font-size: 0.7rem; color: var(--muted); font-style: italic; margin-top: -0.2rem; }

.modal-actions { display: flex; gap: 0.65rem; margin-top: 0.25rem; }

.modal-cancel {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 0.15s, color 0.15s;
}
.modal-cancel:hover { border-color: var(--border-hov); color: var(--text); }

.modal-confirm {
  flex: 1.6;
  padding: 0.6rem;
  border: 1px solid rgba(192,132,252,0.55);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(192,132,252,0.28), rgba(124,58,237,0.2));
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  transition: transform 0.12s, box-shadow 0.2s;
}
.modal-confirm:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(124,58,237,0.4); }

.confirm-body { font-size: 0.85rem; color: var(--text); line-height: 1.5; margin: 0; }
.confirm-danger {
  border-color: rgba(239,68,68,0.55);
  background: linear-gradient(135deg, rgba(239,68,68,0.28), rgba(185,28,28,0.2));
}
.confirm-danger:hover { box-shadow: 0 10px 28px rgba(239,68,68,0.4); }

/* ════════ OMENS (v0.8) ════════ */
.omen-strip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding: 0.35rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  flex-shrink: 0;
}
.omen-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.18rem 0.6rem;
  border-radius: 99px;
  white-space: nowrap;
  cursor: default;
}
.omen-chip-boon   { background: rgba(34,197,94,0.12);  border: 1px solid rgba(34,197,94,0.3);  color: #4ade80; }
.omen-chip-curse  { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.3); color: #f87171; }
.omen-chip-choice { background: rgba(167,139,250,0.12); border: 1px solid rgba(167,139,250,0.3); color: var(--accent); }
.omen-timer { font-size: 0.68em; opacity: 0.75; font-weight: 600; }

/* log kinds for omens */
.log-omen-boon   { color: #4ade80; }
.log-omen-curse  { color: #f87171; }
.log-omen-choice { color: var(--accent); }
.log-omen-boon, .log-omen-curse, .log-omen-choice { cursor: help; }
.log-info:has(b) { cursor: help; }

.log-tooltip {
  display: none; position: fixed; z-index: 999;
  background: var(--surface); border: 1px solid var(--border-hov);
  border-radius: 8px; padding: 0.4rem 0.65rem;
  font-size: 0.72rem; color: var(--text);
  max-width: 260px; pointer-events: none; line-height: 1.4;
}

/* chip tooltip — JS-positioned via initOmenChipTooltip */
.omen-chip[data-tip] { cursor: default; }

/* ════════ CHOICE MODAL ════════ */
.choice-flavor {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
  font-style: italic;
  margin: 0;
}
.choice-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}
.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-hov);
  border-radius: 10px;
  background: var(--inset);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.choice-btn:hover { border-color: var(--accent); background: rgba(167,139,250,0.08); transform: translateY(-1px); }
.choice-btn-label { font-size: 0.88rem; font-weight: 700; }
.choice-btn-desc  { font-size: 0.78rem; color: var(--muted); }

/* ════════ INSTANT OMEN MODAL ════════ */
.instant-omen-kind {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.15rem 0.65rem; border-radius: 99px; display: inline-block; margin: -0.25rem auto 0;
}
.omen-kind-boon  { background: rgba(34,197,94,0.15);   color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.omen-kind-curse { background: rgba(248,113,113,0.15); color: #f87171; border: 1px solid rgba(248,113,113,0.3); }

.instant-omen-effect {
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 0.55rem 1rem;
}
.instant-omen-bar-wrap {
  height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden;
}
.instant-omen-bar {
  height: 100%; border-radius: 2px;
  animation: omenBarShrink 10s linear forwards;
}
.instant-omen-bar.boon  { background: #4ade80; }
.instant-omen-bar.curse { background: #f87171; }
@keyframes omenBarShrink { from { width: 100%; } to { width: 0%; } }

.instant-omen-dismiss {
  background: transparent; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; color: var(--muted); font-size: 0.8rem; font-family: inherit;
  padding: 0.4rem 1.4rem; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.instant-omen-dismiss:hover { border-color: var(--accent); color: var(--text); }

/* ════════ CHANGELOG MODAL ════════ */
.changelog-header-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, transform 0.2s;
  flex-shrink: 0;
  opacity: 0.75;
}
.changelog-header-btn:hover { border-color: var(--border-hov); opacity: 1; transform: scale(1.08); }

.changelog-box {
  max-width: 480px;
  width: 92vw;
  text-align: left;
  gap: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.changelog-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.changelog-title { font-size: 0.95rem; font-weight: 700; }

.changelog-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--inset);
}
.cl-nav-btn {
  padding: 0.25rem 0.65rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.cl-nav-btn:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.cl-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.cl-version-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; min-width: 0; flex: 1; }
.cl-version-label { font-size: 0.82rem; font-weight: 700; color: var(--accent); text-align: center; }
.cl-counter { font-size: 0.6rem; color: var(--muted); font-weight: 600; }

.changelog-notes {
  list-style: none;
  padding: 1rem 1.25rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 4rem;
  overflow-y: auto;
  flex: 1;
}
.changelog-notes li {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  padding-left: 1rem;
  position: relative;
}
.changelog-notes li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.7rem;
  top: 0.17rem;
}

.changelog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--inset);
}
.cl-suppress-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.cl-suppress-label input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }
.cl-suppress-label:hover { color: var(--text); }

.changelog-footer .modal-cancel {
  flex: 0 0 auto;
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
}

/* ════════ RESPONSIVE ════════ */
@media (max-width: 880px) {
  .game-layout { grid-template-columns: 1fr; grid-template-rows: none; height: auto; overflow: visible; align-content: start; }
  .panel { min-height: unset; }
  .study-panel { order: -1; }
  .event-log { min-height: 160px; max-height: 260px; }
  .research-panel { overflow: visible; }
  .research-list { flex: none; max-height: 60vh; }
  /* Grimoire panel switcher */
  .grimoire-panel-hidden { display: none !important; }
  /* Spell list: uncap height — panel switcher makes nested scroll unnecessary */
  .spell-list { max-height: none; }
  /* Nav: icons only at tablet/mobile — labels inflate bar height */
  .nav-label { display: none !important; }
  .nav-btn { padding: 0; flex: 1; justify-content: center; }
  /* Subnavs: only visible on mobile, flush against the nav bar */
  #grimoire-subnav, #frontier-subnav { display: flex; margin-top: -0.875rem; }
  /* Frontier: collapse 3-column grid to single column */
  .frontier-screen { grid-template-columns: 1fr; overflow: visible; height: auto; align-content: start; padding: 0; }
  .frontier-wrap, .frontier-research-wrap, .frontier-log-wrap { min-height: unset; }
  .frontier-panel-hidden { display: none !important; }
}
@media (max-width: 520px) {
  .back-btn { display: none; }
  /* Stack header: title row on top, badges row below */
  .header {
    flex-direction: column;
    align-items: stretch;
    padding: 0.35rem 0.75rem 0.4rem;
    gap: 0.3rem;
  }
  .header-left { justify-content: space-between; }
  /* Single scrollable badges row — no wrapping */
  .header-right {
    justify-content: flex-start;
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1px;
    min-width: 0;
    width: 100%;
  }
  .header-right::-webkit-scrollbar { display: none; }
  .hbadge { font-size: 0.72rem; padding: 0.15rem 0.45rem; flex-shrink: 0; }
  /* Hide individual essence badges; show combined one instead */
  .essence-badges { display: none; }
  .essence-combined-badge { display: inline-flex; flex-shrink: 0; }
  /* Remove /max on other badges to save space */
  .ess-max { display: none; }
  .game-layout { padding: 0.6rem; gap: 0.6rem; }
  .orb-core { font-size: 4rem; }
  /* Nav: icons only — all 7 fit without scrolling */
  .nav-label { display: none; }
  .nav-btn { padding: 0; flex: 1; justify-content: center; font-size: 1.15rem; }
  .nav-icon { font-size: 1.15rem; }
  .omen-strip {
    padding: 0.35rem 0.6rem;
    gap: 0.35rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 2.5rem), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 2.5rem), transparent 100%);
  }
  .omen-strip::-webkit-scrollbar { display: none; }
  .omen-chip { font-size: 0.7rem; padding: 0.16rem 0.5rem; flex-shrink: 0; }

  /* ── Toast: clear iOS home-bar gesture strip ── */
  .toast-container {
    bottom: max(1.25rem, env(safe-area-inset-bottom) + 0.5rem);
  }

  /* ── Min 44px touch targets ── */
  /* sch-btn ± : expand tap area without changing layout */
  .sch-btn {
    position: relative;
    width: 1.8rem;
    height: 1.8rem;
  }
  .sch-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
  }
  /* begin-btn, sch-auto-btn */
  .begin-btn       { min-height: 44px; padding: 0.6rem 1rem; font-size: 0.8rem; }
  .sch-auto-btn    { min-height: 36px; }
  /* modal action buttons */
  .modal-cancel,
  .modal-confirm   { min-height: 44px; }

  /* ── Bottom-sheet modals ── */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.75rem 1.5rem;
    padding-bottom: max(1.75rem, env(safe-area-inset-bottom) + 1rem);
    animation: modalInSheet 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
}

/* ════════ LIGHT MODE OVERRIDES ════════ */

[data-theme="light"] {
  --panel-glow: rgba(124, 58, 237, 0.04);
}

[data-theme="light"] .header {
  background: rgba(240, 236, 232, 0.95);
  border-bottom-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .screen-nav {
  background: rgba(240, 236, 232, 0.92);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .frontier-wrap,
[data-theme="light"] .frontier-log-wrap,
[data-theme="light"] .panel {
  background: var(--surface);
  box-shadow: 0 4px 24px var(--shadow);
}


[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .modal-box {
  background: var(--surface);
  border-color: rgba(192, 132, 252, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(192, 132, 252, 0.08);
}

[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(124, 58, 237, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .instant-omen-effect {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .instant-omen-bar-wrap {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .instant-omen-dismiss {
  border-color: rgba(0, 0, 0, 0.12);
}

/* ════════ GUIDE SCREEN ════════ */
.guide-screen.screen--active {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  min-height: 0;
  overflow-y: auto;
}
.guide-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}
.guide-panel { display: flex; flex-direction: column; gap: 0.9rem; }
.guide-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.guide-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.1rem;
}
.guide-p {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}
.guide-p strong { color: var(--accent); font-weight: 700; }
.guide-p em { color: var(--muted); font-style: italic; }
kbd {
  display: inline-block;
  padding: 0.05em 0.4em;
  font-size: 0.78em;
  font-family: inherit;
  background: var(--inset);
  border: 1px solid var(--border-hov);
  border-radius: 4px;
  color: var(--text);
  line-height: 1.4;
}
.guide-kv-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.guide-kv {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.75rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  line-height: 1.5;
}
.guide-kv + .guide-kv { border-top: 1px solid var(--border); }
.guide-k {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.guide-v { color: var(--muted); }
.guide-callout {
  background: rgba(139,92,246,0.08);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 9px;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
}
.guide-callout strong { color: var(--accent); }
@media (max-width: 520px) {
  .guide-kv { grid-template-columns: 1fr; gap: 0.1rem; }
  .guide-k::after { content: ':'; }
}

/* ════════ SETTINGS SCREEN ════════ */
.settings-screen.screen--active {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  min-height: 0;
  overflow-y: auto;
}

.settings-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

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

.settings-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.settings-danger .settings-section-title { color: #f87171; border-bottom-color: rgba(248,113,113,0.25); }

/* ════════ SAVE SLOTS ════════ */

.save-slots {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}

.save-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.save-slot-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 2.8rem;
  flex-shrink: 0;
}

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

.save-slot-date {
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-slot-meta {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 1px;
}

.save-slot-empty {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

.save-slot-btns {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.ss-btn {
  padding: 0.28rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.ss-save { color: var(--accent); border-color: rgba(167,139,250,0.4); }
.ss-save:hover { background: rgba(167,139,250,0.12); border-color: rgba(167,139,250,0.7); }

.ss-load { color: #4ade80; border-color: rgba(74,222,128,0.35); }
.ss-load:hover { background: rgba(74,222,128,0.1); border-color: rgba(74,222,128,0.65); }

.ss-exp  { color: #60a5fa; border-color: rgba(96,165,250,0.3); }
.ss-exp:hover  { background: rgba(96,165,250,0.1); border-color: rgba(96,165,250,0.6); }

.ss-over { color: var(--muted); }
.ss-over:hover { color: var(--text); border-color: var(--border-hov); }

.ss-del { color: #f87171; border-color: rgba(248,113,113,0.3); }
.ss-del:hover { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.6); }

.save-io-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.save-io-btn {
  flex: 1;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--inset);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.save-io-btn:hover { color: var(--text); border-color: var(--border-hov); }

/* ════════ FANCY DARK-THEME POLISH ════════ */

/* Custom scrollbars */
[data-theme="dark"] ::-webkit-scrollbar { width: 5px; height: 5px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,0.25);
  border-radius: 99px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.45); }

/* Glowing research/upgrade buttons */
[data-theme="dark"] .research-btn:not(:disabled),
[data-theme="dark"] .upgrade-btn:not(:disabled) {
  box-shadow: 0 0 0 0 rgba(139,92,246,0);
  transition: box-shadow 0.2s, transform 0.15s, background 0.15s, border-color 0.15s;
}
[data-theme="dark"] .research-btn:not(:disabled):hover,
[data-theme="dark"] .upgrade-btn:not(:disabled):hover {
  box-shadow: 0 0 14px rgba(139,92,246,0.3);
}

/* Enemy wrap in dark */
[data-theme="dark"] .enemy-wrap {
  background: rgba(139,92,246,0.04);
  border-color: rgba(139,92,246,0.14);
}

/* Dev modal dark */
[data-theme="dark"] .dev-modal-box {
  background: linear-gradient(160deg, #0f0e1a 0%, #0a0818 100%);
  border-color: rgba(139,92,246,0.28);
  box-shadow: 0 24px 64px rgba(0,0,0,0.65), 0 0 32px rgba(88,28,220,0.18);
}
[data-theme="dark"] .dev-modal-hdr {
  background: rgba(139,92,246,0.06);
  border-bottom-color: rgba(139,92,246,0.18);
}

/* AP tree container */
[data-theme="dark"] #ap-tree-svg-wrap {
  background: radial-gradient(ellipse 70% 60% at 50% 40%, rgba(60,20,120,0.18) 0%, transparent 70%);
}

/* Animated subtle glow on active nav tab underline */
@keyframes navGlow {
  0%, 100% { box-shadow: 0 2px 8px rgba(167,139,250,0.3); }
  50%       { box-shadow: 0 2px 16px rgba(167,139,250,0.6); }
}
.nav-btn--active { animation: navGlow 3s ease-in-out infinite; }

/* Floating card lift on hoverable surfaces */
[data-theme="dark"] .frontier-wrap,
[data-theme="dark"] .frontier-log-wrap,
[data-theme="dark"] .panel {
  transition: box-shadow 0.25s;
}
