/* ============ BASE ============ */
:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --white: #ffffff;
  --shadow: 0 4px 24px rgba(37, 99, 235, 0.15);
  --shadow-lg: 0 8px 40px rgba(37, 99, 235, 0.2);
  --radius: 20px;
  --radius-sm: 12px;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, var(--blue-50) 0%, var(--blue-100) 50%, var(--blue-200) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============ HEADER ============ */
.header {
  text-align: center;
  padding: 20px;
  background: var(--white);
  border-radius: var(--radius);
  border: 3px solid var(--blue-400);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--blue-700);
  margin-bottom: 12px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat-badge {
  background: var(--blue-100);
  color: var(--blue-700);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid var(--blue-300);
}

.progress-bar-container {
  position: relative;
  height: 24px;
  background: var(--blue-100);
  border-radius: 12px;
  border: 2px solid var(--blue-300);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-400), var(--blue-600));
  border-radius: 10px;
  transition: width 0.8s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--blue-800);
}

/* ============ SCREENS ============ */
.screen {
  display: none;
  flex: 1;
}

.screen.active {
  display: flex;
}

.screen-content {
  background: var(--white);
  border-radius: var(--radius);
  border: 3px solid var(--blue-400);
  box-shadow: var(--shadow);
  padding: 40px 30px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.screen-content h2 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--blue-700);
  line-height: 1.3;
}

.hint {
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.mascot {
  font-size: 4rem;
  line-height: 1;
  animation: bounce 2s ease-in-out infinite;
}

.mascot.big {
  font-size: 6rem;
}

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

/* ============ MIC BUTTON ============ */
.mic-button {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 4px solid var(--blue-500);
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  color: white;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.mic-button:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 48px rgba(37, 99, 235, 0.3);
}

.mic-button:active,
.mic-button.recording {
  transform: scale(0.95);
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: #ef4444;
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.2);
}

.mic-icon {
  font-size: 3rem;
}

.mic-label {
  font-size: 0.85rem;
  font-weight: 700;
}

/* Recording pulse animation */
.mic-button.recording .mic-icon {
  animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ============ TRANSCRIPT ============ */
.transcript-box {
  background: var(--blue-50);
  border: 2px solid var(--blue-300);
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  width: 100%;
  max-width: 500px;
}

.transcript-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 4px;
}

.transcript-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue-700);
}

/* ============ LOADING ============ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading p {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-600);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--blue-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ TOPICS ============ */
.topics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 500px;
}

.topic-card {
  background: var(--blue-50);
  border: 3px solid var(--blue-300);
  border-radius: var(--radius);
  padding: 24px 16px;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.topic-card:hover {
  border-color: var(--blue-500);
  background: var(--blue-100);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.topic-card:active {
  transform: translateY(0);
}

.topic-card.topic-highlight {
  border-color: var(--blue-600);
  background: var(--blue-200);
  transform: scale(1.07);
  box-shadow: 0 0 0 4px var(--blue-400), var(--shadow-lg);
  animation: topic-pulse 0.8s ease-in-out infinite;
}

@keyframes topic-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--blue-400), var(--shadow-lg); }
  50% { box-shadow: 0 0 0 8px rgba(96, 165, 250, 0.3), var(--shadow-lg); }
}

.topic-emoji {
  font-size: 2.5rem;
}

.topic-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-700);
  line-height: 1.3;
}

/* ============ WORD PRACTICE ============ */
.word-practice-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.word-practice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 500px;
}

.word-progress {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.word-progress-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue-200);
  border: 2px solid var(--blue-300);
  transition: all 0.3s ease;
}

.word-progress-dot.active {
  background: var(--blue-500);
  border-color: var(--blue-600);
  transform: scale(1.2);
}

.word-progress-dot.done {
  background: #22c55e;
  border-color: #16a34a;
}

.word-progress-dot.skipped {
  background: var(--blue-300);
  border-color: var(--blue-400);
}

.word-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  min-height: 140px;
  justify-content: center;
}

.word-main {
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--blue-800);
  transition: color 0.4s ease, transform 0.4s ease;
  line-height: 1.2;
}

.word-main.correct {
  color: #22c55e;
  transform: scale(1.1);
}

.word-syllables {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.3;
}

.word-syllables .syl-even {
  color: var(--blue-600);
}

.word-syllables .syl-odd {
  color: var(--blue-400);
}

.word-syllables .syl-sep {
  color: var(--blue-300);
  margin: 0 2px;
}

.word-listening {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.listening-mic {
  font-size: 3rem;
  animation: pulse 0.8s ease-in-out infinite;
}

.listening-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-600);
}

.word-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: successPop 0.5s ease;
}

.success-check {
  font-size: 3.5rem;
  color: #22c55e;
  font-weight: 800;
  animation: checkScale 0.4s ease;
}

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

@keyframes checkScale {
  0% { transform: scale(0) rotate(-45deg); }
  60% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.success-label {
  font-size: 1.4rem;
  font-weight: 800;
  color: #22c55e;
}

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

.encourage-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-500);
}

.word-repeat-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--blue-400);
  background: var(--blue-50);
  font-size: 1.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

.word-repeat-btn:hover {
  background: var(--blue-100);
  border-color: var(--blue-500);
  transform: scale(1.1);
}

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

/* Responsive adjustments for word practice */
@media (max-width: 600px) {
  .word-main {
    font-size: 2.4rem;
  }

  .word-syllables {
    font-size: 1.3rem;
  }

  .word-repeat-btn {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }
}

/* ============ READING ============ */
.timer-display {
  background: var(--blue-600);
  color: white;
  padding: 10px 24px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.timer-display.warning {
  background: #f59e0b;
}

.timer-display.done {
  background: #22c55e;
}

.reading-area {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reading-text {
  font-size: 1.6rem;
  line-height: 2;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  width: 100%;
  padding: 20px;
  background: var(--blue-50);
  border: 2px solid var(--blue-200);
  border-radius: var(--radius-sm);
  max-height: 50vh;
  overflow-y: auto;
}

.reading-text p {
  margin-bottom: 16px;
}

.reading-text p:last-child {
  margin-bottom: 0;
}

.done-button {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  border-radius: 40px;
  padding: 18px 48px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(34, 197, 94, 0.3);
  transition: all 0.2s ease;
}

.done-button:hover {
  transform: scale(1.05);
}

.done-button:active {
  transform: scale(0.98);
}

/* ============ CELEBRATION ============ */
.celebration {
  position: relative;
  overflow: hidden;
}

.celebration-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue-700);
  line-height: 1.5;
  max-width: 500px;
}

.stars {
  display: flex;
  gap: 8px;
}

.star {
  font-size: 2.5rem;
  animation: starPop 0.5s ease backwards;
}

.star:nth-child(1) { animation-delay: 0.1s; }
.star:nth-child(2) { animation-delay: 0.3s; }
.star:nth-child(3) { animation-delay: 0.5s; }
.star:nth-child(4) { animation-delay: 0.7s; }
.star:nth-child(5) { animation-delay: 0.9s; }

@keyframes starPop {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.next-day-button {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: white;
  border: none;
  border-radius: 40px;
  padding: 16px 40px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.next-day-button:hover {
  transform: scale(1.05);
}

/* ============ COMPLETED ============ */
.completed-stats {
  background: var(--blue-50);
  border: 2px solid var(--blue-300);
  border-radius: var(--radius-sm);
  padding: 20px;
  width: 100%;
  max-width: 400px;
}

.completed-stats p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--blue-700);
  margin-bottom: 8px;
}

/* ============ CONFETTI ============ */
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 3s ease-out forwards;
}

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

/* ============ LOGIN ============ */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--blue-100) 0%, var(--blue-200) 50%, var(--blue-300) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 3px solid var(--blue-400);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 90%;
  max-width: 380px;
}

.login-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--blue-700);
}

.login-input {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid var(--blue-300);
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: var(--blue-500);
}

.login-input::placeholder {
  color: var(--blue-300);
}

.login-button {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.login-button:hover {
  transform: scale(1.02);
}

.login-button:active {
  transform: scale(0.98);
}

.login-error {
  color: #ef4444;
  font-weight: 700;
  font-size: 0.95rem;
  min-height: 1.2em;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .screen-content {
    padding: 24px 16px;
  }

  .screen-content h2 {
    font-size: 1.3rem;
  }

  .mic-button {
    width: 130px;
    height: 130px;
  }

  .reading-text {
    font-size: 1.35rem;
    line-height: 1.9;
  }

  .topics-grid {
    grid-template-columns: 1fr;
  }

  .stat-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
  }
}
