/* ============================================================
   Space Team — styles.css
   Kid-friendly, landscape tablet, huge touch targets, no external assets.
   ============================================================ */

:root {
  --font: "Comic Sans MS", "Chalkboard SE", "Baloo", "Trebuchet MS",
          system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --touch: 72px;                 /* minimum touch target height */
  --radius: 28px;
  --gap: 18px;
  --bubble-bg: rgba(255, 255, 255, 0.95);
  --ink: #20204a;
  --good: #2ecc71;
  --good-dark: #1f9e57;
  --warn: #ff8a3d;
  --primary: #6c5ce7;
  --primary-dark: #5848c2;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #0b0c2a;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body { position: relative; }

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 40px);
  overflow: hidden;
  transition: opacity 0.4s ease;
}
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ---------- Scene backgrounds (gradients keyed by data) ---------- */
.scene-bridge {
  background: radial-gradient(circle at 30% 20%, #4a90d9 0%, #2b3a8f 45%, #141a4d 100%);
}
.scene-space {
  background: radial-gradient(circle at 70% 30%, #2d1b69 0%, #14123b 55%, #05031a 100%);
}
.scene-planet {
  background: radial-gradient(circle at 50% 75%, #ff8fcf 0%, #b15bd6 40%, #5a2d8f 100%);
}
.scene-cave {
  background: radial-gradient(circle at 40% 60%, #2bb7c7 0%, #1f5f8f 50%, #0c2240 100%);
}
.scene-stars {
  background: radial-gradient(circle at 50% 30%, #3a2d8f 0%, #1b1656 55%, #07051f 100%);
}

/* ---------- Sparkle / star layer ---------- */
.sparkle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 22%, #fff, transparent),
    radial-gradient(2px 2px at 28% 64%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 45% 18%, #fff, transparent),
    radial-gradient(2.5px 2.5px at 60% 48%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 75% 28%, #fff, transparent),
    radial-gradient(2px 2px at 85% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 18% 82%, #fff, transparent),
    radial-gradient(2px 2px at 92% 40%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 52% 86%, #fff, transparent),
    radial-gradient(2px 2px at 38% 38%, #fff, transparent);
  opacity: 0.85;
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: 0.5; }
  to   { opacity: 0.95; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: clamp(64px, 9vh, 88px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(14px, 3vw, 28px);
  background: rgba(10, 10, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
}
.star-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(26px, 4vw, 40px);
  font-weight: bold;
  color: #ffe680;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 18px;
  border-radius: 999px;
}
.star-icon { filter: drop-shadow(0 0 6px #ffd54a); }
.star-count { min-width: 1ch; }
.topbar-right { display: flex; gap: 12px; }

.icon-btn {
  min-width: 56px;
  min-height: 56px;
  font-size: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.32); }
.icon-btn:active { transform: scale(0.9); }

/* ---------- Start screen ---------- */
.start-inner, .end-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.5vh, 26px);
  max-width: 900px;
}
.start-emoji { font-size: clamp(70px, 14vw, 130px); animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-16px); }
}
.game-title {
  margin: 0;
  font-size: clamp(48px, 11vw, 120px);
  color: #fff;
  text-shadow: 0 0 18px #7c6cff, 0 6px 0 #3a2d8f;
  letter-spacing: 2px;
}
.game-subtitle, .end-message {
  margin: 0;
  font-size: clamp(22px, 4.5vw, 40px);
  color: #ffe680;
}
.start-hint { color: rgba(255,255,255,0.75); font-size: clamp(15px, 2.5vw, 22px); margin: 0; }

.big-start-btn {
  min-height: var(--touch);
  padding: clamp(18px, 3vh, 30px) clamp(28px, 5vw, 60px);
  font-family: var(--font);
  font-size: clamp(22px, 4.2vw, 40px);
  font-weight: bold;
  color: #fff;
  background: linear-gradient(180deg, #ffb14a 0%, #ff7a3d 100%);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 -6px 0 rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: pulse 2.2s ease-in-out infinite;
}
.big-start-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3), inset 0 -3px 0 rgba(0,0,0,0.18);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* ---------- Scene title flash ---------- */
.scene-title {
  position: absolute;
  z-index: 30;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(40px, 9vw, 90px);
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 22px #7c6cff, 0 6px 0 rgba(0,0,0,0.35);
  text-align: center;
  padding: 0 24px;
  animation: titleFlash 2.2s ease forwards;
}
@keyframes titleFlash {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

/* ---------- Dialogue stage ---------- */
.stage {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  width: 100%;
  max-width: 1100px;
  margin-top: clamp(60px, 9vh, 88px);
  animation: rise 0.4s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.avatar-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.avatar {
  font-size: clamp(72px, 16vw, 150px);
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.35));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-10px) rotate(2deg); }
}
.speaker-name {
  font-size: clamp(18px, 3vw, 28px);
  font-weight: bold;
  color: #fff;
  background: rgba(0,0,0,0.3);
  padding: 4px 16px;
  border-radius: 999px;
}
.bubble-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}
.speech-bubble {
  background: var(--bubble-bg);
  color: var(--ink);
  border-radius: var(--radius);
  padding: clamp(20px, 3.5vh, 36px) clamp(22px, 3.5vw, 40px);
  font-size: clamp(24px, 4.2vw, 42px);
  line-height: 1.35;
  box-shadow: var(--shadow);
  position: relative;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 16px 24px 16px 0;
  border-style: solid;
  border-color: transparent var(--bubble-bg) transparent transparent;
}

/* ---------- Controls ---------- */
.dialogue-controls, .activity-controls {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
}
.control-btn {
  min-height: var(--touch);
  flex: 1 1 auto;
  padding: 0 clamp(20px, 4vw, 40px);
  font-family: var(--font);
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: bold;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: #fff;
  box-shadow: var(--shadow), inset 0 -5px 0 rgba(0,0,0,0.18);
  transition: transform 0.12s ease;
}
.control-btn:active { transform: scale(0.95); }
.control-btn.primary   { background: linear-gradient(180deg, #7c6cff, var(--primary-dark)); }
.control-btn.secondary { background: linear-gradient(180deg, #34c6e0, #1f8fb0); }
.control-btn.go        { background: linear-gradient(180deg, #3ddc84, var(--good-dark)); }
.control-btn:disabled  { opacity: 0.4; cursor: default; transform: none; }

/* ---------- Activity ---------- */
.activity {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 1100px;
  margin-top: clamp(60px, 8vh, 80px);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  animation: rise 0.4s ease;
}
.activity-prompt {
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  border-radius: var(--radius);
  padding: clamp(18px, 3vh, 30px) clamp(22px, 3.5vw, 38px);
  font-size: clamp(22px, 4vw, 38px);
  font-weight: bold;
  text-align: center;
  box-shadow: var(--shadow);
}

/* MC options */
.options { display: flex; flex-direction: column; gap: var(--gap); }
.option-btn {
  min-height: var(--touch);
  padding: clamp(16px, 2.6vh, 26px) clamp(20px, 3vw, 34px);
  font-family: var(--font);
  font-size: clamp(20px, 3.6vw, 34px);
  font-weight: bold;
  text-align: left;
  border: 4px solid transparent;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
}
.option-btn:active { transform: scale(0.97); }
.option-btn.correct { background: #d6ffe4; border-color: var(--good); }
.option-btn.wrong   { background: #ffe0d6; border-color: var(--warn); animation: shake 0.4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Feedback line */
.feedback {
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: bold;
  text-align: center;
  padding: clamp(12px, 2vh, 20px);
  border-radius: var(--radius);
  color: #fff;
}
.feedback.good { background: rgba(46, 204, 113, 0.9); }
.feedback.try  { background: rgba(255, 138, 61, 0.9); }
.feedback.said { background: rgba(255,255,255,0.92); color: var(--ink); }

/* Mic button */
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--gap); }
.mic-btn {
  width: clamp(140px, 26vw, 200px);
  height: clamp(140px, 26vw, 200px);
  border-radius: 50%;
  border: none;
  font-family: var(--font);
  font-size: clamp(20px, 3.4vw, 30px);
  font-weight: bold;
  color: #fff;
  background: linear-gradient(180deg, #ff6b9d, #d6336c);
  box-shadow: var(--shadow), inset 0 -6px 0 rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  padding: 10px;
}
.mic-btn:active { transform: scale(0.94); }
.mic-btn.listening { animation: micPulse 1s ease-in-out infinite; background: linear-gradient(180deg, #ff8a3d, #e8590c); }
@keyframes micPulse {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,138,61,0.6); }
  50%     { transform: scale(1.06); box-shadow: 0 0 0 26px rgba(255,138,61,0); }
}

/* Writing area */
.writing-box {
  width: 100%;
  min-height: clamp(120px, 22vh, 220px);
  font-family: var(--font);
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1.4;
  color: var(--ink);
  padding: clamp(16px, 2.5vh, 24px);
  border: 4px solid #7c6cff;
  border-radius: var(--radius);
  resize: none;
  box-shadow: var(--shadow);
  -webkit-user-select: text;
  user-select: text;
}
.writing-box:focus { outline: none; border-color: var(--good); }

.checklist { display: flex; flex-direction: column; gap: 10px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: bold;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  padding: clamp(10px, 1.8vh, 16px) clamp(16px, 2.5vw, 24px);
  border-radius: var(--radius);
}
.check-item .mark { font-size: 1.3em; flex: 0 0 auto; }
.check-item.pass .mark { color: var(--good); }
.check-item.fail .mark { color: var(--warn); }

/* ---------- Reward fly-in ---------- */
.reward-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
.flying-star {
  position: fixed;
  font-size: clamp(50px, 10vw, 90px);
  filter: drop-shadow(0 0 12px #ffd54a);
  transition: all 1.1s cubic-bezier(0.4, 0.0, 0.2, 1);
  z-index: 61;
}
.reward-line {
  position: fixed;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: bold;
  padding: clamp(14px, 2.5vh, 22px) clamp(24px, 4vw, 40px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 90%;
  animation: rise 0.4s ease;
}
.star-counter.bump { animation: bump 0.5s ease; }
@keyframes bump {
  0%,100% { transform: scale(1); }
  40% { transform: scale(1.35); }
}

/* ---------- End screen ---------- */
.end-emoji { font-size: clamp(70px, 14vw, 130px); animation: float 3s ease-in-out infinite; }
.end-title {
  margin: 0;
  font-size: clamp(44px, 10vw, 100px);
  color: #fff;
  text-shadow: 0 0 18px #ffd54a, 0 6px 0 #b8860b;
}
.end-stars {
  font-size: clamp(40px, 8vw, 70px);
  letter-spacing: 6px;
  filter: drop-shadow(0 0 10px #ffd54a);
}

/* Confetti */
.confetti-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute;
  top: -10%;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  opacity: 0.9;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(115vh) rotate(720deg); opacity: 0.7; }
}

/* ---------- Landscape nudge for portrait phones/tablets ---------- */
@media (orientation: portrait) {
  .start-hint { color: #ffd54a; font-weight: bold; }
}
