@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 700;
  src: local("Cinzel"), local("Cinzel-Regular");
}

@font-face {
  font-family: "Bangers";
  font-style: normal;
  font-weight: 400;
  src: local("Bangers");
}

:root {
  --bg: #140e12;
  --bg-2: #1f1820;
  --panel: rgba(17, 13, 18, 0.92);
  --ink: #f7f1e2;
  --muted: #d6c9a5;
  --gold: #f6c66a;
  --accent: #d9674d;
  --glow: rgba(246, 198, 106, 0.35);
  --crimson: #e03a3e;
  --crimson-accent: #9b1c20;
  --crimson-glow: rgba(224, 58, 62, 0.45);
  --shadow: rgba(0, 0, 0, 0.5);
  --font-display: "Cinzel", "Times New Roman", serif;
  --font-alt: "Bangers", "Trebuchet MS", cursive;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg-2), var(--bg));
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body.realm-fantasy {
  --bg: #0c111b;
  --bg-2: #1b2437;
  --accent: #5aa9e6;
}

body.realm-space {
  --bg: #04050a;
  --bg-2: #0d1b2a;
  --accent: #7b8dff;
}

body.realm-ancient {
  --bg: #1a120b;
  --bg-2: #2b1d12;
  --accent: #db8b44;
}

body.realm-west {
  --bg: #1b120b;
  --bg-2: #2e1f14;
  --accent: #c77728;
}

body.realm-own {
  --bg: #0f0c1d;
  --bg-2: #1b1433;
  --accent: #b66dff;
}

body.realm-upside {
  --bg: #050203;
  --bg-2: #140507;
  --panel: rgba(10, 3, 5, 0.92);
  --gold: var(--crimson);
  --accent: var(--crimson-accent);
  --glow: var(--crimson-glow);
  --muted: #d2b3b4;
  --ink: #f7e8e9;
}

#particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.6;
}

.quest-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 5vw 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
  backdrop-filter: blur(4px);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.crest-mini {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  box-shadow: 0 0 16px var(--glow);
}

.eyebrow {
  font-family: var(--font-alt);
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 12px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 32px);
}

.progress-wrap {
  text-align: right;
  min-width: 180px;
}

.progress-label {
  font-family: var(--font-alt);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width 0.4s ease;
}

.quest-main {
  position: relative;
  z-index: 2;
  padding: 40px 5vw 80px;
  display: grid;
  gap: 30px;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 60px var(--shadow);
  padding: 26px;
}

.panel-inner {
  max-width: 900px;
  margin: 0 auto;
}

.lead {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.realm-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.realm-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 18px;
  padding: 18px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.realm-card:hover,
.realm-card.selected {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 0 20px var(--glow);
}

.realm-title {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.realm-desc {
  color: var(--muted);
  font-size: 14px;
}

[hidden] { display: none !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s ease; }

.realm-custom {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

input,
textarea {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
}

textarea {
  resize: vertical;
}

.primary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 22px;
  font-family: var(--font-alt);
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.primary {
  background: linear-gradient(120deg, var(--gold), var(--accent));
  color: #1b0f07;
  box-shadow: 0 10px 24px var(--glow);
}

.danger {
  background: linear-gradient(120deg, var(--crimson), var(--crimson-accent));
  color: #1b0b0b;
  box-shadow: 0 10px 24px var(--crimson-glow);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.questions .question-card {
  display: grid;
  gap: 18px;
}

.question-step {
  font-family: var(--font-alt);
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 12px;
  color: var(--muted);
}

.question-text {
  font-size: 20px;
  line-height: 1.5;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.choice-btn {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease;
}

.choice-btn.selected {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.finale-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.quest-footer {
  text-align: center;
  color: var(--muted);
  padding: 10px 0 30px;
  font-size: 14px;
}

.fade-in {
  animation: fadeUp 0.6s ease both;
}

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

@media (max-width: 700px) {
  .quest-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .progress-wrap {
    width: 100%;
  }

  .nav-row {
    flex-direction: column;
  }
}

/* Profile + parent pages */
.profile-wrap {
  padding: 60px 6vw 80px;
  position: relative;
  z-index: 2;
}

.profile-card {
  background: rgba(12, 10, 18, 0.92);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 32px;
  box-shadow: 0 30px 60px var(--shadow);
  display: grid;
  gap: 24px;
}

.profile-hero {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(160px, 220px) 1fr;
}

.profile-hero svg {
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
}

.profile-title {
  font-size: clamp(26px, 3vw, 38px);
  margin: 0;
}

.profile-sub {
  color: var(--muted);
  font-size: 16px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.profile-item {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-item h4 {
  margin: 0 0 6px;
  font-family: var(--font-alt);
  letter-spacing: 2px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-item p {
  margin: 0;
  font-size: 16px;
}

.chat-panel {
  margin-top: 10px;
  border-radius: 20px;
  border: 1px solid rgba(246, 198, 106, 0.35);
  background: rgba(8, 6, 12, 0.85);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 12px;
  padding: 18px;
}

.chat-header {
  font-family: var(--font-alt);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 14px;
  color: var(--gold);
}

.chat-window {
  height: 280px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 10px;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
}

.chat-user {
  justify-self: end;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: #1b0f07;
}

.chat-kit {
  justify-self: start;
  background: rgba(20, 16, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.chat-input-row input {
  width: 100%;
}

.chat-send {
  padding: 12px 20px;
}

.parent-note {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

/* Stage 3 Learn Panel */
.learn-card {
  max-width: 680px;
  margin: 0 auto;
}
.learn-section {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(246,198,106,0.15);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 14px 0;
}
.learn-label {
  font-family: var(--font-alt);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}
.learn-reveal {
  margin-top: 12px;
  font-size: 14px;
  color: var(--gold);
  font-style: italic;
}
