/* PhonicQuest Design System and Styling */

:root {
  --primary-font: 'Fredoka', cursive, system-ui;
  --secondary-font: 'Quicksand', sans-serif;
  
  /* Cheerful Kid-Friendly Palette */
  --bg-gradient: linear-gradient(135deg, #eef2f7 0%, #d8e5f3 100%);
  --sky-blue: #4ea8de;
  --sky-blue-hover: #56cfe1;
  --coral-pink: #f72585;
  --royal-purple: #7209b7;
  --sunny-gold: #ffb703;
  --mint-green: #48cae4;
  --mint-green-dark: #0077b6;
  --leaf-green: #38b000;
  
  --dark-slate: #2b2d42;
  --light-slate: #8d99ae;
  
  /* Premium Glassmorphism Specs */
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  
  /* UI Layout Dimensions */
  --game-max-width: 1024px;
  --game-max-height: 768px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-drag: none;
}

body {
  font-family: var(--secondary-font);
  background: var(--bg-gradient);
  color: var(--dark-slate);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 1. Dynamic Drifting Background Bubbles */
.bubble-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.bg-bubble {
  position: absolute;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  animation: float-bubble 20s infinite ease-in-out;
}

.bg-bubble:nth-child(1) { width: 300px; height: 300px; top: -50px; left: -50px; animation-duration: 25s; }
.bg-bubble:nth-child(2) { width: 450px; height: 450px; bottom: -100px; right: -50px; animation-duration: 35s; }
.bg-bubble:nth-child(3) { width: 200px; height: 200px; top: 40%; left: 10%; animation-duration: 18s; }
.bg-bubble:nth-child(4) { width: 150px; height: 150px; bottom: 30%; left: 60%; animation-duration: 22s; }
.bg-bubble:nth-child(5) { width: 250px; height: 250px; top: 10%; right: 20%; animation-duration: 28s; }

@keyframes float-bubble {
  0%, 100% { transform: translateY(0) translateX(0) scale(1); }
  50% { transform: translateY(-40px) translateX(30px) scale(1.05); }
}

/* 2. Main Game Viewport Shell */
#app-viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: var(--game-max-width);
  max-height: var(--game-max-height);
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid var(--glass-border);
  border-radius: 32px;
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1024px), (max-height: 768px) {
  #app-viewport {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
}

/* 3. Screen Structure and Transition */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto; /* Enable safe vertical scrolling */
  animation: fade-in-screen 0.4s ease-out;
}

.screen.active {
  display: flex;
}

@keyframes fade-in-screen {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* 4. Glass Panel Component */
.glass-panel {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--glass-shadow);
  padding: 32px;
}

/* 5. Buttons Styling */
.primary-btn {
  font-family: var(--primary-font);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, var(--sky-blue-hover) 0%, var(--sky-blue) 100%);
  border: none;
  border-radius: 50px;
  padding: 16px 40px;
  cursor: pointer;
  box-shadow: 0 8px 0 #3b82c4, 0 12px 20px rgba(0,0,0,0.15);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: all 0.1s ease;
  transform: translateY(0);
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.primary-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #3b82c4, 0 4px 10px rgba(0,0,0,0.15);
}

.circle-btn {
  font-family: var(--primary-font);
  font-size: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
}

.circle-btn:hover {
  background: #fff;
  transform: scale(1.08);
}

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

/* === SPLASH SCREEN STYLE === */
#screen-splash {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(circle, #e6f2ff 0%, #cbdcf2 100%);
}

.logo-container {
  margin-bottom: 32px;
  animation: logo-bounce 2s infinite ease-in-out;
}

.logo-title {
  font-family: var(--primary-font);
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 700;
  color: var(--royal-purple);
  text-shadow: 0 4px 0 #fff, 0 8px 16px rgba(114, 9, 183, 0.15);
  letter-spacing: -2px;
}

.logo-title span {
  color: var(--coral-pink);
  text-shadow: 0 4px 0 #fff, 0 8px 16px rgba(247, 37, 133, 0.15);
}

.logo-subtitle {
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 700;
  color: #5d677a;
  margin-top: 8px;
}

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

.profile-panel {
  max-width: 480px;
  width: 100%;
}

.profile-panel h2 {
  font-family: var(--primary-font);
  font-size: 24px;
  margin-bottom: 24px;
  color: #4a5568;
}

.profile-setup {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}

#player-name {
  font-family: var(--secondary-font);
  font-size: 18px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: 16px;
  border: 2px solid #cbd5e0;
  outline: none;
  background: white;
  text-align: center;
  color: var(--dark-slate);
}

#player-name:focus {
  border-color: var(--sky-blue);
  box-shadow: 0 0 0 4px rgba(78, 168, 222, 0.25);
}

.avatar-selector h3 {
  font-size: 16px;
  color: #718096;
  margin-bottom: 12px;
}

.avatar-options {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.avatar-btn {
  font-size: 32px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  width: 60px;
  height: 60px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
}

.avatar-btn:hover {
  transform: translateY(-4px);
  border-color: var(--sky-blue);
}

.avatar-btn.active {
  background: var(--sky-blue);
  border-color: var(--sky-blue);
  transform: scale(1.1) translateY(-4px);
  box-shadow: 0 8px 16px rgba(78, 168, 222, 0.3);
}

/* === ADVENTURE MAP SCREEN STYLE === */
#screen-map {
  background: radial-gradient(circle, #f0f7ff 0%, #dbe9fa 100%);
  padding: 0;
}

.map-header {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  height: 60px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-badge {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 6px 18px 6px 12px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-avatar { font-size: 26px; }
.badge-name { font-weight: 700; font-size: 16px; color: #4a5568; }

.score-display {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 8px 20px;
  border-radius: 50px;
  font-family: var(--primary-font);
  font-size: 22px;
  font-weight: 700;
  color: #3b3a36;
}

.map-scroll-container {
  width: 100%;
  height: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
  white-space: nowrap;
  display: flex;
  align-items: center;
  scroll-behavior: smooth;
}

/* Hide scrollbar for clean look */
.map-scroll-container::-webkit-scrollbar { display: none; }
.map-scroll-container { -ms-overflow-style: none; scrollbar-width: none; }

.adventure-map {
  position: relative;
  display: inline-block;
  min-width: 1400px;
  height: 100%;
}

.map-path-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.islands-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* Island Node Style */
.map-island {
  position: absolute;
  width: 110px;
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.island-avatar-balloon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--sky-blue);
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 38px;
  transition: all 0.3s ease;
  animation: island-bob 3s infinite ease-in-out;
}

.map-island:nth-child(odd) .island-avatar-balloon { animation-delay: 0.5s; }

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

.island-label {
  font-family: var(--primary-font);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--dark-slate);
  padding: 4px 14px;
  border-radius: 20px;
  margin-top: 10px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  white-space: nowrap;
}

.map-island:hover .island-avatar-balloon {
  transform: scale(1.15) translateY(-5px);
  box-shadow: 0 15px 25px rgba(0,0,0,0.15);
}

.map-island.locked {
  cursor: not-allowed;
  opacity: 0.7;
}

.map-island.locked .island-avatar-balloon {
  background: #cbd5e0;
  border-color: #a0aec0;
  filter: grayscale(1);
}

.map-island.locked .island-label {
  background: #a0aec0;
}

/* === UNIVERSAL HUD HEADER === */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  border-bottom: 2px solid rgba(255,255,255,0.3);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.hud-level-info {
  flex-grow: 1;
  margin: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#hud-level-title {
  font-family: var(--primary-font);
  font-size: 20px;
  color: var(--dark-slate);
}

.hud-progress-container {
  height: 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.6);
}

.hud-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--sky-blue) 0%, var(--leaf-green) 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-level-stars {
  font-family: var(--primary-font);
  font-size: 20px;
  font-weight: 700;
  background: var(--sunny-gold);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(255, 183, 3, 0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.game-board {
  flex-grow: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* === GAME 1: BALLOON POP STAGE === */
.balloon-pop-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.balloon {
  position: absolute;
  width: 130px;
  height: 165px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-family: var(--primary-font);
  font-size: 24px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  box-shadow: inset -8px -8px 0 rgba(0,0,0,0.1), 0 10px 20px rgba(0,0,0,0.1);
  animation: balloon-wobble 4s infinite ease-in-out;
  transform-origin: bottom center;
}

/* Balloon string tail */
.balloon::after {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 50%;
  width: 2px;
  height: 25px;
  background: rgba(0,0,0,0.15);
  transform: translateX(-50%);
}

.balloon::before {
  content: "";
  position: absolute;
  bottom: 0px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid currentColor;
  transform: translateX(-50%);
  filter: brightness(0.9);
}

@keyframes balloon-wobble {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.prompt-card {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 14px 32px;
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
  cursor: pointer;
  animation: pulse-attention 2.5s infinite ease-in-out;
}

.prompt-icon {
  font-size: 28px;
}

.prompt-text {
  font-family: var(--primary-font);
  font-size: 20px;
  color: var(--dark-slate);
}

@keyframes pulse-attention {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* === GAME 2: DECODING SCREEN === */
.decoding-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.picture-slot {
  height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.06));
}

.picture-slot svg {
  animation: card-hover 4s infinite ease-in-out;
}

@keyframes card-hover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.bubble-rack {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 12px 0;
}

.phoneme-bubble {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--sky-blue);
  box-shadow: 0 10px 20px rgba(0,0,0,0.06), inset -4px -4px 0 rgba(0,0,0,0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--primary-font);
  font-size: 36px;
  font-weight: 700;
  color: var(--dark-slate);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.phoneme-bubble:hover {
  transform: scale(1.1);
  border-color: var(--sky-blue-hover);
}

.phoneme-bubble.active {
  animation: phoneme-pulse 0.4s ease-out;
  border-color: var(--sunny-gold);
  background: #fffdf5;
}

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

/* Color Coding for Phonemes */
.phoneme-bubble.short-vowel { border-color: #ff6b6b; background: #fff5f5; }
.phoneme-bubble.long-vowel { border-color: #f72585; background: #fff0f6; }
.phoneme-bubble.digraph { border-color: #48bb78; background: #f0fff4; }
.phoneme-bubble.magic-e { border-color: #9f7aea; background: #faf5ff; }

/* The magnet animations */
.bubble-rack.blended {
  gap: 0;
}

.bubble-rack.blended .phoneme-bubble {
  border-radius: 0;
  border-width: 4px 2px;
}

.bubble-rack.blended .phoneme-bubble:first-child {
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  border-left-width: 4px;
}

.bubble-rack.blended .phoneme-bubble:last-child {
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  border-right-width: 4px;
}

.blend-btn-container {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* === GAME 3: WORD BUILDER SCREEN === */
.builder-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.slots-rack {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 12px 0;
}

.letter-slot {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  border: 3px dashed #cbd5e0;
  background: rgba(255,255,255,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
}

.letter-slot.highlight {
  border-color: var(--sky-blue);
  background: rgba(78, 168, 222, 0.1);
  transform: scale(1.05);
}

.tiles-rack {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  background: rgba(255,255,255,0.3);
  border: 2px dashed rgba(255,255,255,0.5);
  border-radius: 24px;
  padding: 20px;
  width: 100%;
  min-height: 110px;
  margin-top: 16px;
}

.letter-tile {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  background: white;
  border: 3px solid var(--sky-blue);
  box-shadow: 0 6px 0 rgba(78, 168, 222, 0.4), 0 8px 16px rgba(0,0,0,0.06);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--primary-font);
  font-size: 32px;
  font-weight: 700;
  color: var(--dark-slate);
  cursor: grab;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.letter-tile:active {
  cursor: grabbing;
}

.letter-tile.dragging {
  opacity: 0.5;
  transform: scale(1.1);
}

.letter-tile.incorrect {
  animation: tile-shake 0.4s ease-in-out;
  border-color: var(--coral-pink);
  box-shadow: 0 6px 0 rgba(247, 37, 133, 0.4);
}

@keyframes tile-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* === VICTORY MODAL & CONFETTI === */
.victory-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(43, 45, 66, 0.5);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.victory-modal.active {
  display: flex;
}

.victory-content {
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: victory-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes victory-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.victory-crown {
  font-size: 64px;
  margin-bottom: 12px;
  animation: crown-pulse 1.5s infinite ease-in-out;
}

@keyframes crown-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(5deg); }
}

.victory-title {
  font-family: var(--primary-font);
  font-size: 36px;
  color: var(--royal-purple);
  margin-bottom: 8px;
}

#victory-subtitle {
  font-size: 18px;
  color: var(--light-slate);
  margin-bottom: 24px;
}

.star-reward-rack {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 54px;
  margin-bottom: 24px;
}

.victory-star {
  opacity: 0.2;
  transform: scale(0.5);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-block;
}

.victory-star.active {
  opacity: 1;
  transform: scale(1) rotate(360deg);
}

.victory-star.star-1 { transition-delay: 0.1s; }
.victory-star.star-2 { transition-delay: 0.3s; }
.victory-star.star-3 { transition-delay: 0.5s; }

.victory-stats {
  margin-bottom: 32px;
  font-size: 18px;
  color: var(--dark-slate);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.victory-stats span {
  font-weight: 700;
  color: var(--mint-green-dark);
}

.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99;
}

/* ==========================================================================
   5. PARALLEL READERS STYLE SHEET
   ========================================================================== */

#screen-reader {
  display: none;
  flex-direction: column;
  height: 100%;
  background: radial-gradient(circle, #f0f5fa 0%, #e2edf8 100%);
}

#screen-reader.active {
  display: flex;
}

/* Glowing book icon on the adventure map */
.btn-island-reader {
  position: absolute;
  width: 38px;
  height: 38px;
  background: #ffb703;
  border: 3px solid #fff;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 183, 3, 0.4), 0 0 0 0px rgba(255, 183, 3, 0.4);
  z-index: 10;
  transform: translate(25px, -25px); /* Offset slightly from the main island balloon */
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: pulse-book-glow 2s infinite;
}

.btn-island-reader:hover {
  transform: translate(25px, -28px) scale(1.15);
  background: #f72585;
  box-shadow: 0 6px 16px rgba(247, 37, 133, 0.5);
}

.btn-island-reader.locked {
  background: #a8dadc;
  cursor: not-allowed;
  animation: none;
  opacity: 0.5;
  box-shadow: none;
}

@keyframes pulse-book-glow {
  0% {
    box-shadow: 0 4px 12px rgba(255, 183, 3, 0.4), 0 0 0 0px rgba(255, 183, 3, 0.4);
  }
  70% {
    box-shadow: 0 4px 12px rgba(255, 183, 3, 0.4), 0 0 0 10px rgba(255, 183, 3, 0);
  }
  100% {
    box-shadow: 0 4px 12px rgba(255, 183, 3, 0.4), 0 0 0 0px rgba(255, 183, 3, 0);
  }
}

/* Landscape Book Spread Structure */
.reader-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  gap: 15px;
}

.reader-book-container {
  display: flex;
  width: 95%;
  height: 460px;
  background: #FAF8F5; /* Warm paperbook color */
  border-radius: 20px;
  box-shadow: 0 15px 40px rgba(43, 45, 66, 0.15), inset 0 0 40px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
  border: 8px solid #3c2f2f; /* Premium wooden desk border feel */
  box-sizing: border-box;
}

.reader-page {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 30px;
  box-sizing: border-box;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.left-page {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  background: linear-gradient(to right, #FAF8F5 94%, #eae6e0 100%);
}

.right-page {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  background: linear-gradient(to left, #FAF8F5 94%, #eae6e0 100%);
}

.reader-spine {
  position: absolute;
  left: 50%;
  top: 0;
  width: 14px;
  height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 25%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0) 75%, rgba(0,0,0,0.1) 100%);
  transform: translateX(-50%);
  z-index: 5;
  border-left: 1px dashed rgba(0,0,0,0.06);
  border-right: 1px dashed rgba(0,0,0,0.06);
}

.reader-illustration {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 250px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 10px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
}

.reader-illustration svg {
  max-width: 100%;
  max-height: 100%;
  height: auto;
}

.reader-text-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 12px;
  padding: 10px;
  text-align: center;
}

/* Words layout inside readers */
.reader-word {
  font-family: var(--primary-font);
  font-size: 28px;
  color: var(--dark-slate);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  border-bottom: 3px dashed transparent;
  display: inline-block;
}

.reader-word:hover {
  background-color: rgba(78, 168, 222, 0.15);
  color: var(--mint-green-dark);
  transform: scale(1.08) translateY(-2px);
  border-bottom: 3px dashed var(--sky-blue);
}

.reader-word.active-playing {
  background-color: #ffe3a8;
  color: #d48c00;
  transform: scale(1.12);
  border-bottom: 3px solid var(--sunny-gold);
  box-shadow: 0 4px 8px rgba(255, 183, 3, 0.2);
}

/* Heart Words styled inside stories */
.reader-word.heart-word {
  color: var(--coral-pink);
  font-weight: 700;
}

.reader-word.heart-word:hover {
  background-color: rgba(247, 37, 133, 0.12);
  border-bottom-color: var(--coral-pink);
}

/* Page navigation bottom rack */
.reader-navigation {
  display: flex;
  align-items: center;
  gap: 25px;
  margin-top: 5px;
}

.nav-btn {
  font-family: var(--primary-font);
  font-size: 16px;
  padding: 0 20px !important;
  width: auto !important;
  border-radius: 20px !important;
  height: 44px !important;
}

.page-indicator {
  font-family: var(--primary-font);
  font-size: 18px;
  color: var(--dark-slate);
  background: rgba(255, 255, 255, 0.8);
  padding: 6px 16px;
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

/* ==========================================================================
   6. PHONICS RPG QUEST & CUSTOMIZATION SHOP STYLES
   ========================================================================== */

/* Glowing Symmetric RPG Launcher on main Adventure Map */
.btn-island-rpg {
  position: absolute;
  width: 38px;
  height: 38px;
  background: #4cc9f0;
  border: 3px solid #fff;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(76, 201, 240, 0.4), 0 0 0 0px rgba(76, 201, 240, 0.4);
  z-index: 10;
  transform: translate(-25px, -25px); /* Positioned top-left opposite reader book */
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: pulse-rpg-glow 2s infinite;
}

.btn-island-rpg:hover {
  transform: translate(-25px, -28px) scale(1.15);
  background: #f72585;
  box-shadow: 0 6px 16px rgba(247, 37, 133, 0.5);
}

.btn-island-rpg.locked {
  background: #a8dadc;
  cursor: not-allowed;
  animation: none;
  opacity: 0.5;
  box-shadow: none;
}

@keyframes pulse-rpg-glow {
  0% {
    box-shadow: 0 4px 12px rgba(76, 201, 240, 0.4), 0 0 0 0px rgba(76, 201, 240, 0.4);
  }
  70% {
    box-shadow: 0 4px 12px rgba(76, 201, 240, 0.1), 0 0 0 8px rgba(76, 201, 240, 0);
  }
  100% {
    box-shadow: 0 4px 12px rgba(76, 201, 240, 0.4), 0 0 0 0px rgba(76, 201, 240, 0);
  }
}

/* Screen RPG Container */
#screen-rpg {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background: radial-gradient(circle, #e2eafc 0%, #c1d3fe 100%);
  padding: 15px 30px;
  height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
}

#screen-rpg.active {
  display: flex;
}

/* Viewport & Canvas Layout */
.rpg-viewport {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  flex: 1;
  margin: 10px 0;
}

#rpg-canvas {
  background: #2b9348;
  border: 5px solid #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  max-width: 90vw;
  max-height: 60vh;
  aspect-ratio: 4 / 3;
  image-rendering: pixelated;
}

/* HUD Coin Counter */
.rpg-hud-coins {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: bold;
  color: #e85d04;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

/* Mobile-Friendly Touch D-Pad */
.rpg-controls-dpad {
  position: absolute;
  bottom: 20px;
  right: 30px;
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
  z-index: 20;
}

.dpad-btn {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #ddd;
  border-radius: 12px;
  font-size: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: all 0.1s ease;
}

.dpad-btn:active {
  transform: scale(0.92);
  background: #e2eafc;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Interactive CSS Quiz Overlay */
#rpg-quiz-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#rpg-quiz-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.rpg-quiz-card {
  background: #fff;
  border-radius: 24px;
  padding: 24px 30px;
  width: 450px;
  max-width: 90%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  text-align: center;
  border: 6px solid #ffb703;
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#rpg-quiz-overlay.active .rpg-quiz-card {
  transform: scale(1);
}

.rpg-quiz-question {
  font-size: 20px;
  font-weight: bold;
  color: var(--dark-slate);
  margin-bottom: 20px;
  line-height: 1.4;
}

.rpg-quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 15px;
}

.rpg-quiz-opt {
  font-family: var(--primary-font);
  background: #f8f9fa;
  border: 3px solid #dee2e6;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rpg-quiz-opt:hover {
  background: rgba(76, 201, 240, 0.1);
  border-color: #4cc9f0;
  transform: translateY(-2px);
}

.rpg-quiz-feedback {
  min-height: 24px;
  font-size: 16px;
  font-weight: bold;
  margin-top: 10px;
}

/* Glassmorphic Avatar Customization Shop */
#rpg-shop-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#rpg-shop-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.rpg-shop-card {
  background: #fff;
  border-radius: 24px;
  padding: 24px;
  width: 520px;
  max-width: 92%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  border: 6px solid #4cc9f0;
  display: flex;
  flex-direction: column;
  max-height: 85%;
}

.rpg-shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #eee;
  padding-bottom: 12px;
  margin-bottom: 15px;
}

.rpg-shop-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  transition: color 0.2s ease;
}

.rpg-shop-close:hover {
  color: #333;
}

.rpg-shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  overflow-y: auto;
  padding: 5px;
  flex: 1;
}

.rpg-shop-item {
  border: 3px solid #eee;
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.rpg-shop-item.equipped {
  border-color: #38b000;
  background: rgba(56, 176, 0, 0.05);
}

.rpg-shop-item-icon {
  font-size: 44px;
  margin-bottom: 8px;
}

.rpg-shop-item-name {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--dark-slate);
}

.rpg-shop-item-price {
  font-size: 14px;
  color: #e85d04;
  font-weight: bold;
  margin-bottom: 10px;
}

.rpg-shop-buy-btn {
  font-family: var(--primary-font);
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 12px;
  background: #4cc9f0;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rpg-shop-buy-btn:hover {
  background: #3fbae3;
  transform: translateY(-1px);
}

.rpg-shop-buy-btn.owned {
  background: #ffb703;
}

.rpg-shop-buy-btn.equipped {
  background: #38b000;
}

/* Real-Time RPG HUD and Controls */
.rpg-hud-health {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: bold;
  color: #e63946;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  border: 2px solid #ffccd5;
  transition: all 0.2s ease;
}

.rpg-hud-ammo {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: bold;
  color: #4cc9f0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  border: 2px solid #caf0f8;
  transition: all 0.2s ease;
}

#btn-rpg-earn-ammo {
  background: linear-gradient(135deg, #ffb703 0%, #fb8500 100%);
  color: #fff;
  font-weight: bold;
  font-family: var(--primary-font);
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(251, 133, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  animation: pulse-ammo-glow 2s infinite;
}

#btn-rpg-earn-ammo:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 16px rgba(251, 133, 0, 0.5);
}

#btn-rpg-earn-ammo:active {
  transform: translateY(0) scale(0.98);
}

@keyframes pulse-ammo-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(251, 133, 0, 0.6);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(251, 133, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(251, 133, 0, 0);
  }
}


