/* =========================================================
   Junior Lab · Listen Up — "Glossy Glass" Design System
   Soft pastel gradients, frosted-glass cards, glossy jelly
   buttons and gentle shadows.
   ========================================================= */

:root {
  /* Soft pastel palette (variable names kept from the old theme) */
  --ink: #3d3a63;            /* soft indigo — text */
  --ink-soft: #6b6896;
  --cream: #f4f1ff;          /* pale lavender mist */
  --sky: #e1ecff;            /* option hover tint */
  --coral: #9a8cff;          /* periwinkle — primary */
  --coral-dark: #8173f0;
  --sun: #fff1b8;            /* butter */
  --sun-dark: #ffe58f;
  --mint: #8fe9d0;
  --mint-soft: #dcfaf1;
  --grape: #ff9fcd;          /* candy pink */
  --grape-soft: #ffe4f1;
  --bubble: #ffe9a8;
  --bubble-soft: #fff5cc;
  --white: #ffffff;
  --success: #2fbf8f;
  --success-soft: #d9f7ec;
  --danger: #ff7a90;
  --danger-soft: #ffe5ea;
  --orange: #ffa95c;
  --muted: #8784ad;

  --r-xl: 30px;
  --r-lg: 24px;
  --r-md: 18px;

  /* Glass tokens */
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.74);
  --glass-border: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 12px 32px rgba(120, 110, 200, 0.2);
  --glass-shadow-sm: 0 5px 16px rgba(120, 110, 200, 0.18);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.95);

  --line: 1px solid var(--glass-border);
  --pop-shadow: var(--glass-shadow);
  --pop-shadow-sm: var(--glass-shadow-sm);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow-x: hidden;
  /* Prevent iOS font-size auto-inflation that shifts layout */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
  /* Prevent double-tap zoom & scroll chaining wobble on mobile */
  touch-action: manipulation;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Baloo 2', 'Fredoka', 'Comic Sans MS', sans-serif;
  font-weight: 500;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  /* pastel mesh: soft colour orbs over a lavender-pink-sky gradient */
  background:
    radial-gradient(circle at 12% 8%, rgba(176, 156, 255, 0.60) 0, transparent 38%),
    radial-gradient(circle at 92% 22%, rgba(255, 168, 212, 0.50) 0, transparent 36%),
    radial-gradient(circle at 18% 88%, rgba(134, 228, 212, 0.55) 0, transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(255, 226, 150, 0.50) 0, transparent 38%),
    linear-gradient(160deg, #e9e4ff 0%, #fde7f3 48%, #dff2ff 100%);
}

/* background-attachment: fixed causes jitter/repaint on mobile scroll — only enable on desktop */
@media (min-width: 540px) {
  body { background-attachment: fixed; }
}

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

/* The frosted glass lives on a pseudo-element, NOT on .app-shell itself:
   backdrop-filter on the shell would turn it into the containing block for
   the position:fixed overlays/toast living inside it. */
.app-shell {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.7);
  border-right: 1px solid rgba(255, 255, 255, 0.7);
  z-index: 1;
}

.app-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0, rgba(255, 255, 255, 0) 180px),
    radial-gradient(circle at 88% 14%, rgba(255, 190, 224, 0.45) 0, transparent 120px),
    radial-gradient(circle at 8% 60%, rgba(160, 232, 214, 0.40) 0, transparent 140px),
    radial-gradient(circle at 92% 82%, rgba(190, 176, 255, 0.40) 0, transparent 150px),
    rgba(255, 255, 255, 0.34);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  backdrop-filter: blur(22px) saturate(1.35);
}
.app-shell > * {
  position: relative;
  z-index: 1;
}

.icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ===================== Top Header ===================== */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 18px 10px;
  gap: 12px;
}

.brand-junior { display: flex; align-items: center; gap: 6px; }

.jl-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(150deg, #7ff0e6 0%, #2cc9c4 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 5px 12px rgba(44, 201, 196, 0.42),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.85),
    inset 0 -3px 5px rgba(15, 140, 140, 0.2);
  color: #fff;
  text-shadow: 0 1px 2px rgba(10, 120, 125, 0.45);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.jl-badge-sm {
  width: 20px;
  height: 20px;
  font-size: 9px;
  border-radius: 7px;
  box-shadow: 0 2px 5px rgba(44, 201, 196, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  vertical-align: middle;
  margin-right: 5px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.brand-title h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0;
  color: #1fb5b5; /* fallback */
  background: linear-gradient(90deg, #14b8b8 0%, #46d9cf 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.3px;
  filter: drop-shadow(0 2px 6px rgba(255, 255, 255, 0.9));
}
.brand-title .icon {
  width: 26px;
  height: 26px;
  color: #1fc4c0;
  stroke-width: 2;
  animation: wiggle 3s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.score-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.score-box {
  position: relative;
  text-align: center;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 243, 196, 0.80) 100%);
  border: var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--glass-shadow-sm), var(--glass-inset);
  padding: 8px 14px;
}
.score-value {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.score-value .icon-star {
  width: 20px;
  height: 20px;
  color: #f3b13c;
  fill: #ffe38a;
  stroke-width: 2;
}
.score-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.score-sub {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 3px;
  font-weight: 600;
}

/* ===================== Progress Section ===================== */
.progress-section {
  padding: 44px 18px 16px; /* top space for the robot walking above the bar */
}

.rank-current {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--white);
  background: linear-gradient(180deg, #ffb6d9 0%, #ff8fc1 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 2px 10px;
  box-shadow: 0 3px 8px rgba(255, 125, 185, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 2px rgba(190, 60, 120, 0.4);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.progress-track {
  position: relative;
  height: 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  overflow: visible;
  box-shadow:
    inset 0 2px 5px rgba(120, 110, 200, 0.22),
    0 2px 8px rgba(255, 255, 255, 0.7);
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b5a8ff 0%, #ff9fd0 100%);
  border-radius: 999px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    0 2px 10px rgba(165, 135, 255, 0.45);
  transition: width 0.7s cubic-bezier(0.34, 1.4, 0.64, 1);
}
/* glossy highlight on the fill */
.progress-fill::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: 2px;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.milestones {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 0;
}

.milestone-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #efeaff 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 3px 8px rgba(120, 110, 200, 0.28), inset 0 -2px 4px rgba(150, 135, 220, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, transform 0.3s;
}
.milestone-dot svg {
  width: 13px;
  height: 13px;
  color: #cdc7ee;
  transition: color 0.3s;
}
.milestone-dot.reached {
  background: linear-gradient(180deg, #fff4bd 0%, #ffd96b 100%);
  box-shadow:
    0 0 0 3px rgba(255, 217, 107, 0.35),
    0 4px 10px rgba(240, 180, 60, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: pop-in 0.45s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.milestone-dot.reached svg {
  color: #c78a00;
  fill: var(--white);
}

@keyframes pop-in {
  0% { transform: translate(-50%, -50%) scale(0.4); }
  70% { transform: translate(-50%, -50%) scale(1.25); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.milestone-label {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== Robot mascot walking on top of the progress bar ===== */
.progress-robot {
  position: absolute;
  bottom: 100%;
  left: 0%;
  transform: translate(-50%, 6px);
  width: 46px;
  height: 46px;
  z-index: 3;
  pointer-events: none;
  transition: left 0.8s cubic-bezier(0.34, 1.3, 0.5, 1);
  filter: drop-shadow(0 4px 8px rgba(110, 90, 200, 0.3));
  animation: robot-bob 2.2s ease-in-out infinite;
}

@keyframes robot-bob {
  0%, 100% { transform: translate(-50%, 6px) rotate(-2deg); }
  50% { transform: translate(-50%, 2px) rotate(2deg); }
}

/* ===================== Milestone Toast ===================== */
.milestone-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 243, 196, 0.88) 100%);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--ink);
  padding: 14px 20px;
  border: var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 14px 34px rgba(120, 110, 200, 0.3), var(--glass-inset);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s;
  max-width: 90%;
}
.milestone-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.milestone-toast .icon-trophy {
  width: 32px;
  height: 32px;
  color: #f0a82a;
  flex-shrink: 0;
  animation: wiggle 1s ease-in-out infinite;
}
.milestone-toast strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.milestone-toast div#milestone-toast-rank {
  font-size: 17px;
  font-weight: 800;
}

/* ===================== Quiz Card (frosted glass) ===================== */
.quiz-card {
  margin: 0 14px 18px;
  padding: 18px 16px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(160deg, rgba(255,255,255,.82), rgba(255,255,255,.52));
  border: var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--glass-shadow), var(--glass-inset);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
}

.image-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 2px;
}
.image-card[hidden] { display: none !important; }
.image-frame {
  position: relative;
  width: 320px;
  max-width: 92%;
  aspect-ratio: 1 / 1;
  border-radius: 26px;
  padding: 6px;
  background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(210,200,255,.65) 45%, rgba(255,205,230,.7));
  border: var(--line);
  box-shadow: 0 14px 30px rgba(120,110,200,.28), var(--glass-inset);
}
/* glossy sheen over the frame */
.image-frame::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(255,255,255,.38) 0%, rgba(255,255,255,0) 38%);
  pointer-events: none;
}
.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 20px;
  background: var(--grape-soft);
  border: none;
}

.listen-controls {
  display: flex;
  gap: 12px;
}

/* ===================== Glossy jelly buttons ===================== */
.btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,.8);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s, opacity 0.15s;
  flex: 1;
  box-shadow: 0 8px 18px rgba(120,110,200,.25), inset 0 1px 0 rgba(255,255,255,.9), inset 0 -3px 6px rgba(120,110,200,.12);
}
/* top gloss highlight */
.btn::before {
  content: '';
  position: absolute;
  left: 6%;
  right: 6%;
  top: 2px;
  height: 46%;
  border-radius: 14px 14px 40px 40px / 14px 14px 18px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,.08));
  pointer-events: none;
  z-index: -1;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.04) saturate(1.05);
  box-shadow: 0 12px 24px rgba(120,110,200,.32), inset 0 1px 0 rgba(255,255,255,.9), inset 0 -3px 6px rgba(120,110,200,.12);
}
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(.99);
  box-shadow: 0 3px 8px rgba(120,110,200,.22), inset 0 1px 0 rgba(255,255,255,.7);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #b9adff, #8f9bff 55%, #82b4ff);
  color: white;
  text-shadow: 0 1px 2px rgba(90,80,190,.35);
}
.btn-primary.is-playing {
  background: linear-gradient(135deg, #ffb3d6, #ff9fcd 55%, #ffb8a8);
  animation: pulse-play 1s ease-in-out infinite;
}
@keyframes pulse-play {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.btn-outline {
  background: linear-gradient(135deg, #e6fff7, #bdf3e1 60%, #a9ecd8);
  color: #1f6f58;
}

.btn-next {
  background: linear-gradient(135deg, #fff6c9, #ffe8a0 55%, #ffd9b0);
  color: #7a5a14;
  width: 100%;
  font-size: 17px;
  animation: bounce-hint 1.6s ease-in-out infinite;
}
@keyframes bounce-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ===================== Subtitle Box ===================== */
.subtitle-box {
  display: none;
  position: relative;
  background: linear-gradient(135deg, rgba(255,249,214,.85), rgba(255,236,246,.8));
  border: var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px 14px 44px;
  box-shadow: var(--glass-shadow-sm), var(--glass-inset);
}
.subtitle-box::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 12px;
  font-size: 20px;
}
.subtitle-box.show {
  display: block;
  animation: fadeIn 0.4s ease;
}
.subtitle-box p {
  margin: 0;
  font-family: 'Quicksand', 'Comic Sans MS', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 600;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== Question Block ===================== */
.question-block h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--ink);
  line-height: 1.35;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: linear-gradient(160deg, rgba(255,255,255,.92), rgba(255,255,255,.62));
  border: 1px solid rgba(255,255,255,.95);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(120,110,200,.16), inset 0 1px 0 #fff, inset 0 -2px 5px rgba(120,110,200,.07);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.option-btn:hover:not(:disabled) {
  background: linear-gradient(160deg, #ffffff, var(--sky));
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(120,110,200,.24), inset 0 1px 0 #fff;
}
.option-btn:active:not(:disabled) {
  transform: translateY(1px) scale(.99);
  box-shadow: 0 2px 6px rgba(120,110,200,.18), inset 0 1px 0 #fff;
}
.option-btn .option-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.9);
  background: linear-gradient(145deg, #fff8d6, var(--sun-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #7a5a14;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(255,200,90,.35), inset 0 1px 0 #fff;
}
.option-btn:disabled { cursor: default; }
.option-btn.selected {
  background: linear-gradient(160deg, #fff, var(--grape-soft));
}
.option-btn.correct {
  background: linear-gradient(160deg, #efffF9, #c9f5e4);
  border-color: rgba(47,191,143,.65);
  box-shadow: 0 8px 20px rgba(47,191,143,.28), inset 0 1px 0 #fff;
  animation: correct-jump 0.5s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.option-btn.correct .option-badge {
  background: linear-gradient(145deg, #6fe0b8, var(--success));
  border-color: rgba(255,255,255,.9);
  color: white;
  box-shadow: 0 3px 8px rgba(47,191,143,.4), inset 0 1px 0 rgba(255,255,255,.6);
}
@keyframes correct-jump {
  0% { transform: scale(1); }
  40% { transform: scale(1.04) rotate(-1deg); }
  100% { transform: scale(1); }
}
.option-btn.incorrect {
  background: linear-gradient(160deg, #fff, #ffeedd);
  border-color: rgba(255,169,92,.7);
  box-shadow: 0 8px 18px rgba(255,169,92,.25), inset 0 1px 0 #fff;
  animation: shake 0.4s ease;
}
/* Correct answer revealed after a WRONG choice: pink glow */
.option-btn.reveal-correct {
  background: linear-gradient(160deg, #fff, var(--grape-soft));
  border-color: rgba(255,159,205,.8);
  box-shadow: 0 8px 20px rgba(255,159,205,.32), inset 0 1px 0 #fff;
  animation: correct-jump 0.5s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.option-btn.reveal-correct .option-badge {
  background: linear-gradient(145deg, #ffc0de, var(--grape));
  color: white;
  box-shadow: 0 3px 8px rgba(255,159,205,.45), inset 0 1px 0 rgba(255,255,255,.6);
}
.option-btn.incorrect .option-badge {
  background: linear-gradient(145deg, #ffc994, var(--orange));
  color: white;
  box-shadow: 0 3px 8px rgba(255,169,92,.4), inset 0 1px 0 rgba(255,255,255,.6);
}

/* ===== Image-choice options (click the correct picture) ===== */
.options.image-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.option-btn.image-option {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  padding: 8px;
  gap: 0;
}
.option-btn.image-option img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: calc(var(--r-md) - 6px);
  display: block;
  pointer-events: none;
}
.option-btn.image-option .option-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
}
.image-option-label {
  display: block;
  text-align: center;
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 6px 4px 2px;
  animation: label-pop 0.3s ease;
}
.image-option-label[hidden] {
  display: none;
}
@keyframes label-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ===================== Feedback ===================== */
.feedback {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.feedback.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}
.feedback.correct {
  background: linear-gradient(135deg, rgba(217,247,236,.92), rgba(190,243,225,.75));
  border-color: rgba(47,191,143,.4);
  color: #1c8b69;
  box-shadow: 0 6px 16px rgba(47,191,143,.18), var(--glass-inset);
}
.feedback.incorrect {
  background: linear-gradient(135deg, rgba(255,255,255,.9), rgba(255,228,241,.75));
  border-color: rgba(255,159,205,.55);
  color: var(--ink);
  flex-direction: column;
  align-items: flex-start;
  box-shadow: 0 6px 16px rgba(255,159,205,.2), var(--glass-inset);
}

/* Sentence meaning box shown when a sentence question is answered correctly */
.sentence-meaning {
  width: 100%;
  background: rgba(255,255,255,.75);
  border: var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-top: 6px;
  font-family: 'Quicksand', 'Comic Sans MS', sans-serif;
}
.sentence-meaning-en {
  font-size: 15px;
  font-weight: 700;
  color: #4b3f72;
  margin-bottom: 4px;
}
.sentence-meaning-tr {
  font-size: 14px;
  font-weight: 600;
  color: #7a6fa0;
}

/* Hint box (word meanings) shown on wrong answers */
.feedback-hints {
  width: 100%;
  background: rgba(255,255,255,.7);
  border: var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px 8px;
  margin-top: 4px;
  font-family: 'Quicksand', 'Comic Sans MS', sans-serif;
}
.feedback-hints-title {
  font-family: 'Quicksand', 'Comic Sans MS', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.feedback-hints-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.feedback-hints-list li {
  font-family: 'Quicksand', 'Comic Sans MS', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.hint-en {
  color: var(--coral-dark);
  font-weight: 700;
}
.hint-tr {
  color: var(--ink);
}

/* ===================== Footer ===================== */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 6px 20px 20px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* ===================== Student Login Modal (frosted) ===================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background:
    radial-gradient(circle at 20% 15%, rgba(176,156,255,.45), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(255,168,212,.4), transparent 45%),
    rgba(235, 230, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.login-overlay[hidden] { display: none; }

.login-card {
  position: relative;
  background: linear-gradient(160deg, rgba(255,255,255,.88), rgba(255,255,255,.62));
  border: var(--line);
  border-radius: var(--r-xl);
  padding: 30px 24px 26px;
  max-width: 370px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(120,110,200,.32), var(--glass-inset);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  text-align: center;
  animation: card-drop 0.5s cubic-bezier(0.34, 1.5, 0.64, 1);
}
@keyframes card-drop {
  from { transform: translateY(-30px) scale(.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.login-card::before {
  content: '';
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  animation: wiggle 2s ease-in-out infinite;
}
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #14aeae;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
  margin-top: 8px;
}
.login-card h2 {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 700;
  color: var(--ink);
}
.login-sub {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}
.login-card input {
  /* 16px minimum prevents iOS auto-zoom on focus (screen jumping) */
  font-size: 16px !important;
  width: 100%;
  padding: 13px 18px;
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255,255,255,.8);
  margin-bottom: 10px;
  outline: none;
  box-shadow: inset 0 2px 6px rgba(120,110,200,.14), 0 4px 12px rgba(120,110,200,.1);
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.login-card input:focus {
  background: #fff;
  border-color: rgba(154,140,255,.8);
  box-shadow: 0 0 0 4px rgba(154,140,255,.25), inset 0 2px 6px rgba(120,110,200,.08);
}
.login-card input::placeholder {
  color: var(--muted);
  font-weight: 500;
  opacity: .8;
}
.login-card .btn {
  width: 100%;
  margin-top: 6px;
}
.login-error {
  min-height: 18px;
  color: #e5566f;
  font-size: 13px;
  font-weight: 700;
  margin-top: 8px;
}

/* ===================== Level Select ===================== */
.level-overlay[hidden] { display: none; }
.level-card .level-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  margin-top: 12px;
}
.level-btn-title {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
}
.level-btn-sub {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}
#btn-level-beginner {
  background: linear-gradient(135deg, #e6fff7, #b4f0dc 55%, #9fe8d0);
  color: #1f6f58;
}
#btn-level-starter {
  background: linear-gradient(135deg, #ffd9ec, #ffb4d8 55%, #ffa6cf);
  color: #a6286f;
}
#btn-level-movers {
  background: linear-gradient(135deg, #e0e6ff, #b9c3ff 55%, #a7b4ff);
  color: #3b3f9a;
}

/* ===================== Home Button ===================== */
.btn-home {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 50%;
  background: linear-gradient(145deg, #fffbe3, var(--sun-dark));
  color: #7a5a14;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(255,200,90,.38), inset 0 1px 0 #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  align-self: flex-start;
  margin-top: 8px;
  padding: 0;
}
.btn-home .icon { width: 17px; height: 17px; }
.btn-home:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow: 0 8px 16px rgba(255,200,90,.45), inset 0 1px 0 #fff;
}
.btn-home:active {
  transform: translateY(1px) scale(.97);
}

/* ===================== Category Select (Beginner) ===================== */
.category-card {
  max-width: 480px;
  width: min(480px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
}
.category-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.category-group-title {
  margin: 10px 2px 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.category-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px 10px 10px;
  border: var(--line);
  border-left: 6px solid var(--cat-color, var(--coral));
  border-radius: var(--r-md);
  background: linear-gradient(160deg, rgba(255,255,255,.92), rgba(255,255,255,.6));
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(120,110,200,.16), inset 0 1px 0 #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
}
.category-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(120,110,200,.26), inset 0 1px 0 #fff;
}
.category-btn:active {
  transform: translateY(1px) scale(.99);
}
.category-ring {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 3px 6px rgba(120,110,200,.2));
}
.category-icon { font-size: 28px; line-height: 1.2; }
.category-img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: block;
  background: var(--white);
  padding: 8px;
  box-sizing: border-box;
}
.category-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.category-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}
.category-tr {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.category-count {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.category-done { opacity: 0.6; }
.btn-back {
  margin-top: 14px;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-back:hover { color: var(--ink); text-decoration: underline; }

/* ===================== Student Badge ===================== */
.student-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.9), rgba(205,248,234,.8));
  border: var(--line);
  border-radius: 999px;
  width: fit-content;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #1f6f58;
  box-shadow: 0 4px 10px rgba(79,205,168,.25), inset 0 1px 0 #fff;
}
.student-badge .icon { width: 15px; height: 15px; }
.student-badge[hidden] { display: none; }

/* ===================== Responsive ===================== */
@media (min-width: 540px) {
  .app-shell {
    margin-top: 28px;
    margin-bottom: 28px;
    border: var(--line);
    border-radius: 36px;
    min-height: auto;
    box-shadow: 0 24px 60px rgba(120, 110, 200, 0.3), var(--glass-inset);
  }
}

/* ===================== Fit-to-screen (no scroll on mobile) ===================== */
@media (max-width: 539px) {
  html, body {
    height: 100%;
    overflow: hidden; /* no page scroll — everything fits on one screen */
  }

  .app-shell {
    height: 100vh; /* fallback for older browsers */
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  /* Compact header */
  .top-header { padding: 8px 14px 4px; }
  .brand-title h1 { font-size: 20px; }
  .brand-title .icon { width: 20px; height: 20px; }
  .jl-badge { width: 26px; height: 26px; font-size: 10px; border-radius: 9px; }
  .score-box { padding: 4px 10px; }
  .score-value { font-size: 17px; }
  .score-value .icon-star { width: 15px; height: 15px; }
  .score-label { font-size: 11px; }
  .score-sub { font-size: 9px; margin-top: 1px; }

  /* Compact student badge */
  .student-badge { padding: 2px 8px; font-size: 10px; max-width: 120px; }
  .btn-home { width: 30px; height: 30px; }

  /* Compact progress */
  .progress-section { padding: 36px 14px 10px; }
  .progress-robot { width: 38px; height: 38px; }
  .rank-current { font-size: 9px; padding: 1px 7px; margin-bottom: 4px; }
  .progress-track { height: 12px; }

  /* Quiz card fills remaining space, children shrink to fit */
  .quiz-card {
    margin: 0 10px 10px;
    padding: 12px 14px 14px;
    gap: 12px;
    min-height: 0;
    overflow-y: auto; /* answer feedback + Next button can extend; card scrolls so nothing is cut off */
    -webkit-overflow-scrolling: touch;
  }

  /* Image: big and prominent */
  .image-card {
    padding: 2px 0 0;
    flex: 0 0 auto;
  }
  .image-frame {
    width: 88%;
    height: auto;
    max-height: none;
    max-width: 88%;
    aspect-ratio: 1 / 1;
    padding: 5px;
    border-radius: 22px;
  }
  .image-frame::after { inset: 5px; border-radius: 17px; }
  .image-card img { border-radius: 17px; }

  /* Listen / Subtitles buttons */
  .listen-controls { gap: 12px; }
  .btn { font-size: 14.5px; padding: 14px 12px; gap: 7px; }
  .btn .icon { width: 16px; height: 16px; }

  /* Next button: full width but shorter */
  .btn-next {
    width: 100%;
    font-size: 14px;
    padding: 8px 14px;
    animation: none;
  }

  /* Compact subtitles */
  .subtitle-box { padding: 8px 10px 8px 34px; }
  .subtitle-box::before { font-size: 15px; left: 9px; top: 8px; }
  .subtitle-box p { font-size: 12.5px; line-height: 1.4; }

  /* Compact question + options */
  .question-block h2 { font-size: 15px; margin: 0 0 10px; }
  .options { gap: 10px; }
  .option-btn { padding: 8px 11px; font-size: 13px; gap: 9px; }
  .option-btn .option-badge { width: 24px; height: 24px; font-size: 12px; }

  /* Image-choice options on mobile: 2x2 compact grid */
  .options.image-options { gap: 10px; }
  .option-btn.image-option { padding: 6px; }
  .option-btn.image-option img { max-height: 24vh; max-height: 24dvh; }
  .option-btn.image-option .option-badge { top: 9px; left: 9px; }

  /* Compact feedback + hints */
  .feedback { font-size: 12.5px; padding: 8px 10px; }
  .feedback-hints { padding: 9px 12px; }
  .feedback-hints-title { font-size: 12px; margin-bottom: 5px; }
  .feedback-hints-list { gap: 3px; }
  .feedback-hints-list li { font-size: 12px; }

  /* Hide footer on mobile to save vertical space */
  .app-footer { display: none; }
}

/* ===== Praise celebration popup (5-correct streak) ===== */
.wow-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(235, 228, 255, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: wow-fade-in 0.25s ease;
  pointer-events: none;
}

.wow-overlay.fade-out { animation: wow-fade-out 0.4s ease forwards; }

.wow-popup {
  position: relative;
  text-align: center;
  animation: wow-pop 0.55s cubic-bezier(0.18, 1.6, 0.4, 1);
}

.wow-image {
  display: block;
  width: min(420px, 78vw);
  height: auto;
  filter: drop-shadow(0 18px 40px rgba(120, 90, 210, 0.4));
}

.wow-robot {
  position: absolute;
  top: -38px;
  right: -30px;
  width: min(110px, 22vw);
  height: auto;
  z-index: 2;
  transform: rotate(12deg);
  filter: drop-shadow(0 8px 16px rgba(120, 90, 210, 0.3));
  animation: wow-robot-bounce 1.1s ease-in-out infinite alternate;
}

@keyframes wow-robot-bounce {
  from { transform: rotate(12deg) translateY(0); }
  to   { transform: rotate(6deg) translateY(-12px); }
}

.wow-streak {
  margin-top: -22px;
  position: relative;
  z-index: 1;
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: #6a4fb8;
  background: linear-gradient(160deg, rgba(255,255,255,.95), rgba(255,255,255,.7));
  border: var(--line);
  border-radius: 999px;
  padding: 10px 26px;
  display: inline-block;
  box-shadow: 0 10px 26px rgba(120, 90, 210, 0.3), var(--glass-inset);
}

@keyframes wow-pop {
  0% { transform: scale(0.2) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes wow-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes wow-fade-out { from { opacity: 1; } to { opacity: 0; } }
