/* =========================================================
   Junior Lab · Listen Up — "Candy Cartoon" Design System
   Playful neo-cartoon style for kids:
   chunky outlines, sticker shadows, bouncy motion, candy colors
   ========================================================= */

:root {
  /* "Uzay" palette — dark cosmic bg + neon accents */
  --ink: #12122e;            /* deep space navy — outline / text */
  --cream: #e9e7ff;          /* pale lavender — app shell */
  --sky: #cfe0ff;            /* moonlight blue (option hover) */
  --coral: #7c5cff;          /* nebula purple — primary */
  --coral-dark: #6647e8;
  --sun: #d3fdf1;            /* pale mint — score box & next btn (badge fill color) */
  --sun-dark: #aef5e0;
  --mint: #37f0c2;           /* alien neon green */
  --mint-soft: #d3fdf1;
  --grape: #ff5db1;          /* cosmic pink — rank badge & accents */
  --grape-soft: #ffdcee;
  --bubble: #ffe066;         /* golden stripe partner */
  --bubble-soft: #fff5cc;
  --white: #ffffff;
  --success: #24c98a;
  --success-soft: #d5f8ea;
  --danger: #ff5470;
  --danger-soft: #ffe0e7;
  --orange: #ff9330;         /* wrong-choice frame */
  --muted: #6f6c99;

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

  --line: 3px solid var(--ink);
  --pop-shadow: 0 6px 0 var(--ink);
  --pop-shadow-sm: 0 4px 0 var(--ink);
}

* { 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;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 85% 12%, rgba(255, 255, 255, 0.8) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 70% 35%, rgba(255, 224, 102, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 30% 55%, rgba(255, 255, 255, 0.7) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 92% 70%, rgba(55, 240, 194, 0.8) 0 2px, transparent 3px),
    radial-gradient(circle at 10% 85%, rgba(255, 93, 177, 0.8) 0 2px, transparent 3px),
    radial-gradient(circle at 55% 90%, rgba(255, 255, 255, 0.8) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 45% 8%, rgba(255, 255, 255, 0.6) 0 1.5px, transparent 2.5px),
    linear-gradient(180deg, #1a1a40 0%, #2d2b6b 55%, #453e97 100%);
}

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

/* floating doodle clouds */
body::before,
body::after {
  content: '';
  position: fixed;
  font-size: 46px;
  opacity: 0.8;
  z-index: 0;
  pointer-events: none;
  animation: floaty 7s ease-in-out infinite;
  will-change: transform;
}
body::before { top: 10%; left: 4%; }
body::after { content: ''; }

/* Hide floating emojis on mobile: they sit outside the shell and cause repaint jitter */
@media (max-width: 539px) {
  body::before,
  body::after { display: none; }
}

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

.app-shell {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: var(--line);
  border-right: var(--line);
  z-index: 1;
}

/* confetti dots inside the shell */
.app-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 6% 30%, var(--sun) 0 5px, transparent 6px),
    radial-gradient(circle at 94% 22%, var(--bubble) 0 4px, transparent 5px),
    radial-gradient(circle at 90% 60%, var(--mint) 0 5px, transparent 6px),
    radial-gradient(circle at 5% 70%, var(--grape) 0 4px, transparent 5px),
    radial-gradient(circle at 50% 96%, var(--coral) 0 4px, transparent 5px);
  opacity: 0.5;
}
.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 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--grape);
  border: var(--line);
  box-shadow: 0 3px 0 var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  transform: rotate(-6deg);
}
.jl-badge-sm {
  width: 20px;
  height: 20px;
  font-size: 9px;
  border-radius: 7px;
  border-width: 2px;
  box-shadow: 0 2px 0 var(--ink);
  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: var(--ink);
  text-shadow: 2px 2px 0 var(--sun);
  letter-spacing: 0.3px;
}
.brand-title .icon {
  width: 26px;
  height: 26px;
  color: var(--coral);
  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 {
  text-align: center;
  flex-shrink: 0;
  background: var(--sun);
  border: var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--pop-shadow-sm);
  padding: 8px 14px;
  transform: rotate(2deg);
}
.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: var(--ink);
  fill: var(--white);
  stroke-width: 2;
}
.score-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.score-sub {
  font-size: 11px;
  color: var(--ink);
  margin-top: 3px;
  font-weight: 600;
  opacity: 0.75;
}

/* ===================== 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: var(--grape);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 9px;
  box-shadow: 0 2px 0 var(--ink);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  transform: rotate(-1.5deg);
}

.progress-track {
  position: relative;
  height: 18px;
  background: var(--white);
  border: var(--line);
  border-radius: 999px;
  overflow: visible;
  box-shadow: inset 0 2px 0 rgba(18, 18, 46, 0.12);
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    45deg,
    var(--coral) 0 10px,
    var(--grape) 10px 20px
  );
  border-radius: 999px;
  transition: width 0.7s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.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: var(--white);
  border: 2.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, transform 0.3s;
}
.milestone-dot svg {
  width: 13px;
  height: 13px;
  color: #c6c2e6;
  transition: color 0.3s;
}
.milestone-dot.reached {
  background: var(--sun);
  animation: pop-in 0.45s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.milestone-dot.reached svg {
  color: var(--ink);
  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(60, 20, 120, 0.35));
  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: var(--sun);
  color: var(--ink);
  padding: 14px 20px;
  border: var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--pop-shadow);
  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: var(--ink);
  flex-shrink: 0;
  animation: wiggle 1s ease-in-out infinite;
}
.milestone-toast strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.7;
}
.milestone-toast div#milestone-toast-rank {
  font-size: 17px;
  font-weight: 800;
}

/* ===================== Quiz Card ===================== */
.quiz-card {
  margin: 0 14px 18px;
  padding: 18px 16px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--white);
  border: var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--pop-shadow);
}

.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: 14px; /* square with soft corners */
  padding: 7px;
  background: linear-gradient(135deg, var(--mint), var(--sun), var(--grape));
  border: var(--line);
  box-shadow: var(--pop-shadow);
}
.image-frame::after {
  content: '';
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 32px;
  transform: rotate(15deg);
  animation: floaty 4s ease-in-out infinite;
}
.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 9px;
  background: var(--grape-soft);
  border: 2.5px solid var(--ink);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 18px;
  border-radius: var(--r-md);
  border: var(--line);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s, opacity 0.15s;
  flex: 1;
  box-shadow: var(--pop-shadow-sm);
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--coral);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--coral-dark); }
.btn-primary.is-playing {
  background: var(--grape);
  animation: pulse-play 1s ease-in-out infinite;
}
@keyframes pulse-play {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.btn-outline {
  background: var(--mint-soft);
  color: var(--ink);
}
.btn-outline:hover:not(:disabled) { background: var(--mint); color: var(--white); }

.btn-next {
  background: var(--sun);
  color: var(--ink);
  width: 100%;
  font-size: 17px;
  animation: bounce-hint 1.6s ease-in-out infinite;
}
.btn-next:hover { background: var(--sun-dark); }
@keyframes bounce-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ===================== Subtitle Box ===================== */
.subtitle-box {
  display: none;
  position: relative;
  background: #fff9d6;
  border: none;
  border-radius: var(--r-md);
  padding: 14px 16px 14px 44px;
}
.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: 800;
  margin: 0 0 14px;
  color: var(--ink);
  line-height: 1.35;
}

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

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: background 0.15s, transform 0.12s, box-shadow 0.12s;
}
.option-btn:hover:not(:disabled) {
  background: var(--sky);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--ink);
}
.option-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.option-btn .option-badge {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  background: var(--sun);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  flex-shrink: 0;
  transform: rotate(-4deg);
}
.option-btn:disabled { cursor: default; }
.option-btn.selected {
  background: var(--grape-soft);
}
.option-btn.correct {
  background: var(--success-soft);
  border-color: var(--success);
  box-shadow: 0 3px 0 var(--success);
  animation: correct-jump 0.5s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.option-btn.correct .option-badge {
  background: var(--success);
  border-color: var(--success);
  color: white;
  transform: rotate(0deg);
}
@keyframes correct-jump {
  0% { transform: scale(1); }
  40% { transform: scale(1.04) rotate(-1deg); }
  100% { transform: scale(1); }
}
.option-btn.incorrect {
  background: var(--white);
  border-color: var(--orange);
  box-shadow: 0 3px 0 var(--orange);
  animation: shake 0.4s ease;
}
/* Correct answer revealed after a WRONG choice: pink frame on white */
.option-btn.reveal-correct {
  background: var(--white);
  border-color: var(--grape);
  box-shadow: 0 3px 0 var(--grape);
  animation: correct-jump 0.5s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.option-btn.reveal-correct .option-badge {
  background: var(--grape);
  border-color: var(--grape);
  color: white;
  transform: rotate(0deg);
}
.option-btn.incorrect .option-badge {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
}

/* ===== 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;
  box-shadow: 0 2px 0 var(--ink);
}
.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: 800;
  padding: 13px 16px;
  border-radius: var(--r-md);
  border: 2.5px solid transparent;
}
.feedback.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}
.feedback.correct {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}
.feedback.incorrect {
  background: var(--white);
  border-color: var(--grape);
  color: var(--ink);
  flex-direction: column;
  align-items: flex-start;
}

/* Sentence meaning box shown when a sentence question is answered correctly */
.sentence-meaning {
  width: 100%;
  background: var(--white);
  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: var(--white); /* words on clean white */
  border: none;
  border-radius: var(--r-md);
  padding: 10px 4px 2px;
  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: 700;
}

/* ===================== Student Login Modal ===================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(18, 18, 46, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.login-overlay[hidden] { display: none; }

.login-card {
  position: relative;
  background: var(--cream);
  border: var(--line);
  border-radius: var(--r-xl);
  padding: 30px 24px 26px;
  max-width: 370px;
  width: 100%;
  box-shadow: var(--pop-shadow);
  text-align: center;
  animation: card-drop 0.5s cubic-bezier(0.34, 1.5, 0.64, 1);
}
@keyframes card-drop {
  from { transform: translateY(-40px) rotate(-2deg); opacity: 0; }
  to { transform: translateY(0) rotate(0deg); 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: var(--grape);
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 12px;
  margin-top: 8px;
}
.login-card h2 {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 800;
  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 16px;
  border: 2.5px solid var(--ink);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--white);
  margin-bottom: 10px;
  outline: none;
  box-shadow: 0 3px 0 var(--ink);
  transition: box-shadow 0.15s, transform 0.15s;
}
.login-card input:focus {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--grape);
  border-color: var(--grape);
}
.login-card input::placeholder {
  color: var(--muted);
  font-weight: 600;
}
.login-card .btn {
  width: 100%;
  margin-top: 6px;
}
.login-error {
  min-height: 18px;
  color: var(--danger);
  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: 900;
  line-height: 1.1;
}
.level-btn-sub {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
}
#btn-level-beginner {
  background: var(--mint);
  color: var(--ink);
}
#btn-level-starter {
  background: var(--grape);
  color: #ffffff;
}

/* ===================== Home Button ===================== */
.btn-home {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--sun);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  align-self: flex-start;
  margin-top: 8px;
  padding: 0;
}
.btn-home .icon { width: 17px; height: 17px; }
.btn-home:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--ink);
  background: var(--sun-dark);
}
.btn-home:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ink);
}

/* ===================== 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: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  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: 10px solid var(--cat-color, var(--coral));
  border-radius: var(--r-md);
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--pop-shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-align: left;
}
.category-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}
.category-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}
.category-ring {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.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: 800;
  color: var(--ink);
  line-height: 1.15;
}
.category-tr {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.category-count {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.category-done { opacity: 0.6; }
.btn-back {
  margin-top: 14px;
  background: transparent;
  border: none;
  color: #6b7280;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-back:hover { color: var(--ink, #222); text-decoration: underline; }

/* ===================== Student Badge ===================== */
.student-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 12px;
  background: var(--mint-soft);
  border: 2.5px solid var(--mint);
  border-radius: 999px;
  width: fit-content;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--mint);
}
.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 10px 0 rgba(0, 0, 0, 0.4);
  }
}

/* ===================== 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; }

  /* 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; border-width: 1.5px; }
  .progress-track { height: 12px; }

  /* Quiz card fills remaining space, children shrink to fit.
     Note: buttons cast a 3-4px "pop" shadow below them, so gaps are
     slightly larger to keep visual spacing even. */
  .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;
  }
  .image-frame::after { font-size: 22px; top: -8px; right: -4px; }

  /* Listen / Subtitles buttons: taller (more top/bottom padding) */
  .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 (less top/bottom padding) */
  .btn-next {
    width: 100%;
    font-size: 14px;
    padding: 7px 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: even 10px rhythm between all options
     (shadow is 3px, so 10px gap reads as ~7px visually) */
  .question-block h2 { font-size: 15px; margin: 0 0 10px; }
  .options { gap: 10px; }
  .option-btn { padding: 8px 11px; font-size: 13px; gap: 9px; border-width: 2px; }
  .option-btn .option-badge { width: 24px; height: 24px; font-size: 12px; border-radius: 8px; }

  /* Image-choice options on mobile: 2x2 compact grid, fits on screen */
  .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(30, 15, 60, 0.4);
  backdrop-filter: blur(2px);
  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 50px rgba(60, 20, 120, 0.55));
}

.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 18px rgba(60, 20, 120, 0.4));
  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: #5b2a86;
  background: #fff;
  border-radius: 999px;
  padding: 10px 26px;
  display: inline-block;
  box-shadow: 0 8px 24px rgba(60, 20, 120, 0.35);
}

@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; } }
