:root {
  --ink: #0f1419;
  --ink-soft: #3d4654;
  --parchment: #f4ead8;
  --parchment-deep: #e8dcc4;
  --gold: #c9a227;
  --gold-bright: #e8c547;
  --crimson: #7a1e2a;
  --emerald: #1f5c4a;
  --sapphire: #1e3a5f;
  --amber: #8b4510;
  --shadow: rgba(15, 20, 25, 0.45);
  --glow: rgba(201, 162, 39, 0.35);
  --radius: 16px;
  --font-display: "Cinzel", "Times New Roman", serif;
  --font-body: "Source Serif 4", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1a2744 0%, #0b0f16 55%, #06080c 100%);
  line-height: 1.55;
}

.magic-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.85;
}

.bg-aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(122, 30, 42, 0.2), transparent 60%),
    radial-gradient(ellipse 50% 45% at 80% 20%, rgba(30, 58, 95, 0.25), transparent 55%),
    radial-gradient(ellipse 45% 50% at 50% 80%, rgba(31, 92, 74, 0.18), transparent 50%);
  z-index: 0;
  animation: auroraPulse 11s ease-in-out infinite alternate;
}

.bg-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(1px 1px at 30% 75%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 90% 85%, rgba(255, 255, 255, 0.3), transparent);
  background-size: 100% 100%;
  opacity: 0.6;
  z-index: 0;
  animation: starsDrift 36s linear infinite;
}

@keyframes auroraPulse {
  0% {
    filter: saturate(0.95) brightness(0.95);
    transform: scale(1);
  }
  100% {
    filter: saturate(1.15) brightness(1.08);
    transform: scale(1.035);
  }
}

@keyframes starsDrift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -8px, 0);
  }
  100% {
    transform: translate3d(0, -16px, 0);
  }
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.brand {
  text-align: center;
  margin-bottom: 1.75rem;
  color: var(--parchment);
}

.brand__eyebrow {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.75;
  margin: 0 0 0.5rem;
}

.brand__title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.06em;
  text-shadow: 0 0 40px var(--glow);
}

.brand__tagline {
  margin: 0.75rem auto 0;
  max-width: 28rem;
  font-size: 0.95rem;
  opacity: 0.88;
}

.arcane-nav {
  position: sticky;
  top: 0.75rem;
  z-index: 3;
  margin: 0 auto 1rem;
  padding: 0.7rem 0.8rem 0.75rem;
  border-radius: 14px;
  background: rgba(12, 17, 29, 0.72);
  border: 1px solid rgba(201, 162, 39, 0.35);
  box-shadow: 0 8px 22px rgba(6, 8, 12, 0.4), 0 0 18px rgba(201, 162, 39, 0.12);
  backdrop-filter: blur(6px);
}

.arcane-nav__row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.arcane-pill {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(244, 234, 216, 0.78);
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  font-family: var(--font-display);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: all 0.25s ease;
  pointer-events: none;
}

.arcane-pill.is-active {
  color: #14110a;
  background: linear-gradient(135deg, #efd076, #c9a227);
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 14px rgba(232, 197, 71, 0.45);
}

.arcane-meter {
  margin-top: 0.55rem;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.arcane-meter__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #a71d31, #e8c547 45%, #2ea87d);
  transition: width 0.4s ease;
}

.card {
  background: linear-gradient(165deg, var(--parchment) 0%, var(--parchment-deep) 100%);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow:
    0 4px 24px var(--shadow),
    0 0 0 1px rgba(201, 162, 39, 0.25) inset;
  position: relative;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(232, 197, 71, 0.18), transparent 36%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::after {
  opacity: 1;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--crimson), var(--gold), var(--emerald), var(--sapphire));
  opacity: 0.9;
}

.step--wide {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.step:not(.is-active) {
  display: none;
}

.step.is-active {
  animation: riseIn 0.45s ease-out both;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card__heading {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
  color: var(--ink);
}

.card__hint {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field__label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field__input {
  font-family: var(--font-body);
  font-size: 1.1rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(15, 20, 25, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.field__input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--glow);
}

.error {
  color: var(--crimson);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.actions--split {
  justify-content: space-between;
  align-items: center;
}

.tap-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-style: italic;
}

.btn {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.2s,
    background 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(201, 162, 39, 0.45);
}

.btn--primary:hover {
  box-shadow: 0 6px 22px rgba(201, 162, 39, 0.55);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(15, 20, 25, 0.2);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.5);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.quiz-top {
  margin-bottom: 1.25rem;
}

.quiz-progress {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.5rem;
}

.quiz-progress__name {
  letter-spacing: 0.06em;
  text-transform: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.1);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--crimson), var(--gold), var(--emerald));
  transition: width 0.35s ease;
}

.question {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.35;
  margin: 0 0 1.25rem;
  color: var(--ink);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  width: 100%;
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 20, 25, 0.12);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--ink);
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.15s,
    box-shadow 0.2s;
}

.option:hover {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 12px rgba(201, 162, 39, 0.2);
}

.option:focus-visible {
  outline: 2px solid rgba(201, 162, 39, 0.75);
  outline-offset: 2px;
}

.option:active {
  transform: scale(0.99);
}

.option__key {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(15, 20, 25, 0.08);
  color: var(--ink-soft);
}

.option__text {
  flex: 1;
  padding-top: 0.1rem;
}

.results-hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.results-hero__eyebrow {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}

.results-hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  margin: 0;
  color: var(--ink);
}

.results-hero__lead {
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.results-grid {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 520px) {
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.result-tile {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(15, 20, 25, 0.1);
  min-height: 5.5rem;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.result-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 20, 25, 0.15);
}

.result-tile__label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}

.result-tile__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.result-tile__icon {
  width: 2.35rem;
  height: 2.35rem;
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(15, 20, 25, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.result-tile__value {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.result-tile__detail {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.result-tile--house-gryffindor {
  border-left: 4px solid var(--crimson);
}
.result-tile--house-slytherin {
  border-left: 4px solid var(--emerald);
}
.result-tile--house-ravenclaw {
  border-left: 4px solid var(--sapphire);
}
.result-tile--house-hufflepuff {
  border-left: 4px solid var(--amber);
}

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 1rem 2rem;
  font-size: 0.75rem;
  color: rgba(244, 234, 216, 0.45);
}

.footer p {
  margin: 0;
  max-width: 28rem;
  margin-inline: auto;
}

@media (max-width: 560px) {
  .arcane-pill {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .magic-bg {
    display: none;
  }
}
