:root {
  --bg: #04060f;
  --panel: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.12);
  --text: #e9edf7;
  --muted: #9aa3bd;
  --accent: #ffc46b;
  --correct: #4ade80;
  --wrong: #f87171;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 50% -10%, #0a1030, var(--bg));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.layout {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s ease;
}
.loading.hide { opacity: 0; pointer-events: none; }
.loading .spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--muted); font-size: 14px; }

/* ---------- Scene ---------- */
.scene-wrap {
  position: relative;
  min-height: 55vh;
}

#scene {
  position: relative;
  height: 60vh;
  min-height: 420px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(40, 60, 120, 0.25), transparent 60%),
    linear-gradient(180deg, #03050d 0%, #070c1d 60%, #02040a 100%);
}

.starfield { position: absolute; inset: 0; }
.starfield i {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.body {
  position: absolute;
  width: clamp(280px, 40vmin, 420px);
  height: clamp(280px, 40vmin, 420px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  transition: left 1.2s cubic-bezier(0.4, 0, 0.2, 1),
              top 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: left, top;
}

#sun .sun-img,
#moon .moon-img {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
}

#sun { z-index: 3; }
#sun .sun-img {
  background-color: transparent;
  background-image: radial-gradient(circle at 35% 35%, #fff7d6, #ffcf5e 40%, #ff8c1a 72%, #c73c00 100%);
  filter: saturate(1.15) brightness(1.05);
  box-shadow:
    0 0 40px 10px rgba(255, 190, 90, 0.55),
    0 0 120px 40px rgba(255, 160, 60, 0.35);
  transition: filter 1.5s ease;
}

/* warm halo that dims when eclipse happens */
#sun::after {
  content: "";
  position: absolute;
  inset: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 90, 0.5) 0%, transparent 65%);
  filter: blur(8px);
  z-index: -1;
  transition: opacity 1.5s ease;
}

.corona {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(380px, 55vmin, 560px);
  height: clamp(380px, 55vmin, 560px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(255, 250, 235, 0) 34%,
    rgba(255, 250, 235, 0.55) 42%,
    rgba(255, 235, 180, 0.35) 52%,
    rgba(255, 200, 130, 0.15) 70%,
    transparent 85%);
  filter: blur(2px);
  opacity: 0;
  transition: opacity 1.5s ease;
  z-index: 2;
  pointer-events: none;
}

#moon { z-index: 4; }
#moon .moon-img {
  background-color: transparent;
  background-image:
    radial-gradient(circle at 30% 30%, #eef0f5, #c9cdd8 45%, #9aa0b0 70%, #6d7280 100%),
    radial-gradient(circle at 65% 55%, rgba(90,95,110,0.6) 0 12%, transparent 14%),
    radial-gradient(circle at 40% 70%, rgba(90,95,110,0.5) 0 16%, transparent 18%),
    radial-gradient(circle at 72% 25%, rgba(90,95,110,0.5) 0 10%, transparent 12%);
  transition: filter 1.5s ease;
}
/* eclipse shadow over the moon */
#moon .moon-img::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,0,0,0) 45%, rgba(0,0,0,0.85) 78%);
  opacity: 0;
  transition: opacity 1.5s ease;
}
#moon.eclipse .moon-img {
  filter: brightness(0.25) saturate(0.4);
}
#moon.eclipse .moon-img::after {
  opacity: 1;
}
/* thin sliver ring right before alignment */
#moon.eclipse .moon-img {
  box-shadow: inset 0 0 30px 8px rgba(255, 190, 90, 0.7);
}

.sun-label, .moon-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
  transition: left 1.2s cubic-bezier(0.4,0,0.2,1), top 1.2s cubic-bezier(0.4,0,0.2,1), opacity 0.6s ease;
  z-index: 5;
  pointer-events: none;
}
.sun-label { top: 50%; }
.moon-label { top: 50%; }

.status {
  position: absolute;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255, 190, 90, 0.5);
  z-index: 6;
  white-space: nowrap;
}

/* ---------- Quiz ---------- */
.quiz-wrap {
  padding: 40px 44px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.progress {
  margin-top: 14px;
  height: 8px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffd89b, var(--accent));
  transition: width 0.5s ease;
}
.score {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 26px;
  backdrop-filter: blur(6px);
}
.qtext {
  font-size: 17px;
  line-height: 1.5;
  min-height: 52px;
}
.options {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}
.option {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
  font-size: 15px;
  color: var(--text);
  text-align: left;
}
.option:hover { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.06); }
.option:active { transform: scale(0.99); }
.option .letter {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
}
.option.correct {
  border-color: var(--correct);
  background: rgba(74, 222, 128, 0.12);
}
.option.correct .letter { background: var(--correct); color: #052e16; }
.option.wrong {
  border-color: var(--wrong);
  background: rgba(248, 113, 113, 0.12);
}
.option.wrong .letter { background: var(--wrong); color: #450a0a; }
.option.disabled { cursor: default; pointer-events: none; }

.feedback {
  margin-top: 16px;
  min-height: 22px;
  font-size: 15px;
  color: var(--muted);
}
.feedback.good { color: var(--correct); }
.feedback.bad { color: var(--wrong); }

.hint-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 196, 107, 0.5);
  background: rgba(255, 196, 107, 0.08);
  font-size: 14px;
  line-height: 1.5;
  color: var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  text-align: right;
}
.actions button { flex: 1 1 auto; margin-top: 0; }
button.subtle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button.subtle:hover { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.05); }

#nextBtn, #restartBtn {
  margin-top: 6px;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(90deg, #ffb75e, #ff8c42);
  color: #231503;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}
#nextBtn:hover, #restartBtn:hover { filter: brightness(1.08); }
#nextBtn:active, #restartBtn:active { transform: scale(0.99); }

.result { text-align: center; }
.result h2 { font-size: 24px; }
.result p { margin: 12px 0 22px; color: var(--muted); line-height: 1.6; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .scene-wrap { min-height: 44vh; }
  #scene { position: relative; height: 44vh; }
  .body { width: clamp(200px, 30vh, 280px); height: clamp(200px, 30vh, 280px); }
  .corona { width: clamp(280px, 42vh, 380px); height: clamp(280px, 42vh, 380px); }
  .quiz-wrap { padding: 24px 20px; justify-content: flex-start; }
  .status { bottom: 8%; font-size: 13px; }
}
