/* ================================================================
   WordPals — cute chibi design system
   ================================================================ */

:root {
  --bg1: #FFF7FB;
  --bg2: #EFF7FF;
  --ink: #4E3A5E;
  --ink-soft: #8E7CA3;
  --white: #FFFFFF;

  --pink: #FF8FB5;
  --pink-deep: #F76F9F;
  --pink-soft: #FFD9E6;
  --mint: #5ED9A5;
  --mint-deep: #3EC58F;
  --mint-soft: #CDF5E4;
  --sky: #6FBFFF;
  --sky-deep: #4FA8F5;
  --sky-soft: #D3EAFF;
  --lemon: #FFD166;
  --lemon-deep: #F5B93F;
  --lemon-soft: #FFF0C9;
  --lav: #A78BFA;
  --lav-deep: #8B6Cf1;
  --lav-soft: #E5DBFF;
  --coral: #FF9E7D;
  --coral-soft: #FFDFD3;
  --teal: #2EC4B6;
  --teal-soft: #C9F2EE;

  --card-shadow: 0 14px 34px rgba(150, 100, 190, 0.16);
  --radius: 26px;
  --radius-sm: 16px;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Baloo 2", "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --nav-h: 74px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg1) 0%, var(--bg2) 55%, #F2FBF4 100%);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea { user-select: text; -webkit-user-select: text; }

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

/* ================= background decorations ================= */

#bg-decor { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.5; }
.blob-1 { width: 42vmax; height: 42vmax; left: -12vmax; top: -10vmax; background: #FFD9E8; animation: blobFloat 16s ease-in-out infinite; }
.blob-2 { width: 36vmax; height: 36vmax; right: -10vmax; top: 24vh; background: #D6E9FF; animation: blobFloat 20s ease-in-out infinite reverse; }
.blob-3 { width: 34vmax; height: 34vmax; left: 18vw; bottom: -14vmax; background: #D9F6E6; animation: blobFloat 24s ease-in-out infinite; }

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vmax, -3vmax) scale(1.08); }
}

.cloud {
  position: absolute; background: #fff; border-radius: 999px; opacity: 0.85;
  box-shadow: 0 8px 24px rgba(160, 140, 200, 0.12);
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: #fff; border-radius: 50%;
}
.cloud-1 { width: 110px; height: 34px; top: 12vh; left: -130px; animation: cloudDrift 46s linear infinite; }
.cloud-1::before { width: 44px; height: 44px; left: 16px; top: -22px; }
.cloud-1::after { width: 30px; height: 30px; left: 56px; top: -14px; }
.cloud-2 { width: 84px; height: 26px; top: 32vh; left: -100px; animation: cloudDrift 62s linear infinite 8s; opacity: 0.65; }
.cloud-2::before { width: 32px; height: 32px; left: 12px; top: -16px; }
.cloud-2::after { width: 22px; height: 22px; left: 42px; top: -10px; }
.cloud-3 { width: 130px; height: 38px; top: 66vh; left: -150px; animation: cloudDrift 55s linear infinite 20s; opacity: 0.7; }
.cloud-3::before { width: 50px; height: 50px; left: 20px; top: -26px; }
.cloud-3::after { width: 34px; height: 34px; left: 68px; top: -16px; }

@keyframes cloudDrift {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 300px)); }
}

.sparkle { position: absolute; color: #FFC7DE; font-size: 18px; animation: twinkle 3.4s ease-in-out infinite; }
.s1 { top: 18vh; left: 12vw; }
.s2 { top: 9vh; right: 16vw; color: #A8D8FF; animation-delay: 0.8s; }
.s3 { top: 48vh; right: 8vw; color: #C9B8FF; animation-delay: 1.6s; }
.s4 { bottom: 22vh; left: 8vw; color: #9EE8C4; animation-delay: 2.2s; }
.s5 { bottom: 12vh; right: 22vw; animation-delay: 1.1s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.8) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.25) rotate(20deg); }
}

/* ================= layout ================= */

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

.screen {
  min-height: 100vh; min-height: 100dvh;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  animation: screenIn 0.5s var(--bounce);
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.screen-heading { font-size: 26px; font-weight: 800; margin: 8px 2px 14px; }
.section-title { font-size: 19px; font-weight: 800; margin: 20px 2px 10px; }

/* ================= buttons ================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 800; font-size: 16px;
  padding: 11px 18px; border-radius: 999px;
  color: #fff; background: linear-gradient(180deg, var(--pink) 0%, var(--pink-deep) 100%);
  box-shadow: 0 5px 0 #D95687, 0 12px 22px rgba(247, 111, 159, 0.35);
  transition: transform 0.15s var(--bounce), box-shadow 0.15s;
  text-shadow: 0 1px 0 rgba(0,0,0,0.08);
}
.btn:active { transform: translateY(4px) scale(0.98); box-shadow: 0 1px 0 #D95687, 0 4px 10px rgba(247, 111, 159, 0.3); }

.btn-big { width: 100%; font-size: 19px; padding: 15px 22px; }

.btn-ghost {
  color: var(--ink-soft); background: #fff;
  box-shadow: 0 4px 0 #E8DCEF, 0 8px 18px rgba(150, 100, 190, 0.10);
  width: 100%; margin-top: 10px;
}
.btn-ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 #E8DCEF; }

.btn-soft {
  color: #B07A2A; background: linear-gradient(180deg, #FFE9AE, #FFD97E);
  box-shadow: 0 5px 0 #E8BC55, 0 10px 20px rgba(232, 188, 85, 0.30);
  text-shadow: none;
}
.btn-soft:active { transform: translateY(4px) scale(0.98); box-shadow: 0 1px 0 #E8BC55; }

.btn-known { background: linear-gradient(180deg, var(--mint), var(--mint-deep)); box-shadow: 0 5px 0 #2FA476, 0 12px 22px rgba(62, 197, 143, 0.35); }
.btn-known:active { box-shadow: 0 1px 0 #2FA476, 0 4px 10px rgba(62, 197, 143, 0.3); }

.btn-facts { background: linear-gradient(180deg, #45D8C8, var(--teal)); box-shadow: 0 5px 0 #1EA396, 0 12px 22px rgba(46, 196, 182, 0.35); }
.btn-facts:active { box-shadow: 0 1px 0 #1EA396; }

.btn-danger { background: linear-gradient(180deg, #FF8A80, #F2635C); box-shadow: 0 4px 0 #D14A44; font-size: 14px; padding: 8px 14px; }
.btn-danger:active { transform: translateY(3px); box-shadow: 0 1px 0 #D14A44; }

.btn:disabled { opacity: 0.55; pointer-events: none; }

.chip-btn {
  width: 44px; height: 44px; border-radius: 16px; font-size: 20px;
  background: #fff; box-shadow: 0 3px 0 #EADFF1, 0 8px 16px rgba(150, 100, 190, 0.10);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s var(--bounce), box-shadow 0.15s;
  flex: none;
}
.chip-btn:active { transform: translateY(2px) scale(0.95); box-shadow: 0 1px 0 #EADFF1; }
.chip-static { width: auto; padding: 0 12px; font-size: 15px; font-weight: 800; color: var(--ink-soft); pointer-events: none; }

.auth-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px;
  border-radius: 16px; background: var(--sky-soft); color: var(--sky-deep); border: none; cursor: pointer;
  font-weight: 700; font-size: 14px; box-shadow: 0 3px 0 #BCDFFF, 0 8px 16px rgba(150, 100, 190, 0.10);
  transition: transform 0.15s var(--bounce), box-shadow 0.15s;
  flex: none; font-family: var(--font);
}
.auth-btn:active { transform: translateY(2px) scale(0.95); box-shadow: 0 1px 0 #BCDFFF; }

.auth-icon { display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }

.linklike { color: var(--sky-deep); font-weight: 800; text-decoration: underline; font-size: inherit; }

/* ================= login ================= */

.screen-login { justify-content: center; gap: 20px; padding-bottom: 40px; }

.login-hero { text-align: center; }

.mascot-wrap { display: flex; justify-content: center; }
.mascot { width: 132px; height: 132px; animation: mascotBob 3s ease-in-out infinite; filter: drop-shadow(0 14px 18px rgba(150, 100, 190, 0.25)); }
.mascot svg { width: 100%; height: 100%; }

@keyframes mascotBob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-9px) rotate(2deg); }
}

.mascot .eye { transform-origin: center; animation: blink 4.6s infinite; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.08); }
}

.app-title { font-size: 44px; font-weight: 800; letter-spacing: 1px; margin-top: 6px; }
.app-title span { display: inline-block; animation: letterWave 2.6s var(--bounce) infinite; }
.app-title span:nth-child(odd) { color: var(--pink-deep); }
.app-title span:nth-child(even) { color: var(--sky-deep); }
.app-title span:nth-child(3n) { color: var(--mint-deep); }
.app-title span:nth-child(5) { color: var(--lemon-deep); }
.app-title span:nth-child(1) { animation-delay: 0s; }
.app-title span:nth-child(2) { animation-delay: 0.07s; }
.app-title span:nth-child(3) { animation-delay: 0.14s; }
.app-title span:nth-child(4) { animation-delay: 0.21s; }
.app-title span:nth-child(5) { animation-delay: 0.28s; }
.app-title span:nth-child(6) { animation-delay: 0.35s; }
.app-title span:nth-child(7) { animation-delay: 0.42s; }
.app-title span:nth-child(8) { animation-delay: 0.49s; }

@keyframes letterWave {
  0%, 30%, 100% { transform: translateY(0); }
  15% { transform: translateY(-8px) scale(1.12); }
}

.app-tagline { color: var(--ink-soft); font-weight: 600; margin-top: 2px; }

.login-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius);
  padding: 22px 20px 16px;
  box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 800; color: var(--ink-soft); padding-left: 6px; }
.field input {
  font-family: inherit; font-size: 17px; font-weight: 600; color: var(--ink);
  background: #F7F2FB; border: 2.5px solid #EBDFF4; border-radius: 18px;
  padding: 12px 16px; width: 100%; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.field input:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 143, 181, 0.18); transform: scale(1.01); }

.pw-wrap { position: relative; display: block; }
.btn-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 18px; padding: 6px; opacity: 0.7; }

.login-error {
  color: #E2557B; font-weight: 700; font-size: 14px; text-align: center;
  background: #FFE9F0; border-radius: 12px; padding: 8px;
}
.login-card.shake { animation: shake 0.4s; }

.auth-toggle {
  display: flex; gap: 6px; background: #F7F2FB; border-radius: 16px; padding: 5px;
  margin-bottom: 2px;
}
.auth-tab {
  flex: 1; padding: 12px 8px; border-radius: 12px;
  font-weight: 800; font-size: 15px; color: var(--ink-soft);
  transition: all 0.2s var(--bounce);
}
.auth-tab.active {
  background: linear-gradient(180deg, var(--pink), var(--pink-deep));
  color: #fff; box-shadow: 0 4px 12px rgba(247, 111, 159, 0.35);
  transform: scale(1.03);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ================= home ================= */

.home-header { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.home-hello { display: flex; align-items: center; gap: 12px; }
.mini-mascot { width: 56px; height: 56px; animation: mascotBob 3.4s ease-in-out infinite; filter: drop-shadow(0 6px 8px rgba(150,100,190,0.2)); }
.mini-mascot svg { width: 100%; height: 100%; }
.hello-hi { font-size: 20px; font-weight: 800; }
.hello-sub { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; }
.home-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.guest-banner {
  margin-top: 12px; background: var(--lemon-soft); border: 2px dashed var(--lemon);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 14px; font-weight: 700; color: #A8792B;
}

.level-tabs {
  display: flex; gap: 8px; margin-top: 16px;
  background: rgba(255,255,255,0.7); border-radius: 999px; padding: 6px;
  box-shadow: 0 6px 16px rgba(150, 100, 190, 0.10);
}
.level-tab {
  flex: 1; padding: 10px 4px; border-radius: 999px;
  font-weight: 800; font-size: 14px; color: var(--ink-soft);
  transition: all 0.25s var(--bounce);
}
.level-tab.active { color: #fff; transform: scale(1.04); }
.level-tab.active[data-level="1"] { background: linear-gradient(180deg, var(--mint), var(--mint-deep)); box-shadow: 0 4px 12px rgba(62,197,143,0.4); }
.level-tab.active[data-level="2"] { background: linear-gradient(180deg, var(--lemon), var(--lemon-deep)); box-shadow: 0 4px 12px rgba(245,185,63,0.4); }
.level-tab.active[data-level="3"] { background: linear-gradient(180deg, var(--lav), var(--lav-deep)); box-shadow: 0 4px 12px rgba(139,108,241,0.4); }

.facts-banner {
  margin-top: 16px; width: 100%;
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: linear-gradient(120deg, #C0F5EE 0%, #D8F1FF 100%);
  border-radius: var(--radius); padding: 14px 18px;
  box-shadow: 0 6px 0 #9BDCD4, 0 14px 26px rgba(46, 196, 182, 0.25);
  transition: transform 0.15s var(--bounce), box-shadow 0.15s;
  position: relative; overflow: hidden;
}
.facts-banner:active { transform: translateY(4px); box-shadow: 0 2px 0 #9BDCD4; }
.facts-banner::after {
  content: "✨"; position: absolute; right: 44px; top: 8px; font-size: 14px;
  animation: twinkle 2.8s ease-in-out infinite;
}
.facts-banner-emoji { width: 52px; height: 52px; flex: none; display: block; animation: wiggle 3s ease-in-out infinite; filter: drop-shadow(0 5px 6px rgba(0,0,0,0.12)); }
.facts-banner-emoji svg { width: 100%; height: 100%; }
@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(8deg) translateY(-3px); }
}
.facts-banner-text { flex: 1; }
.facts-banner-text b { font-size: 17px; color: #0E7C72; display: block; }
.facts-banner-text small { font-size: 12.5px; color: #4AA39B; font-weight: 700; }
.facts-banner-go { font-size: 22px; font-weight: 800; color: #0E7C72; }

.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.topic-card {
  border-radius: var(--radius); padding: 16px 14px 14px; text-align: left;
  box-shadow: 0 6px 0 rgba(0,0,0,0.07), 0 14px 26px rgba(150, 100, 190, 0.14);
  transition: transform 0.18s var(--bounce), box-shadow 0.18s;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
}
.topic-card:active { transform: translateY(4px) scale(0.98); box-shadow: 0 2px 0 rgba(0,0,0,0.07); }
.topic-card::before {
  content: ""; position: absolute; right: -22px; top: -22px;
  width: 84px; height: 84px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}
.topic-icon { width: 44px; height: 44px; display: block; filter: drop-shadow(0 5px 6px rgba(0,0,0,0.15)); animation: emojiFloat 3.6s ease-in-out infinite; }
.topic-icon svg { width: 100%; height: 100%; }
.topic-card:nth-child(odd) .topic-icon { animation-delay: 0.8s; }
.topic-icon-emoji { font-size: 40px; line-height: 1; display: block; filter: drop-shadow(0 5px 6px rgba(0,0,0,0.15)); animation: emojiFloat 3.6s ease-in-out infinite; }
.topic-card:nth-child(odd) .topic-icon-emoji { animation-delay: 0.8s; }
.topic-card.disabled { opacity: 0.45; filter: grayscale(0.4); pointer-events: none; }

/* ================= quiz hub ================= */

.quizhub-header { margin-bottom: 4px; }
.quizhub-tagline { font-size: 14.5px; font-weight: 700; color: var(--ink-soft); margin-top: -8px; }

.mixed-quiz-card {
  margin-top: 16px; width: 100%;
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: linear-gradient(120deg, #FFE1A0 0%, #FFC97A 100%);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: 0 6px 0 #E8A94A, 0 14px 26px rgba(232, 169, 74, 0.3);
  transition: transform 0.15s var(--bounce), box-shadow 0.15s;
  position: relative; overflow: hidden;
}
.mixed-quiz-card:active { transform: translateY(4px); box-shadow: 0 2px 0 #E8A94A; }
.mixed-quiz-card.disabled { opacity: 0.5; pointer-events: none; }
.mixed-quiz-emoji { font-size: 40px; line-height: 1; animation: wiggle 3s ease-in-out infinite; filter: drop-shadow(0 5px 6px rgba(0,0,0,0.15)); }
.mixed-quiz-text { flex: 1; }
.mixed-quiz-text b { font-size: 18px; color: #7A4A0E; display: block; }
.mixed-quiz-text small { font-size: 12.5px; color: #9C6A1F; font-weight: 700; }
.mixed-quiz-go { font-size: 24px; font-weight: 800; color: #7A4A0E; }

/* ================= quiz streak ================= */

.quiz-streak-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 800; color: #C4522E;
  background: linear-gradient(90deg, #FFE1A0, #FFC7A0); border-radius: 999px;
  padding: 5px 14px; margin: 4px auto 0; width: fit-content;
}
.quiz-streak-flame { font-size: 15px; animation: streakFlame 0.9s ease-in-out infinite; }
@keyframes streakFlame {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  50% { transform: scale(1.2) rotate(4deg); }
}
.quiz-streak-row.pulse { animation: streakPulse 0.4s var(--bounce); }
@keyframes streakPulse {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ================= praise burst ================= */

.praise-burst {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%);
  z-index: 500; pointer-events: none;
  font-family: var(--font); font-weight: 800; font-size: 30px; text-align: center;
  color: var(--pink-deep); text-shadow: 0 3px 0 rgba(255,255,255,0.6), 0 8px 20px rgba(0,0,0,0.15);
  animation: praisePop 1.1s var(--bounce) forwards;
  white-space: nowrap;
}
.praise-burst.tier-2 { color: #E8792E; font-size: 33px; }
.praise-burst.tier-3 { color: #D6469B; font-size: 37px; }
.praise-burst.tier-4 {
  font-size: 42px;
  background: linear-gradient(90deg, #FF8FB5, #FFD166, #6FBFFF, #A78BFA);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: praisePop 1.1s var(--bounce) forwards, rainbowShift 1.1s linear infinite;
}
.praise-burst.tier-oops { color: var(--ink-soft); font-size: 22px; }
@keyframes praisePop {
  0% { transform: translate(-50%, -40%) scale(0.4) rotate(-8deg); opacity: 0; }
  25% { transform: translate(-50%, -52%) scale(1.15) rotate(4deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -65%) scale(0.9) rotate(0deg); opacity: 0; }
}
@keyframes rainbowShift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* ================= trophy result tiers ================= */

.trophy-emoji { animation: trophyBounce 1.4s ease-in-out infinite; }
@keyframes trophyBounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-12px) rotate(4deg); }
}
.summary-card.trophy-perfect { box-shadow: 0 14px 34px rgba(255, 209, 102, 0.45), 0 0 0 3px #FFD166 inset; }
.summary-card.trophy-gold { box-shadow: 0 14px 34px rgba(245, 185, 63, 0.4), 0 0 0 3px #F5B93F inset; }
.summary-card.trophy-silver { box-shadow: 0 14px 34px rgba(150, 100, 190, 0.2), 0 0 0 3px #D3EAFF inset; }
.streak-sub { color: #C4522E !important; font-weight: 800 !important; }

/* small topic icon used inline in titles, progress bars and history rows */
.title-icon, .inline-icon, .tbar-icon, .qh-icon {
  display: inline-flex; vertical-align: middle; flex: none;
}
.title-icon svg, .inline-icon svg, .tbar-icon svg, .qh-icon svg { width: 100%; height: 100%; display: block; }
.title-icon { width: 24px; height: 24px; margin-right: 6px; }
.inline-icon { width: 19px; height: 19px; margin: 0 4px -4px 0; }
.tbar-icon { width: 30px; height: 30px; }
.qh-icon { width: 30px; height: 30px; }

.level-tab-icon, .level-badge-icon, .stat-tile-icon {
  display: inline-flex; vertical-align: middle; flex: none;
}
.level-tab-icon svg, .level-badge-icon svg, .stat-tile-icon svg { width: 100%; height: 100%; display: block; }
.level-tab-icon { width: 22px; height: 22px; margin: 0 5px -6px 0; }
.level-badge-icon { width: 17px; height: 17px; margin: 0 3px -4px 0; }
.stat-tile-icon { width: 34px; height: 34px; margin-bottom: 2px; }
@keyframes emojiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.topic-name { font-size: 16.5px; font-weight: 800; line-height: 1.15; }
.topic-meta { display: flex; align-items: center; gap: 8px; }
.topic-bar { flex: 1; height: 9px; border-radius: 99px; background: rgba(255,255,255,0.55); overflow: hidden; }
.topic-bar i { display: block; height: 100%; border-radius: 99px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.12); transition: width 0.6s var(--bounce); }
.topic-frac { font-size: 12px; font-weight: 800; opacity: 0.75; }

/* ================= deck screens (study / facts) ================= */

.screen-deck { padding-left: 2px; padding-right: 2px; }

.deck-header { display: flex; align-items: center; gap: 12px; }
.deck-titles { flex: 1; text-align: center; min-width: 0; }
.deck-topic { font-size: 18px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-topic .title-icon { margin-right: 2px; }
.deck-count { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.deck-progress {
  height: 10px; margin: 12px 6px 0; border-radius: 99px;
  background: rgba(255,255,255,0.8); box-shadow: inset 0 2px 4px rgba(150,100,190,0.12);
  overflow: hidden;
}
.deck-progress i {
  display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--lav));
  transition: width 0.5s var(--bounce);
}
.deck-progress-facts i { background: linear-gradient(90deg, #45D8C8, var(--sky)); }

.deck-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 4px 0 2px; min-height: 0;
}
.deck-stage.summary-align { align-items: flex-start; }

.deck {
  position: relative;
  width: min(88vw, 400px);
  height: min(45vh, 350px);
  max-height: 350px;
  perspective: 1400px;
}

/* stacked cards illusion — must stay BEHIND real card content (.flashcard,
   .summary-card): pseudo-elements paint after normal children with the same
   auto z-index, so without z-index:0 + pointer-events:none here, ::after
   visually washes out and intercepts clicks on whatever is inside #deck. */
.deck::before, .deck::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(150, 100, 190, 0.10);
}
.deck::before { transform: translateY(14px) scale(0.93) rotate(2.5deg); }
.deck::after { transform: translateY(7px) scale(0.965) rotate(-1.8deg); }

.deck.deck-summary-mode { height: auto; max-height: none; }
.deck.deck-summary-mode::before, .deck.deck-summary-mode::after { display: none; }

.flashcard {
  position: absolute; inset: 0; z-index: 2;
  touch-action: pan-y;
  cursor: grab;
  transition: transform 0.45s var(--bounce), opacity 0.3s;
}
.flashcard.dragging { transition: none; cursor: grabbing; }
.flashcard.fly-left { transform: translateX(-130vw) rotate(-24deg) !important; opacity: 0; }
.flashcard.fly-right { transform: translateX(130vw) rotate(24deg) !important; opacity: 0; }
.flashcard.deal-in { animation: dealIn 0.5s var(--bounce); }
@keyframes dealIn {
  from { transform: translateY(34px) scale(0.9) rotate(4deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.65s var(--bounce);
}
.card-inner.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 16px; text-align: center; gap: 6px;
  overflow: hidden;
}
.card-face::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px;
  background: linear-gradient(90deg, var(--pink-soft), var(--lav-soft), var(--sky-soft));
}
.card-back { transform: rotateY(180deg); justify-content: center; gap: 12px; }

.card-level {
  position: absolute; top: 20px; right: 16px;
  font-size: 11.5px; font-weight: 800; padding: 4px 10px; border-radius: 99px;
}
.card-level.lv1 { background: var(--mint-soft); color: #1F8A63; }
.card-level.lv2 { background: var(--lemon-soft); color: #A8792B; }
.card-level.lv3 { background: var(--lav-soft); color: #6B4FD8; }

.card-emoji-wrap { position: relative; margin-bottom: 4px; }
.card-emoji {
  font-size: 80px; line-height: 1; display: block;
  animation: emojiHover 3s ease-in-out infinite;
  filter: drop-shadow(0 12px 10px rgba(78, 58, 94, 0.18));
}
@keyframes emojiHover {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
.emoji-shadow {
  width: 64px; height: 12px; margin: 2px auto 0; border-radius: 50%;
  background: rgba(78, 58, 94, 0.12);
  animation: shadowPulse 3s ease-in-out infinite;
}
@keyframes shadowPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(0.72); opacity: 0.45; }
}

.card-word { font-size: 38px; font-weight: 800; line-height: 1.1; color: var(--ink); border-radius: 14px; padding: 2px 10px; }
.card-word:active { background: var(--pink-soft); }
.card-phonetic { font-size: 16px; color: var(--ink-soft); font-weight: 600; }
.card-pos { font-size: 12px; font-weight: 800; color: #fff; background: var(--sky); padding: 3px 12px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.5px; }

.speak-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 800; color: var(--sky-deep);
  background: var(--sky-soft); padding: 8px 16px; border-radius: 99px;
  margin-top: 6px;
  transition: transform 0.15s var(--bounce);
}
.speak-chip:active { transform: scale(0.92); }
.speak-chip.speaking { animation: pulse 0.6s ease-in-out infinite; background: var(--pink-soft); color: var(--pink-deep); }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.flip-hint { position: absolute; bottom: 14px; font-size: 12px; font-weight: 700; color: #C7B8D6; }

.card-back-word { font-size: 24px; font-weight: 800; }
.card-meaning { font-size: 18.5px; font-weight: 700; color: var(--ink); line-height: 1.35; border-radius: 12px; padding: 2px 6px; }
.card-divider { width: 60px; height: 4px; border-radius: 99px; background: var(--pink-soft); }
.card-sentence-box { background: #FBF6FF; border-radius: 18px; padding: 14px 16px; width: 100%; }
.card-sentence { font-size: 16.5px; font-weight: 600; color: var(--ink); line-height: 1.45; border-radius: 10px; }
.card-sentence b { color: var(--pink-deep); }
.card-mini-emoji { font-size: 40px; line-height: 1; }

.deck-hint { text-align: center; font-size: 12.5px; font-weight: 700; color: #C7B8D6; padding: 3px 0 6px; }

.btn-icon { display: inline-flex; width: 28px; height: 28px; flex: none; }
.btn-icon svg { width: 100%; height: 100%; display: block; }

.deck-actions { display: flex; gap: 10px; justify-content: center; padding-bottom: 4px; }
.deck-actions .btn { flex: 1; max-width: 220px; }

/* fun-fact card face */
.fact-front-title { font-size: 27px; font-weight: 800; line-height: 1.2; border-radius: 12px; padding: 2px 8px; }
.fact-ribbon {
  font-size: 13px; font-weight: 800; color: #0E7C72; background: var(--teal-soft);
  padding: 5px 14px; border-radius: 99px;
}
.fact-text { font-size: 17.5px; font-weight: 600; line-height: 1.5; border-radius: 12px; padding: 2px 6px; }
.keyword-chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--lemon-soft); border-radius: 16px; padding: 8px 18px;
  transition: transform 0.15s var(--bounce);
}
.keyword-chip:active { transform: scale(0.93); }
.keyword-chip b { font-size: 17px; color: #A8792B; }
.keyword-chip small { font-size: 12px; color: #C49A4E; font-weight: 700; }
.keyword-label { font-size: 11.5px; font-weight: 800; color: #C7B8D6; text-transform: uppercase; letter-spacing: 1px; }

/* ================= study summary / quiz results ================= */

.summary-card {
  position: relative; z-index: 2;
  background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow);
  padding: 20px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: dealIn 0.5s var(--bounce);
  width: min(88vw, 400px);
}
.summary-emoji { font-size: 48px; animation: emojiHover 2.6s ease-in-out infinite; }
.summary-title { font-size: 22px; font-weight: 800; }
.summary-sub { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.summary-stats { display: flex; gap: 12px; width: 100%; margin-top: 4px; }
.stat-box { flex: 1; border-radius: 18px; padding: 8px 8px; }
.stat-box b { display: block; font-size: 22px; font-weight: 800; }
.stat-box span { font-size: 12px; font-weight: 700; }
.stat-known { background: var(--mint-soft); color: #1F8A63; }
.stat-learning { background: var(--lemon-soft); color: #A8792B; }
.stat-wrong { background: #FFE3E0; color: #C4524B; }
.summary-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 4px; }
.summary-actions .btn { padding: 12px; font-size: 15px; }

.score-ring {
  width: 130px; height: 130px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: conic-gradient(var(--mint) calc(var(--pct) * 1%), #EFE7F6 0);
  position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 12px; background: #fff; border-radius: 50%; }
.score-ring b, .score-ring span { position: relative; }
.score-ring b { font-size: 30px; font-weight: 800; }
.score-ring span { font-size: 12px; font-weight: 700; color: var(--ink-soft); }

/* ================= quiz ================= */

.quiz-area { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 14px 4px; }

.quiz-question {
  background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow);
  padding: 24px 18px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: dealIn 0.45s var(--bounce);
}
.quiz-prompt-label { font-size: 12.5px; font-weight: 800; color: #C7B8D6; text-transform: uppercase; letter-spacing: 1px; }
.quiz-emoji { font-size: 62px; line-height: 1.1; animation: emojiHover 3s ease-in-out infinite; }
.quiz-prompt { font-size: 21px; font-weight: 800; line-height: 1.3; border-radius: 12px; padding: 2px 8px; }

.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-option {
  background: #fff; border-radius: 20px; padding: 16px 10px;
  font-size: 17px; font-weight: 800; color: var(--ink);
  box-shadow: 0 5px 0 #EADFF1, 0 10px 20px rgba(150, 100, 190, 0.10);
  transition: transform 0.15s var(--bounce), box-shadow 0.15s, background 0.2s;
  min-height: 62px; display: flex; align-items: center; justify-content: center; text-align: center;
  line-height: 1.25;
}
.quiz-option:active { transform: translateY(3px); box-shadow: 0 2px 0 #EADFF1; }
.quiz-option.opt-meaning { font-size: 14.5px; font-weight: 700; }
.quiz-option.correct {
  background: linear-gradient(180deg, var(--mint), var(--mint-deep)); color: #fff;
  box-shadow: 0 5px 0 #2FA476; animation: optPop 0.5s var(--bounce);
}
.quiz-option.wrong {
  background: linear-gradient(180deg, #FF9A92, #F2635C); color: #fff;
  box-shadow: 0 5px 0 #D14A44; animation: shake 0.4s;
}
.quiz-option.dim { opacity: 0.45; }
@keyframes optPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

/* ================= progress ================= */

.progress-hero {
  background: linear-gradient(135deg, #FFE1EC 0%, #E5DBFF 55%, #D3EAFF 100%);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 16px;
}
.progress-avatar { font-size: 52px; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.12)); display: inline-flex; }
.progress-avatar-icon { display: inline-flex; width: 56px; height: 56px; }
.progress-avatar-icon svg { width: 100%; height: 100%; display: block; }
.progress-avatar-emoji { font-size: 52px; line-height: 1; }
.progress-hero-name { font-size: 22px; font-weight: 800; }
.progress-hero-sub { font-size: 13.5px; font-weight: 700; color: #8E7CA3; }

.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.stat-tile {
  background: #fff; border-radius: 20px; padding: 14px 8px; text-align: center;
  box-shadow: 0 8px 18px rgba(150, 100, 190, 0.10);
  display: flex; flex-direction: column; align-items: center;
}
.stat-tile .tile-emoji { font-size: 24px; }
.stat-tile b { display: block; font-size: 22px; font-weight: 800; margin-top: 2px; }
.stat-tile span { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }

.tbar-row {
  display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 18px;
  padding: 10px 14px; box-shadow: 0 6px 14px rgba(150,100,190,0.08); margin-bottom: 8px;
  width: 100%; text-align: left; transition: transform 0.15s var(--bounce), box-shadow 0.15s;
}
.tbar-row:active { transform: scale(0.98); box-shadow: 0 2px 8px rgba(150,100,190,0.1); }
.tbar-emoji { font-size: 24px; }
.tbar-name { font-size: 14px; font-weight: 800; width: 108px; }
.tbar-track { flex: 1; height: 10px; border-radius: 99px; background: #F1EAF7; overflow: hidden; }
.tbar-track i { display: block; height: 100%; border-radius: 99px; transition: width 0.7s var(--bounce); }
.tbar-frac { font-size: 12px; font-weight: 800; color: var(--ink-soft); min-width: 44px; text-align: right; }

.learned-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 20px;
}
.learned-card {
  display: flex; align-items: flex-start; gap: 8px;
  background: linear-gradient(135deg, #FFF0F5, #E8F5E9); border-radius: 14px; padding: 10px;
  box-shadow: 0 4px 12px rgba(150,100,190,0.12); cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.learned-card:active { transform: scale(0.97); box-shadow: 0 2px 6px rgba(150,100,190,0.2); }
.lc-emoji { font-size: 22px; line-height: 1.2; flex: none; }
.lc-body { min-width: 0; }
.lc-word { font-size: 14px; font-weight: 800; color: var(--ink); margin-bottom: 2px; }
.lc-meaning { font-size: 11px; color: var(--ink-soft); line-height: 1.3; }

.topic-words-card { width: min(92vw, 420px); }
.topic-words-grid {
  max-height: 52vh; overflow-y: auto; margin-bottom: 4px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.quiz-history-item {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border-radius: 18px; padding: 12px 14px; margin-bottom: 8px;
  box-shadow: 0 6px 14px rgba(150,100,190,0.08);
}
.qh-emoji { font-size: 26px; }
.qh-main { flex: 1; }
.qh-title { font-size: 15px; font-weight: 800; }
.qh-sub { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.qh-score { font-size: 17px; font-weight: 800; }
.qh-score.good { color: var(--mint-deep); }
.qh-score.meh { color: var(--lemon-deep); }
.qh-score.oops { color: #F2635C; }

.empty-note {
  text-align: center; color: var(--ink-soft); font-weight: 700; font-size: 14.5px;
  background: rgba(255,255,255,0.75); border-radius: var(--radius-sm);
  padding: 22px 16px; line-height: 1.5;
}
.empty-note .big { font-size: 44px; display: block; margin-bottom: 6px; }

.logout-row { margin-top: 22px; display: flex; justify-content: center; }

/* ================= admin ================= */

.admin-form {
  background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px;
}
.admin-form-row { display: flex; gap: 10px; }
.admin-form-row .field { flex: 1; }
.admin-loading { text-align: center; font-weight: 700; color: var(--ink-soft); padding: 30px 0; }
.role-toggle { display: flex; gap: 8px; }
.role-pill {
  flex: 1; padding: 10px; border-radius: 14px; font-weight: 800; font-size: 14px;
  background: #F7F2FB; color: var(--ink-soft); border: 2.5px solid transparent;
  transition: all 0.2s;
}
.role-pill.active { background: var(--sky-soft); color: var(--sky-deep); border-color: var(--sky); }

.user-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 20px; padding: 12px 14px; margin-bottom: 10px;
  box-shadow: 0 6px 14px rgba(150,100,190,0.08);
  animation: screenIn 0.4s var(--bounce);
}
.user-avatar { font-size: 32px; }
.icon-edit-btn {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%;
  overflow: visible; transition: transform 0.15s var(--bounce);
}
.icon-edit-btn:active { transform: scale(0.92); }
.icon-edit-preview { display: block; width: 44px; height: 44px; }
.icon-edit-preview svg { width: 100%; height: 100%; display: block; }
.icon-edit-badge {
  position: absolute; bottom: -2px; right: -2px; font-size: 11px;
  background: #fff; border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(150,100,190,0.25);
}
.user-main { flex: 1; min-width: 0; }
.user-name { font-size: 16px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.role-chip { font-size: 10.5px; font-weight: 800; padding: 3px 8px; border-radius: 99px; vertical-align: 2px; margin-left: 6px; }
.role-chip.admin { background: var(--lav-soft); color: #6B4FD8; }
.role-chip.user { background: var(--mint-soft); color: #1F8A63; }

.user-actions { display: flex; align-items: center; gap: 8px; }

.icon-picker-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  max-height: 50vh; overflow-y: auto; padding: 4px 2px; width: 100%;
}
.icon-pick {
  position: relative; border-radius: 18px; padding: 6px;
  border: 2.5px solid transparent; background: #F7F2FB;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s var(--bounce);
}
.icon-pick:active { transform: scale(0.9); }
.icon-pick.active { border-color: var(--sky-deep); background: var(--sky-soft); }
.icon-pick-svg { display: block; width: 48px; height: 48px; }
.icon-pick-svg svg { width: 100%; height: 100%; display: block; }

/* ================= bottom nav ================= */

#bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(94vw, 440px);
  display: flex; justify-content: space-around; align-items: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-radius: 26px; padding: 8px 6px;
  box-shadow: 0 12px 30px rgba(120, 80, 160, 0.22);
  z-index: 50;
}
#nav-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 0;
  width: 0; border-radius: 18px;
  background: linear-gradient(160deg, #FFE1EC, #FFD0E2);
  box-shadow: 0 4px 14px rgba(247, 111, 159, 0.25);
  transition: transform 0.4s var(--bounce), width 0.4s var(--bounce), background 0.4s var(--bounce);
  z-index: 0;
  pointer-events: none;
}
.nav-item {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10.5px; font-weight: 800; color: #B9A8C9;
  padding: 6px 11px; border-radius: 18px;
  transition: color 0.3s;
}
.nav-icon {
  width: 29px; height: 29px; display: block;
  transition: transform 0.3s var(--bounce), filter 0.3s;
  filter: saturate(1.05) opacity(0.88);
}
.nav-icon svg { width: 100%; height: 100%; display: block; }
.nav-item.active { color: var(--pink-deep); }
.nav-item.active .nav-icon { transform: translateY(-3px) scale(1.22) rotate(-4deg); filter: saturate(1.25) opacity(1); }
.nav-item.bump .nav-icon { animation: navBump 0.4s var(--bounce); }
@keyframes navBump {
  0% { transform: translateY(-3px) scale(1.22) rotate(-4deg); }
  40% { transform: translateY(-7px) scale(1.34) rotate(6deg); }
  100% { transform: translateY(-3px) scale(1.22) rotate(-4deg); }
}

/* ================= overlays ================= */

.vi-bubble {
  position: fixed; z-index: 200; max-width: min(80vw, 340px);
  background: var(--ink); color: #fff;
  font-size: 15px; font-weight: 700; line-height: 1.4;
  padding: 10px 15px; border-radius: 16px;
  box-shadow: 0 12px 26px rgba(78, 58, 94, 0.4);
  animation: bubbleIn 0.22s var(--bounce);
  pointer-events: none;
}
.vi-bubble::after {
  content: ""; position: absolute; left: var(--arrow-x, 50%); top: 100%;
  transform: translateX(-50%);
  border: 8px solid transparent; border-top-color: var(--ink);
}
.vi-bubble .vi-flag { font-size: 11px; opacity: 0.75; display: block; margin-bottom: 2px; letter-spacing: 0.5px; }
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  background: rgba(78, 58, 94, 0.94); color: #fff;
  font-size: 15px; font-weight: 700;
  padding: 11px 20px; border-radius: 99px;
  box-shadow: 0 10px 24px rgba(78, 58, 94, 0.35);
  z-index: 300; animation: toastIn 0.35s var(--bounce);
  max-width: 86vw; text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.9); }
  to { opacity: 1; transform: translateX(-50%); }
}

#confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti {
  position: absolute; top: -20px; border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

.float-emoji {
  position: fixed; z-index: 350; pointer-events: none; font-size: 26px;
  animation: floatUp 1.1s ease-out forwards;
}
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0) scale(0.7); }
  to { opacity: 0; transform: translateY(-110px) scale(1.5) rotate(14deg); }
}

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(78, 58, 94, 0.35);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn 0.25s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: #fff; border-radius: var(--radius); padding: 24px 20px;
  width: min(90vw, 360px); text-align: center;
  box-shadow: 0 20px 50px rgba(78, 58, 94, 0.3);
  animation: dealIn 0.35s var(--bounce);
  display: flex; flex-direction: column; gap: 10px;
}
.modal-emoji { font-size: 48px; }
.modal-title { font-size: 20px; font-weight: 800; }
.modal-text { font-size: 14.5px; font-weight: 600; color: var(--ink-soft); line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; font-size: 15px; padding: 11px 12px; }

/* ================= responsive: tablet / iPad ================= */

@media (min-width: 700px) {
  #app { max-width: 760px; }
  .topic-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .deck { width: 440px; height: 540px; }
  .app-title { font-size: 54px; }
  .mascot { width: 156px; height: 156px; }
  .login-card { width: 440px; margin: 0 auto; }
  .quiz-area { max-width: 560px; width: 100%; margin: 0 auto; }
  .quiz-options { gap: 14px; }
  .screen { padding-top: 28px; }
  .card-word { font-size: 44px; }
  .card-emoji { font-size: 104px; }
}

@media (min-width: 1000px) {
  #app { max-width: 980px; }
  .topic-grid { grid-template-columns: repeat(4, 1fr); }
}

/* short landscape phones */
@media (max-height: 620px) {
  .deck { min-height: 300px; height: 62vh; }
  .card-emoji { font-size: 60px; }
  .card-word { font-size: 30px; }
  .deck-hint { display: none; }
}

/* fine pointers: hover lift for desktop/iPad trackpad */
@media (hover: hover) {
  .topic-card:hover { transform: translateY(-4px) scale(1.02); }
  .btn:hover { filter: brightness(1.05); }
  .chip-btn:hover { transform: translateY(-2px); }
  .nav-item:hover .nav-icon { transform: translateY(-2px); }
  .quiz-option:hover:not(.correct):not(.wrong):not(.dim) { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.1s !important; }
}
