:root {
  --navy: #080e36;
  --navy-deep: #050924;
  --card-blue: #cfe3e8;
  --dome-blue: #7aa3b4;
  --bubble-cream: #fff8dc;
  --sky-accent: #7bc8f6;
  --pink-accent: #f14a9b;
  --yellow: #ffd000;
  --orange: #ff6b1a;
  --purple-head: #8e3a78;
  --red-question: #e52d27;
  --opt-navy: #1a105a;
  --teal-shadow: #2a9d8f;
  --green-ok: #1f9d55;
  --font-display: "Coiny", "Nunito", cursive, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--navy);
  color: #161838;
  font-family: var(--font-body);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* Space Background & Canva Blobs */
.space-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 35%, #0d164d 0%, var(--navy) 65%, var(--navy-deep) 100%);
}

.stars-layer {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 18%, rgba(255, 255, 255, 0.75) 50%, transparent 100%),
    radial-gradient(2px 2px at 82% 22%, rgba(255, 255, 255, 0.7) 50%, transparent 100%),
    radial-gradient(1.5px 1.5px at 26% 74%, rgba(123, 200, 246, 0.7) 50%, transparent 100%),
    radial-gradient(2px 2px at 66% 80%, rgba(255, 255, 255, 0.55) 50%, transparent 100%),
    radial-gradient(1.5px 1.5px at 45% 12%, rgba(255, 208, 0, 0.65) 50%, transparent 100%),
    radial-gradient(2px 2px at 90% 62%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
  background-size: 420px 420px;
  opacity: 0.75;
}

.blob {
  position: absolute;
  border-radius: 44% 56% 62% 38% / 48% 36% 64% 52%;
}

.blob-yellow {
  width: 240px;
  height: 220px;
  top: -75px;
  left: -75px;
  background: var(--yellow);
}

.blob-orange {
  width: 240px;
  height: 210px;
  top: -65px;
  right: -75px;
  background: var(--orange);
  background-image: radial-gradient(rgba(255, 255, 255, 0.35) 1.5px, transparent 1.5px);
  background-size: 16px 16px;
}

.blob-pink-dots {
  width: 240px;
  height: 240px;
  bottom: -95px;
  right: -55px;
  background: #f6b6c8;
  background-image: radial-gradient(#ffffff 2px, transparent 2px);
  background-size: 14px 14px;
  opacity: 0.35;
}

.blob-mint {
  width: 200px;
  height: 180px;
  bottom: -95px;
  left: -55px;
  background: #9dd9df;
  opacity: 0.25;
}

/* HUD */
.hud {
  position: relative;
  z-index: 20;
  max-width: 1020px;
  margin: 0 auto;
  padding: 14px 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.hud-step {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1.5px solid rgba(123, 200, 246, 0.45);
  backdrop-filter: blur(6px);
}

.hud-student {
  background: var(--bubble-cream);
  color: var(--opt-navy);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

.hud-btn-sound {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.hud-btn-sound:hover {
  transform: scale(1.06);
  background: rgba(255, 255, 255, 0.24);
}

/* Stage & Screen Transitions */
.stage {
  position: relative;
  z-index: 10;
  max-width: 1000px;
  margin: 0 auto;
  padding: 8px 16px 36px;
}

.screen {
  display: none;
  animation: slideFadeIn 0.35s ease;
}

.screen.active {
  display: block;
}

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

/* Slide Banner */
.slide-banner {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.8vw, 1.9rem);
  color: #2b0f35;
  -webkit-text-stroke: 1.5px #f7a8c4;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 12px rgba(247, 168, 196, 0.55);
  margin: 4px auto 14px;
  letter-spacing: 0.5px;
}

/* Cover Screen */
.cover-wrapper {
  position: relative;
  text-align: center;
  padding-top: 4px;
}

.cover-top-title {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.7vw, 1.65rem);
  color: var(--yellow);
  margin: 0 0 14px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}

.cover-dome {
  position: relative;
  background: linear-gradient(180deg, #8ab4c4 0%, #739eb0 100%);
  border-radius: 260px 260px 32px 32px / 170px 170px 32px 32px;
  padding: 40px 28px 34px;
  max-width: 780px;
  margin: 0 auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.22);
}

.cover-deco-bulb {
  position: absolute;
  top: 22px;
  width: 50px;
  opacity: 0.9;
}

.bulb-left {
  left: -26px;
  transform: rotate(-12deg);
}

.bulb-right {
  right: -26px;
  transform: rotate(12deg);
}

.cover-main-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.2vw, 3.35rem);
  line-height: 1.12;
  color: #ef2323;
  margin: 0;
  text-shadow: 3px 3px 0 #ffffff, 0 6px 14px rgba(0, 0, 0, 0.28);
}

.cover-term {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  font-style: italic;
  color: #f6ff7a;
  margin: 8px 0 4px;
  text-shadow: 0 0 16px rgba(145, 255, 110, 0.85), 2px 3px 0 #3f7a24;
}

.cover-subject {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  color: #a6f23c;
  margin: 0 0 20px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.student-form {
  background: rgba(255, 248, 220, 0.96);
  border-radius: 24px;
  padding: 20px 22px;
  max-width: 560px;
  margin: 0 auto;
  border: 3px solid var(--sky-accent);
  box-shadow: 0 8px 0 rgba(26, 16, 90, 0.25);
  text-align: left;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--opt-navy);
}

.field .req {
  color: var(--red-question);
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2.5px solid #96cddb;
  background: #ffffff;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--opt-navy);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--pink-accent);
  box-shadow: 0 0 0 3px rgba(241, 74, 155, 0.2);
}

.form-error,
.inline-warn {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #ffe3e3;
  color: #b01818;
  font-weight: 800;
  font-size: 0.95rem;
  border: 1.5px solid #f5a3a3;
  text-align: center;
}

.cover-cony {
  width: 165px;
  margin: 12px auto 0;
  display: block;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
  animation: floatSlow 3.4s ease-in-out infinite;
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}

/* Speech Bubbles */
.speech-bubble {
  position: relative;
  background: var(--bubble-cream);
  color: #161626;
  border: 6px solid var(--sky-accent);
  outline: 3px solid var(--pink-accent);
  outline-offset: 4px;
  border-radius: 40px;
  padding: 24px 28px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
}

.speech-bubble p {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.2vw, 1.38rem);
  line-height: 1.5;
  text-align: center;
}

/* Welcome Screen */
.welcome-layout {
  position: relative;
  max-width: 780px;
  margin: 16px auto 0;
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.welcome-bubble {
  max-width: 680px;
}

.side-cony {
  width: 185px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
  animation: floatSlow 3.2s ease-in-out infinite;
}

/* Quiz Card */
.quiz-card {
  position: relative;
  background: var(--card-blue);
  border-radius: 30px;
  padding: 26px 28px 28px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.45);
}

.card-heading {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.95rem);
  color: var(--purple-head);
  text-align: center;
  margin: 0 0 8px;
}

.card-instruction {
  font-family: var(--font-display);
  font-size: clamp(0.98rem, 2vw, 1.15rem);
  color: #111111;
  text-align: center;
  margin: 0 0 12px;
}

.card-question {
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 2.3vw, 1.36rem);
  line-height: 1.45;
  color: var(--red-question);
  text-align: center;
  margin: 0 0 22px;
}

.q-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: center;
  margin-bottom: 20px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.option-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 12px 18px;
  border-radius: 18px;
  border: 3px solid rgba(26, 16, 90, 0.14);
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.1vw, 1.28rem);
  color: var(--opt-navy);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.option-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
  border-color: var(--teal-shadow);
}

.option-btn.selected {
  background: #fff9db;
  border-color: var(--teal-shadow);
  box-shadow: 0 6px 0 var(--teal-shadow);
  transform: translateY(-2px);
}

.option-box {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 2.5px solid #16233b;
  box-shadow: 3px 3px 0 var(--teal-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 1.35rem;
  font-weight: 900;
  color: #0e7c6b;
}

.option-btn.selected .option-box {
  background: #d7f9f2;
}

.q-media-box {
  background: #ffffff;
  padding: 8px;
  border-radius: 18px;
  box-shadow: 0 8px 18px rgba(8, 14, 54, 0.2);
}

.q-media-box img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  object-fit: cover;
}

/* Question 3 Passage & Inputs */
.passage-box {
  background: rgba(255, 255, 255, 0.78);
  border: 2.5px solid #96c5d1;
  border-radius: 20px;
  padding: 20px 22px;
  font-family: var(--font-display);
  font-size: clamp(1.02rem, 2.1vw, 1.26rem);
  line-height: 1.95;
  color: var(--red-question);
  margin-bottom: 18px;
}

.blank-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 4px;
  vertical-align: middle;
}

.blank-tag {
  font-family: var(--font-body);
  font-weight: 900;
  color: var(--opt-navy);
  font-size: 0.95rem;
}

.blank-input {
  min-width: 195px;
  max-width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 2.5px solid var(--opt-navy);
  background: #ffffff;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  color: var(--opt-navy);
  outline: none;
}

.blank-input:focus {
  border-color: var(--pink-accent);
  box-shadow: 0 0 0 3px rgba(241, 74, 155, 0.22);
}

.q3-hints {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.hint-card {
  margin: 0;
  background: #ffffff;
  padding: 8px;
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(8, 14, 54, 0.18);
  text-align: center;
}

.hint-card img {
  width: 100%;
  height: 155px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.hint-card figcaption {
  margin-top: 6px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--opt-navy);
}

/* Buttons */
.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  min-height: 48px;
  padding: 11px 22px;
  border-radius: 999px;
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.btn:active {
  transform: translateY(1px);
}

.btn-lg {
  width: 100%;
  min-height: 54px;
  font-size: 1.12rem;
}

.btn-primary {
  background: linear-gradient(180deg, #ff8a1f 0%, #ef4f1a 100%);
  color: #ffffff;
  box-shadow: 0 5px 0 #a32c08;
}

.btn-secondary {
  background: #ffffff;
  color: var(--opt-navy);
  border: 2px solid #94b8c4;
  box-shadow: 0 4px 0 #7fa6b4;
}

.btn-submit {
  background: linear-gradient(180deg, #27c272 0%, #159452 100%);
  color: #ffffff;
  box-shadow: 0 5px 0 #0b5d33;
}

.corner-cony {
  width: 115px;
  display: block;
  margin: 12px 0 0 auto;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

/* Reunion Screen */
.reunion-layout {
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.reunion-pair {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  align-items: end;
}

.reunion-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.reunion-bubble {
  width: 100%;
  min-height: 138px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reunion-mascot {
  width: 175px;
  max-width: 60%;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45));
  animation: floatSlow 3s ease-in-out infinite;
}

.reunion-actions {
  width: 100%;
  max-width: 400px;
}

/* Closing Screen */
.closing-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding-top: 6px;
}

.closing-bubble {
  max-width: 640px;
}

.you-did-it {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  user-select: none;
}

.ydi-you {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  color: #16d19a;
  -webkit-text-stroke: 2px #ffffff;
  text-shadow: 0 5px 0 #09684b;
}

.ydi-did {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6.5vw, 3.8rem);
  color: #ffffff;
  -webkit-text-stroke: 2px #ff8a1f;
  text-shadow: 0 5px 0 #1c6bd6;
}

.result-card {
  width: 100%;
  max-width: 780px;
  background: var(--card-blue);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.42);
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.result-student {
  margin: 0 0 8px;
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--opt-navy);
}

.result-badge {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe259, #ffa751);
  color: #4b2100;
  font-weight: 900;
  font-size: 0.96rem;
  box-shadow: 0 3px 0 rgba(120, 60, 0, 0.25);
}

.result-badge-encourage {
  background: #ffffff;
  color: var(--opt-navy);
}

.score-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--yellow);
  border: 4px solid var(--sky-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.score-num {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1;
}

.score-cap {
  font-size: 0.78rem;
  font-weight: 800;
  color: #ffffff;
}

.sync-banner {
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.94rem;
  text-align: center;
  margin-bottom: 12px;
}

.sync-banner.sync-ok {
  background: #dcfce7;
  color: #14532d;
  border: 1.5px solid #86efac;
}

.sync-banner.sync-sending {
  background: #e0f2fe;
  color: #0c4a6e;
  border: 1.5px solid #7dd3fc;
}

.sync-banner.sync-demo {
  background: #fef9c3;
  color: #713f12;
  border: 1.5px solid #fde047;
}

.sync-banner.sync-err {
  background: #fee2e2;
  color: #991b1b;
  border: 1.5px solid #fca5a5;
}

.btn-retry-sync {
  background: #ef4444;
  color: #fff;
  margin: 0 auto 14px;
  display: flex;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.review-item {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  padding: 12px 16px;
  border-left: 6px solid var(--green-ok);
}

.review-item.wrong {
  border-left-color: var(--red-question);
}

.review-q {
  margin: 0 0 4px;
  font-weight: 900;
  color: var(--opt-navy);
  font-size: 0.98rem;
}

.review-a {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: #2c344e;
}

.closing-actions {
  display: flex;
  justify-content: center;
}

.closing-mascots {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  max-width: 780px;
  margin-top: 4px;
}

.closing-friend,
.closing-cony {
  width: 140px;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
}

/* Mobile Responsive */
@media (max-width: 720px) {
  .cover-dome {
    border-radius: 42px;
    padding: 28px 16px 24px;
  }

  .cover-deco-bulb {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .quiz-card {
    padding: 20px 16px 22px;
    border-radius: 22px;
  }

  .q-split {
    grid-template-columns: 1fr;
  }

  .q-split-reverse-mobile .q-media-box {
    order: -1;
  }

  .q3-hints {
    grid-template-columns: 1fr;
  }

  .reunion-pair {
    grid-template-columns: 1fr;
  }

  .reunion-bubble {
    min-height: auto;
  }

  .blank-input {
    min-width: 155px;
    width: 100%;
  }

  .card-actions {
    flex-direction: column-reverse;
  }

  .card-actions .btn {
    width: 100%;
  }

  .corner-cony {
    width: 88px;
  }

  .closing-friend,
  .closing-cony {
    width: 105px;
  }
}
