/* ==========================================================================
   Level 9 – Hint-Based Word Search Adventure 🔤🔍
   Kids Vision IQ Web Application
   Rich, vibrant aesthetics, responsive 7x8 letter grid, smooth dragging & animations
   ========================================================================== */

:root {
  --l9-bg-gradient: linear-gradient(135deg, #090B22 0%, #151945 35%, #271E56 70%, #181A42 100%);
  --l9-card-bg: rgba(255, 255, 255, 0.98);
  --l9-primary: #6366F1;
  --l9-primary-dark: #4F46E5;
  --l9-success: #10B981;
  --l9-danger: #EF4444;
  --l9-gold: #F59E0B;
  --l9-purple: #8B5CF6;
  --l9-cell-border: #CBD5E1;
  --l9-cell-bg: #F8FAFC;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  background: var(--l9-bg-gradient) !important;
  font-family: 'Fredoka', 'Plus Jakarta Sans', sans-serif;
  color: #1E293B;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
}

/* Ambient Floating Decorations */
.decor-ambient-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

.decor-twinkle {
  position: absolute;
  font-size: 1.4rem;
  animation: floatDecor 4s infinite ease-in-out;
  opacity: 0.7;
}

.dt-1 { top: 12%; left: 8%; animation-delay: 0s; font-size: 1.8rem; }
.dt-2 { top: 20%; right: 10%; animation-delay: 1.2s; font-size: 1.5rem; }
.dt-3 { top: 70%; left: 6%; animation-delay: 2.1s; font-size: 1.3rem; }
.dt-4 { top: 82%; right: 12%; animation-delay: 0.7s; font-size: 1.9rem; }
.dt-5 { top: 45%; right: 5%; animation-delay: 1.7s; font-size: 1.4rem; }

@keyframes floatDecor {
  0%, 100% { transform: translateY(0) scale(0.9); opacity: 0.5; }
  50% { transform: translateY(-8px) scale(1.15); opacity: 0.95; }
}

/* Celebration Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* Main Container */
.l9-app-container {
  width: 100%;
  width: 100% !important; max-width: 100% !important;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Header Navigation Bar
   ========================================================================== */
.l9-header-bar {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge-icon {
  font-size: 2.2rem;
  animation: bounceBadge 2.8s infinite ease-in-out;
}

@keyframes bounceBadge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.brand-text-block h1 {
  font-size: 1.35rem;
  margin: 0;
  color: #0F172A;
  font-weight: 800;
}

.brand-text-block p {
  margin: 0;
  font-size: 0.85rem;
  color: #64748B;
  font-weight: 600;
}

.header-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-pill-btn {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-sound-toggle {
  background: #F1F5F9;
  color: #334155;
  border: 1.5px solid #CBD5E1;
}

.badge-level9 {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-nav-link {
  background: #F8FAFC;
  color: #334155;
  border: 1.5px solid #CBD5E1;
}

.btn-nav-link:hover, .btn-sound-toggle:hover {
  background: #E2E8F0;
  transform: translateY(-2px);
}

/* ==========================================================================
   Top Controls Toolbar (Matching Level 7 Standard)
   ========================================================================== */
.clutter-top-toolbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #FFFFFF;
  border: 2.5px solid #E2E8F0;
  padding: 14px 20px;
  border-radius: 24px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.scene-info-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.scene-badge {
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 8px 18px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.scene-mixed-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 16px;
  font-size: 0.95rem;
  font-weight: 800;
  background: #EEF2FF;
  color: #4338CA;
  border: 2px solid #C7D2FE;
}

.difficulty-pill {
  font-size: 0.95rem;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 16px;
  border: 2px solid #A7F3D0;
  background: #ECFDF5;
  color: #047857;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.type-pill {
  font-size: 0.95rem;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 16px;
  background: #FDF4FF;
  color: #9333EA;
  border: 2px dashed #D8B4FE;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stats-pills-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #F8FAFC;
  padding: 8px 18px;
  border-radius: 18px;
  border: 2px solid #E2E8F0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.stat-pill-icon {
  font-size: 1.6rem;
}

.stat-pill-details {
  display: flex;
  flex-direction: column;
}

.stat-pill-label {
  font-size: 0.72rem;
  color: #64748B;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-pill-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #1E293B;
}

.action-controls-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-tool-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  padding: 10px 18px;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.btn-tool-action:hover {
  transform: translateY(-2px) scale(1.02);
}

.btn-prev-scene {
  background: #F1F5F9;
  color: #334155;
  border: 2px solid #CBD5E1;
}

.btn-restart-round {
  background: #E0F2FE;
  color: #0369A1;
  border: 2px solid #7DD3FC;
}

.btn-next-scene {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.35);
}

/* ==========================================================================
   Main Word Search Card
   ========================================================================== */
.wordsearch-card-main {
  background: var(--l9-card-bg);
  border-radius: 32px;
  padding: 26px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  border: 3.5px solid #CBD5E1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

/* 1. Level Title Ribbon */
.level-title-banner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.title-ribbon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ribbon-icon {
  font-size: 1.8rem;
}

.title-ribbon h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 900;
  color: #1E1B4B;
  letter-spacing: -0.5px;
}

.title-tagline {
  margin: 0;
  font-size: 0.95rem;
  color: #64748B;
  font-weight: 600;
}

/* 2. Score & 4-Min Countdown Timer Toolbar */
.l9-stats-toolbar {
  width: 100%;
  max-width: 580px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 18px;
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.stat-icon {
  font-size: 1.15rem;
}

.stat-val {
  font-weight: 900;
  font-size: 1.15rem;
  color: #0F172A;
}

.chip-score .stat-val {
  color: #D97706;
}

/* Question Number Bar (1 to 10 Palette matching Level 1) */
.q-num-bar-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F8FAFC;
  padding: 10px 16px;
  border-radius: 20px;
  border: 2px solid #E2E8F0;
  width: 100%;
  max-width: 580px;
  box-sizing: border-box;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    display: flex !important;
}

.bar-label {
  font-size: 0.88rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.num-bubbles-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 4px 2px;
  scrollbar-width: thin;
  width: 100%;
}

.num-bubble {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  color: #64748B;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.num-bubble:hover {
  border-color: #6366F1;
  color: #4F46E5;
  transform: scale(1.12);
}

.num-bubble.active {
  background: linear-gradient(135deg, #6366F1, #4F46E5) !important;
  color: #FFFFFF !important;
  border-color: #4338CA !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
  transform: scale(1.18);
}

.num-bubble.answered {
  background: #DCFCE7 !important;
  color: #15803D !important;
  border-color: #86EFAC !important;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.num-bubble.failed {
  background: #FEE2E2 !important;
  color: #B91C1C !important;
  border-color: #FCA5A5 !important;
}

/* 3. Countdown Timer (4 Minutes) */
.chip-timer {
  background: #ECFDF5;
  border-color: #A7F3D0;
  color: #065F46;
  position: relative;
  overflow: hidden;
  min-width: 145px;
  justify-content: center;
}

.timer-countdown {
  font-weight: 900;
  font-size: 1.2rem;
  color: #059669;
  min-width: 54px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timer-warning {
  background: #FFFBEB !important;
  border-color: #FDE68A !important;
}

.timer-warning .timer-countdown {
  color: #D97706 !important;
  animation: pulseTimer 1s infinite ease-in-out;
}

.timer-danger {
  background: #FEF2F2 !important;
  border-color: #FECACA !important;
}

.timer-danger .timer-countdown {
  color: #DC2626 !important;
  animation: shakeTimer 0.6s infinite ease-in-out;
}

@keyframes pulseTimer {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes shakeTimer {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* 4. Hint / Riddle Card */
.hint-riddle-card {
  width: 100%;
  max-width: 580px;
  background: #FFFFFF;
  border-radius: 24px;
  border: 3px solid #E0E7FF;
  padding: 18px 20px;
  box-shadow: 0 10px 26px rgba(99, 102, 241, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.hint-category-tag {
  background: #EEF2FF;
  color: #4F46E5;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1.5px solid #C7D2FE;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-audio-clue {
  background: #F1F5F9;
  border: 1.5px solid #CBD5E1;
  color: #334155;
  padding: 5px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-audio-clue:hover {
  background: #E2E8F0;
  transform: translateY(-1px);
}

.hint-speech-bubble {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #F8FAFC;
  border-radius: 18px;
  padding: 12px 16px;
  border: 2px solid #E2E8F0;
}

.hint-quote-mark {
  font-size: 1.6rem;
  flex-shrink: 0;
  margin-top: -2px;
}

.hint-riddle-text {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1E1B4B;
  line-height: 1.45;
  font-family: 'Fredoka', sans-serif;
}

/* Revealed Answer Badge (Appears only after correct or timeout) */
.revealed-answer-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #FEF3C7;
  border: 2px solid #FCD34D;
  padding: 8px 18px;
  border-radius: 16px;
  animation: revealPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes revealPop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.reveal-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: #B45309;
}

.reveal-word {
  font-size: 1.4rem;
  font-weight: 900;
  color: #92400E;
  letter-spacing: 1.5px;
}

.reveal-emoji {
  font-size: 1.6rem;
}

/* 6. Short Instruction Bar */
.instruction-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6366F1;
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
}

.instruction-arrow {
  font-size: 1.1rem;
}

/* Live Selection Tray */
.live-selection-tray {
  width: 100%;
  max-width: 580px;
  background: #F8FAFC;
  border-radius: 16px;
  border: 2px dashed #CBD5E1;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.tray-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #64748B;
  text-transform: uppercase;
  flex-shrink: 0;
}

.spelled-letters-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.placeholder-tip {
  font-size: 0.92rem;
  color: #94A3B8;
  font-weight: 600;
}

.spelled-letter-chip {
  background: #6366F1;
  color: #FFFFFF;
  font-weight: 800;
  font-size: 1.15rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
  animation: popChip 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popChip {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

.btn-clear-selection {
  background: #FEE2E2;
  border: 1.5px solid #FCA5A5;
  color: #DC2626;
  font-weight: 800;
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Feedback Notification Banner */
.feedback-banner {
  width: 100%;
  max-width: 580px;
  padding: 10px 18px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  transition: all 0.25s ease;
}

.feedback-ready {
  background: #F1F5F9;
  color: #475569;
  border: 1.5px solid #CBD5E1;
}

.feedback-correct {
  background: #D1FAE5;
  color: #065F46;
  border: 2px solid #34D399;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  animation: bounceCorrect 0.4s ease;
}

@keyframes bounceCorrect {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.feedback-wrong {
  background: #FEE2E2;
  color: #991B1B;
  border: 2px solid #F87171;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
  animation: shakeFeedback 0.4s ease;
}

@keyframes shakeFeedback {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.feedback-timeout {
  background: #FEF3C7;
  color: #92400E;
  border: 2px solid #FCD34D;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

/* ==========================================================================
   5. Letter Grid Arena (Exactly 7 Rows x 8 Columns = 56 Cells)
   ========================================================================== */
.grid-arena-wrapper {
  width: 100%;
  max-width: 920px;
  display: flex;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

.word-search-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-auto-rows: 60px;
  gap: 8px;
  width: 100%;
  max-width: 880px;
  background: #F8FAFC;
  padding: 16px;
  border-radius: 28px;
  border: 4px solid #818CF8;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.07), 0 16px 40px rgba(99, 102, 241, 0.22);
  touch-action: none; /* Prevents scroll while swiping across cells */
}

/* Individual Grid Cell (Equal Dimensions 56 Cells) */
.grid-cell {
  width: 100%;
  height: 60px;
  background: var(--l9-cell-bg);
  border: 2.5px solid var(--l9-cell-border);
  border-radius: 12px;
  color: #1E293B;
  font-family: 'Fredoka', 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: clamp(1.25rem, 3.4vw, 1.85rem);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 3px 0 #CBD5E1;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.grid-cell:hover {
  transform: translateY(-2px);
  border-color: #93C5FD;
  background: #EFF6FF;
}

/* Active Highlight During Drag / Selection */
.grid-cell.cell-selected {
  background: linear-gradient(135deg, #6366F1, #8B5CF6) !important;
  color: #FFFFFF !important;
  border-color: #4338CA !important;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.65), 0 3px 0 #3730A3 !important;
  transform: scale(1.06);
  z-index: 5;
}

/* Start Cell Anchor Glow */
.grid-cell.cell-start {
  border-color: #FCD34D !important;
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.8), 0 3px 0 #D97706 !important;
}

/* Correct Found State */
.grid-cell.cell-correct {
  background: linear-gradient(135deg, #10B981, #059669) !important;
  color: #FFFFFF !important;
  border-color: #047857 !important;
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.7), 0 3px 0 #064E3B !important;
  animation: cellVictoryPulse 0.8s ease-in-out infinite alternate;
  z-index: 10;
}

@keyframes cellVictoryPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* Wrong Shake State */
.grid-cell.cell-wrong {
  background: linear-gradient(135deg, #EF4444, #DC2626) !important;
  color: #FFFFFF !important;
  border-color: #B91C1C !important;
  animation: shakeCell 0.4s ease;
}

@keyframes shakeCell {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Revealed Timeout State */
.grid-cell.cell-revealed {
  background: linear-gradient(135deg, #F59E0B, #D97706) !important;
  color: #FFFFFF !important;
  border-color: #B45309 !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.7) !important;
  animation: cellRevealPulse 0.6s ease-in-out infinite alternate;
}

@keyframes cellRevealPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

/* Game Actions Row */
.game-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  flex-wrap: wrap;
  margin-top: 6px;
}

.action-btn {
  padding: 10px 22px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.95rem;
  border: 1.5px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.action-btn:hover {
  background: #E2E8F0;
  transform: translateY(-2px);
}

.btn-skip-round:hover {
  background: #FEF3C7;
  border-color: #FCD34D;
  color: #B45309;
}

/* ==========================================================================
   Victory Superstar Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.victory-card {
  background: #FFFFFF;
  border-radius: 32px;
  max-width: 480px;
  width: 100%;
  padding: 34px 24px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  border: 4px solid #F59E0B;
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.victory-trophy {
  font-size: 4rem;
  animation: trophyFloat 2s infinite ease-in-out;
}

@keyframes trophyFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

.victory-card h2 {
  font-size: 1.85rem;
  color: #1E1B4B;
  margin: 12px 0 6px 0;
  font-weight: 900;
}

.victory-card p {
  color: #64748B;
  font-size: 1rem;
  margin: 0 0 20px 0;
}

.victory-stats-box {
  display: flex;
  justify-content: center;
  gap: 24px;
  background: #F8FAFC;
  padding: 14px 20px;
  border-radius: 18px;
  border: 1.5px solid #E2E8F0;
  margin-bottom: 24px;
}

.v-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.v-label {
  font-size: 0.82rem;
  color: #64748B;
  font-weight: 700;
  text-transform: uppercase;
}

.v-val {
  font-size: 1.45rem;
  font-weight: 900;
  color: #0F172A;
}

.v-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-v-action {
  padding: 12px 20px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-v-replay {
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-v-replay:hover {
  transform: translateY(-2px);
}

.btn-v-back {
  background: #F1F5F9;
  color: #334155;
  border: 1.5px solid #CBD5E1;
}

.btn-v-back:hover {
  background: #E2E8F0;
}

/* Direction Indicator Pill (Inside Clue Header) */
.hint-direction-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  border: 1.5px solid #F59E0B;
  color: #92400E;
  padding: 5px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.hint-direction-pill .dir-icon {
  font-size: 1.05rem;
}

/* 3-Column Results Breakdown Table (Hint | Time Taken | Correct Answer) */
.results-table-scroll-container {
  width: 100%;
  max-height: 380px;
  overflow-y: auto;
  border-radius: 18px;
  border: 2px solid #E2E8F0;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04);
  margin-top: 10px;
  background: #FFFFFF;
}

.level9-results-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--l9-font-body);
  text-align: left;
  font-size: 0.92rem;
}

.level9-results-table thead {
  position: sticky;
  top: 0;
  background: #F8FAFC;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.level9-results-table th {
  padding: 12px 14px;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #E2E8F0;
}

.level9-results-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #F1F5F9;
  color: #1E293B;
  vertical-align: middle;
}

.level9-results-table tr:hover {
  background: #F8FAFC;
}

.res-hint-cell {
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.35;
}

.res-time-cell {
  font-weight: 700;
  color: #059669;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.res-time-cell.timeout {
  color: #DC2626;
  font-weight: 800;
}

.res-answer-cell {
  font-weight: 800;
  color: #4F46E5;
  white-space: nowrap;
}

.res-status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 800;
  margin-left: 6px;
}

.res-status-tag.correct {
  background: #DCFCE7;
  color: #166534;
}

.res-status-tag.wrong {
  background: #FEE2E2;
  color: #991B1B;
}

/* Responsive Adaptations */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  .l9-header-bar {
    padding: 10px 16px;
  }

  .wordsearch-card-main {
    padding: 20px 14px;
  }

  .title-ribbon h2 {
    font-size: 1.45rem;
  }

  .hint-riddle-text {
    font-size: 1.1rem;
  }

  .word-search-grid {
    gap: 5px;
    padding: 8px;
  }

  .grid-cell {
    border-radius: 8px;
    font-size: 1.15rem;
  }
}


/* FULL SCREEN EXPANSION */
body {
    width: 100vw !important;
    min-height: 100vh !important;
    margin: 0 !important;
    padding: 8px 14px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

.game-container,
.level5-container,
.level6-container,
.level7-container,
.l8-page-wrapper,
.l9-app-container,
.l10-page-container,
.level11-viewport,
.story-theater-card,
.realistic-video-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
}


/* =========================================================
   ATTRACTIVE KIDS ARCADE THEME (DISTINCT INSIDE & OUTSIDE)
   ========================================================= */
body, html {
    background: radial-gradient(circle at 12% 18%, rgba(254, 240, 138, 0.5) 0%, transparent 28%),
                radial-gradient(circle at 88% 82%, rgba(251, 207, 232, 0.45) 0%, transparent 32%),
                radial-gradient(circle at 50% 8%, rgba(147, 197, 253, 0.45) 0%, transparent 35%),
                linear-gradient(135deg, #1E40AF 0%, #4F46E5 30%, #7C3AED 60%, #C026D3 85%, #E11D48 100%) !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
}

.game-header,
.unified-header,
.l8-header,
.l10-top-bar,
.map-header-bar {
    background: linear-gradient(135deg, #FEF08A 0%, #FDE047 50%, #FACC15 100%) !important;
    border: 3.5px solid #F59E0B !important;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.35) !important;
    border-radius: 22px !important;
}
.game-header h1,
.game-header .header-left h1 {
    color: #1E1B4B !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8) !important;
}
.game-subtitle {
    color: #78350F !important;
    font-weight: 700 !important;
}

.game-card,
.coloring-studio-card,
.wordsearch-card-main,
.habitat-main-card,
.story-theater-card,
.unified-top-card,
.level7-game-card,
.l12-main-card,
.l13-civics-card,
.puzzle-expanded-container,
.clean-game-container,
.level5-container,
.level6-container,
.level7-container,
.l8-page-wrapper,
.l9-app-container,
.l10-page-container {
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 35%, #EFF6FF 80%, #E0E7FF 100%) !important;
    border: 4px solid #6366F1 !important;
    border-radius: 28px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), inset 0 2px 6px rgba(255, 255, 255, 0.95), 0 0 0 4px rgba(255, 255, 255, 0.6) !important;
}

.question-box,
.quiz-image-frame,
.memory-grid,
.puzzle-board-area,
.canvas-container,
.spot-diff-container,
.shadow-board,
.maze-canvas-wrapper,
.map-stage-wrapper,
.question-card,
.image-area-box,
.canvas-wrapper,
.maze-board-container,
.l4-puzzle-board {
    background: linear-gradient(180deg, #FFFFFF 0%, #FFFDF5 50%, #FEF9C3 100%) !important;
    border: 3px solid #FCD34D !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 24px rgba(234, 179, 8, 0.2), inset 0 2px 5px rgba(255, 255, 255, 0.9) !important;
}


/* Universally remove Play Level X Again / Play Again button */
#btn-victory-replay,
#btn-results-replay,
#btn-restart-summary,
#btn-restart-level,
#btn-restart,
.btn-v-replay,
.btn-replay-round,
.btn-replay-action,
.btn-results-replay,
.btn-restart-level,
.btn-restart {
    display: none !important;
}


/* ==========================================================================
   Level 9 - Alphabet Letter Pattern Background & Left AI Child Companion
   ========================================================================== */
.wordsearch-card-main {
    background: #FFFFFF url('/Kids/Games/level9/static/images/alphabet_pattern_light.svg?v=20261104_l9') repeat !important;
    background-size: 260px 260px !important;
    position: relative;
    border-radius: 32px;
    padding: 26px 22px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    border: 3.5px solid #CBD5E1;
}

/* 2-Column Word Search Arena Layout */
.wordsearch-arena-2col {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 32px;
    width: 100%;
    max-width: 1300px;
    margin: 8px auto 0 auto;
}

/* Left AI Child Stage */
.ai-child-stage {
    flex: 0 0 215px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    top: 20px;
}

.baby-speech-bubble {
    background: #FFFFFF;
    color: #0F172A;
    border: 2.5px solid #F59E0B;
    border-radius: 16px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    position: relative;
    animation: floatBabyBubble 2.5s ease-in-out infinite alternate;
    width: 100%;
    max-width: 200px;
}

.baby-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 7px 0;
    border-style: solid;
    border-color: #F59E0B transparent;
}

@keyframes floatBabyBubble {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

.baby-character-wrapper {
    position: relative;
    width: 190px;
    height: 330px;
    border-radius: 95px 95px 28px 28px;
    overflow: hidden;
    border: 4px solid #F59E0B;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22), 0 0 24px rgba(245, 158, 11, 0.4);
    background: #FFFFFF;
}

.baby-avatar-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    user-select: none;
}

.baby-avatar-img.hidden {
    display: none !important;
}

.baby-mood-badge {
    margin-top: 10px;
    background: #FEF3C7;
    border: 1.5px solid #F59E0B;
    color: #92400E;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

/* Animations */
/* Dance and jump on correct answer! */
.baby-jump-dance {
    animation: babyJumpDanceAnim 0.9s cubic-bezier(0.28, 0.84, 0.42, 1);
}

@keyframes babyJumpDanceAnim {
    0% { transform: translateY(0) scale(1) rotate(0deg); }
    20% { transform: translateY(-40px) scale(1.08) rotate(-4deg); }
    40% { transform: translateY(-55px) scale(1.12) rotate(4deg); }
    60% { transform: translateY(-40px) scale(1.08) rotate(-2deg); }
    80% { transform: translateY(-10px) scale(0.98) rotate(1deg); }
    100% { transform: translateY(0) scale(1) rotate(0deg); }
}

/* Sit and be sad on wrong answer! */
.baby-sit-sad {
    animation: babySitSadAnim 1.1s ease-in-out;
}

@keyframes babySitSadAnim {
    0% { transform: translateY(0) scale(1); }
    25% { transform: translateY(12px) scale(0.94) rotate(-3deg); }
    50% { transform: translateY(16px) scale(0.92) rotate(3deg); }
    75% { transform: translateY(10px) scale(0.96) rotate(-1deg); }
    100% { transform: translateY(0) scale(1); }
}

/* Cry with tears on skip round! */
.baby-cry-tears {
    animation: babyCryTearsAnim 1.2s ease-in-out;
}

@keyframes babyCryTearsAnim {
    0% { transform: translateY(0) scale(1); }
    20% { transform: translateY(10px) scale(0.96) rotate(-2deg); }
    40% { transform: translateY(14px) scale(0.94) rotate(2deg); }
    60% { transform: translateY(16px) scale(0.94) rotate(-2deg); }
    80% { transform: translateY(10px) scale(0.97) rotate(1deg); }
    100% { transform: translateY(0) scale(1); }
}

/* Right Play Column */
.wordsearch-play-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

@media (max-width: 768px) {
    .wordsearch-arena-2col {
        flex-direction: column;
        align-items: center;
    }
    .ai-child-stage {
        position: static;
        margin-bottom: 12px;
    }
}
