/* ============================================================
   STYLES — the look of the site. You normally won't need to edit
   this. Colors are at the very top if you ever want to tweak them.
   ============================================================ */

:root {
  /* Theme colors — brown + sky blue, with warm cream paper */
  --brown:      #8b5e3c;
  --brown-dark: #6b4424;
  --brown-soft: #c9a886;
  --sky:        #6fc3e8;
  --sky-dark:   #3a9ed4;
  --sky-soft:   #cdeafb;
  --cream:      #fdf6ec;
  --cream-2:    #f6ead7;
  --ink:        #4a3526;
  --good:       #5cbf6a;
  --good-dark:  #3f9e4d;
  --wrong:      #e8836f;
  --star:       #ffce4f;
  --white:      #ffffff;

  --shadow: 0 6px 0 rgba(107, 68, 36, 0.18), 0 12px 24px rgba(107, 68, 36, 0.16);
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Quicksand', 'Jua', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, var(--sky-soft) 0, transparent 28%),
    radial-gradient(circle at 85% 8%, #ffe9c7 0, transparent 26%),
    radial-gradient(circle at 80% 92%, var(--sky-soft) 0, transparent 30%),
    var(--cream);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  user-select: none;
}

/* little floating clouds/dots in the background for atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(var(--brown-soft) 1.5px, transparent 1.6px);
  background-size: 40px 40px;
  opacity: 0.10;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}

h1, h2, h3 { font-family: 'Jua', 'Quicksand', sans-serif; font-weight: 700; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--cream);
  padding: 10px 0 10px;
  margin-left: -16px;
  margin-right: -16px;
  padding-left: 16px;
  padding-right: 16px;
}
/* Topbar children must not shrink or wrap — when coin/level pills grow, the
   back button used to collapse and the "나가기" text stacked vertically. */
.topbar > * {
  flex-shrink: 0;
  white-space: nowrap;
}
.topbar .who {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Jua', sans-serif; font-size: 1.1rem; color: var(--brown-dark);
}
.points-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--white);
  border: 3px solid var(--star);
  color: var(--brown-dark);
  font-family: 'Jua', sans-serif;
  padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 4px 0 rgba(255, 206, 79, 0.5);
}

/* ---------- buttons ---------- */
.btn {
  font-family: 'Jua', 'Quicksand', sans-serif;
  font-size: 1.1rem;
  border: none;
  border-radius: var(--radius);
  padding: 16px 22px;
  cursor: pointer;
  color: var(--white);
  background: var(--sky);
  box-shadow: 0 5px 0 var(--sky-dark);
  transition: transform .06s ease, box-shadow .06s ease, filter .1s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--sky-dark); }
.btn.brown { background: var(--brown); box-shadow: 0 5px 0 var(--brown-dark); }
.btn.green { background: var(--good); box-shadow: 0 5px 0 var(--good-dark); }
.btn.ghost {
  background: var(--white); color: var(--brown-dark);
  box-shadow: 0 5px 0 var(--cream-2); border: 2px solid var(--cream-2);
}
.btn.small { font-size: .95rem; padding: 10px 16px; border-radius: 16px; }
.btn:disabled { filter: grayscale(.5) opacity(.6); }

/* ---------- cards / panels ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 3px solid var(--cream-2);
}

/* ---------- login screen ---------- */
.welcome {
  text-align: center;
  margin-top: 6vh;
}
.welcome .mascot { font-size: 5rem; animation: bob 2.2s ease-in-out infinite; }
.welcome h1 { font-size: 2rem; color: var(--brown-dark); margin: 6px 0 2px; }
.welcome p  { color: var(--brown); margin-top: 0; }
.name-grid { display: grid; gap: 16px; margin-top: 26px; }
.name-card {
  display: flex; align-items: center; gap: 20px;
  border: 3px solid var(--sky-soft);
  border-radius: var(--radius);
  padding: 22px 26px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
}
.name-card:active { transform: scale(.97); box-shadow: 0 2px 0 rgba(107,68,36,0.18); }
.name-card .face { font-size: 3.8rem; line-height: 1; }
.name-card .label { font-family: 'Jua', sans-serif; font-size: 1.8rem; color: var(--brown-dark); }

/* ── Family picker grid + cards ─────────────────────────────────── */
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 26px;
  width: 100%;
}
.family-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px;
  border: 3px solid #f5c97a;
  border-radius: var(--radius);
  padding: 22px 16px 16px;
  cursor: pointer;
  background: #fffdf7;
  box-shadow: var(--shadow);
  transition: transform .10s ease, box-shadow .10s ease;
  text-align: center;
  position: relative; overflow: hidden;
}
/* subtle shimmer bar along top */
.family-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--sky) 0%, var(--star) 50%, var(--good) 100%);
  opacity: .5; border-radius: 4px 4px 0 0;
}
.family-card:active { transform: scale(.96); box-shadow: 0 2px 0 rgba(107,68,36,0.18); }
/* photo avatar */
.family-card .fc-avatar {
  width: 82px; height: 82px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid white;
  box-shadow: 0 4px 16px rgba(107,68,36,0.22);
  display: block;
  transition: transform .12s ease;
}
.family-card:active .fc-avatar { transform: scale(.95); }
/* placeholder circle when no photo */
.family-card .fc-placeholder {
  width: 82px; height: 82px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem;
  border: 4px solid white;
  box-shadow: 0 4px 16px rgba(107,68,36,0.22);
  flex-shrink: 0;
  transition: transform .12s ease;
}
.family-card:active .fc-placeholder { transform: scale(.95); }
.family-card .fc-name {
  font-family: 'Jua', sans-serif;
  font-size: 1.1rem;
  color: var(--brown-dark);
  line-height: 1.25;
  word-break: break-word;
  max-width: 140px;
}

/* ── Family icon in student-picker header pill ───────────────────── */
.family-header .fh-photo {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #f5c842;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Admin: family avatar upload widget ─────────────────────────── */
.family-icon-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  cursor: pointer;
}
.family-icon-wrap .fi-img {
  width: 68px; height: 68px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid var(--cream-2);
  box-shadow: 0 3px 10px rgba(107,68,36,0.18);
  transition: opacity .15s, box-shadow .15s;
}
.family-icon-wrap:hover .fi-img,
.family-icon-wrap:active .fi-img {
  opacity: .8;
  box-shadow: 0 0 0 4px var(--star), 0 3px 10px rgba(107,68,36,0.18);
}
.family-icon-wrap .fi-placeholder {
  width: 68px; height: 68px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  background: linear-gradient(135deg, #fff5e6, #ffe4b5);
  border: 3px solid var(--cream-2);
  box-shadow: 0 3px 10px rgba(107,68,36,0.18);
  transition: opacity .15s, box-shadow .15s;
}
.family-icon-wrap:hover .fi-placeholder,
.family-icon-wrap:active .fi-placeholder {
  opacity: .8;
  box-shadow: 0 0 0 4px var(--star), 0 3px 10px rgba(107,68,36,0.18);
}
.fi-uploading {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.82);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.4 } }

/* ── Crop modal ────────────────────────────────────────────── */
#cropWrap {
  width: min(260px, 72vw);
  height: min(260px, 72vw);
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: grab;
  margin: 0 auto;
  background: #1a1a1a;
  box-shadow: 0 0 0 4px var(--star), 0 8px 24px rgba(0,0,0,0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#cropWrap:active { cursor: grabbing; }
#cropImg {
  position: absolute;
  top: 50%; left: 50%;
  transform-origin: center;
  pointer-events: none;
  -webkit-user-drag: none;
  max-width: none;
}
.admin-link {
  margin-top: 30px; text-align: center;
}
.admin-link button {
  background: none; border: none; color: var(--brown-soft);
  font-family: 'Quicksand'; font-size: .9rem; cursor: pointer; text-decoration: underline;
}

/* ---------- login screen leaderboard ---------- */
.leaderboard-card {
  background: linear-gradient(135deg, #fff5e0 0%, #ffe4a8 100%);
  border: 2.5px solid #f5c842;
  border-radius: 20px;
  padding: 16px 18px;
  margin: 26px 0 6px;
  box-shadow: 0 6px 18px rgba(245, 200, 66, 0.22);
}
.leaderboard-title {
  font-family: 'Jua', sans-serif;
  font-size: 1.15rem;
  color: var(--brown-dark);
  text-align: center;
  margin: 0 0 12px;
  letter-spacing: .3px;
}
.leaderboard-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #ffffffd9;
  border-radius: 14px;
  border: 1.5px solid #f5e3b3;
  font-family: 'Quicksand', sans-serif;
}
.lb-row.lb-top {
  background: linear-gradient(135deg, #fffbe6 0%, #ffe066 100%);
  border-color: #f5c842;
  box-shadow: 0 3px 10px rgba(245, 200, 66, 0.3);
}
.lb-rank {
  font-size: 1.35rem;
  min-width: 30px;
  text-align: center;
}
.lb-num {
  font-family: 'Jua', sans-serif;
  font-size: 1rem;
  color: var(--brown-mid);
}
.lb-face { font-size: 1.5rem; line-height: 1; }
.lb-name {
  font-weight: 700;
  color: var(--brown-dark);
  flex: 1;
  font-size: 1rem;
}
.lb-stars {
  font-family: 'Jua', sans-serif;
  color: #b88817;
  font-weight: 700;
  font-size: 1.02rem;
  white-space: nowrap;
}

/* ---------- lesson list ---------- */
.section-title { color: var(--brown-dark); margin: 6px 0 14px; }
.lessons-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.lesson-list { display: grid; gap: 14px; }
.lesson-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 3px solid var(--cream-2);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.lesson-card h3 { margin: 0 0 4px; color: var(--brown-dark); font-size: 1.15rem; }
.lesson-card .meta { color: var(--brown); font-size: .9rem; margin-bottom: 12px; }

/* Lesson progress bar inside compact lesson button */
.lesson-progress-track {
  height: 6px; background: var(--cream-2); border-radius: 999px;
  overflow: hidden; margin-top: 8px;
}
.lesson-progress-fill {
  height: 100%; background: var(--sky); border-radius: 999px;
  transition: width .4s ease;
}
.lesson-progress-fill.complete { background: var(--good); }

/* Activity dots — per-activity state + jump-in on the lesson card */
.lesson-act-dots {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}
.act-dot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1 / 1;
  max-width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.05rem;
  background: var(--cream-2);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .1s ease;
}
.act-dot:active { transform: scale(.9); }
.act-dot.done {
  background: #e9f8ec;
  border-color: var(--good);
}
.act-dot.next {
  background: #e6f1fb;
  border-color: var(--sky-dark);
  animation: actDotPulse 1.3s ease-in-out infinite;
}
.act-dot.todo { opacity: .4; filter: grayscale(.6); }
.act-dot.locked { opacity: .45; }
.act-dot-check {
  position: absolute;
  bottom: -3px; right: -3px;
  background: var(--good);
  color: white;
  font-size: .55rem;
  width: 13px; height: 13px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  font-weight: 700;
}
@keyframes actDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56,150,222,.5); }
  60%      { box-shadow: 0 0 0 6px rgba(56,150,222,0); }
}

/* Streak pill */
.streak-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--white); border: 2.5px solid #f5a623;
  border-radius: 999px; padding: 5px 12px;
  box-shadow: 0 3px 0 rgba(245,166,35,0.35);
  font-family: 'Jua', sans-serif;
}
.streak-flame { font-size: 1.1rem; line-height: 1; }
.streak-num { font-size: 1rem; color: var(--brown-dark); }
.streak-label { font-size: .75rem; color: var(--brown); }

/* 2-column activity chip grid */
.act-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.act-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act-chip {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--cream); border: 2.5px solid var(--cream-2);
  border-radius: 18px; padding: 18px 8px 14px; cursor: pointer;
  color: var(--brown-dark); text-align: center;
  transition: transform .08s ease, box-shadow .08s ease;
  box-shadow: 0 3px 0 rgba(139,94,60,0.10);
  position: relative;
}
.act-chip:active { transform: scale(.95); box-shadow: none; }
.act-chip .ico { font-size: 2rem; line-height: 1; }
.act-chip .act-label { font-family: 'Jua', sans-serif; font-size: .9rem; }
.act-chip .act-status { font-size: .85rem; min-height: 1.1em; }
.act-chip.done {
  background: #e9f8ec; border-color: var(--good);
  box-shadow: 0 3px 0 rgba(92,191,106,0.30);
}
.act-chip.done .act-label { color: var(--good-dark); }
.act-chip.locked { opacity: .55; cursor: default; }
.act-chip .check { color: var(--good-dark); font-weight: 700; }

/* dimmed (wrong first guess in quiz) */
.option.dimmed { opacity: .4; pointer-events: none; filter: grayscale(.6); }

/* ---------- memory game ---------- */
.mem-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-top: 14px; max-width: 440px; margin-left: auto; margin-right: auto;
}
.mem-card { aspect-ratio: 3 / 4; perspective: 800px; cursor: pointer; }
.mem-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .4s; transform-style: preserve-3d;
}
.mem-card.up .mem-inner { transform: rotateY(180deg); }
.mem-front, .mem-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 14px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 4px 0 rgba(107,68,36,0.18);
}
.mem-front {
  background: var(--brown); color: #fff; font-size: 2rem;
  border: 3px solid var(--brown-dark);
}
.mem-back {
  transform: rotateY(180deg); background: var(--white);
  border: 3px solid var(--sky-soft); padding: 5px;
}
.mem-back.ko { background: var(--sky-soft); border-color: var(--sky); }
.mem-emoji { font-size: 2rem; line-height: 1; }
.mem-text {
  font-family: 'Jua'; font-size: .9rem; color: var(--brown-dark);
  text-align: center; line-height: 1.1; word-break: keep-all;
}
.mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-card.matched .mem-back { background: #e9f8ec; border-color: var(--good); opacity: .85; }
.mem-card.matched { animation: pop .3s; }

/* ---------- activity screens ---------- */
.activity-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.activity-head h2 { font-size: 1.25rem; color: var(--brown-dark); margin: 0; }
.progress-track {
  height: 14px; background: var(--cream-2); border-radius: 999px; overflow: hidden; margin-bottom: 18px;
  border: 2px solid var(--cream-2);
}
.progress-fill { height: 100%; background: var(--sky); border-radius: 999px; transition: width .35s ease; }

/* flashcard */
.flashcard {
  perspective: 1200px;
  margin: 10px auto 22px;
  width: 100%; max-width: 320px; height: 300px;
}
.flashcard-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .5s; transform-style: preserve-3d; cursor: pointer;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--radius); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  box-shadow: var(--shadow); border: 4px solid var(--cream-2); background: var(--white);
}
.flash-face .big-emoji { font-size: 5.5rem; }
.flash-face .word { font-family: 'Jua'; font-size: 2.2rem; color: var(--brown-dark); }
.flash-face .ko   { font-family: 'Jua'; font-size: 2rem; color: var(--sky-dark); padding: 0 14px; word-break: break-word; overflow-wrap: break-word; text-align: center; }
.flash-face .ko.long { font-size: 1.15rem; line-height: 1.35; }
.flash-face .hint { color: var(--brown-soft); font-size: .9rem; }
.flash-back { transform: rotateY(180deg); background: var(--sky-soft); }

/* quiz / matching option buttons */
.options { display: grid; gap: 12px; margin-top: 6px; }
.option {
  font-family: 'Jua'; font-size: 1.25rem;
  background: var(--white); border: 3px solid var(--sky-soft);
  border-radius: 18px; padding: 16px; cursor: pointer; color: var(--brown-dark);
  box-shadow: 0 4px 0 var(--sky-soft); transition: transform .06s;
}
.option:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--sky-soft); }
.option.correct { background: #e9f8ec; border-color: var(--good); box-shadow: 0 4px 0 var(--good); }
.option.wrong   { background: #fdecea; border-color: var(--wrong); box-shadow: 0 4px 0 var(--wrong); }

.prompt-emoji { font-size: 4.5rem; text-align: center; }
.prompt-ko { font-family: 'Jua'; font-size: 2rem; text-align: center; color: var(--sky-dark); margin: 4px 0 14px; word-break: break-word; padding: 0 8px; }
.prompt-label { text-align: center; color: var(--brown); margin-bottom: 4px; }
/* when a prompt card shows only Korean (quiz/typing), give it breathing room */
.card > .prompt-ko:first-child,
.card > .prompt-label:first-child + .prompt-ko { padding: 18px 0; }

/* matching */
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: grid; gap: 10px; }
.match-tile {
  font-family: 'Jua'; font-size: 1.1rem; background: var(--white);
  border: 3px solid var(--sky-soft); border-radius: 16px; padding: 14px 8px;
  cursor: pointer; color: var(--brown-dark); text-align: center;
  box-shadow: 0 4px 0 var(--sky-soft); transition: transform .06s;
}
.match-tile .em { font-size: 1.6rem; display: block; }
.match-tile.selected { border-color: var(--star); background: #fff8e6; }
.match-tile.matched { background: #e9f8ec; border-color: var(--good); box-shadow: none; opacity: .55; pointer-events: none; }
.match-tile.shake { animation: shake .35s; }

/* typing */
.type-input {
  width: 100%; font-family: 'Jua'; font-size: 1.6rem; text-align: center;
  padding: 14px; border-radius: 16px; border: 3px solid var(--sky-soft);
  color: var(--brown-dark); background: var(--white); outline: none;
}
.type-input:focus { border-color: var(--sky-dark); }
.type-feedback { text-align: center; min-height: 28px; margin-top: 10px; font-family: 'Jua'; }
.type-feedback.ok  { color: var(--good-dark); }
.type-feedback.no  { color: var(--wrong); }

/* crossword */
.cw-wrap { overflow-x: auto; padding-bottom: 6px; }
.cw-grid { display: grid; gap: 3px; margin: 0 auto 16px; width: max-content; }
.cw-cell {
  width: 34px; height: 34px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.cw-cell.block { background: transparent; }
.cw-cell.open {
  background: var(--white); border: 2px solid var(--brown-soft); border-radius: 6px;
}
.cw-cell input {
  width: 100%; height: 100%; border: none; background: transparent;
  text-align: center; font-family: 'Jua'; font-size: 1.1rem; text-transform: uppercase;
  color: var(--brown-dark); outline: none; padding: 0;
}
.cw-cell.right { background: #e9f8ec; }
.cw-cell .num { position: absolute; top: 1px; left: 3px; font-size: .55rem; color: var(--brown); }
.cw-clues { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cw-clue-group h4 { margin: 0 0 6px; color: var(--brown-dark); }
.cw-clue-group ol { margin: 0; padding-left: 22px; }
.cw-clue-group li { margin-bottom: 5px; color: var(--ink); }

/* ---------- recording screen ---------- */
.rec-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 4px; border-bottom: 2px solid var(--cream-2);
  flex-wrap: wrap;
}
.rec-word { font-size: 1rem; color: var(--brown-dark); }
.rec-word .muted { font-size: .85rem; }
.rec-controls { display: flex; align-items: center; gap: 8px; }
.rec-btn {
  border: 2px solid var(--sky-soft); background: var(--white); color: var(--brown-dark);
  border-radius: 12px; padding: 8px 12px; font-size: 1.05rem; cursor: pointer;
  box-shadow: 0 3px 0 var(--sky-soft); transition: transform .06s;
}
.rec-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--sky-soft); }
.rec-btn.rec-dim { opacity: .4; }
.rec-btn.rec-del {
  border-color: #f3c0bd; box-shadow: 0 3px 0 #f3c0bd;
}
.rec-btn.rec-del:active { box-shadow: 0 1px 0 #f3c0bd; }
.rec-btn.rec-mic.recording {
  background: var(--wrong); color: var(--white); border-color: var(--wrong);
  animation: pulse 1s ease-in-out infinite;
}
.rec-status { font-size: .78rem; color: var(--brown-soft); min-width: 70px; }
.rec-status.has { color: var(--good-dark); }
.rec-msg-box {
  background: var(--sky-soft); border: 2px solid var(--sky); border-radius: 14px;
  padding: 12px; margin-bottom: 12px;
}
.rec-list-label { font-size: .82rem; color: var(--brown); margin: 10px 0 4px; }

/* parent message in celebration */
.parent-msg {
  background: var(--cream); border: 3px dashed var(--brown-soft);
  border-radius: 16px; padding: 12px; margin-bottom: 16px;
}
.parent-msg-title { font-family: 'Jua'; color: var(--brown-dark); margin-bottom: 8px; }
.child-msg {
  background: #fff5e9; border: 3px dashed var(--sky); border-radius: 16px;
  padding: 12px; margin-bottom: 16px;
}

@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }

/* ---------- celebration overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(74, 53, 38, 0.45); backdrop-filter: blur(3px);
  animation: fadein .25s ease;
}
.reward {
  background: var(--white); border-radius: 28px; padding: 30px 26px; text-align: center;
  max-width: 360px; width: 88%; box-shadow: var(--shadow); border: 4px solid var(--star);
  animation: pop .4s cubic-bezier(.2,1.3,.5,1);
}
.reward .big { font-size: 4.5rem; animation: bob 1.4s ease-in-out infinite; }
.reward h2 { color: var(--brown-dark); margin: 8px 0 4px; }
.reward p { color: var(--brown); margin: 4px 0 18px; }
.reward .earn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cream); border: 3px solid var(--star); color: var(--brown-dark);
  font-family: 'Jua'; font-size: 1.3rem; padding: 8px 18px; border-radius: 999px; margin-bottom: 18px;
}
.stars { font-size: 2rem; letter-spacing: 6px; margin-bottom: 8px; }

/* confetti */
.confetti {
  position: fixed; top: -20px; width: 10px; height: 14px; z-index: 49;
  border-radius: 2px; animation: fall linear forwards;
}

/* admin */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.admin-table th, .admin-table td {
  border-bottom: 2px solid var(--cream-2); padding: 9px 6px; text-align: left; font-size: .92rem;
}
.admin-table th { color: var(--brown-dark); font-family: 'Jua'; }
.bar-mini { height: 10px; background: var(--cream-2); border-radius: 999px; overflow: hidden; min-width: 90px; }
.bar-mini > div { height: 100%; background: var(--good); }

.center { text-align: center; }
.muted { color: var(--brown-soft); }
.spacer { height: 14px; }
.row-gap { display: grid; gap: 12px; }

/* ---------- animations ---------- */
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
@keyframes fall {
  to { transform: translateY(105vh) rotate(620deg); opacity: 1; }
}

/* fade-in for screen changes — opacity only (no transform, which would break
   position:sticky on the topbar by creating a containing block). */
.screen { animation: slidein .3s ease; }
@keyframes slidein { from { opacity: 0 } to { opacity: 1 } }

/* ---------- story activity ---------- */
.story-card {
  line-height: 1.85;
  font-size: 1.08rem;
}
.story-text { margin: 0; color: var(--ink); }
.vocab-word {
  background: var(--sky-soft);
  color: var(--sky-dark);
  border-radius: 6px;
  padding: 1px 4px;
  cursor: pointer;
  font-weight: 700;
  border-bottom: 2px solid var(--sky);
  transition: background .12s;
}
.vocab-word:active { background: var(--sky); color: var(--white); }

.story-popup {
  position: absolute;
  background: var(--white);
  border: 3px solid var(--sky);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 6px 20px rgba(107,68,36,.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 200;
  animation: pop .15s ease;
  max-width: 280px;
  min-width: 120px;
  text-align: center;
  pointer-events: none;
}
.story-popup.hidden { display: none; }
.story-popup-emoji { font-size: 1.8rem; line-height: 1; }
.story-popup-en {
  font-family: 'Jua';
  color: var(--brown-dark);
  font-size: 1rem;
  white-space: nowrap;
}
.story-popup-ko {
  color: var(--sky-dark);
  font-size: .92rem;
  word-break: keep-all;
  line-height: 1.3;
}

.hidden { display: none !important; }
/* audio progress bar is tappable to seek */
#stAudioBar { cursor: pointer; }
#stAudioBar:hover .progress-fill { filter: brightness(1.1); }

/* crossword word-complete pop animation */
@keyframes cwpop { 0%{transform:scale(1)} 40%{transform:scale(1.18)} 100%{transform:scale(1)} }
.cw-pop { animation: cwpop .35s ease; }

/* crossword wrong letter — red flash + shake */
@keyframes cwshake {
  0%  { transform: translateX(0);    background: #fde8e8; }
  20% { transform: translateX(-4px); background: #fbb;    }
  40% { transform: translateX(4px);  background: #fbb;    }
  60% { transform: translateX(-3px); background: #fde8e8; }
  80% { transform: translateX(3px);  background: #fde8e8; }
  100%{ transform: translateX(0);    background: "";       }
}
.cw-wrong { animation: cwshake .45s ease; }
.cw-wrong input { color: var(--wrong, #c0392b); }

/* difficulty selector buttons in Create Lesson */
.diff-btn {
  flex: 1;
  padding: 10px 6px;
  border-radius: 14px;
  border: 2px solid var(--cream-2);
  background: var(--cream);
  cursor: pointer;
  text-align: center;
  font-family: 'Quicksand', sans-serif;
  font-size: .82rem;
  line-height: 1.4;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.diff-btn.active {
  border-color: var(--brown-dark);
  background: #fff8f0;
}
.diff-btn b { font-family: 'Jua', sans-serif; font-size: .9rem; }

/* ── Study mode ── */
.study-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 4px;
}

.study-card {
  height: 110px;
  perspective: 600px;
  cursor: pointer;
}

.study-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .35s ease;
  border-radius: 16px;
}

.study-card.flipped .study-inner {
  transform: rotateY(180deg);
}

.study-front, .study-back {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.study-front {
  background: #fff;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--brown-dark);
  text-align: center;
}

.study-back {
  background: var(--sky-light, #e8f7fd);
  transform: rotateY(180deg);
  gap: 4px;
}

.study-ko {
  font-family: 'Jua', sans-serif;
  font-size: .95rem;
  color: var(--brown-dark);
  text-align: center;
}

.study-emoji {
  font-size: 1.5rem;
}

/* admin auto-play toggle */
.toggle-btn {
  padding: 4px 14px;
  border-radius: 20px;
  border: 2px solid var(--cream-2);
  background: var(--cream-2);
  color: var(--brown-mid);
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.toggle-btn.on {
  background: var(--brown-dark);
  border-color: var(--brown-dark);
  color: #fff;
}

/* ── Branded modal dialogs (replace native alert/confirm) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
  animation: modalFade .15s ease;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: #fff;
  border-radius: 24px;
  padding: 28px 24px 22px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  animation: modalPop .2s ease;
}
@keyframes modalPop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-emoji { font-size: 2.6rem; margin-bottom: 10px; }
.modal-msg {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--brown-dark);
  margin-bottom: 20px;
  word-break: keep-all;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.modal-actions .btn { flex: 1; max-width: 150px; }
/* Stacked variant: full-width buttons, one per row (e.g. level detail popup) */
.modal-actions-stacked {
  flex-direction: column;
  gap: 8px;
}
.modal-actions-stacked .btn {
  flex: none;
  max-width: none;
  width: 100%;
  white-space: nowrap;
}
.btn.danger {
  background: var(--wrong, #e8836f);
  color: #fff;
}
.btn.danger:active { filter: brightness(.92); }

/* part-of-speech badge (intermediate lessons only) */
.pos-badge {
  display: inline-block;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.5em;
  vertical-align: middle;
  color: var(--brown);
  background: var(--cream-2);
  border-radius: 8px;
  padding: 2px 7px;
  margin-left: 6px;
  letter-spacing: .3px;
  position: relative;
  top: -2px;
}
.story-popup-en .pos-badge { font-size: .7rem; }

/* ── Topbar back button (icon-only, circular) ── */
.btn.back-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Level pill (topbar) with progress ring ──
   .level-pill-ring is the gold conic-gradient outer ring; --level-pct controls
   how much of the ring is filled (0–100%). The inner .level-pill is plain
   white with no border — the ring IS the visual frame. */
.level-pill-ring {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: conic-gradient(
    var(--star) 0%,
    var(--star) var(--level-pct, 0%),
    var(--cream-2) var(--level-pct, 0%),
    var(--cream-2) 100%
  );
  box-shadow: 0 4px 0 rgba(255, 206, 79, 0.5);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .5s ease;
}
.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  color: var(--brown-dark);
  font-family: 'Jua', sans-serif;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.level-tier { font-size: 1.1rem; line-height: 1; }
.level-num  { font-size: .95rem; }
/* The horizontal level-bar still lives in the level detail modal. */
.level-bar {
  display: inline-block;
  width: 46px;
  height: 8px;
  background: var(--cream-2);
  border-radius: 999px;
  overflow: hidden;
}
.level-bar-fill {
  display: block;
  height: 100%;
  background: var(--star);
  border-radius: 999px;
  transition: width .5s ease;
}

/* ── Level-up celebration ── */
.levelup-reward { border: 4px solid var(--star); }
.levelup-banner {
  font-family: 'Jua', sans-serif;
  font-size: 1.4rem;
  color: var(--brown-dark);
  background: var(--star);
  border-radius: 999px;
  padding: 4px 22px;
  display: inline-block;
  margin-bottom: 6px;
  letter-spacing: 1px;
  animation: levelPop .4s ease;
}
.levelup-num {
  font-family: 'Jua', sans-serif;
  font-size: 2rem;
  color: var(--brown-dark);
  margin: 2px 0;
}
@keyframes levelPop {
  0% { transform: scale(.6); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Compact lesson buttons (lesson list) ── */
.lesson-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(139, 94, 60, 0.12);
  transition: transform .08s ease, box-shadow .08s ease;
  font-family: 'Quicksand', sans-serif;
}
.lesson-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(139, 94, 60, 0.12);
}
.lesson-button-main { flex: 1; min-width: 0; }
.lesson-button-title {
  font-family: 'Jua', sans-serif;
  font-size: 1.1rem;
  color: var(--brown-dark);
  margin-bottom: 3px;
  overflow-wrap: break-word;
}
.lesson-button-meta {
  font-size: .85rem;
  color: var(--brown-mid, #8b5e3c);
  opacity: .75;
}
.lesson-button-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 10px;
}
.lesson-done-badge {
  background: #5cbf6a;
  color: #fff;
  font-family: 'Jua', sans-serif;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.lesson-button-chevron {
  font-size: 1.6rem;
  color: var(--brown-mid, #8b5e3c);
  opacity: .5;
  line-height: 1;
}

/* ── All-levels ladder (level detail → See all levels) ── */
.ladder-scroll {
  max-height: 50vh;
  overflow-y: auto;
  text-align: left;
  border-radius: 12px;
  background: var(--cream);
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.ladder-tier-header {
  font-family: 'Jua', sans-serif;
  color: var(--brown-dark);
  font-size: 1rem;
  padding: 10px 8px 4px;
  position: sticky;
  top: 0;
  background: var(--cream);
}
.ladder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  margin: 4px 0;
  border-radius: 10px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
}
.ladder-row .ladder-level {
  font-family: 'Jua', sans-serif;
  color: var(--brown-dark);
}
.ladder-row .ladder-status { font-size: .85rem; }
.ladder-row.done {
  background: #e7f6e9;
  color: #3f9d4e;
}
.ladder-row.current {
  background: var(--star);
  color: var(--brown-dark);
  box-shadow: 0 3px 0 rgba(255, 206, 79, 0.5);
}
.ladder-row.current .ladder-status { font-weight: 700; }
.ladder-row.locked {
  background: var(--white);
  color: var(--brown-mid, #8b5e3c);
  opacity: .8;
}

/* crossword solved state */
.cw-solved-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 4px;
}
.cw-solved-badge {
  font-family: 'Jua', sans-serif; font-size: 1.1rem;
  color: var(--good-dark); background: #e9f8ec;
  border: 2px solid var(--good); border-radius: 999px;
  padding: 8px 18px;
}
.cw-cell input[readonly] { cursor: default; pointer-events: none; }

/* ── Playlist player (admin lesson recordings) ── */
.playlist-player {
  background: var(--brown-dark);
  border-radius: 16px;
  padding: 16px 18px 14px;
  margin-bottom: 18px;
  color: #fff;
}
.playlist-player.pl-empty {
  background: var(--cream-2);
  text-align: center;
  padding: 14px;
}
.pl-title {
  font-family: 'Jua', sans-serif;
  font-size: .9rem;
  opacity: .8;
  margin-bottom: 6px;
}
.pl-track-label {
  font-family: 'Jua', sans-serif;
  font-size: 1.15rem;
  margin-bottom: 10px;
  min-height: 1.4em;
}
.pl-progress-wrap {
  padding: 4px 0 2px;
}
.pl-seek {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.25);
  outline: none;
  cursor: pointer;
}
.pl-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--star);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.pl-seek::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--star);
  border: none;
  cursor: pointer;
}
.pl-time-row {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  opacity: .7;
  margin: 4px 0 10px;
  font-family: 'Quicksand', sans-serif;
}
.pl-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.pl-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.pl-btn:active { background: rgba(255,255,255,0.3); }
.pl-btn-main {
  width: 56px; height: 56px;
  font-size: 1.5rem;
  background: var(--star);
  color: var(--brown-dark);
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}
.pl-btn-main:active { box-shadow: none; transform: translateY(2px); }
.pl-track-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pl-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.pl-dot.active {
  background: var(--star);
  transform: scale(1.4);
}

/* test-given badge on admin lesson rows. Reused on the student lesson list
   and detail screen so the kid sees the same icon the parent toggles. */
.test-given-badge {
  display: inline-block;
  font-size: .72rem;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  background: #fff4cc;
  color: #8a6200;
  border: 1.5px solid #f5c842;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  white-space: nowrap;
}

.lesson-test-line {
  margin-top: 5px;
  margin-bottom: 4px;
}

/* lesson title subtitle in screenRecord sticky topbar */
/* Special topbar variant for screenRecord with a lesson title subtitle.
   The whole .topbar is already sticky; we just stack the subtitle inside it
   so they move together as one unit. */
.topbar-with-subtitle {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding-bottom: 8px;
}
.topbar-with-subtitle .topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar-subtitle {
  text-align: center;
  font-family: 'Jua', sans-serif;
  font-size: .9rem;
  color: var(--brown-dark);
  padding: 2px 8px 0;
  border-top: 1px solid var(--cream-2);
  padding-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Record All Words */
.rec-all-active {
  background: #fffbe6;
  border-radius: 10px;
  outline: 2px solid var(--star);
  transition: outline .2s;
}
.btn.recording {
  background: var(--wrong);
  color: #fff;
  animation: pulse-rec 1s ease-in-out infinite;
}
@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

/* TTS voice picker in admin per-child card */
.voice-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.voice-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.voice-btn {
  font-family: 'Quicksand', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid var(--cream-2);
  background: var(--cream);
  color: var(--brown);
  cursor: pointer;
  transition: all .1s;
}
.voice-btn:hover { border-color: var(--sky); }
.voice-btn.active {
  background: var(--brown-dark);
  color: #fff;
  border-color: var(--brown-dark);
}

/* Story sentence translations (full story mode) — hidden by default,
   revealed when the .with-trans class is on the parent story-card */
.story-sent-block {
  display: inline;
}
.story-card.with-trans .story-sent-block {
  display: block;
  margin-bottom: 14px;
}
.story-trans {
  display: none;
  font-family: 'Quicksand', sans-serif;
  font-size: .92rem;
  line-height: 1.5;
  color: var(--brown);
  background: #fff8e8;
  border: 1.5px dashed var(--cream-2);
  border-radius: 12px;
  padding: 8px 14px;
  margin-top: 6px;
}
.story-card.with-trans .story-trans {
  display: block;
}

/* UI language toggle on login screen */
.lang-toggle-btn {
  font-family: 'Quicksand', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--cream-2);
  background: var(--white);
  color: var(--brown);
  cursor: pointer;
  transition: all .15s;
}
.lang-toggle-btn:hover { background: var(--cream); border-color: var(--sky); }

/* Collapsible student cards on admin screen */
.student-card-header {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  border-radius: 12px;
  padding: 4px;
  margin: -4px;
  transition: background .15s;
}
.student-card-header:hover { background: var(--cream); }
.student-chevron {
  font-size: 1.1rem;
  color: var(--brown-mid);
  transition: transform .2s;
  display: inline-block;
  line-height: 1;
}
.student-card.expanded .student-chevron { transform: rotate(180deg); }
.student-expandable { display: none; }
.student-card.expanded .student-expandable { display: block; }

/* ── Drag-to-reorder ────────────────────────────────────────────── */
.drag-grip {
  font-size: 1.1rem;
  color: var(--brown-soft);
  cursor: grab;
  flex-shrink: 0;
  padding: 0 4px 0 0;
  user-select: none;
  line-height: 1;
  transition: color .15s;
}
.student-card-header:hover .drag-grip { color: var(--brown); }
/* The original card while dragging — kept in layout but nearly invisible */
.student-card.drag-source {
  opacity: 0.25;
  transition: opacity .1s;
  pointer-events: none;
}

/* Completed lessons collapsed section on lesson list */
.completed-section { margin-top: 20px; }
.completed-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; background: var(--cream); border: 2px solid var(--cream-2);
  border-radius: 16px; cursor: pointer; font-family: 'Jua', sans-serif;
  color: var(--brown-mid); font-size: .95rem; transition: background .15s;
}
.completed-header:hover { background: var(--cream-2); }
.completed-body { padding-top: 8px; }

/* ── Pet system ──────────────────────────────────────────── */

.pet-nav-btn {
  font-size: 1.3rem;
  background: white;
  border: 2px solid var(--cream-2);
  border-radius: 999px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.pet-nav-btn:hover  { transform: scale(1.1); }
.pet-nav-btn:active { transform: scale(.92); }

.pet-coin-pill {
  background: #fff8e1;
  border: 2px solid #FFD54F;
  border-radius: 999px;
  padding: 4px 10px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  color: #E65100;
  white-space: nowrap;
}

.pet-act-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  background: white;
  border: 2px solid var(--cream-2);
  border-radius: 18px;
  padding: 12px 6px;
  cursor: pointer;
  font-family: 'Jua', sans-serif;
  font-size: .82rem;
  color: var(--brown-dark);
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 3px 0 rgba(107,68,36,.15);
  -webkit-tap-highlight-color: transparent;
}
.pet-act-btn:hover:not(:disabled)  { transform: translateY(-2px); box-shadow: 0 5px 0 rgba(107,68,36,.15); }
.pet-act-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.pet-act-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Idle breathing bob — on the img, always running */
@keyframes petBob {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-9px); }
}

/* Interaction animations — applied to #petSprite */
@keyframes petWiggle {
  0%,100% { transform: rotate(0deg); }
  20%     { transform: rotate(-13deg); }
  45%     { transform: rotate(13deg); }
  65%     { transform: rotate(-9deg); }
  85%     { transform: rotate(9deg); }
}
@keyframes petHop {
  0%,100% { transform: translateY(0) scaleY(1); }
  35%     { transform: translateY(-32px) scaleY(1.08); }
  65%     { transform: translateY(6px) scaleY(.93); }
}
@keyframes petSpin {
  0%   { transform: rotate(0deg) scale(1); }
  40%  { transform: rotate(200deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}
@keyframes petBounce {
  0%,100% { transform: scale(1); }
  40%     { transform: scale(1.18); }
  70%     { transform: scale(.94); }
}
@keyframes petPulse {
  0%   { transform: scale(1);    filter: brightness(1);   }
  30%  { transform: scale(1.12); filter: brightness(1.25); }
  65%  { transform: scale(.95);  filter: brightness(1);   }
  100% { transform: scale(1);    filter: brightness(1);   }
}

/* Classes toggled by playAnim() */
.petWiggle { animation: petWiggle .52s ease-in-out !important; }
.petHop    { animation: petHop    .65s ease-in-out !important; }
.petSpin   { animation: petSpin   .65s ease-in-out !important; }
.petBounce { animation: petBounce .42s ease-in-out !important; }
.petPulse  { animation: petPulse  .72s ease-in-out !important; }

/* Hearts floating on tap */
@keyframes heartFloat {
  0%   { transform: translateY(0) scale(1);   opacity: 1; }
  100% { transform: translateY(-52px) scale(1.3); opacity: 0; }
}

/* Consumable treats (sushi/cake) pop into the room when purchased. */
@keyframes treatPop {
  0%   { transform: scale(0.2) translateY(-10px); opacity: 0; }
  60%  { transform: scale(1.15) translateY(0);    opacity: 1; }
  100% { transform: scale(1) translateY(0);       opacity: 1; }
}

/* Family header on the student picker — clickable, goes back to family picker */
.family-header {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 244, 204, 0.7);
  border: 1.5px solid #f5c842;
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  margin: 4px auto 14px;
  width: fit-content;
  font-family: 'Jua', sans-serif;
  color: var(--brown-dark);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.family-header:active { transform: scale(.96); }
.family-header .family-back {
  font-size: 1rem;
  color: var(--brown-mid);
  font-weight: 700;
}
.family-header .family-name {
  font-size: .95rem;
}

/* ───── Topbar pills (coins + streak) ───── */
.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: 'Jua', sans-serif;
  background: linear-gradient(135deg, #fff8dc 0%, #ffd966 100%);
  border: 2px solid #f5c842;
  color: #8a6200;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: .82rem;
  white-space: nowrap;
  transition: transform .2s ease;
}
.coin-pill-pulse {
  animation: coinPulse .5s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes coinPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); filter: brightness(1.15); }
  100% { transform: scale(1); }
}
.streak-pill {
  display: inline-flex;
  align-items: center;
  font-family: 'Jua', sans-serif;
  background: linear-gradient(135deg, #fff0e0 0%, #ffaa70 100%);
  border: 2px solid #ff6b35;
  color: #8a3200;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .82rem;
  white-space: nowrap;
}

/* ───── Flying coin emoji used in the celebration ───── */
.flying-coin {
  position: fixed;
  font-size: 1.6rem;
  z-index: 9999;
  pointer-events: none;
  transition: transform .85s cubic-bezier(.35, .15, .25, 1),
              opacity   .85s ease-out;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.3));
}

/* ───── Streak bonus block inside the celebration overlay ───── */
.streak-bonus {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #fff0e0 0%, #ffd0a0 100%);
  border: 2px solid #ff8c42;
  color: #7a2e00;
  border-radius: 14px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: .9rem;
}
.streak-bonus.milestone {
  background: linear-gradient(135deg, #fff4cc 0%, #ffd966 50%, #ff9966 100%);
  border-color: #f5c842;
  font-size: 1rem;
  animation: milestoneGlow 1.4s ease-in-out infinite alternate;
}
@keyframes milestoneGlow {
  0%   { box-shadow: 0 0 5px rgba(245, 200, 66, 0.4); }
  100% { box-shadow: 0 0 18px rgba(245, 200, 66, 0.8); }
}

/* 🛒 shop button in pet topbar */
.pet-shop-btn {
  font-size: 1.15rem;
  background: white;
  border: 2px solid var(--cream-2);
  border-radius: 999px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.pet-shop-btn:hover  { transform: scale(1.1); }
.pet-shop-btn:active { transform: scale(.92); }

/* ============================================================
   DESKTOP — compress the pet screen so the whole room, stats and
   action buttons fit comfortably in one viewport without scrolling.
   Triggered when the viewport is wide enough (typical laptop+ size).
   On mobile this rule doesn't apply so nothing changes.
   ============================================================ */
@media (min-width: 600px) {
  /* Reduce wasted bottom padding (which existed for iOS safe area) */
  #app { padding-bottom: 16px; }

  /* Cap the pet screen at viewport height minus #app's top+bottom
     padding (18 + 16 = 34) so no page scrolling is needed.
     Combined with the compression below, this leaves a big chunk of
     space for the petRoom (flex:1). */
  .pet-screen {
    min-height: calc(100vh - 34px) !important;
    max-height: calc(100vh - 34px);
  }

  /* On tall desktop windows, #petRoom (flex:1) stretches huge and scatters the
     pet/house with a big dead zone between them. Cap it to a compact height and
     ground it just above the stat bars (sky above, pet on the "floor").
     flex-shrink stays on so it still fits short windows. */
  .pet-screen #petRoom {
    flex: 0 1 auto !important;
    height: 340px !important;
    margin-top: auto !important;
  }

  /* Smaller, side-by-side action buttons — saves ~40px height */
  .pet-screen .pet-act-btn {
    flex-direction: row;
    padding: 8px 10px;
    gap: 8px;
    font-size: .9rem;
  }
  .pet-screen .pet-act-btn > span:first-child {
    font-size: 1.3rem !important;
  }
}

/* ---- student test screen ---- */
.test-question {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--white); border-radius: 16px;
  padding: 14px 16px; border: 2px solid var(--cream-2);
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.test-q-num {
  font-family: 'Jua', sans-serif; background: var(--sky); color: #fff;
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .95rem;
}
.test-q-num.en { background: var(--brown); }
.test-q-body { flex: 1; min-width: 0; }
.test-q-prompt {
  font-family: 'Jua', sans-serif; font-size: 1.05rem;
  color: var(--brown-dark); margin-bottom: 8px;
  word-break: break-word; line-height: 1.35;
}
.test-answer {
  width: 100%; font-family: 'Quicksand', sans-serif; font-size: 1rem;
  padding: 7px 12px; border-radius: 10px; border: 2px solid var(--sky-soft);
  color: var(--brown-dark); background: var(--white); outline: none;
  box-sizing: border-box;
}
.test-answer:focus { border-color: var(--sky-dark); }
.test-leave-warn {
  background: #fff3e0; border: 2px solid #ffb74d; border-radius: 14px;
  padding: 12px 16px; margin-bottom: 14px; display: none;
  font-family: 'Quicksand', sans-serif; font-size: .92rem; line-height: 1.5;
  color: #7c4700;
}
/* Part-of-speech label inside test question prompts */
.q-pos {
  display: inline-block;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.55em;
  vertical-align: middle;
  color: var(--brown);
  background: var(--cream-2);
  border-radius: 8px;
  padding: 2px 7px;
  margin-left: 6px;
  position: relative;
  top: -2px;
}

/* Pinned lesson — has an active test waiting */
.lesson-pinned {
  border: 2px solid var(--sky-dark) !important;
  background: #f0f8ff !important;
}

/* "Take the Test →" / "📊 See Results →" call-to-action inside a lesson card */
.lesson-test-cta {
  display: inline-block;
  margin-top: 6px;
  font-family: 'Jua', sans-serif;
  font-size: .88rem;
  color: var(--sky-dark);
  background: #e6f1fb;
  border: 1.5px solid var(--sky-dark);
  border-radius: 20px;
  padding: 4px 14px;
  font-weight: 700;
  cursor: pointer;
}

/* Purple pin border for lessons with unviewed graded results */
.lesson-pinned-results {
  border: 2px solid #ce93d8 !important;
  background: #fdf6ff !important;
}

/* Pulse animation to signal the Check Test Results button is tappable */
@keyframes resultsPulse {
  0%   { box-shadow: 0 0 0 0 rgba(206,147,216,.55); }
  60%  { box-shadow: 0 0 0 7px rgba(206,147,216,.0); }
  100% { box-shadow: 0 0 0 0 rgba(206,147,216,.0); }
}
.lesson-results-btn--pulse {
  animation: resultsPulse 1.3s ease-out 3;
}

/* "Check Test Results" button inside a testGiven lesson card */
.lesson-results-btn {
  display: inline-block;
  margin-top: 6px;
  font-family: 'Jua', sans-serif;
  font-size: .83rem;
  color: #6a1b9a;
  background: #f3e5f5;
  border: 1.5px solid #ce93d8;
  border-radius: 20px;
  padding: 4px 14px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
@keyframes badgeTap {
  0%   { transform: scale(1);    filter: brightness(1); }
  55%  { transform: scale(1.1);  filter: brightness(1.25); }
  100% { transform: scale(1.08); filter: brightness(1.2); }
}
.badge-tapped {
  animation: badgeTap 0.18s ease-out forwards;
}

/* Bonus coins notification on the student results screen */
.test-bonus-coins {
  text-align: center;
  font-family: 'Jua', sans-serif;
  font-size: 1.15rem;
  color: #7a5200;
  background: #fff8e1;
  border: 2px solid #ffd54f;
  border-radius: 14px;
  padding: 10px 18px;
  margin-bottom: 12px;
}

/* Coin shower on the results screen when bonus coins were awarded */
.coin-particle {
  position: fixed;
  z-index: 50;
  font-size: 1.6rem;
  pointer-events: none;
  will-change: transform, opacity;
  animation: coinFloat 1.4s ease-out forwards;
}
@keyframes coinFloat {
  0%   { transform: translate(-50%, -50%) scale(.4);  opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(240deg); opacity: 0; }
}
.coin-pop { animation: coinBannerPop .5s ease-out; }
@keyframes coinBannerPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* "Practice your missed words" card on the test results screen */
.missed-words-card {
  background: #fff8e1;
  border: 2px solid #ffd54f;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.missed-words-title {
  font-family: 'Jua', sans-serif;
  color: #7a5200;
  font-size: 1rem;
  margin-bottom: 10px;
}
.missed-words-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.missed-chip {
  background: white;
  border: 1.5px solid #ffd54f;
  border-radius: 14px;
  padding: 6px 12px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  color: var(--brown-dark);
  font-size: .95rem;
}

/* Streak chain strip on the lesson list — stacked so it never overflows */
.streak-strip {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: white;
  border-radius: 16px;
  padding: 10px 14px;
  margin: 0 0 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}
.streak-strip-count {
  font-family: 'Jua', sans-serif;
  color: #e8590c;
  font-size: .95rem;
}
.streak-week {
  display: flex;
  gap: 4px;
  width: 100%;
}
.streak-day {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0;
}
.streak-day.today {
  background: #fff3e0;
  border-radius: 8px;
}
.streak-day .sd-letter {
  font-size: .65rem;
  color: var(--brown-mid);
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
}
.streak-day .sd-flame {
  font-size: 1.05rem;
  line-height: 1.25;
  opacity: .28;
  filter: grayscale(1);
}
.streak-day .sd-flame.on {
  opacity: 1;
  filter: none;
}
.sd-flame.pulse {
  animation: streakNudgePulse 1.2s ease-in-out infinite;
}
@keyframes streakNudgePulse {
  0%, 100% { opacity: .35; transform: scale(1); }
  50%      { opacity: .7;  transform: scale(1.18); }
}
.streak-nudge {
  text-align: center;
  font-family: 'Jua', sans-serif;
  color: #e8590c;
  font-size: .85rem;
  margin: 0 0 8px;
}

/* Admin top strip — active tests summary */
.admin-test-strip {
  border-left: 4px solid var(--sky-dark);
  padding: 12px 14px;
}
.admin-test-strip-section { }
.admin-test-strip-label {
  font-family: 'Jua', sans-serif;
  font-size: .82rem;
  color: var(--brown-dark);
  margin-bottom: 5px;
  font-weight: 700;
}
.admin-test-strip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  font-family: 'Quicksand', sans-serif;
  color: var(--brown-dark);
  padding: 3px 0;
  flex-wrap: wrap;
}
.admin-test-strip-lesson {
  color: var(--brown-mid);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Test Complete collapsible section inside admin student card */
.test-complete-section {
  margin-top: 14px;
  border-top: 1px solid var(--cream-2);
  padding-top: 8px;
}
.test-complete-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Jua', sans-serif;
  font-size: .88rem;
  color: var(--brown-dark);
  padding: 4px 0;
  gap: 8px;
  opacity: .8;
}
.test-complete-header:hover { opacity: 1; }
.test-complete-body { margin-top: 6px; }

/* ── Mobile overflow fixes (phone only — desktop unchanged) ── */
@media (max-width: 520px) {
  /* Admin progress table: tighter cells so table fits without page-level scroll */
  .admin-table th, .admin-table td {
    font-size: .72rem;
    padding: 6px 3px;
  }
  .admin-table td:first-child, .admin-table th:first-child {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Activity chip grid: chips must shrink into their grid cells on narrow screens */
  .act-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .act-chip {
    min-width: 0;          /* lets the grid cell shrink below chip's natural size */
    padding: 14px 6px 10px;
    word-break: break-word;
  }
  .act-chip .ico { font-size: 1.7rem; }
  .act-chip .act-label { font-size: .82rem; }
}
