/* ================================================================
   PULOTIS — THEME.CSS
   Dark Fantasy Modern — Obsidian, Amber, Blood
   ================================================================ */

:root {
  --obsidian:      #0a0a0f;
  --obsidian-mid:  #111118;
  --obsidian-light:#1a1a28;
  --obsidian-card: #14141f;
  --amber:         #c8922a;
  --amber-bright:  #f0b84a;
  --amber-dim:     #6b4d15;
  --amber-glow:    rgba(200,146,42,0.15);
  --blood:         #8b1a1a;
  --blood-bright:  #c0392b;
  --mana:          #1e3a6e;
  --mana-bright:   #4a90d9;
  --text-primary:  #e8dcc8;
  --text-secondary:#9a8a72;
  --text-dim:      #5a4e3c;
  --border:        rgba(200,146,42,0.2);
  --border-bright: rgba(200,146,42,0.5);
  --shadow-amber:  0 0 20px rgba(200,146,42,0.3);
  --shadow-deep:   0 8px 32px rgba(0,0,0,0.8);
  --font-display:  'Cinzel', serif;
  --font-body:     'Crimson Pro', serif;
  --font-mono:     'JetBrains Mono', monospace;
  --radius:        4px;
  --radius-lg:     8px;
  --tile-size:     clamp(36px, 5.5vw, 52px);
}

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

html, body {
  height: 100%;
  background: var(--obsidian);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SCREEN SYSTEM ────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 10; overflow: auto;
}
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ── TITLE SCREEN ─────────────────────────────────────────── */
.title-bg {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(139,26,26,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 20% 80%, rgba(200,146,42,0.08) 0%, transparent 60%),
    linear-gradient(180deg, #060609 0%, #0d0d18 50%, #08080f 100%);
  z-index: -1;
}
.title-bg::after {
  content: ''; position: fixed; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(200,146,42,0.01) 2px, rgba(200,146,42,0.01) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(200,146,42,0.02) 60px, rgba(200,146,42,0.02) 61px);
  pointer-events: none;
}
.title-content { text-align: center; padding: 2rem; animation: fadeUp 1s ease both; }
@keyframes fadeUp {
  from { opacity:0; transform: translateY(30px); }
  to   { opacity:1; transform: translateY(0); }
}
.title-rune {
  font-size: 3rem; color: var(--amber); margin-bottom: 1rem;
  animation: runeGlow 3s ease-in-out infinite alternate;
  text-shadow: 0 0 30px var(--amber), 0 0 60px rgba(200,146,42,0.4);
}
@keyframes runeGlow {
  from { text-shadow: 0 0 20px var(--amber), 0 0 40px rgba(200,146,42,0.3); }
  to   { text-shadow: 0 0 40px var(--amber-bright), 0 0 80px rgba(240,184,74,0.5); }
}
.title-main {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(3rem, 10vw, 7rem); letter-spacing: 0.2em;
  color: var(--amber-bright); line-height: 1; margin-bottom: 0.2em;
  text-shadow: 0 0 60px rgba(200,146,42,0.5), 2px 2px 0 rgba(0,0,0,0.8);
}
.title-sub {
  font-family: var(--font-display); font-size: clamp(0.9rem, 2.5vw, 1.3rem);
  letter-spacing: 0.4em; color: var(--text-secondary);
  text-transform: uppercase; margin-bottom: 1.5rem;
}
.title-tagline {
  font-size: 1.1rem; color: var(--text-dim); font-style: italic;
  max-width: 420px; margin: 0 auto 2.5rem; line-height: 1.6;
}
.title-version {
  margin-top: 2rem; font-family: var(--font-mono);
  font-size: 0.7rem; color: var(--text-dim); letter-spacing: 0.1em;
}
.btn-continue-save {
  border-color: #4a90d9 !important;
  color: #4a90d9 !important;
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn-arcane {
  display: block; width: 100%; max-width: 300px;
  margin: 0.5rem auto; padding: 0.9rem 2rem;
  background: linear-gradient(135deg, rgba(200,146,42,0.15) 0%, rgba(200,146,42,0.05) 100%);
  border: 1px solid var(--amber); color: var(--amber-bright);
  font-family: var(--font-display); font-size: 0.85rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  cursor: pointer; border-radius: var(--radius);
  transition: all 0.2s ease; position: relative; overflow: hidden;
}
.btn-arcane::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(200,146,42,0.2), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.btn-arcane:hover::before { opacity: 1; }
.btn-arcane:hover {
  border-color: var(--amber-bright);
  box-shadow: 0 0 20px rgba(200,146,42,0.3), inset 0 0 20px rgba(200,146,42,0.05);
  transform: translateY(-1px);
}
.btn-arcane:active { transform: translateY(0); }
.btn-arcane.secondary {
  background: transparent; border-color: var(--text-dim); color: var(--text-secondary);
}
.btn-arcane.secondary:hover {
  border-color: var(--text-secondary); color: var(--text-primary); box-shadow: none;
}
.btn-arcane.small { padding: 0.5rem 1.2rem; font-size: 0.75rem; max-width: 200px; }

/* ── PANELS ───────────────────────────────────────────────── */
.char-panel, .leaderboard-panel {
  background: var(--obsidian-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.6rem;
  max-width: 720px; width: 95%; max-height: 95vh; overflow-y: auto;
  box-shadow: var(--shadow-deep), 0 0 60px rgba(200,146,42,0.1);
}
.panel-title {
  font-family: var(--font-display); font-size: 1.4rem;
  color: var(--amber-bright); text-align: center; letter-spacing: 0.1em;
  margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}

/* ── INPUTS ───────────────────────────────────────────────── */
.form-group-arcane { margin-bottom: 1.2rem; }
.form-group-arcane label {
  display: block; font-family: var(--font-display); font-size: 0.7rem;
  letter-spacing: 0.15em; color: var(--amber); text-transform: uppercase; margin-bottom: 0.4rem;
}
.input-arcane {
  width: 100%; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-family: var(--font-body); font-size: 1.3rem;
  padding: 0.8rem 1rem; outline: none; transition: border-color 0.2s;
}
.input-arcane:focus { border-color: var(--amber); box-shadow: 0 0 12px var(--amber-glow); }

/* ── CLASS CARDS ──────────────────────────────────────────── */
.class-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.class-card {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.8rem; cursor: pointer;
  transition: all 0.2s; text-align: center;
}
.class-card:hover { border-color: var(--amber-dim); background: var(--amber-glow); }
.class-card.active {
  border-color: var(--amber); background: rgba(200,146,42,0.12);
  box-shadow: 0 0 16px var(--amber-glow);
}
.class-icon { font-size: 1.5rem; margin-bottom: 0.2rem; }
.class-name { font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.1em; color: var(--amber-bright); }
.class-desc { font-size: 0.94rem; color: var(--text-secondary); margin: 0.2rem 0; line-height: 1.3; }
.class-stats { font-family: var(--font-mono); font-size: 0.84rem; color: var(--amber-dim); }

/* ── STAT ROLL ────────────────────────────────────────────── */
.stat-roll-panel {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin: 1rem 0;
}
.stat-grid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem; margin-bottom: 0.8rem;
}
.stat-roll-item {
  text-align: center; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.4rem 0.2rem;
}
.stat-roll-name { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.05em; }
.stat-roll-val { font-family: var(--font-display); font-size: 1.3rem; color: var(--amber-bright); font-weight: 600; }

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

/* ── COMBAT PANEL ─────────────────────────────────────────── */
.combat-panel {
  background: var(--obsidian-card); border: 1px solid var(--blood-bright);
  border-radius: var(--radius-lg); padding: 1.5rem;
  width: min(420px, 95vw); box-shadow: 0 0 60px rgba(192,57,43,0.3);
}
.combat-header {
  font-family: var(--font-display); font-size: 1.1rem; letter-spacing: 0.2em;
  color: var(--blood-bright); text-align: center; margin-bottom: 0.8rem;
  border-bottom: 1px solid rgba(192,57,43,0.3); padding-bottom: 0.6rem;
}
.monster-portrait { font-family: var(--font-display); font-size: 1.56rem; color: var(--amber-bright); text-align: center; margin: 0.5rem 0; }
.combat-hp-row {
  display: flex; justify-content: space-around; align-items: center;
  margin: 0.8rem 0; padding: 0.6rem;
  background: rgba(0,0,0,0.3); border-radius: var(--radius);
}
.chp-label { font-size: 0.91rem; color: var(--text-dim); font-family: var(--font-mono); }
.chp-val { font-family: var(--font-display); font-size: 1.69rem; color: var(--amber-bright); }
.vs-divider { font-family: var(--font-display); color: var(--blood-bright); font-size: 0.8rem; }
.combat-log {
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius); height: 100px; overflow-y: auto;
  padding: 0.5rem; font-size: 0.82rem; color: var(--text-secondary);
  line-height: 1.5; margin-bottom: 1rem;
}
.combat-actions { display: flex; gap: 0.5rem; }
.btn-combat {
  flex: 1; padding: 0.6rem 0.4rem; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-family: var(--font-display);
  font-size: 0.91rem; letter-spacing: 0.1em; cursor: pointer; transition: all 0.2s;
}
.btn-combat:hover { border-color: var(--amber); background: var(--amber-glow); color: var(--amber-bright); }

/* ── FEATURE PANEL ────────────────────────────────────────── */
.feature-panel {
  background: var(--obsidian-card); border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg); padding: 2rem;
  width: min(400px, 92vw); text-align: center; box-shadow: var(--shadow-amber);
}
.feature-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.feature-title { font-family: var(--font-display); font-size: 1.56rem; color: var(--amber-bright); letter-spacing: 0.1em; margin-bottom: 0.8rem; }
.feature-desc { color: var(--text-secondary); font-style: italic; font-size: 1.24rem; line-height: 1.6; margin-bottom: 1.2rem; }
.feature-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 1rem; }
.btn-feature {
  padding: 0.65rem 1.56rem; background: rgba(200,146,42,0.1);
  border: 1px solid var(--amber-dim); border-radius: var(--radius);
  color: var(--amber-bright); font-family: var(--font-display);
  font-size: 0.94rem; letter-spacing: 0.1em; cursor: pointer; transition: all 0.2s;
}
.btn-feature:hover { border-color: var(--amber); background: var(--amber-glow); }

/* ── SPELL PANEL ──────────────────────────────────────────── */
.spell-panel {
  background: var(--obsidian-card); border: 1px solid rgba(74,144,217,0.4);
  border-radius: var(--radius-lg); padding: 1.5rem;
  width: min(380px, 92vw); box-shadow: 0 0 40px rgba(74,144,217,0.15);
}
.spell-header {
  font-family: var(--font-display); font-size: 1rem; color: var(--mana-bright);
  letter-spacing: 0.15em; text-align: center; margin-bottom: 1rem;
  border-bottom: 1px solid rgba(74,144,217,0.2); padding-bottom: 0.6rem;
}
.spell-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; max-height: 300px; overflow-y: auto; }
.spell-item {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.8rem;
  background: rgba(74,144,217,0.05); border: 1px solid rgba(74,144,217,0.15);
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s;
}
.spell-item:hover { border-color: var(--mana-bright); background: rgba(74,144,217,0.12); }
.spell-item.disabled { opacity: 0.4; cursor: not-allowed; }
.spell-name { font-family: var(--font-display); font-size: 1.04rem; color: var(--mana-bright); flex: 1; }
.spell-cost { font-family: var(--font-mono); font-size: 0.84rem; color: var(--text-dim); }
.spell-desc { font-size: 0.94rem; color: var(--text-secondary); }

/* ── DEATH SCREEN ─────────────────────────────────────────── */
#screen-death { background: rgba(0,0,0,0.97); flex-direction: column; }
.death-content { text-align: center; padding: 2rem; animation: fadeUp 0.8s ease; }
.death-skull { font-size: 4rem; margin-bottom: 1rem; filter: grayscale(0.5); animation: deathPulse 2s ease-in-out infinite; }
@keyframes deathPulse { 0%,100% { opacity:0.7; } 50% { opacity:1; } }
.death-title { font-family: var(--font-display); font-size: 3.25rem; color: var(--blood-bright); letter-spacing: 0.15em; margin-bottom: 1.5rem; }
.death-stats {
  font-family: var(--font-mono); font-size: 1.1rem; color: var(--text-secondary);
  line-height: 2; margin-bottom: 1rem; background: rgba(255,255,255,0.03);
  padding: 1rem 2rem; border: 1px solid var(--border); border-radius: var(--radius);
  display: inline-block; white-space: pre-line;
}
.death-epitaph { font-style: italic; color: var(--text-dim); margin-bottom: 2rem; font-size: 0.95rem; }

/* ── LEADERBOARD ──────────────────────────────────────────── */
.leaderboard-table { margin: 1rem 0; }
.lb-row {
  display: grid; grid-template-columns: 2rem 1fr auto auto auto;
  gap: 0.5rem; align-items: center; padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.lb-row.header {
  font-family: var(--font-display); font-size: 0.65rem; letter-spacing: 0.1em;
  color: var(--amber); text-transform: uppercase; border-bottom: 1px solid var(--border-bright);
}
.lb-rank { font-family: var(--font-mono); color: var(--amber-dim); font-size: 0.97rem; }
.lb-name { font-family: var(--font-display); color: var(--text-primary); }
.lb-class { font-family: var(--font-mono); font-size: 0.94rem; color: var(--text-secondary); }
.lb-depth { color: var(--amber); font-family: var(--font-mono); font-size: 1.04rem; }
.lb-gold { color: #d4af37; font-family: var(--font-mono); font-size: 1.04rem; }
.lb-loading { text-align: center; color: var(--text-dim); padding: 2rem; font-style: italic; }

/* ── LEVEL UP ─────────────────────────────────────────────── */
.levelup-panel {
  background: var(--obsidian-card); border: 1px solid var(--amber);
  border-radius: var(--radius-lg); padding: 2rem; width: min(350px, 92vw);
  text-align: center; box-shadow: var(--shadow-amber); position: relative; overflow: hidden;
}
.levelup-shine {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(200,146,42,0.2) 0%, transparent 70%);
  animation: shineAnim 2s ease-in-out infinite alternate;
}
@keyframes shineAnim { from { opacity: 0.5; } to { opacity: 1; } }
.levelup-icon { font-size: 2.5rem; position: relative; z-index: 1; }
.levelup-title { font-family: var(--font-display); font-size: 1.95rem; color: var(--amber-bright); letter-spacing: 0.1em; margin: 0.5rem 0; position: relative; z-index: 1; }
.levelup-info { font-family: var(--font-mono); font-size: 1.04rem; color: var(--text-secondary); line-height: 1.8; margin: 0.8rem 0 1.2rem; position: relative; z-index: 1; white-space: pre-line; }

/* ── SAVE STATUS INDICATOR ────────────────────────────────── */
.save-status {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.05em;
  color: var(--text-dim); transition: color 0.3s, opacity 0.5s;
  opacity: 0; margin-right: 0.4rem; pointer-events: none;
}
.save-status.visible { opacity: 1; }
.save-status.saving  { color: var(--amber); }
.save-status.saved   { color: #6ec87a; }
.save-status.error   { color: var(--blood-bright); }

/* ── TOPBAR ICON BUTTONS ──────────────────────────────────── */
.btn-topbar {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  padding: 0.15rem 0.3rem; border-radius: var(--radius);
  transition: background 0.15s; line-height: 1; -webkit-tap-highlight-color: transparent;
}
.btn-topbar:hover { background: rgba(255,255,255,0.07); }

/* ── SETTINGS PANEL ───────────────────────────────────────── */
.settings-panel {
  background: var(--obsidian-card); border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg); padding: 1.5rem;
  width: min(420px, 95vw); max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-deep), var(--shadow-amber);
}
.settings-header {
  font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.15em;
  color: var(--amber-bright); text-align: center; margin-bottom: 1.2rem;
  padding-bottom: 0.6rem; border-bottom: 1px solid var(--border);
}
.settings-section { margin-bottom: 1rem; }
.settings-section-title {
  font-family: var(--font-display); font-size: 0.65rem; letter-spacing: 0.15em;
  color: var(--amber-dim); text-transform: uppercase; margin-bottom: 0.7rem;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.settings-label { display: flex; flex-direction: column; gap: 0.1rem; font-size: 1.1rem; color: var(--text-primary); }
.settings-hint { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); }
.settings-select {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-family: var(--font-mono); font-size: 0.72rem; padding: 0.3rem 0.5rem;
  cursor: pointer; outline: none;
}
.settings-select:focus { border-color: var(--amber); }
.settings-divider { height: 1px; background: var(--border); margin: 0.6rem 0; }
.settings-uuid {
  margin-top: 0.8rem; padding: 0.5rem;
  background: rgba(0,0,0,0.3); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 0.2rem;
}
.uuid-display { font-family: var(--font-mono); font-size: 0.58rem; color: var(--text-dim); word-break: break-all; letter-spacing: 0.03em; }

/* ── TOGGLE SWITCH ────────────────────────────────────────── */
.toggle-switch {
  position: relative; display: inline-block;
  width: 42px; height: 22px; flex-shrink: 0; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.08); border: 1px solid var(--border);
  border-radius: 11px; transition: all 0.2s;
}
.toggle-track::after {
  content: ''; position: absolute; left: 3px; top: 50%;
  transform: translateY(-50%); width: 14px; height: 14px;
  background: var(--text-dim); border-radius: 50%; transition: all 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: rgba(200,146,42,0.2); border-color: var(--amber); }
.toggle-switch input:checked + .toggle-track::after {
  left: calc(100% - 17px); background: var(--amber-bright);
  box-shadow: 0 0 6px rgba(200,146,42,0.6);
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--amber-dim); border-radius: 2px; }

/* ── 5-CLASS GRID (2+2+1) ──────────────────────────────── */
.class-grid-5 {
  grid-template-columns: 1fr 1fr;
}
.class-grid-5 .class-card:last-child {
  grid-column: 1 / -1;
}

/* ── TOPBAR GOLD ───────────────────────────────────────── */
.topbar-gold {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #d4af37;
  letter-spacing: 0.04em;
  margin-right: 0.3rem;
  white-space: nowrap;
}
