/* === COSMIC THEME - Space Academy === */
:root {
  --bg-primary: #0a0e27;
  --bg-secondary: #141937;
  --bg-card: #1a2142;
  --text-primary: #e8eaf6;
  --text-secondary: #9fa8da;
  --accent-primary: #7c4dff;
  --accent-secondary: #448aff;
  --accent-gold: #ffd740;
  --accent-green: #69f0ae;
  --accent-red: #ff5252;
  --accent-orange: #ffab40;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

/* Stars background */
.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 90% 80%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 15% 90%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 85% 15%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 45% 75%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 60% 55%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.6), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Screens */
.screen {
  display: none;
  position: relative;
  min-height: 100vh;
  z-index: 1;
  padding: 16px;
  padding-bottom: 100px;
}

.screen.active {
  display: block;
}

/* === LOADING SCREEN === */
#loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  text-align: center;
  z-index: 2;
}

.rocket-animation {
  font-size: 64px;
  animation: rocketBounce 1.5s ease-in-out infinite;
}

@keyframes rocketBounce {
  0%, 100% { transform: translateY(0) rotate(-15deg); }
  50% { transform: translateY(-20px) rotate(-15deg); }
}

.loading-content h1 {
  font-size: 28px;
  margin: 20px 0 24px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-bar {
  width: 200px;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  margin: 0 auto 16px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 3px;
  transition: width 0.3s;
  animation: loadingProgress 2s ease-in-out forwards;
}

@keyframes loadingProgress {
  0% { width: 0%; }
  50% { width: 60%; }
  100% { width: 100%; }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
}

/* === HEADER === */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.player-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-name {
  font-weight: 600;
  font-size: 15px;
}

.player-level {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent-gold);
}

.xp-bar {
  width: 60px;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-orange));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.currency-panel {
  display: flex;
  gap: 12px;
}

.currency {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.currency-icon {
  font-size: 16px;
}

/* === SPACE MAP === */
.space-map {
  position: relative;
  z-index: 2;
}

.map-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #e8eaf6, #7c4dff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.planets-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.planet-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}

.planet-card:active {
  transform: scale(0.97);
}

.planet-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--planet-color, var(--accent-primary));
}

.planet-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: radial-gradient(circle, rgba(255,255,255,0.1), transparent);
  border: 2px solid var(--planet-color, var(--accent-primary));
  animation: planetFloat 3s ease-in-out infinite;
  flex-shrink: 0;
}

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

.planet-info {
  flex: 1;
  min-width: 0;
}

.planet-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.planet-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.planet-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
}

.planet-progress-fill {
  height: 100%;
  background: var(--planet-color, var(--accent-primary));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.planet-missions-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.planet-arrow {
  font-size: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* === STATS BAR === */
.stats-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 16px;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 10;
}

.stat-item {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-gold);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* === PLANET/MISSIONS SCREEN === */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  position: relative;
  z-index: 2;
}

.back-btn {
  background: var(--bg-card);
  border: none;
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
}

.screen-header h2 {
  flex: 1;
  font-size: 20px;
}

.planet-progress-header {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.planet-progress-header span {
  font-size: 12px;
  font-weight: 700;
}

.missions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.mission-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.2s;
  border: 1px solid rgba(255,255,255,0.05);
}

.mission-card:active {
  transform: scale(0.97);
}

.mission-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.mission-card.completed {
  border-color: var(--accent-green);
}

.mission-status-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.mission-card.completed .mission-status-icon {
  background: rgba(105, 240, 174, 0.15);
}

.mission-card.locked .mission-status-icon {
  background: rgba(255,255,255,0.05);
}

.mission-info {
  flex: 1;
}

.mission-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.mission-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.mission-reward {
  text-align: right;
  flex-shrink: 0;
}

.mission-reward span {
  display: block;
  font-size: 12px;
  color: var(--accent-gold);
}

/* === QUIZ SCREEN === */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
  z-index: 2;
}

.quiz-progress {
  flex: 1;
  margin-right: 16px;
}

.quiz-progress > span {
  font-size: 14px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.quiz-progress-bar {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 3px;
  transition: width 0.3s;
}

.quiz-score {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
}

.quiz-content {
  position: relative;
  z-index: 2;
}

.question-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.question-difficulty {
  font-size: 14px;
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

.answers-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-btn {
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.answer-btn:active {
  transform: scale(0.97);
}

.answer-btn.selected {
  border-color: var(--accent-secondary);
  background: rgba(68, 138, 255, 0.15);
}

.answer-btn.correct {
  border-color: var(--accent-green);
  background: rgba(105, 240, 174, 0.15);
  animation: correctPulse 0.5s ease;
}

.answer-btn.wrong {
  border-color: var(--accent-red);
  background: rgba(255, 82, 82, 0.15);
  animation: wrongShake 0.5s ease;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Quiz Feedback Overlay */
.quiz-feedback {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  padding: 24px;
  z-index: 20;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}

.quiz-feedback.active {
  display: block;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.feedback-content {
  text-align: center;
}

.feedback-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.feedback-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.feedback-explanation {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* === RESULTS SCREEN === */
.results-content {
  text-align: center;
  padding-top: 40px;
  position: relative;
  z-index: 2;
}

.results-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.results-content h2 {
  font-size: 24px;
  margin-bottom: 24px;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.score-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-gold);
}

.results-rewards {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
}

.reward-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.reward-item .reward-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-gold);
}

.reward-item .reward-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.results-achievements {
  margin-bottom: 24px;
}

.achievement-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(255, 215, 64, 0.15), rgba(124, 77, 255, 0.15));
  border: 1px solid var(--accent-gold);
  border-radius: 20px;
  padding: 8px 16px;
  margin: 4px;
  animation: achievementPop 0.5s ease;
}

@keyframes achievementPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.results-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* === BUTTONS === */
.btn {
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.1);
}

/* === RESPONSIVE === */
@media (min-width: 400px) {
  .answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
