:root {
  color-scheme: light;
  --bg: #fff7dc;
  --space: #9fdcff;
  --ink: #293056;
  --muted: #53607f;
  --line: rgba(90, 110, 160, 0.22);
  --cyan: #45c7f4;
  --mint: #68d391;
  --gold: #ffd45a;
  --rose: #ff7ca8;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --shadow: 0 16px 32px rgba(85, 92, 130, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 212, 90, 0.42), transparent 20rem),
    radial-gradient(circle at 84% 18%, rgba(255, 124, 168, 0.28), transparent 22rem),
    radial-gradient(circle at 48% 68%, rgba(104, 211, 145, 0.28), transparent 26rem),
    linear-gradient(180deg, #aee6ff 0%, #eaf8ff 48%, #fff7dc 100%);
  color: var(--ink);
  font-family:
    "Segoe UI",
    "Tahoma",
    "Arial",
    sans-serif;
  line-height: 1.75;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  background:
    radial-gradient(ellipse at 12% 78%, rgba(255, 255, 255, 0.94) 0 5rem, transparent 5.1rem),
    radial-gradient(ellipse at 22% 80%, rgba(255, 255, 255, 0.9) 0 7rem, transparent 7.1rem),
    radial-gradient(ellipse at 76% 84%, rgba(255, 255, 255, 0.86) 0 8rem, transparent 8.1rem);
  background-repeat: no-repeat;
  opacity: 0.72;
}

.stars,
.stars::before,
.stars::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 1.5px, transparent 2px),
    radial-gradient(circle, rgba(255, 212, 90, 0.95) 0 1.4px, transparent 2px);
  background-position:
    0 0,
    42px 74px;
  background-size:
    132px 132px,
    188px 188px;
  opacity: 0.72;
}

.stars::before {
  content: "";
  transform: scale(1.3);
  opacity: 0.34;
  animation: drift 30s linear infinite;
}

.stars::after {
  content: "";
  transform: scale(0.8);
  opacity: 0.4;
  animation: drift 42s linear infinite reverse;
}

.stars {
  overflow: hidden;
}

.stars::marker {
  content: "";
}

body::after {
  position: fixed;
  top: 14%;
  left: -12rem;
  z-index: -1;
  width: 10rem;
  height: 2px;
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), rgba(255, 212, 90, 0.35));
  filter: drop-shadow(0 0 10px rgba(255, 212, 90, 0.9));
  transform: rotate(-18deg);
  animation: shooting-star 9s ease-in-out infinite;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(69, 199, 244, 0.9);
  outline-offset: 4px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 1rem 0;
  backdrop-filter: blur(14px);
}

.brand,
.actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand {
  color: #293056;
  font-size: 0.95rem;
  font-weight: 800;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 33%, #fff8c5 0 12%, #ffd166 26%, #e46f42 58%, #652d26 100%);
  box-shadow: 0 0 28px rgba(255, 209, 102, 0.65);
}

.icon-button,
.ghost-button,
.panel-nav button {
  min-height: 3.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 0.95rem;
  color: #293056;
  font-weight: 850;
}

.icon-button[aria-pressed="true"],
.ghost-button:hover,
.icon-button:hover,
.panel-nav button:hover {
  border-color: rgba(125, 227, 255, 0.62);
  background: rgba(255, 255, 255, 0.94);
  transform: translateY(-1px);
}

main {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 1.5rem;
  min-height: 24vh;
  padding: clamp(1.4rem, 4vw, 3.4rem) 0 1.2rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.45rem;
  color: #d95783;
  font-size: 1.02rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 13ch;
  margin-bottom: 0.7rem;
  font-size: clamp(2.5rem, 5.4vw, 5rem);
  line-height: 1.02;
  letter-spacing: 0;
  text-wrap: balance;
  color: #293056;
}

.subtitle {
  max-width: 42rem;
  margin: 0;
  color: #3f4f75;
  font-size: clamp(1.15rem, 2.2vw, 1.65rem);
  font-weight: 850;
}

.student-credit,
.signature {
  display: inline-flex;
  align-items: center;
  margin: 1rem 0 0;
  padding: 0.52rem 0.86rem;
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.1);
  color: #684c00;
  font-size: 1.02rem;
  font-weight: 800;
}

.space-friend {
  position: relative;
  width: clamp(9rem, 18vw, 13rem);
  aspect-ratio: 220 / 260;
  align-self: center;
  animation: float-friend 4.6s ease-in-out infinite;
}

.ghina-character {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.ghina-body {
  transform-box: fill-box;
  transform-origin: center;
}

.ghina-head {
  transform-box: fill-box;
  transform-origin: 50% 80%;
  animation: ghina-head 4.6s ease-in-out infinite;
}

.ghina-arm-wave {
  transform-box: fill-box;
  transform-origin: 150px 152px;
}

.ghina-arm-back {
  transform-box: fill-box;
  transform-origin: 76px 153px;
}

.ghina-eyes,
.ghina-blink {
  transform-box: fill-box;
  transform-origin: center;
}

.ghina-blink {
  opacity: 0;
  animation: ghina-blink 5.2s steps(1, end) infinite;
}

.ghina-eyes {
  animation: ghina-eyes 5.2s steps(1, end) infinite;
}

.ghina-smile {
  transition: d 180ms ease;
}

.ghina-sparkles {
  opacity: 0.62;
  transform-box: fill-box;
  transform-origin: center;
}

.space-friend[data-state="welcome"] .ghina-arm-wave {
  animation: ghina-wave 1.8s ease-in-out 2;
}

.space-friend[data-state="discover"] .ghina-body {
  animation: ghina-discover 760ms ease;
}

.space-friend[data-state="discover"] .ghina-head {
  animation: ghina-nod 760ms ease;
}

.space-friend[data-state="encourage"] .ghina-head {
  animation: ghina-nod 820ms ease;
}

.space-friend[data-state="encourage"] .ghina-arm-back {
  animation: ghina-encourage 820ms ease;
}

.space-friend[data-state="celebrate"] .ghina-body {
  animation: ghina-celebrate 980ms ease;
}

.space-friend[data-state="celebrate"] .ghina-arm-wave {
  animation: ghina-fast-wave 820ms ease;
}

.space-friend[data-state="celebrate"] .ghina-sparkles {
  opacity: 1;
  animation: sparkle-pop 980ms ease;
}

.ghina-bubble {
  position: relative;
  direction: rtl;
  min-width: 15rem;
  max-width: 20rem;
  padding: 1rem 1.15rem;
  border: 2px solid rgba(255, 143, 189, 0.36);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 220, 0.92));
  box-shadow: var(--shadow);
  text-align: right;
  transform: translateY(0);
}

.ghina-bubble::before {
  position: absolute;
  top: 42%;
  right: -0.7rem;
  width: 1.1rem;
  height: 1.1rem;
  border-top: 2px solid rgba(255, 143, 189, 0.36);
  border-right: 2px solid rgba(255, 143, 189, 0.36);
  content: "";
  background: rgba(255, 255, 255, 0.94);
  transform: rotate(45deg);
}

.bubble-name,
.ghina-bubble p {
  display: block;
}

.bubble-name {
  margin-bottom: 0.18rem;
  color: #d95783;
  font-size: 0.88rem;
  font-weight: 900;
}

.ghina-bubble p {
  min-height: 3.4rem;
  margin: 0;
  color: #293056;
  font-size: 1.04rem;
  font-weight: 850;
  line-height: 1.65;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.ghina-bubble.is-changing p {
  opacity: 0;
  transform: translateY(0.35rem);
}

.experience {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 25rem);
  gap: 1rem;
  align-items: stretch;
  min-height: 650px;
}

.scene-shell,
.info-panel,
.ai-grid article,
.quiz-card,
.summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.scene-shell {
  position: relative;
  min-height: 620px;
  overflow: hidden;
}

#spaceCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  cursor: pointer;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.55), transparent 10rem),
    linear-gradient(180deg, rgba(142, 217, 255, 0.7), rgba(238, 249, 255, 0.35));
}

.scene-controls {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.ghost-button {
  padding: 0.66rem 1rem;
  color: #293056;
  font-weight: 900;
  font-size: 1rem;
}

.primary-action {
  border-color: rgba(255, 209, 102, 0.5);
  background: linear-gradient(135deg, #ffd45a, #ff9fcb);
  color: #293056;
}

.quick-fact {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  max-width: min(24rem, calc(100% - 2rem));
  padding: 0.9rem 1rem;
  border: 1px solid rgba(180, 248, 200, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #276749;
  font-size: 1.05rem;
  font-weight: 800;
  transform: translateY(0);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.quick-fact.is-fresh {
  animation: pop 360ms ease;
}

.info-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(1.05rem, 2.4vw, 1.55rem);
}

.info-panel h2 {
  margin-bottom: 0.45rem;
  font-size: clamp(2rem, 3.5vw, 3rem);
  line-height: 1.16;
  color: #293056;
}

.planet-description {
  color: #293056;
  font-size: 1.24rem;
  font-weight: 850;
}

.planet-details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 0.4rem 0 1rem;
}

.planet-details div {
  padding: 0.92rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 247, 220, 0.82);
}

.planet-details dt {
  color: #d95783;
  font-size: 0.96rem;
  font-weight: 800;
}

.planet-details dd {
  margin: 0.15rem 0 0;
  color: #293056;
  font-size: 1.08rem;
  font-weight: 800;
}

.ai-note {
  display: grid;
  grid-template-columns: 3.6rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  margin-top: auto;
  padding: 0.95rem;
  border: 1px solid rgba(125, 227, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(125, 227, 255, 0.13), rgba(180, 248, 200, 0.08));
}

.ai-note span {
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  background: rgba(69, 199, 244, 0.2);
  color: #293056;
  font-weight: 900;
  font-size: 0.95rem;
  box-shadow: 0 0 24px rgba(125, 227, 255, 0.24);
}

.ai-note p {
  margin: 0;
  color: #293056;
  font-size: 1.04rem;
  font-weight: 800;
}

.planet-progress {
  overflow: hidden;
  margin: 0.2rem 0 0.9rem;
  border: 1px solid rgba(125, 227, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}

.planet-progress span {
  display: block;
  width: var(--progress, 0%);
  height: 0.45rem;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--cyan));
  box-shadow: 0 0 18px rgba(125, 227, 255, 0.5);
}

.planet-count {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 800;
}

.panel-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.panel-nav button {
  padding: 0.68rem 0.9rem;
  font-weight: 800;
}

.ai-section {
  display: grid;
  grid-template-columns: 0.65fr 1.35fr;
  gap: clamp(1.2rem, 3vw, 2rem);
  padding: clamp(3rem, 7vw, 5rem) 0 2rem;
}

.ai-section h2,
.quiz-section h2,
.summary h2 {
  font-size: clamp(1.9rem, 3.4vw, 3rem);
  line-height: 1.2;
  color: #293056;
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.ai-grid article {
  min-height: 12rem;
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 247, 220, 0.78));
}

.ai-grid span {
  color: #d95783;
  font-size: 1.7rem;
  font-weight: 900;
}

.ai-grid h3 {
  margin: 0.35rem 0;
  font-size: 1.28rem;
}

.ai-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 700;
}

.summary {
  margin: 1rem 0 4rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  background:
    linear-gradient(135deg, rgba(255, 212, 90, 0.36), rgba(69, 199, 244, 0.2)),
    var(--panel-strong);
}

.summary p {
  max-width: 55rem;
  margin-bottom: 0;
  color: #293056;
  font-size: 1.12rem;
}

.summary .signature {
  margin-top: 1.1rem;
  color: #684c00;
  font-size: 0.95rem;
}

.quiz-section {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
  padding: 1.4rem 0 2rem;
}

.quiz-intro p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.05rem;
}

.quiz-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(1rem, 2.8vw, 1.5rem);
  background:
    radial-gradient(circle at 16% 10%, rgba(255, 212, 90, 0.3), transparent 18rem),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.quiz-question {
  margin-bottom: 1rem;
  color: #293056;
  font-size: 1.55rem;
  font-weight: 850;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.quiz-options button {
  min-height: 3.6rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: #293056;
  font-weight: 800;
  font-size: 1.08rem;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.quiz-options button:hover {
  border-color: rgba(125, 227, 255, 0.55);
  background: rgba(69, 199, 244, 0.16);
  transform: translateY(-1px);
}

.quiz-options button.is-correct {
  border-color: rgba(180, 248, 200, 0.7);
  background: rgba(180, 248, 200, 0.18);
}

.quiz-options button.is-wrong {
  border-color: rgba(255, 139, 167, 0.72);
  background: rgba(255, 139, 167, 0.16);
}

.quiz-feedback {
  min-height: 2rem;
  margin: 0.9rem 0 0;
  color: #dff7ff;
  font-weight: 800;
  font-size: 1.06rem;
}

.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-weight: 800;
}

body.presentation-mode .topbar,
body.presentation-mode .ai-section,
body.presentation-mode .quiz-section,
body.presentation-mode .summary,
body.presentation-mode .quick-fact,
body.presentation-mode .scene-controls #quickFact {
  display: none;
}

body.presentation-mode main {
  width: min(1300px, calc(100% - 24px));
}

body.presentation-mode .hero {
  min-height: auto;
  padding: 0.8rem 0;
}

body.presentation-mode .hero h1 {
  font-size: clamp(2.2rem, 4.2vw, 4.4rem);
}

body.presentation-mode .ghina-bubble {
  max-width: 24rem;
}

body.presentation-mode .experience {
  min-height: calc(100vh - 160px);
  grid-template-columns: minmax(0, 1fr) minmax(21rem, 27rem);
}

body.presentation-mode .scene-shell,
body.presentation-mode #spaceCanvas {
  min-height: calc(100vh - 160px);
}

body.presentation-mode .student-credit {
  margin-top: 0.55rem;
}

@keyframes drift {
  from {
    background-position:
      0 0,
      42px 74px;
  }

  to {
    background-position:
      132px 132px,
      230px 262px;
  }
}

@keyframes pop {
  0% {
    transform: translateY(8px) scale(0.98);
    opacity: 0.45;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes shooting-star {
  0%,
  68% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(-18deg);
  }

  72% {
    opacity: 1;
  }

  88%,
  100% {
    opacity: 0;
    transform: translate3d(130vw, 44vh, 0) rotate(-18deg);
  }
}

@keyframes float-friend {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-0.7rem);
  }
}

@keyframes ghina-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-2px) scale(1.012);
  }
}

@keyframes ghina-head {
  0%,
  100% {
    transform: rotate(-1deg);
  }

  50% {
    transform: rotate(2deg);
  }
}

@keyframes ghina-wave {
  0%,
  100% {
    transform: rotate(0deg);
  }

  35% {
    transform: rotate(-8deg);
  }

  68% {
    transform: rotate(7deg);
  }
}

@keyframes ghina-fast-wave {
  0%,
  100% {
    transform: rotate(0deg);
  }

  22% {
    transform: rotate(-18deg);
  }

  45% {
    transform: rotate(14deg);
  }

  68% {
    transform: rotate(-12deg);
  }
}

@keyframes ghina-encourage {
  0%,
  100% {
    transform: rotate(0deg);
  }

  45% {
    transform: rotate(7deg);
  }
}

@keyframes ghina-blink {
  0%,
  88%,
  94%,
  100% {
    opacity: 0;
  }

  90%,
  92% {
    opacity: 1;
  }
}

@keyframes ghina-eyes {
  0%,
  88%,
  94%,
  100% {
    opacity: 1;
  }

  90%,
  92% {
    opacity: 0;
  }
}

@keyframes sparkle-twinkle {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.62;
  }

  50% {
    transform: scale(1.06);
    opacity: 0.9;
  }
}

@keyframes sparkle-pop {
  0% {
    transform: scale(0.78);
    opacity: 0.25;
  }

  48% {
    transform: scale(1.2);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.9;
  }
}

@keyframes ghina-discover {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  42% {
    transform: translateY(-10px) scale(1.045);
  }

  72% {
    transform: translateY(3px) scale(0.99);
  }
}

@keyframes ghina-nod {
  0%,
  100% {
    transform: rotate(0deg);
  }

  36% {
    transform: rotate(-6deg);
  }

  72% {
    transform: rotate(4deg);
  }
}

@keyframes ghina-celebrate {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  28% {
    transform: translateY(-16px) scale(1.06);
  }

  56% {
    transform: translateY(4px) scale(0.99);
  }

  78% {
    transform: translateY(-7px) scale(1.025);
  }
}

@media (max-width: 960px) {
  .hero,
  .experience,
  .ai-section,
  .quiz-section {
    grid-template-columns: 1fr;
  }

  .space-friend {
    justify-self: center;
  }

  .hero {
    min-height: auto;
  }

  .ghina-bubble {
    justify-self: center;
    min-width: 0;
    width: min(100%, 30rem);
    max-width: none;
  }

  .ghina-bubble::before {
    top: -0.58rem;
    right: calc(50% - 0.55rem);
    transform: rotate(-45deg);
  }

  .scene-shell,
  #spaceCanvas {
    min-height: 560px;
  }

  .info-panel {
    min-height: auto;
  }

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

  .quiz-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    position: relative;
    flex-direction: column;
    align-items: stretch;
  }

  .brand,
  .actions {
    justify-content: space-between;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  h1 {
    font-size: clamp(2.35rem, 14vw, 3.4rem);
  }

  .scene-shell,
  #spaceCanvas {
    min-height: 500px;
  }

  .scene-controls,
  .quick-fact {
    position: static;
    margin: 0 1rem 1rem;
  }

  .scene-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .planet-details {
    grid-template-columns: 1fr;
  }

  .quiz-footer {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .ghina-blink {
    opacity: 0;
  }

  .ghina-eyes {
    opacity: 1;
  }
}
