/* Oxford Phonics World Enhanced Stylesheet */
:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --purple: #8B5CF6;
  --pink: #EC4899;
  --bg-main: #F0F4F8;
  --card-bg: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 14px 35px rgba(0,0,0,0.12);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background: #F8FAFC;
  color: var(--text-main);
  width: 100vw;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
}

/* App device container */
#app-container {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  background: #F8FAFC;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Full width on all mobile devices */
@media (min-width: 768px) {
  #app-container {
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid #E2E8F0;
    border-right: 1px solid #E2E8F0;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
  }
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, #4338CA 0%, #6366F1 50%, #818CF8 100%);
  color: white;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title-group h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-title-group p {
  font-size: 0.72rem;
  opacity: 0.88;
  font-weight: 500;
}

.header-stats {
  display: flex;
  gap: 8px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Viewport for all screens */
.screen-viewport {
  flex: 1 1 0%;
  height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding-bottom: 24px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Bottom Navigation Bar */
.bottom-nav {
  width: 100%;
  height: calc(68px + env(safe-area-inset-bottom, 0px));
  min-height: 68px;
  background: #FFFFFF;
  border-top: 1.5px solid #E2E8F0;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 8px;
  padding-bottom: env(safe-area-inset-bottom, 8px);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  z-index: 100;
  flex-shrink: 0;
  box-sizing: border-box;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #64748B;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 4px 14px;
  border-radius: 12px;
  flex: 1;
}

.nav-item .icon {
  font-size: 1.35rem;
  margin-bottom: 2px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-item.active {
  color: #4F46E5;
}

.nav-item.active .icon {
  transform: scale(1.15);
}

/* Level Tabs */
.level-selector-row {
  display: flex;
  padding: 12px 16px 6px;
  gap: 10px;
  background: white;
  border-bottom: 1px solid #F1F5F9;
}

.level-tab {
  flex: 1;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-tab.active {
  border-color: #4F46E5;
  background: #EEF2FF;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.level-tab .lvl-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  background: #E2E8F0;
  color: #475569;
  margin-bottom: 4px;
}

.level-tab.active .lvl-badge {
  background: #4F46E5;
  color: white;
}

.level-tab .lvl-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1E293B;
}

/* Level Overview Banner */
.level-overview-banner {
  margin: 12px 16px 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  color: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

.level-overview-banner h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.level-overview-banner p {
  font-size: 0.8rem;
  opacity: 0.9;
  line-height: 1.4;
}

/* Units list container */
.units-container {
  padding: 8px 16px 20px;
}

.section-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #475569;
  margin: 12px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.unit-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid #E2E8F0;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.unit-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #CBD5E1;
}

.unit-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--level-color, #4F46E5);
}

.unit-info {
  flex: 1;
  padding-left: 8px;
}

.unit-num-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--level-color, #4F46E5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.unit-target {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0F172A;
  margin: 2px 0;
}

.unit-phonics {
  font-size: 0.8rem;
  color: #64748B;
  font-weight: 600;
}

.unit-action-btn {
  background: #EEF2FF;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #4F46E5;
  transition: all 0.2s;
}

.unit-card:hover .unit-action-btn {
  background: #4F46E5;
  color: white;
  transform: scale(1.08);
}

/* Modal View */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: white;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px 20px 24px;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #F1F5F9;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0F172A;
}

.btn-close {
  background: #F1F5F9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  transition: background 0.2s;
}

.btn-close:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.modal-body {
  overflow-y: auto;
  padding-top: 14px;
}

/* Word Cards Grid in Study Modal */
.word-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.word-card {
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.word-card:hover {
  background: white;
  border-color: #4F46E5;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.12);
  transform: translateY(-2px);
}

.word-card-emoji {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.word-card-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0F172A;
}

.word-card-sub {
  font-size: 0.75rem;
  color: #64748B;
  font-weight: 600;
}

/* Game / Practice Mode Styles */
.game-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.game-progress-bar {
  width: 100%;
  height: 8px;
  background: #E2E8F0;
  border-radius: 4px;
  overflow: hidden;
}

.game-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4F46E5, #10B981);
  width: 0%;
  transition: width 0.3s ease;
}

.game-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 2px solid #E2E8F0;
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.word-display-box {
  font-size: 2.4rem;
  font-weight: 900;
  color: #1E293B;
  letter-spacing: 2px;
  margin: 12px 0 6px;
}

.phonics-parts {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.phonics-chip {
  background: #EEF2FF;
  color: #4F46E5;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 12px;
  border: 2px solid #C7D2FE;
  cursor: pointer;
  transition: transform 0.15s;
}

.phonics-chip:active {
  transform: scale(0.92);
}

.big-emoji-hero {
  font-size: 4.8rem;
  margin: 8px 0;
  animation: bounce 2s infinite ease-in-out;
}

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

.sound-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F1F5F9;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  margin: 6px auto;
  border: 1px solid #E2E8F0;
  transition: background 0.15s;
}

.sound-badge:hover {
  background: #E2E8F0;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.option-btn {
  background: white;
  border: 2px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 16px 10px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #1E293B;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.option-btn:hover {
  border-color: #6366F1;
  background: #F8FAFC;
}

.option-btn.correct-choice {
  background: #DCFCE7 !important;
  border-color: #22C55E !important;
  color: #15803D !important;
  animation: pulse-green 0.4s ease;
}

.option-btn.wrong-choice {
  background: #FEE2E2 !important;
  border-color: #EF4444 !important;
  color: #B91C1C !important;
  animation: shake 0.4s ease;
}

@keyframes pulse-green {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

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

.btn-primary {
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
  transition: all 0.2s;
}

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

.btn-secondary {
  background: #F1F5F9;
  color: #334155;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}

/* Flashcard mode */
.flashcard {
  perspective: 1000px;
  width: 100%;
  height: 320px;
  margin: 10px 0;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 2px solid #E2E8F0;
  background: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  border-color: #C7D2FE;
}

/* Spelling Game - Letter Blocks */
.spell-slots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.spell-slot {
  width: 46px;
  height: 52px;
  border-bottom: 3px solid #4F46E5;
  background: #F8FAFC;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: #1E293B;
}

.letter-pool {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.letter-btn {
  width: 48px;
  height: 48px;
  background: white;
  border: 2px solid #CBD5E1;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #1E293B;
  box-shadow: 0 4px 6px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: all 0.15s;
}

.letter-btn:active {
  transform: scale(0.92);
}

.letter-btn.used {
  opacity: 0.3;
  pointer-events: none;
}

/* Review / Score Overlay */
.victory-modal {
  text-align: center;
  padding: 30px 20px;
}

.victory-stars {
  font-size: 3rem;
  margin: 10px 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}
