/* Cosmo Math - Main Styles */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --yellow: #FFD600;
  --blue: #00B4D8;
  --coral: #FF6B6B;
  --mint: #06D6A0;
  --navy: #0D1B2A;
  --white: #FFFFFF;
  --gold: #FFD700;
}

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

html, body {
  font-family: 'Nunito', sans-serif;
  background: var(--navy);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Floating stars background */
.stars-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--yellow);
  border-radius: 50%;
  animation: float 15s infinite ease-in-out;
  opacity: 0.6;
}

.star:nth-child(2n) { background: var(--blue); animation-delay: -3s; }
.star:nth-child(3n) { background: var(--coral); animation-delay: -6s; }
.star:nth-child(4n) { background: var(--mint); animation-delay: -9s; }
.star:nth-child(5n) { width: 6px; height: 6px; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.3; }
  50% { transform: translateY(-100px) rotate(180deg); opacity: 0.8; }
}

/* Typography */
h1, h2, h3 {
  font-family: 'Fredoka One', cursive;
  font-weight: 400;
}

/* Container */
.container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Header */
.header {
  text-align: center;
  padding: 20px 0;
}

.greeting {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, var(--coral), #FF8E53);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}

.streak-badge .flame {
  font-size: 1.2rem;
}

/* XP Bar */
.xp-bar-container {
  background: rgba(255,255,255,0.1);
  border-radius: 15px;
  padding: 15px;
  margin: 20px 0;
}

.xp-bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.xp-bar {
  height: 12px;
  background: rgba(255,255,255,0.2);
  border-radius: 6px;
  overflow: hidden;
}

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

/* Cosmo Mascot */
.cosmo-container {
  text-align: center;
  padding: 20px 0;
}

.cosmo {
  width: 120px;
  height: 140px;
  margin: 0 auto;
  animation: bounce 2s infinite ease-in-out;
}

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

.cosmo.happy { animation: celebrate 0.5s ease; }
.cosmo.sad { animation: shake 0.5s ease; }

@keyframes celebrate {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-10deg); }
  75% { transform: scale(1.1) rotate(10deg); }
}

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

/* Module Cards */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.module-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 20px 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.module-card:hover, .module-card:active {
  transform: scale(0.98);
  border-color: var(--yellow);
}

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

.module-card.locked::after {
  content: '🔒';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
}

.module-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.module-name {
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  margin-bottom: 8px;
}

.module-stars {
  font-size: 1.2rem;
  letter-spacing: 2px;
}

/* Buttons */
.btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.2rem;
  padding: 15px 30px;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 56px;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--yellow), #FFA000);
  color: var(--navy);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--blue), #0077B6);
  color: var(--white);
}

.btn-coral {
  background: linear-gradient(135deg, var(--coral), #E63946);
  color: var(--white);
}

.btn-mint {
  background: linear-gradient(135deg, var(--mint), #04A777);
  color: var(--white);
}

/* Number Pad */
.number-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 20px auto;
}

.num-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.5rem;
  padding: 20px;
  border: none;
  border-radius: 15px;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 64px;
}

.num-btn:hover, .num-btn:active {
  background: var(--yellow);
  color: var(--navy);
  transform: scale(0.95);
}

/* Game Area */
.game-area {
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 30px 20px;
  margin: 20px 0;
  min-height: 300px;
}

.question {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 30px;
}

/* Counting objects */
.objects-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 30px 0;
  min-height: 150px;
}

.count-object {
  font-size: 3rem;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: popIn 0.5s ease;
}

.count-object:hover {
  transform: scale(1.1);
}

.count-object.popped {
  animation: popOut 0.3s ease forwards;
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes popOut {
  to { transform: scale(1.5); opacity: 0; }
}

/* Ten Frame */
.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
  max-width: 250px;
  margin: 20px auto;
}

.frame-cell {
  aspect-ratio: 1;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s;
}

.frame-cell.filled {
  background: var(--blue);
}

.frame-cell.dot::before {
  content: '';
  width: 70%;
  height: 70%;
  background: var(--coral);
  border-radius: 50%;
}

/* Number Bonds */
.bond-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 40px 0;
}

.bond-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 3px solid var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.5rem;
  position: relative;
}

.bond-circle.whole {
  width: 100px;
  height: 100px;
  background: var(--mint);
  border-color: var(--mint);
}

.bond-circle.blank {
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,214,0,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255,214,0,0); }
}

/* Timer */
.timer {
  text-align: center;
  margin: 20px 0;
}

.timer-display {
  font-family: 'Fredoka One', cursive;
  font-size: 3rem;
  color: var(--yellow);
}

.timer-bar {
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--yellow), var(--coral));
  border-radius: 4px;
  transition: width 1s linear;
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: linear-gradient(135deg, var(--navy), #1a2d3d);
  border: 2px solid var(--yellow);
  border-radius: 25px;
  padding: 40px 30px;
  text-align: center;
  max-width: 90%;
  width: 350px;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  margin-bottom: 20px;
  color: var(--yellow);
}

.modal-stars {
  font-size: 3rem;
  margin: 20px 0;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, transparent, var(--navy));
  padding: 20px;
  display: flex;
  justify-content: space-around;
  z-index: 50;
}

.nav-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 15px;
  padding: 12px 20px;
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 80px;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--yellow);
  color: var(--navy);
}

.nav-btn .icon {
  font-size: 1.5rem;
}

.nav-btn .label {
  font-size: 0.75rem;
}

/* Progress page */
.progress-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.stat-card {
  background: rgba(255,255,255,0.05);
  border-radius: 15px;
  padding: 20px 10px;
  text-align: center;
}

.stat-value {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--yellow);
}

.stat-label {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Star chart */
.star-chart {
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 20px;
  margin: 20px 0;
}

.chart-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chart-row:last-child {
  border-bottom: none;
}

.chart-label {
  flex: 1;
  font-weight: 600;
}

.chart-stars {
  font-size: 1.3rem;
  letter-spacing: 3px;
}

/* Level up animation */
.level-up-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,214,0,0.3), rgba(13,27,42,0.95));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
}

.level-up-overlay.active {
  opacity: 1;
  visibility: visible;
  animation: levelUpPulse 0.5s ease;
}

@keyframes levelUpPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.level-up-text {
  font-family: 'Fredoka One', cursive;
  font-size: 3rem;
  color: var(--yellow);
  text-shadow: 0 0 30px var(--yellow);
  animation: zoomIn 0.5s ease;
}

@keyframes zoomIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* Name input */
.name-input-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.name-input-container.hidden {
  display: none;
}

.name-input {
  font-family: 'Fredoka One', cursive;
  font-size: 1.5rem;
  padding: 15px 25px;
  border: 3px solid var(--yellow);
  border-radius: 15px;
  background: rgba(255,255,255,0.1);
  color: var(--white);
  text-align: center;
  width: 80%;
  max-width: 300px;
  margin: 20px 0;
}

.name-input::placeholder {
  color: rgba(255,255,255,0.5);
}

/* Desktop-friendly adjustments */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
    padding: 40px 20px;
  }
  
  .modules-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
  
  .module-card {
    padding: 25px;
  }
  
  .game-area {
    padding: 40px;
  }
}

/* Safe area for bottom nav */
.content-padded {
  padding-bottom: 100px;
}

/* Reading App Specific Styles */
:root {
  --amber: #FF9F1C;
}

/* Book spine module cards */
.module-card {
  background: linear-gradient(135deg, var(--amber), #FF7F00);
  border-radius: 8px 4px 4px 8px;
  transform-origin: left center;
  transition: all 0.3s ease;
  border-left: 8px solid rgba(0,0,0,0.2);
}

.module-card:hover, .module-card:active {
  transform: perspective(500px) rotateY(-5deg) scale(1.02);
}

.module-card.locked {
  background: linear-gradient(135deg, #666, #444);
  opacity: 0.6;
}

.module-card .module-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.module-card .module-name {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.9rem;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Letter tiles */
.letter-tile {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #DEB887, #CD853F);
  border: 3px solid #8B4513;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 #8B4513, 0 6px 10px rgba(0,0,0,0.3);
  transition: all 0.1s;
  color: #3E2723;
}

.letter-tile:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #8B4513, 0 2px 5px rgba(0,0,0,0.3);
}

.letter-tile.selected {
  background: linear-gradient(135deg, var(--mint), #04A777);
  border-color: #027A5E;
  box-shadow: 0 4px 0 #027A5E, 0 6px 10px rgba(0,0,0,0.3);
}

/* Word slots */
.word-slot {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.1);
  border: 3px dashed rgba(255,255,255,0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
}

.word-slot.filled {
  background: rgba(255,255,255,0.2);
  border-style: solid;
  border-color: var(--mint);
}

/* Flash card */
.flash-card {
  background: linear-gradient(135deg, #FFF8E1, #FFECB3);
  border: 4px solid var(--amber);
  border-radius: 20px;
  padding: 40px 60px;
  min-width: 200px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.flash-card .word {
  font-family: 'Fredoka One', cursive;
  font-size: 3rem;
  color: var(--navy);
}

/* Story book UI */
.story-book {
  background: linear-gradient(135deg, #FFF8E1, #F5F5DC);
  border-radius: 15px;
  padding: 30px;
  border: 8px solid #8B4513;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
}

.story-book .story-text {
  font-size: 1.4rem;
  line-height: 2;
  color: var(--navy);
  text-align: center;
}

.story-book .page-indicator {
  text-align: center;
  margin-top: 20px;
  color: #8B4513;
  font-size: 0.9rem;
}

/* Picture choices */
.picture-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.picture-choice {
  background: rgba(255,255,255,0.1);
  border: 3px solid transparent;
  border-radius: 15px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 3rem;
}

.picture-choice:hover, .picture-choice:active {
  border-color: var(--yellow);
  transform: scale(1.05);
}

.picture-choice.selected {
  border-color: var(--mint);
  background: rgba(6,214,160,0.2);
}

/* Sound buttons */
.sound-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #0077B6);
  border: none;
  color: white;
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,180,216,0.4);
  transition: all 0.2s;
}

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

.sound-btn.large {
  width: 90px;
  height: 90px;
  font-size: 1.6rem;
}

/* Progress badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--amber), #FF7F00);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Timer bar for speed reader */
.speed-timer {
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  margin: 20px auto;
  max-width: 300px;
  overflow: hidden;
}

.speed-timer-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* Question card */
.question-card {
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 25px;
  margin: 20px 0;
}

/* Countdown badge */
.countdown-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--coral), #FF8E53);
  padding: 10px 20px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 15px;
}

/* Trophy animation */
@keyframes trophyPop {
  0% { transform: scale(0) rotate(-20deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.trophy-appear {
  animation: trophyPop 0.5s ease;
}

/* Word mastered animation */
@keyframes wordFly {
  0% { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.5) translateY(-100px); opacity: 0; }
}

.word-fly {
  animation: wordFly 0.8s ease forwards;
}
