/* ========================================
   CSS Variables
   ======================================== */
:root {
  --fire-dark: #1a0500;
  --fire-mid: #6b1800;
  --fire-bright: #cc3300;
  --fire-glow: #ff6600;
  --fire-yellow: #ffaa00;
  --sky-top: #1a5276;
  --sky-mid: #5dade2;
  --sky-light: #85c1e9;
  --sky-pale: #d6eaf8;
  --cloud-white: rgba(255, 255, 255, 0.9);
  --sun-gold: #f9e547;
  --card-bg: rgba(255, 255, 255, 0.65);
  --text-dark: #1c1c1c;
  --text-muted: #555;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  font-family: 'Crimson Text', Georgia, serif;
  color: var(--text-dark);
  background: #111;
}

/* ========================================
   Split Background — Fire (left)
   ======================================== */
.bg-fire {
  position: fixed;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  z-index: 0;
  background:
    linear-gradient(0deg,
      var(--fire-yellow) 0%,
      var(--fire-glow) 15%,
      var(--fire-bright) 30%,
      var(--fire-mid) 55%,
      var(--fire-dark) 100%);
  background-size: 100% 200%;
  animation: fireShift 4s ease-in-out infinite alternate;
  transition: width 1.5s ease, opacity 1.5s ease;
}

.bg-fire::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 90%, rgba(255, 102, 0, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(204, 51, 0, 0.3) 0%, transparent 50%);
  animation: firePulse 3s ease-in-out infinite alternate;
}

@keyframes fireShift {
  0%   { background-position: 0% 0%; }
  100% { background-position: 0% 40%; }
}

@keyframes firePulse {
  0%   { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Floating embers */
.ember {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--fire-yellow);
  border-radius: 50%;
  box-shadow: 0 0 6px 2px rgba(255, 170, 0, 0.6);
  animation: emberRise linear infinite;
  opacity: 0;
}

.ember-1 { left: 15%; animation-duration: 5s; animation-delay: 0s; }
.ember-2 { left: 35%; animation-duration: 4s; animation-delay: 1.2s; }
.ember-3 { left: 55%; animation-duration: 6s; animation-delay: 0.5s; }
.ember-4 { left: 75%; animation-duration: 4.5s; animation-delay: 2s; }
.ember-5 { left: 25%; animation-duration: 5.5s; animation-delay: 3s; width: 3px; height: 3px; }
.ember-6 { left: 65%; animation-duration: 4.2s; animation-delay: 1.8s; width: 3px; height: 3px; }

@keyframes emberRise {
  0%   { bottom: 0%; opacity: 0; transform: translateX(0); }
  10%  { opacity: 1; }
  80%  { opacity: 0.6; }
  100% { bottom: 100%; opacity: 0; transform: translateX(-30px); }
}

/* Animated flames from bottom */
.flames {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45%;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.flame {
  position: absolute;
  bottom: -10%;
  border-radius: 50% 50% 20% 20%;
  filter: blur(8px);
  opacity: 0.8;
  animation: flameRise ease-in-out infinite alternate;
}

.flame-1 {
  left: 5%;
  width: 60px;
  height: 120px;
  background: radial-gradient(ellipse at bottom, var(--fire-yellow) 0%, var(--fire-glow) 40%, var(--fire-bright) 70%, transparent 100%);
  animation-duration: 2.2s;
}

.flame-2 {
  left: 20%;
  width: 80px;
  height: 160px;
  background: radial-gradient(ellipse at bottom, #fff4c0 0%, var(--fire-yellow) 20%, var(--fire-glow) 50%, var(--fire-bright) 80%, transparent 100%);
  animation-duration: 1.8s;
  animation-delay: -0.5s;
}

.flame-3 {
  left: 38%;
  width: 55px;
  height: 110px;
  background: radial-gradient(ellipse at bottom, var(--fire-yellow) 0%, var(--fire-glow) 40%, var(--fire-mid) 80%, transparent 100%);
  animation-duration: 2.5s;
  animation-delay: -1.2s;
}

.flame-4 {
  left: 52%;
  width: 90px;
  height: 180px;
  background: radial-gradient(ellipse at bottom, #fff4c0 0%, var(--fire-yellow) 15%, var(--fire-glow) 40%, var(--fire-bright) 70%, transparent 100%);
  animation-duration: 2s;
  animation-delay: -0.3s;
}

.flame-5 {
  left: 70%;
  width: 65px;
  height: 130px;
  background: radial-gradient(ellipse at bottom, var(--fire-yellow) 0%, var(--fire-bright) 50%, var(--fire-mid) 80%, transparent 100%);
  animation-duration: 2.3s;
  animation-delay: -0.8s;
}

.flame-6 {
  left: 85%;
  width: 50px;
  height: 100px;
  background: radial-gradient(ellipse at bottom, var(--fire-yellow) 0%, var(--fire-glow) 40%, var(--fire-bright) 75%, transparent 100%);
  animation-duration: 1.9s;
  animation-delay: -1.5s;
}

.flame-7 {
  left: 12%;
  width: 45px;
  height: 95px;
  background: radial-gradient(ellipse at bottom, var(--fire-glow) 0%, var(--fire-bright) 50%, transparent 100%);
  animation-duration: 2.6s;
  animation-delay: -0.7s;
  opacity: 0.6;
}

.flame-8 {
  left: 60%;
  width: 70px;
  height: 140px;
  background: radial-gradient(ellipse at bottom, var(--fire-yellow) 0%, var(--fire-glow) 35%, var(--fire-mid) 70%, transparent 100%);
  animation-duration: 2.1s;
  animation-delay: -1s;
}

@keyframes flameRise {
  0% {
    transform: scaleY(0.8) scaleX(1) translateY(0);
    opacity: 0.7;
  }
  50% {
    transform: scaleY(1.15) scaleX(0.85) translateY(-20px);
    opacity: 0.9;
  }
  100% {
    transform: scaleY(0.9) scaleX(1.1) translateY(-10px);
    opacity: 0.75;
  }
}

/* ========================================
   Split Background — Sky (right)
   ======================================== */
.bg-sky {
  position: fixed;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  z-index: 0;
  background: linear-gradient(180deg,
    var(--sky-top) 0%,
    var(--sky-mid) 40%,
    var(--sky-light) 70%,
    var(--sky-pale) 100%);
  overflow: hidden;
  transition: width 1.5s ease, opacity 1.5s ease;
}

/* Sun */
.sun {
  position: absolute;
  top: 8%;
  left: 15%;
  width: 70px;
  height: 70px;
  background: radial-gradient(circle, #fff 30%, var(--sun-gold) 60%, rgba(249, 229, 71, 0) 100%);
  border-radius: 50%;
  box-shadow: 0 0 60px 20px rgba(249, 229, 71, 0.35);
  animation: sunPulse 5s ease-in-out infinite alternate;
}

@keyframes sunPulse {
  0%   { box-shadow: 0 0 60px 20px rgba(249, 229, 71, 0.35); }
  100% { box-shadow: 0 0 80px 30px rgba(249, 229, 71, 0.5); }
}

/* Clouds */
.cloud {
  position: absolute;
  background: var(--cloud-white);
  border-radius: 50%;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.05);
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: var(--cloud-white);
  border-radius: 50%;
}

.cloud-1 {
  width: 120px;
  height: 40px;
  top: 25%;
  left: -140px;
  animation: cloudDrift 28s linear infinite;
}
.cloud-1::before {
  width: 50px; height: 50px;
  top: -25px; left: 20px;
}
.cloud-1::after {
  width: 70px; height: 45px;
  top: -18px; left: 45px;
}

.cloud-2 {
  width: 90px;
  height: 30px;
  top: 42%;
  left: -110px;
  animation: cloudDrift 35s linear infinite;
  animation-delay: -10s;
  opacity: 0.75;
}
.cloud-2::before {
  width: 40px; height: 40px;
  top: -20px; left: 15px;
}
.cloud-2::after {
  width: 55px; height: 35px;
  top: -14px; left: 35px;
}

.cloud-3 {
  width: 140px;
  height: 45px;
  top: 60%;
  left: -160px;
  animation: cloudDrift 40s linear infinite;
  animation-delay: -22s;
  opacity: 0.6;
}
.cloud-3::before {
  width: 55px; height: 55px;
  top: -28px; left: 25px;
}
.cloud-3::after {
  width: 80px; height: 50px;
  top: -20px; left: 55px;
}

@keyframes cloudDrift {
  0%   { transform: translateX(0); }
  100% { transform: translateX(calc(100% + 60vw)); }
}

/* ========================================
   Outcome Animations — body classes
   ======================================== */

/* Correct: sky expands, fire shrinks */
body.outcome-correct .bg-sky {
  width: 80%;
}
body.outcome-correct .bg-fire {
  width: 20%;
  opacity: 0.5;
}
body.outcome-correct .sun {
  animation: sunBlast 0.8s ease-out forwards, sunPulse 3s 0.8s ease-in-out infinite alternate;
}

@keyframes sunBlast {
  0%   { transform: scale(1); box-shadow: 0 0 60px 20px rgba(249, 229, 71, 0.35); }
  50%  { transform: scale(2.5); box-shadow: 0 0 120px 60px rgba(249, 229, 71, 0.7); }
  100% { transform: scale(1.3); box-shadow: 0 0 90px 40px rgba(249, 229, 71, 0.5); }
}

/* Incorrect: fire expands, sky shrinks */
body.outcome-incorrect .bg-fire {
  width: 80%;
}
body.outcome-incorrect .bg-sky {
  width: 20%;
  opacity: 0.5;
}
body.outcome-incorrect .bg-fire::after {
  animation: fireRage 0.3s ease-in-out infinite alternate;
}

@keyframes fireRage {
  0%   { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Screen shake on incorrect */
body.shake {
  animation: shakeIt 0.6s ease-in-out;
}

@keyframes shakeIt {
  0%, 100% { transform: translateX(0); }
  10%  { transform: translateX(-8px) rotate(-0.5deg); }
  20%  { transform: translateX(8px) rotate(0.5deg); }
  30%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  50%  { transform: translateX(-4px); }
  60%  { transform: translateX(4px); }
  70%  { transform: translateX(-2px); }
  80%  { transform: translateX(2px); }
}

/* ========================================
   Quiz Card & Layout
   ======================================== */
.quiz-wrapper {
  position: relative;
  z-index: 10;
  max-width: 620px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

h1 {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 42px;
  text-align: center;
  color: #fff;
  text-shadow:
    0 2px 20px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(0, 0, 0, 0.3);
  margin-bottom: 30px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.container {
  background: var(--card-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* ========================================
   Questions
   ======================================== */
.question {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.question:last-of-type {
  border-bottom: none;
  margin-bottom: 10px;
}

.question > label {
  display: block;
  font-size: 20px;
  line-height: 1.5;
  color: var(--text-dark);
  margin-bottom: 10px;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--sky-top);
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 700;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.radio-group {
  display: flex;
  gap: 16px;
  padding-left: 34px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.55);
  transition: all 0.2s ease;
}

.radio-label:hover {
  border-color: var(--sky-mid);
  background: rgba(93, 173, 226, 0.08);
}

.radio-label input[type="radio"] {
  accent-color: var(--sky-top);
}

/* ========================================
   Buttons
   ======================================== */
.btn-submit {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--sky-top), var(--sky-mid));
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 15px rgba(26, 82, 118, 0.3);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(26, 82, 118, 0.4);
}

.btn-submit:active {
  transform: translateY(0);
}

.btn-startover {
  display: block;
  margin: 24px auto 0;
  padding: 10px 28px;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-startover:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.1);
}

/* ========================================
   Result Message
   ======================================== */
.result {
  text-align: center;
  margin-top: 20px;
}

.success {
  font-family: 'Cinzel', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--sky-top);
  animation: resultReveal 0.8s ease-out;
}

.failure {
  font-family: 'Cinzel', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--fire-bright);
  animation: resultReveal 0.8s ease-out;
}

@keyframes resultReveal {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* ========================================
   Contact Form
   ======================================== */
.contact-section {
  margin-top: 30px;
  animation: slideUp 0.7s ease-out;
}

@keyframes slideUp {
  0%   { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}

.contact-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 12px;
  padding: 30px 32px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  text-align: center;
}

.contact-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.contact-card p {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.contact-card form {
  text-align: left;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 17px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.8);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--sky-mid);
  box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.15);
}

.btn-contact {
  margin-top: 8px;
}

#contactResult {
  margin-top: 16px;
  font-size: 17px;
}

.contact-success {
  color: var(--sky-top);
  font-weight: 600;
}

.contact-error {
  color: var(--fire-bright);
  font-weight: 600;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 700px) {
  h1 {
    font-size: 28px;
  }

  .container, .contact-card {
    padding: 24px 18px;
  }

  .question > label {
    font-size: 18px;
  }

  .radio-group {
    padding-left: 34px;
  }

  .success, .failure {
    font-size: 20px;
  }
}