:root {
  --bg-0: #030915;
  --bg-1: #07162b;
  --panel-0: rgba(6, 14, 30, 0.9);
  --panel-1: rgba(5, 19, 42, 0.93);
  --line-soft: rgba(86, 206, 255, 0.42);
  --line-strong: rgba(147, 233, 255, 0.82);
  --text: #d9ecff;
  --muted: #88aeca;
  --accent: #68d8ff;
  --accent-2: #adf8ff;
  --warn: #f1fbff;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.66);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  position: relative;
  background: linear-gradient(180deg, #364a67 0%, #2f435f 100%);
}

.page-cinematic-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: transparent;
}

.page-cinematic-bg::before,
.page-cinematic-bg::after {
  content: '';
  position: absolute;
  inset: 0;
}

.page-cinematic-bg::before {
  top: 210px;
  background:
    linear-gradient(180deg, rgba(24, 36, 56, 0.08), rgba(24, 36, 56, 0.18)),
        url('/assets/solo-quiz-bg.jpg') center 65% / cover no-repeat;
  filter: none;
  opacity: 1;
}

.page-cinematic-bg::after {
  top: 210px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(8, 16, 30, 0.28));
  opacity: 0.32;
}

body.system-boot .quiz-stage {
  animation: stageBoot 820ms cubic-bezier(0.18, 0.76, 0.2, 1) both;
}

body.system-boot .hud-card-left {
  animation: sideSpawnLeft 820ms cubic-bezier(0.18, 0.76, 0.2, 1) both;
}

body.system-boot .hud-card-right {
  animation: sideSpawnRight 820ms cubic-bezier(0.18, 0.76, 0.2, 1) both;
}

.quiz-hero {
  min-height: 210px;
  padding: 26px 26px;
  display: flex;
  overflow: hidden;
  align-items: flex-end;
  position: relative;
  border-bottom: 1px solid var(--line-soft);
  box-shadow: inset 0 -14px 34px rgba(0, 0, 0, 0.44);
  background:
    linear-gradient(180deg, rgba(8, 18, 36, 0.62), rgba(6, 14, 28, 0.48)),
    url('/assets/14579.jpg') center 25% / cover no-repeat;
  z-index: 1;
}

.quiz-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0 19px,
      rgba(109, 212, 255, 0.035) 19px 20px
    );
}

.quiz-title {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.45rem, 3.8vw, 2.6rem);
  letter-spacing: 0.05em;
  color: #f6fbff;
  text-shadow: 0 0 10px rgba(92, 213, 255, 0.85), 0 0 28px rgba(80, 208, 255, 0.48);
  position: relative;
  z-index: 2;
}

.quiz-stage {
  max-width: 1220px;
  margin: -38px auto 52px;
  padding: 0 20px;
  display: grid;
  gap: 18px;
  grid-template-columns: 210px minmax(0, 760px) 210px;
  align-items: center;
  perspective: 1700px;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --stage-pan-x: 0px;
  --stage-pan-y: 0px;
  position: relative;
  z-index: 1;
}

.quiz-container {
  position: relative;
  z-index: 2; /* ensure quiz container sits above the rotated HUD side cards */
  width: 100%;
  margin: 0;
  padding: 30px 24px 34px;
  background: linear-gradient(165deg, rgba(7, 19, 39, 0.62) 0%, rgba(6, 18, 42, 0.62) 100%);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  transform:
    translate3d(var(--stage-pan-x), var(--stage-pan-y), 0)
    rotateX(calc(2deg + var(--tilt-x)))
    rotateY(calc(var(--tilt-y) * -1));
  will-change: transform;
  clip-path: polygon(0 18px, 18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px));
  isolation: isolate;
}

.quiz-container::selection {
  background: rgba(128, 228, 255, 0.35);
}

.quiz-container::before,
.quiz-container::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.quiz-container::before {
  inset: 8px;
  border: 1px solid rgba(142, 248, 255, 0.28);
  clip-path: polygon(0 13px, 13px 0, calc(100% - 13px) 0, 100% 13px, 100% calc(100% - 13px), calc(100% - 13px) 100%, 13px 100%, 0 calc(100% - 13px));
}

.quiz-container::after {
  height: 2px;
  left: 42px;
  right: 42px;
  top: 19px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  box-shadow: 0 0 12px rgba(142, 248, 255, 0.7);
}

.quiz-container .panel-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(148, 234, 255, 0.9);
  filter: drop-shadow(0 0 8px rgba(148, 234, 255, 0.7));
  opacity: 0.9;
  pointer-events: none;
  animation: cornerPulse 2.8s ease-in-out infinite;
}

.quiz-container .panel-corner.tl {
  top: 10px;
  left: 10px;
  border-right: 0;
  border-bottom: 0;
}

.quiz-container .panel-corner.tr {
  top: 10px;
  right: 10px;
  border-left: 0;
  border-bottom: 0;
}

.quiz-container .panel-corner.bl {
  bottom: 10px;
  left: 10px;
  border-right: 0;
  border-top: 0;
}

.quiz-container .panel-corner.br {
  bottom: 10px;
  right: 10px;
  border-left: 0;
  border-top: 0;
}

.quiz-container .panel-flicker {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: screen;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0 17px,
      rgba(150, 233, 255, 0.025) 17px 18px
    ),
    linear-gradient(90deg, transparent, rgba(121, 226, 255, 0.05), transparent);
  animation: edgeFlicker 4.3s linear infinite;
}

.quiz-container .panel-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(132, 240, 255, 0.06) 30%,
    rgba(177, 250, 255, 0.42) 49%,
    rgba(132, 240, 255, 0.08) 68%,
    transparent 100%
  );
  transform: translateY(-105%);
  mix-blend-mode: screen;
}

.quiz-container.scan-active .panel-scan {
  animation: panelScanSweep 740ms cubic-bezier(0.12, 0.72, 0.22, 1);
}

.hud-card {
  min-height: 210px;
  padding: 12px 12px;
  border: 1px solid rgba(99, 203, 247, 0.42);
  background: linear-gradient(165deg, rgba(6, 20, 38, 0.58), rgba(8, 26, 52, 0.58));
  box-shadow: 0 0 18px rgba(100, 214, 255, 0.18);
  clip-path: polygon(0 14px, 14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px));
  pointer-events: none; /* decorative only — prevents 3D-rotated cards from blocking quiz container clicks */
}

.hud-card-left {
  transform:
    translate3d(calc(var(--stage-pan-x) * 0.5), calc(var(--stage-pan-y) * 0.5), 0)
    rotateY(calc(24deg + var(--tilt-y) * -0.45))
    rotateX(calc(var(--tilt-x) * 0.4))
    translateX(10px);
  will-change: transform;
}

.hud-card-right {
  transform:
    translate3d(calc(var(--stage-pan-x) * 0.5), calc(var(--stage-pan-y) * 0.5), 0)
    rotateY(calc(-24deg + var(--tilt-y) * -0.45))
    rotateX(calc(var(--tilt-x) * 0.4))
    translateX(-10px);
  will-change: transform;
}

.hud-card-title {
  font-family: 'Orbitron', sans-serif;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  color: var(--accent-2);
  margin-bottom: 12px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(88, 171, 214, 0.24);
  font-size: 0.86rem;
}

.hud-row span {
  color: var(--muted);
}

.hud-row strong {
  color: #dff4ff;
  font-weight: 700;
}

.quiz-question {
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}

.quiz-question.boot-in {
  animation: bootIn 360ms cubic-bezier(0.2, 0.7, 0.15, 1) both;
}

.sys-header {
  display: inline-flex;
  align-items: center;
  margin-bottom: 8px;
  border: 1px solid rgba(110, 213, 255, 0.58);
  background: rgba(7, 28, 54, 0.64);
  box-shadow: 0 0 12px rgba(108, 222, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.sys-header::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 34px;
  background: linear-gradient(90deg, transparent, rgba(170, 241, 255, 0.3), transparent);
  transform: translateX(-150%);
  animation: headerSweep 2.6s ease-in-out infinite;
}

.sys-icon {
  width: 38px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(110, 213, 255, 0.58);
  color: #d9f7ff;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
}

.sys-label {
  padding: 0 16px;
  text-transform: uppercase;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  color: #e6fbff;
  text-shadow: 0 0 8px rgba(145, 238, 255, 0.45);
}

.sys-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-size: 0.86rem;
}

.quiz-question h2 {
  margin: 0 0 11px;
  color: #d7f0ff;
  letter-spacing: 0.02em;
  font-size: 1.22rem;
  font-family: 'Orbitron', sans-serif;
  text-shadow: 0 0 10px rgba(106, 220, 255, 0.32);
}

.quiz-choices label {
  display: block;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(96, 190, 232, 0.44);
  border-radius: 2px;
  background: rgba(4, 24, 47, 0.66);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.quiz-choices label:hover {
  border-color: var(--line-strong);
  box-shadow: 0 0 14px rgba(120, 219, 255, 0.25);
  transform: translateY(-1px);
}

.quiz-textarea {
  width: 100%;
  min-height: 58px;
  margin-top: 8px;
  border: 1px solid rgba(96, 190, 232, 0.35);
  background: rgba(5, 19, 37, 0.9);
  color: var(--text);
  padding: 10px;
  border-radius: 2px;
  font: inherit;
  resize: vertical;
}

.quiz-nav {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 18px;
}

/* Action buttons shown on the result screen */
.quiz-result-actions {
  justify-content: center;
  margin-top: 24px;
}
.quiz-result-actions a.quiz-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-btn {
  min-width: 112px;
  padding: 10px 20px;
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(45, 145, 211, 0.86), rgba(11, 58, 106, 0.9));
  color: #e8f7ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: box-shadow 0.16s ease, border-color 0.16s ease;
}

.quiz-btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 0 16px rgba(128, 228, 255, 0.4);
}

.quiz-result {
  margin-top: 24px;
  padding: 18px 14px;
  border: 1px solid rgba(96, 190, 232, 0.45);
  background: rgba(6, 23, 44, 0.65);
  color: var(--warn);
  text-align: center;
  font-size: 1.06rem;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 32px rgba(73, 179, 255, 0.12);
}

.quiz-result h2 {
  margin-top: 2px;
  margin-bottom: 10px;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e6fbff;
}

@keyframes cornerPulse {
  0%, 100% {
    opacity: 0.82;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

@keyframes edgeFlicker {
  0%, 100% { opacity: 0.7; }
  8% { opacity: 0.92; }
  10% { opacity: 0.62; }
  11% { opacity: 0.86; }
  32% { opacity: 0.72; }
  33% { opacity: 0.9; }
  63% { opacity: 0.68; }
  64% { opacity: 0.88; }
}

@keyframes headerSweep {
  0% { transform: translateX(-150%); }
  40% { transform: translateX(300%); }
  100% { transform: translateX(300%); }
}

@keyframes bootIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
    filter: saturate(1.2) brightness(1.25);
  }
  55% {
    opacity: 0.92;
    transform: translateY(0) scale(1.002);
    filter: saturate(1.05) brightness(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: none;
  }
}

@keyframes panelScanSweep {
  0% {
    opacity: 0;
    transform: translateY(-105%);
  }
  14% {
    opacity: 1;
  }
  55% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateY(108%);
  }
}

@keyframes stageBoot {
  0% {
    opacity: 0;
    transform: translateY(26px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes panelBoot {
  0% {
    opacity: 0;
    filter: brightness(1.35) saturate(1.3);
    clip-path: polygon(50% 18px, 50% 0, 50% 0, 50% 18px, 50% calc(100% - 18px), 50% 100%, 50% 100%, 50% calc(100% - 18px));
  }
  70% {
    opacity: 1;
    filter: brightness(1.08) saturate(1.06);
  }
  100% {
    clip-path: polygon(0 18px, 18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px));
  }
}

@keyframes sideSpawnLeft {
  0% {
    opacity: 0;
    transform: translateX(52px) rotateY(44deg) scale(0.88);
  }
  100% {
    opacity: 1;
  }
}

@keyframes sideSpawnRight {
  0% {
    opacity: 0;
    transform: translateX(-52px) rotateY(-44deg) scale(0.88);
  }
  100% {
    opacity: 1;
  }
}

@keyframes sideFloatLeft {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -5px; }
}

@keyframes sideFloatRight {
  0%, 100% { margin-top: -2px; }
  50% { margin-top: 4px; }
}

@keyframes ribbonsDrift {
  0%, 100% {
    transform: translateX(-0.8%) translateY(0%);
    opacity: 0.78;
  }
  50% {
    transform: translateX(0.9%) translateY(-1.2%);
    opacity: 0.9;
  }
}

#userBubble {
  position: absolute;
  top: 22px;
  right: 26px;
  z-index: 20;
  pointer-events: none;
}

.user-bubble-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(2, 11, 24, 0.8);
  box-shadow: 0 0 12px rgba(102, 211, 255, 0.2);
  pointer-events: auto;
}

.user-avatar-img,
.user-avatar-fallback {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}

.user-avatar-img {
  object-fit: cover;
  background: #091628;
}

.user-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
}

.user-bubble-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: #cfefff;
}

.user-bubble-visible {
  opacity: 1 !important;
}

@media (max-width: 720px) {
  .quiz-hero {
    min-height: 190px;
    padding: 26px 18px;
  }

  .quiz-stage {
    grid-template-columns: 1fr;
    padding: 0 12px;
    margin: -24px auto 26px;
  }

  .hud-card {
    display: none;
  }

  .quiz-container {
    margin: 0;
    padding: 24px 16px 28px;
    transform: none;
    will-change: auto;
  }

  .quiz-container .panel-corner {
    width: 20px;
    height: 20px;
  }

  .quiz-title {
    letter-spacing: 0.05em;
  }

  #userBubble {
    top: 14px;
    right: 14px;
  }

  .user-bubble-name {
    font-size: 0.72rem;
  }
}

/* ─── Result screen ──────────────────────────────────────────────────────── */

.quiz-result {
  padding: 4px 0 8px;
}

.result-archetype-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.3rem, 3.4vw, 2rem);
  font-weight: 800;
  color: #f2fbff;
  letter-spacing: 0.07em;
  line-height: 1.2;
  margin: 10px 0 14px;
  text-shadow:
    0 0 14px rgba(92, 213, 255, 0.95),
    0 0 34px rgba(80, 208, 255, 0.5);
}

.result-class-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.result-badge {
  display: inline-block;
  padding: 3px 12px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  border: 1px solid;
  clip-path: polygon(0 4px, 4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px));
}

.result-badge-rank {
  color: #f0e68c;
  border-color: rgba(240, 230, 140, 0.55);
  background: rgba(240, 230, 140, 0.07);
  text-shadow: 0 0 8px rgba(240, 230, 140, 0.65);
}

.result-badge-class {
  color: var(--accent-2);
  border-color: rgba(142, 248, 255, 0.48);
  background: rgba(142, 248, 255, 0.06);
}

.result-badge-trait {
  color: #c8b0ff;
  border-color: rgba(200, 176, 255, 0.48);
  background: rgba(200, 176, 255, 0.06);
}

.result-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-soft), transparent);
  margin: 4px 0 16px;
}

.result-description {
  line-height: 1.8;
  color: var(--muted);
  font-size: 0.96rem;
  margin: 0;
}

/* ── Runner-up archetypes ─────────────────────────────────────────────────── */
.result-runner-ups {
  margin-top: 4px;
}
.result-runner-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.62rem;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: 0.75;
}
.result-runner-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.result-runner-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-runner-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #b4d0ee;
  min-width: 120px;
}

/* ── Ideal partner archetype ─────────────────────────────────────────────── */
.result-partner-block {
  margin-top: 4px;
}
.result-partner-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.62rem;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: 0.75;
}
.result-partner-name {
  font-family: 'Cinzel Decorative', 'Orbitron', sans-serif;
  font-size: 1.0rem;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: 6px;
}
.result-partner-note {
  line-height: 1.7;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 6px 0 0;
  font-style: italic;
}

/* ── Compatibility summary ───────────────────────────────────────────────── */
.result-compat-block {
  margin-top: 4px;
}
.result-compat-badge {
  display: inline-block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 4px 12px;
  border: 1px solid;
  margin-bottom: 10px;
}
.result-compat-mirror {
  color: #e8d88a;
  border-color: rgba(232, 216, 138, 0.5);
  background: rgba(232, 216, 138, 0.07);
  text-shadow: 0 0 8px rgba(232, 216, 138, 0.4);
}
.result-compat-complementary {
  color: var(--accent-2);
  border-color: rgba(142, 248, 255, 0.45);
  background: rgba(142, 248, 255, 0.06);
  text-shadow: 0 0 8px rgba(142, 248, 255, 0.35);
}
.result-compat-flavor {
  line-height: 1.75;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  font-style: italic;
}
