/* style.css - Cosmic Quiz (game-styled overlay: text never sits bare on the starfield) */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&display=swap');

:root {
  --primary-color: #ffd700; /* gold for score */
  --secondary-color: #00bfff; /* cyan for accents */
  --text-color: #ffffff;
  --panel-bg: rgba(10, 14, 38, 0.82); /* semi-transparent dark panel */
  --card-navy: #101a3d;
  --card-border: #4fc3f7;
  --font-display: 'Baloo 2', 'Comic Sans MS', 'Chalkboard SE', cursive, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-display);
  background: radial-gradient(ellipse at 20% 50%, #1a1a2e, #0a0a1a);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Game container – fills the window, centers content */
#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  padding: 2vh 4vw;
  gap: 2vh;
  z-index: 1; /* above canvas */
}

#ui-overlay {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2.5vh;
  pointer-events: none;
}
#ui-overlay > * { pointer-events: auto; }

/* Question text – large, bold white, centered on a dark rounded panel with blue glow border */
#question-text {
  font-family: var(--font-display);
  color: #ffffff;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.25;
  background: var(--panel-bg);
  border: 2px solid rgba(79, 195, 247, 0.65);
  border-radius: 20px;
  box-shadow: 0 0 18px rgba(0, 191, 255, 0.35), 0 8px 24px rgba(0, 0, 0, 0.55);
  padding: 18px 22px;
  max-width: min(92vw, 640px);
  word-wrap: break-word;
  margin-top: 8vh;
}

/* Answer choices – big rounded cards */
#answers {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 14px;
  width: min(92vw, 480px);
}

.answer-planet {
  min-height: 64px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 5vw, 1.375rem); /* ~22px for kids */
  font-weight: 800 !important;
  color: #ffffff !important; /* always bright white, every state */
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #22337a, #131c4d) !important; /* brighter card, reads against the starfield */
  border: 2px solid #7fdcff;
  border: 2px solid var(--card-border);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), inset 0 0 12px rgba(0, 191, 255, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.3s ease;
  position: relative;
}
/* white text no matter the state: normal, hover, disabled, after flash */
.answer-planet:hover,
.answer-planet:active,
.answer-planet:focus,
.answer-planet:disabled,
.answer-planet.correct,
.answer-planet.incorrect {
  color: #ffffff !important;
}
/* Real planet sprite in a glowing disc on the left (injected by game.js as .disc) */
.answer-planet .disc {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  margin-right: 12px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 12px rgba(0, 191, 255, 0.7), 0 3px 6px rgba(0, 0, 0, 0.6), inset -4px -6px 10px rgba(0, 0, 0, 0.45);
  animation: discFloat 2.4s ease-in-out infinite;
}
@keyframes discFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
}
.answer-planet .label {
  flex: 1 1 auto;
  text-align: center;
}

/* Hover / active: scale + glow (brighter card, still white text) */
.answer-planet:hover {
  transform: scale(1.04);
  background: linear-gradient(180deg, #3350c8, #1c2a80) !important;
  border-color: #9be7ff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6), 0 0 18px rgba(0, 191, 255, 0.45);
}

/* Feedback: correct glows green and pulses, wrong goes red and shakes */
.answer-planet.correct {
  background: linear-gradient(180deg, #2ecc71, #1e8449) !important;
  border-color: #00ff88;
  box-shadow: 0 0 22px rgba(0, 255, 136, 0.6), 0 6px 16px rgba(0, 0, 0, 0.5);
  animation: correctPulse 0.5s ease;
}
.answer-planet.incorrect {
  background-color: #c0392b !important;
  background-image: none !important;
  border-color: #ff5252;
  box-shadow: 0 0 22px rgba(255, 82, 82, 0.6), 0 6px 16px rgba(0, 0, 0, 0.5);
  animation: shake 0.4s ease;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* Score display – top left, white bold with dark text-shadow */
#score-display {
  position: fixed;
  top: 14px;
  left: 14px;
  color: #ffffff;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 800;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 18px;
  border-radius: 30px;
  border: 2px solid rgba(255, 215, 0, 0.4);
  z-index: 100;
  backdrop-filter: blur(2px);
}

/* Game over screen – solid dark panel card, centered */
#game-over-screen {
  display: none; /* hidden by default */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0d1330;
  border: 2px solid rgba(79, 195, 247, 0.6);
  border-radius: 24px;
  box-shadow: 0 0 30px rgba(0, 191, 255, 0.3), 0 16px 40px rgba(0, 0, 0, 0.7);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 200;
  padding: 32px 28px;
  max-width: min(90vw, 420px);
}
/* Full-dim backdrop behind the panel: covers the whole viewport so nothing shows through */
#game-over-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: -1;
}
#game-over-screen[style*="flex"] { display: flex; }

#game-over-screen.show { display: flex; }

#game-over-screen h2 {
  color: var(--primary-color);
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 44px);
  margin-bottom: 10px;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.9);
}

#game-over-screen p {
  color: var(--text-color);
  font-size: clamp(16px, 3vw, 22px);
  margin: 10px 0;
}

/* Badge name in gold */
#game-over-screen #badge-display {
  color: #ffd700;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

#play-again-btn {
  margin-top: 20px;
  padding: 12px 30px;
  background: linear-gradient(135deg, #ffeb3b, #fbc02d);
  color: #333;
  font-family: var(--font-display);
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 800;
  border: 3px solid #fff;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}

#play-again-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7), 0 0 16px rgba(255, 215, 0, 0.5);
}
#play-again-btn:active { transform: scale(0.95); }

/* Result banner color variants (game.js creates #feedback-msg) */
#feedback-msg.correct {
  border-color: #00ff88;
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.4), 0 6px 18px rgba(0, 0, 0, 0.55);
}
#feedback-msg.incorrect {
  border-color: #ff5252;
  box-shadow: 0 0 14px rgba(255, 82, 82, 0.4), 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* Big result banner (created by game.js as #feedback-msg) - fixed at bottom, always readable */
#feedback-msg {
  position: fixed;
  left: 50%;
  top: 90%;
  transform: translate(-50%, -50%) scale(0.8);
  background: #0d3a1e;
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 4.5vw, 1.7rem);
  text-align: center;
  padding: 14px 26px;
  border-radius: 18px;
  border: 3px solid #00ff88;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), 0 8px 24px rgba(0, 0, 0, 0.7);
  z-index: 300;
  max-width: 92vw;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
#feedback-msg.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}
#feedback-msg.incorrect {
  background: #3a0d0d;
  border-color: #ff5252;
  box-shadow: 0 0 20px rgba(255, 82, 82, 0.4), 0 8px 24px rgba(0, 0, 0, 0.7);
}

/* Brief red screen flash on wrong answers */
#screen-flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 40, 40, 0.35);
  pointer-events: none;
  opacity: 0;
  z-index: 90;
}
#screen-flash.go { animation: redFlash 0.35s ease; }
@keyframes redFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}


/* Responsive: fits 412px */
@media (max-width: 600px) {
  #answers { gap: 12px; }
  .answer-planet { min-height: 64px; }
  #question-text {
    margin-top: 10vh;
    padding: 14px 16px;
  }
  #score-display {
    top: 10px;
    left: 10px;
    font-size: 16px;
    padding: 6px 14px;
  }
  #game-over-screen { padding: 26px 20px; }
}

/* Accessibility: keyboard focus visible */
.answer-planet:focus,
#play-again-btn:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 4px;
}

/* Ensure canvas sits behind and doesn't capture pointer */
canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
