:root {
  --bg-deep: #0b0716;
  --bg-card: #161029;
  --border-accent: #8b5cf6;
  --gold: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

body.theme-goth {
  --bg-deep: #09030b;
  --bg-card: #190714;
  --border-accent: #e11d48;
  --gold: #f43f5e;
  background: radial-gradient(circle at top, #2d091e 0%, #07020a 100%);
}

body.theme-twilight {
  --bg-deep: #0b0716;
  --bg-card: #161029;
  --border-accent: #8b5cf6;
  --gold: #f59e0b;
  background: radial-gradient(circle at top, #1e113a 0%, #090512 100%);
}

body.theme-holy {
  --bg-deep: #131c31;
  --bg-card: #1e2942;
  --border-accent: #fbbf24;
  --gold: #fde047;
  background: radial-gradient(circle at top, #2c3e6b 0%, #0f172a 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  transition: background 0.4s ease;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  background: rgba(18, 12, 34, 0.92);
  border: 1px solid var(--border-accent);
  border-radius: 14px;
  padding: 14px 20px;
  gap: 16px;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fde68a;
}

.brand-sub {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.sep {
  opacity: 0.45;
}

.alignment-meter-wrap {
  min-width: 270px;
  flex: 1;
  max-width: 390px;
}

.alignment-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: #e2e8f0;
}

.alignment-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #881337 0%, #4c1d95 50%, #fbbf24 100%);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.alignment-marker {
  position: absolute;
  top: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #f59e0b;
  transform: translateX(-50%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
  transition: left 0.3s ease;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  min-width: 190px;
  background: rgba(22, 16, 41, 0.85);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: var(--gold);
  color: #fff;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(245, 158, 11, 0.25));
  border-color: var(--gold);
  color: #fde68a;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.2);
}

.view-section {
  margin-top: 18px;
}

.panel-card {
  background: rgba(20, 14, 38, 0.9);
  border: 1px solid var(--border-accent);
  border-radius: 16px;
  padding: 20px;
}

.section-eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fbbf24;
  text-transform: uppercase;
}

.muted-text {
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* Personality Layout */
.personality-layout {
  display: grid;
  grid-template-columns: 1fr 370px;
  gap: 20px;
}

@media (max-width: 920px) {
  .personality-layout,
  .arena-grid {
    grid-template-columns: 1fr !important;
  }
}

.deck-preview-panel {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.deck-cover-frame {
  width: 240px;
  height: 360px;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
  margin: 6px auto 14px;
}

.deck-cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.passive-pill {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #fde68a;
  font-weight: 600;
}

.quiz-choice-btn,
.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(13, 8, 28, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #f1f5f9;
  padding: 13px 16px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.quiz-choice-btn:hover,
.choice-btn:hover {
  transform: translateX(4px);
  border-color: var(--gold);
  background: rgba(139, 92, 246, 0.24);
}

.quiz-progress {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #f59e0b);
  transition: width 0.25s ease;
}

/* Quest Stepper & Combat */
.combat-stats-bar {
  margin-bottom: 14px;
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-pill {
  background: #0d081d;
  border: 1px solid var(--border-accent);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.quest-stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.quest-step-card {
  background: rgba(16, 11, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.82rem;
}

.quest-step-card.active {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
}

.quest-step-card.completed {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

.dilemma-panel {
  margin-bottom: 16px;
  border: 2px solid var(--gold);
}

.arena-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

.boss-panel {
  background: rgba(22, 16, 41, 0.88);
  border: 1px solid var(--border-accent);
  border-radius: 16px;
  padding: 20px;
}

.boss-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.reward-badge-box {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #a7f3d0;
}

.hp-bar-outer {
  width: 100%;
  height: 14px;
  background: #1f1635;
  border-radius: 999px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid var(--border-accent);
}

.hp-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #e11d48, #f59e0b);
  transition: width 0.3s ease;
}

/* Cards in Hand & Grimoire */
.hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.tarot-card {
  background: linear-gradient(160deg, #1b1334 0%, #100a20 100%);
  border: 2px solid var(--border-accent);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.tarot-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
}

.tarot-card.reversed {
  border-color: #e11d48;
  background: linear-gradient(160deg, #2b1126 0%, #12091c 100%);
}

.tarot-card.foil-gold {
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.32);
  border-color: #fbbf24;
}

.card-art-wrap {
  width: 100%;
  height: 165px;
  border-radius: 10px;
  overflow: hidden;
  margin: 6px 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #090512;
}

.card-art-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card-art-wrap img.img-reversed {
  transform: rotate(180deg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fde68a;
}

.cost-orb {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.card-title {
  font-size: 1rem;
  font-weight: 800;
  color: #fef3c7;
  margin-top: 4px;
}

.card-orientation,
.orientation-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
  margin: 4px 0;
}

.up-tag,
.badge-upright {
  background: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.rev-tag,
.badge-reversed {
  background: rgba(244, 63, 94, 0.25);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.45);
}

.tarot-card.unaffordable {
  opacity: 0.65;
  border-color: rgba(148, 163, 184, 0.35);
}

.card-desc {
  font-size: 0.8rem;
  color: #e2e8f0;
  line-height: 1.35;
  flex-grow: 1;
  margin: 4px 0 10px;
}

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

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.btn-cast {
  flex: 1;
  background: #7c3aed;
  color: white;
}

.btn-cast:hover {
  background: #6d28d9;
}

.btn-flip {
  background: #312e81;
  color: #e0e7ff;
}

.btn-primary {
  background: #f59e0b;
  color: #090512;
  padding: 10px 16px;
}

.btn-secondary {
  background: #334155;
  color: #f8fafc;
  padding: 9px 14px;
}

.btn-sanctum {
  background: #065f46;
  color: #ecfdf5;
  width: 100%;
  padding: 10px;
}

.sidebar-panel {
  background: rgba(17, 12, 33, 0.92);
  border: 1px solid var(--border-accent);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-deck-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(9, 5, 18, 0.75);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mini-deck-widget img {
  width: 38px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--gold);
}

.log-box {
  background: #080511;
  border: 1px solid #261b42;
  border-radius: 10px;
  padding: 10px;
  height: 250px;
  overflow-y: auto;
  font-size: 0.76rem;
  font-family: ui-monospace, monospace;
}

.log-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Grimoire Grid */
.grimoire-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.style-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grimoire-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 14px;
}

.grimoire-card {
  background: linear-gradient(160deg, #1b1334 0%, #100a20 100%);
  border: 2px solid var(--border-accent);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tarot-card.locked-card,
.grimoire-card.locked {
  opacity: 0.62;
  filter: grayscale(0.55);
  border-color: rgba(148, 163, 184, 0.35);
}

/* Tarot Reading Sanctum */
.reading-locked-box {
  text-align: center;
  padding: 42px 24px;
}

.reading-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.reading-deck-mini {
  width: 58px;
  height: 86px;
  border-radius: 8px;
  border: 2px solid var(--gold);
  object-fit: cover;
}

.reading-form-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 14px;
}

@media (max-width: 900px) {
  .reading-form-grid {
    grid-template-columns: 1fr;
  }
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fde68a;
  margin-bottom: 6px;
}

.text-input {
  background: #090512;
  border: 1px solid var(--border-accent);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.reading-spread-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.spread-slot-card,
.spread-slot {
  background: rgba(18, 12, 34, 0.92);
  border: 2px solid var(--border-accent);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.spread-slot-card:hover,
.spread-slot:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
}

.spread-position-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fde68a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.spread-position-prompt {
  font-size: 0.76rem;
  color: #94a3b8;
  margin: 4px 0 10px;
}

.card-back-Button {
  width: 180px;
  height: 270px;
  margin: 8px auto;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.card-back-Button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.spread-slot-img {
  width: 180px;
  height: 270px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--gold);
  margin: 8px auto;
  display: block;
}

.meaning-box {
  background: rgba(9, 5, 18, 0.75);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  padding: 10px;
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #e2e8f0;
  text-align: left;
}

.synthesis-panel {
  margin-top: 18px;
  border: 2px solid var(--gold);
  background: linear-gradient(135deg, rgba(39, 23, 69, 0.95), rgba(16, 10, 32, 0.95));
}

.journal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.journal-item,
.journal-entry {
  background: rgba(9, 5, 18, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.84rem;
}

.hidden {
  display: none !important;
}

.modal-card {
  margin-top: 16px;
  background: linear-gradient(135deg, #271745, #140c29);
  border: 2px solid #f59e0b;
  border-radius: 14px;
  padding: 18px;
}
