/* Kid-Friendly Fireworks & Alphabet Learning Styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070b1a;
  font-family: 'Fredoka', 'Comic Sans MS', system-ui, -apple-system, sans-serif;
  color: #ffffff;
}

/* Canvas fills the entire screen */
#fireworksCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  display: block;
  cursor: crosshair;
  background-color: #070b1a;
}

/* Container for keys & alphabet cards popping up */
#keyPopContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 5;
}

.key-pop {
  position: absolute;
  transform: translate(-50%, -50%) scale(0.4);
  animation: popUp 1.1s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(14, 12, 34, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 3px solid currentColor;
  border-radius: 28px;
  padding: 14px 28px;
  box-shadow: 0 0 40px currentColor, 0 8px 32px rgba(0, 0, 0, 0.7);
}

.key-char {
  font-size: 5.5rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 25px currentColor, 0 4px 10px rgba(0, 0, 0, 0.7);
}

.key-word {
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
  margin-top: 6px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

@keyframes popUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.3) rotate(-8deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -75%) scale(1.15) rotate(4deg);
  }
  70% {
    opacity: 0.95;
    transform: translate(-50%, -105%) scale(1.02) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -140%) scale(0.85);
  }
}

/* Floating Word & Emoji Pill positioned beneath the rocket-drawn letter */
.word-pop-pill {
  position: absolute;
  transform: translate(-50%, -50%) scale(0.7);
  animation: pillPop 4.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 10px 28px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.65), 0 0 20px rgba(255, 255, 255, 0.25);
  z-index: 6;
}

.pill-emoji {
  font-size: 1.85rem;
  display: inline-block;
  animation: emojiWiggle 0.6s ease infinite alternate;
}

.pill-word {
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

@keyframes pillPop {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6);
  }
  8% {
    opacity: 1;
    transform: translate(-50%, -8px) scale(1.05);
  }
  16% {
    opacity: 1;
    transform: translate(-50%, -10px) scale(1);
  }
  82% {
    opacity: 0.95;
    transform: translate(-50%, -10px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.85);
  }
}

/* UI Overlay */
.ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
}

/* Parent Controls Header */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.logo-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #a1c4fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.control-btn {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

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

.control-btn.active {
  background: linear-gradient(135deg, #ff007f, #7928ca);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 16px rgba(255, 0, 127, 0.6);
}

/* Clear layman-friendly voice mode toggle button styling */
.speech-style-btn {
  border: 1px solid rgba(255, 209, 102, 0.45);
  background: rgba(255, 209, 102, 0.12);
  transition: all 0.25s ease;
}

.speech-style-btn:hover {
  background: rgba(255, 209, 102, 0.22);
  border-color: #ffd166;
}

.speech-style-btn.phonics-active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(59, 130, 246, 0.25));
  border-color: rgba(52, 211, 153, 0.65);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.mode-switch-hint {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffd166;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
}

.speech-style-btn.phonics-active .mode-switch-hint {
  color: #a7f3d0;
  border-color: rgba(167, 243, 208, 0.4);
  background: rgba(16, 185, 129, 0.2);
}

.speech-style-btn:hover .mode-switch-hint {
  background: rgba(255, 209, 102, 0.35);
  transform: scale(1.05);
}



.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 75px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffcc00;
  cursor: pointer;
  box-shadow: 0 0 8px #ffcc00;
}

/* Center Hint Banner */
.hint-banner {
  align-self: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(56, 189, 248, 0.6);
  padding: 14px 28px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(2, 132, 199, 0.35);
  transition: opacity 0.8s ease, transform 0.8s ease;
  animation: gentlePulse 2.5s infinite ease-in-out;
  pointer-events: auto;
}

.hint-banner.faded {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(-16px) scale(0.9);
}

.hint-banner:hover {
  opacity: 1;
}

.hint-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #7dd3fc;
  text-shadow: 0 0 12px rgba(125, 211, 252, 0.8);
  margin-bottom: 4px;
}

.hint-subtitle {
  font-size: 0.95rem;
  color: #e0e6ed;
}

@keyframes gentlePulse {
  0%, 100% {
    transform: scale(1);
    border-color: rgba(56, 189, 248, 0.4);
  }
  50% {
    transform: scale(1.02);
    border-color: rgba(56, 189, 248, 0.9);
  }
}

/* Kid Button Toolbar at Bottom */
.button-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  pointer-events: auto;
}

.kid-btn {
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.kid-btn:hover {
  transform: translateY(-4px) scale(1.05);
}

.kid-btn:active {
  transform: translateY(2px) scale(0.95);
}

.btn-emoji {
  font-size: 1.4rem;
}

/* Vibrant Kid-Themed Gradients */
.btn-rocket {
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  box-shadow: 0 8px 25px rgba(255, 65, 108, 0.5);
}

.btn-rainbow {
  background: linear-gradient(135deg, #8a2387, #e94057, #f27121);
  box-shadow: 0 8px 25px rgba(233, 64, 87, 0.5);
}

.btn-heart {
  background: linear-gradient(135deg, #f857a6, #ff5858);
  box-shadow: 0 8px 25px rgba(248, 87, 166, 0.5);
}

.btn-star {
  background: linear-gradient(135deg, #f7971e, #ffd200);
  color: #3b2800;
  box-shadow: 0 8px 25px rgba(255, 210, 0, 0.5);
}

.btn-willow {
  background: linear-gradient(135deg, #11998e, #38ef7d);
  box-shadow: 0 8px 25px rgba(56, 239, 125, 0.5);
}

.btn-finale {
  background: linear-gradient(135deg, #654ea3, #eaafc8);
  box-shadow: 0 8px 25px rgba(101, 78, 163, 0.6);
  animation: finaleGlow 2s infinite alternate;
}

@keyframes finaleGlow {
  0% {
    box-shadow: 0 8px 25px rgba(101, 78, 163, 0.5);
  }
  100% {
    box-shadow: 0 8px 35px rgba(255, 0, 128, 0.8), 0 0 20px rgba(255, 215, 0, 0.6);
  }
}

/* ======================================================
   On-Screen Virtual Keypad for Mobile & Touch Screens
   ====================================================== */
.virtual-keypad {
  pointer-events: auto;
  align-self: center;
  width: 100%;
  max-width: 640px;
  background: rgba(14, 16, 36, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  padding: 10px 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(139, 92, 246, 0.2);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  z-index: 20;
  margin-top: auto;
}

.virtual-keypad.hidden {
  display: none !important;
}

/* Keypad Header with Mode Tabs & Minimize Button */
.keypad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.keypad-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.keypad-tab {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.keypad-tab:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.keypad-tab.active {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  border-color: rgba(255, 255, 255, 0.45);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.5);
}

.keypad-case-toggle {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 5px 10px;
}

.keypad-collapse-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.keypad-collapse-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
}

/* Keypad Keys Grid Layout */
.keypad-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keypad-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

.keypad-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  color: #ffffff;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.1s ease, border-color 0.1s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  padding: 3px 2px;
}

.keypad-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}

.keypad-btn:active,
.keypad-btn.key-pressed {
  transform: scale(0.91) translateY(2px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.18));
  border-color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.7);
}

.key-label {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.key-sub {
  font-size: 0.72rem;
  line-height: 1;
  margin-top: 3px;
  opacity: 0.95;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Vibrantly Tinted Kid Columns for Easy Recognition */
.key-tint-1 {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.26), rgba(239, 68, 68, 0.12));
  border-color: rgba(244, 63, 94, 0.45);
  color: #ffe4e6;
}
.key-tint-2 {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.26), rgba(245, 158, 11, 0.12));
  border-color: rgba(249, 115, 22, 0.45);
  color: #ffedd5;
}
.key-tint-3 {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.26), rgba(202, 138, 4, 0.12));
  border-color: rgba(234, 179, 8, 0.45);
  color: #fef9c3;
}
.key-tint-4 {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.26), rgba(16, 185, 129, 0.12));
  border-color: rgba(34, 197, 94, 0.45);
  color: #dcfce7;
}
.key-tint-5 {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.26), rgba(14, 165, 233, 0.12));
  border-color: rgba(6, 182, 212, 0.45);
  color: #cffafe;
}
.key-tint-6 {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.26), rgba(139, 92, 246, 0.12));
  border-color: rgba(99, 102, 241, 0.45);
  color: #e0e7ff;
}
.key-tint-7 {
  background: linear-gradient(135deg, rgba(217, 70, 239, 0.26), rgba(236, 72, 153, 0.12));
  border-color: rgba(217, 70, 239, 0.45);
  color: #fae8ff;
}

/* Special Action Keys (Space, Random, Fireworks FX) */
.key-action {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(139, 92, 246, 0.35));
  border-color: rgba(236, 72, 153, 0.6);
  color: #ffffff;
  font-weight: 800;
}

.key-fx {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.32), rgba(239, 68, 68, 0.25));
  border-color: rgba(251, 146, 60, 0.55);
}

/* Floating Re-Open Keypad Button */
.keypad-reopen-btn {
  pointer-events: auto;
  align-self: center;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(236, 72, 153, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  margin-bottom: 8px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  animation: bouncePill 2s infinite ease-in-out;
}

.keypad-reopen-btn:hover {
  transform: translateY(-3px) scale(1.05);
}

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

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

/* Responsive adjustments for smaller screens / tablets / phones */
@media (max-width: 768px) {
  .ui-overlay {
    padding: 8px 8px env(safe-area-inset-bottom, 8px) 8px;
  }
  .btn-text {
    display: none;
  }
  .logo-title {
    font-size: 0.95rem;
  }
  .logo-area {
    padding: 6px 12px;
  }
  .control-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
  }
  .kid-btn {
    padding: 10px 14px;
    font-size: 1.15rem;
  }
  .key-char {
    font-size: 3.6rem;
  }
  .key-word {
    font-size: 1.1rem;
  }
  .hint-banner {
    padding: 10px 18px;
  }
  .hint-title {
    font-size: 1.05rem;
  }
  .hint-subtitle {
    font-size: 0.8rem;
  }
  .volume-slider {
    width: 50px;
  }

  /* When keypad is open on mobile, streamline toolbar to avoid screen clutter */
  .ui-overlay.keypad-open .button-toolbar {
    display: none;
  }

  .virtual-keypad {
    padding: 8px 6px;
    border-radius: 18px;
    margin-bottom: 4px;
  }
  .keypad-row {
    gap: 4px;
  }
  .keypad-btn {
    min-height: 44px;
    border-radius: 9px;
  }
  .key-label {
    font-size: 1.15rem;
  }
  .key-sub {
    font-size: 0.65rem;
  }
}

@media (max-width: 480px) {
  .keypad-btn {
    min-height: 42px;
  }
  .key-label {
    font-size: 1.05rem;
  }
  .key-sub {
    font-size: 0.58rem;
  }
}

/* ======================================================
   Custom Phonics Words Modal Dialog
   ====================================================== */
.custom-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 20, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.custom-modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.custom-modal-dialog {
  width: 100%;
  max-width: 660px;
  max-height: 88vh;
  background: rgba(15, 18, 42, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85), 0 0 35px rgba(139, 92, 246, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.custom-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title-wrap {
  flex: 1;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.35;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  touch-action: manipulation;
  margin-left: 12px;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
  color: #ffffff;
  transform: scale(1.08);
}

/* Quick Presets Section */
.presets-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.presets-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #cbd5e1;
}

.presets-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f1f5f9;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.preset-btn:hover {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(139, 92, 246, 0.35));
  border-color: rgba(236, 72, 153, 0.6);
  transform: translateY(-1px);
}

/* Search bar */
.modal-search-bar {
  padding: 8px 18px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-search-input {
  width: 100%;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.86rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, background 0.2s;
}

.modal-search-input:focus {
  border-color: #8b5cf6;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

/* Alphabet Cards List Grid */
.custom-words-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  scroll-behavior: smooth;
}

.custom-words-list::-webkit-scrollbar {
  width: 6px;
}
.custom-words-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.custom-words-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.custom-word-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 8px 10px;
  transition: all 0.18s ease;
}

.custom-word-card:focus-within {
  border-color: #ec4899;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
}

.custom-word-card.filtered-out {
  display: none !important;
}

.card-letter-badge {
  min-width: 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f43f5e, #8b5cf6);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.card-inputs-wrap {
  flex: 1;
  display: flex;
  gap: 5px;
  min-width: 0;
}

.card-word-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.18s;
}

.card-word-input:focus {
  border-color: #38bdf8;
}

.card-emoji-input {
  width: 36px;
  padding: 6px 2px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-size: 1rem;
  outline: none;
}

.card-hear-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.18s ease;
  touch-action: manipulation;
  flex-shrink: 0;
}

.card-hear-btn:hover {
  background: rgba(16, 185, 129, 0.35);
  border-color: #10b981;
  transform: scale(1.08);
}

/* Modal Footer */
.custom-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  gap: 10px;
}

.modal-action-btn {
  padding: 8px 18px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.modal-action-btn.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.modal-action-btn.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

.modal-action-btn.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.modal-action-btn.btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
  transform: translateY(-1px);
}

@media (max-width: 540px) {
  .custom-words-list {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }
  .custom-modal-dialog {
    max-height: 94vh;
  }
  .modal-title {
    font-size: 1.1rem;
  }
  .modal-subtitle {
    font-size: 0.75rem;
  }
  .presets-section {
    padding: 8px 12px;
  }
  .preset-btn {
    font-size: 0.72rem;
    padding: 4px 8px;
  }
}

/* ==========================================================
   Dual-Case Typography & Bouncy Emoji Animations
   ========================================================== */
.key-char-lower {
  font-size: 0.72em;
  opacity: 0.88;
  font-weight: 800;
  margin-left: 6px;
}

.word-emoji {
  display: inline-block;
  animation: emojiWiggle 0.6s ease infinite alternate;
}

@keyframes emojiWiggle {
  from { transform: scale(1) rotate(-8deg); }
  to { transform: scale(1.22) rotate(8deg); }
}

/* ==========================================================
   Letter Quest / "Find the Letter" Identification HUD Bar
   ========================================================== */
.quest-btn {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(139, 92, 246, 0.45)) !important;
  border-color: rgba(244, 114, 182, 0.6) !important;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.45) !important;
}

.quest-btn.active {
  background: linear-gradient(135deg, #ec4899, #8b5cf6) !important;
  border-color: #fbcfe8 !important;
  box-shadow: 0 0 24px rgba(236, 72, 153, 0.8) !important;
  transform: scale(1.05);
}

.quest-bar {
  align-self: center;
  margin-top: auto;
  margin-bottom: 12px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid rgba(236, 72, 153, 0.55);
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(236, 72, 153, 0.4);
  pointer-events: auto;
  z-index: 25;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: questBarSlideUp 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.quest-bar.hidden {
  display: none !important;
}

@keyframes questBarSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.quest-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.quest-prompt-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quest-badge {
  background: linear-gradient(135deg, #ec4899, #f43f5e);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.5);
  animation: pulseBadge 1.8s infinite;
}

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

.quest-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e2e8f0;
}

.quest-target-char {
  font-size: 1.6rem;
  font-weight: 900;
  color: #ffd166;
  background: rgba(255, 209, 102, 0.15);
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 209, 102, 0.4);
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.7);
  animation: targetBounce 1.2s ease infinite alternate;
}

@keyframes targetBounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-3px) scale(1.08); }
}

.quest-target-emoji {
  font-size: 1.5rem;
  display: inline-block;
  animation: emojiWiggle 0.8s ease infinite alternate;
}

.quest-speaker-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ffffff;
  transition: all 0.2s ease;
}

.quest-speaker-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.15);
}

.quest-stars-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stars-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #ffd166;
}

.quest-stars-container {
  display: flex;
  gap: 4px;
}

.quest-star {
  font-size: 1.25rem;
  opacity: 0.25;
  filter: grayscale(1);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quest-star.earned {
  opacity: 1;
  filter: grayscale(0);
  transform: scale(1.25);
  animation: starPop 0.5s ease;
}

@keyframes starPop {
  0% { transform: scale(0.3) rotate(-30deg); }
  70% { transform: scale(1.4) rotate(15deg); }
  100% { transform: scale(1.25) rotate(0deg); }
}

.quest-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quest-action-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quest-action-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.quest-close-btn {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #ffffff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quest-close-btn:hover {
  background: rgba(239, 68, 68, 0.5);
  border-color: #f87171;
  transform: translateY(-1px);
}

/* Keypad button highlight hint when quest is active */
.keypad-btn.quest-target-hint {
  border-color: #ffd166 !important;
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.85), inset 0 0 12px rgba(255, 209, 102, 0.3) !important;
  animation: keyHintGlow 1.2s infinite alternate !important;
}

@keyframes keyHintGlow {
  0% { transform: translateY(-2px) scale(1); filter: brightness(1); }
  100% { transform: translateY(-4px) scale(1.08); filter: brightness(1.25); }
}

/* ==========================================================
   Voice & Cheerfulness Settings Modal
   ========================================================== */
.voice-modal-dialog {
  max-width: 620px;
}

.voice-settings-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 24px;
  overflow-y: auto;
  max-height: calc(85vh - 160px);
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 800;
  color: #e2e8f0;
}

.preview-voice-btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
  transition: all 0.2s ease;
}

.preview-voice-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.6);
}


.voice-select-dropdown {
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.voice-select-dropdown:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.voice-select-dropdown option {
  background: #0f172a;
  color: #ffffff;
}

.voice-help-text {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: -4px;
}

.settings-sliders-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.slider-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: #e2e8f0;
}

.slider-val-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffd166;
  background: rgba(255, 209, 102, 0.15);
  padding: 2px 7px;
  border-radius: 999px;
}

.settings-range {
  width: 100%;
  accent-color: #ec4899;
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 600;
}

@media (max-width: 600px) {
  .settings-sliders-row {
    grid-template-columns: 1fr;
  }
  .quest-bar {
    width: calc(100vw - 32px);
    border-radius: 20px;
    padding: 10px 14px;
  }
  .quest-content {
    justify-content: space-between;
    gap: 8px;
  }
}


