/* =========================================================
   IntegerQuest — styles.css
   Vibrant, playful, fully responsive, touch friendly.
   ========================================================= */

:root {
  --bg-0: #1a0b3d;
  --bg-1: #2a0f5e;
  --card: rgba(255, 255, 255, 0.08);
  --card-solid: #33166b;
  --stroke: rgba(255, 255, 255, 0.16);
  --txt: #f4eeff;
  --txt-dim: #b9a8e8;
  --violet: #8b5cf6;
  --fuchsia: #e935c1;
  --cyan: #22d3ee;
  --lime: #a3e635;
  --amber: #fbbf24;
  --red: #fb5e5e;
  --green: #34d399;
  --grad-main: linear-gradient(135deg, #8b5cf6, #e935c1);
  --grad-warm: linear-gradient(135deg, #fbbf24, #fb7185);
  --grad-cool: linear-gradient(135deg, #22d3ee, #8b5cf6);
  --grad-green: linear-gradient(135deg, #34d399, #a3e635);
  --shadow-3d: 0 5px 0 rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --top-safe: env(safe-area-inset-top, 0px);
  --bot-safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 55%, #43137a 100%);
  color: var(--txt);
  overflow-x: hidden;
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- animated background blobs ---------- */
.bg-blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35; animation: blobfloat 18s ease-in-out infinite alternate; }
.b1 { width: 46vmax; height: 46vmax; background: #7c3aed; top: -14vmax; left: -12vmax; }
.b2 { width: 40vmax; height: 40vmax; background: #db2777; bottom: -12vmax; right: -10vmax; animation-delay: -6s; }
.b3 { width: 30vmax; height: 30vmax; background: #0891b2; top: 40%; left: 55%; animation-delay: -12s; }
@keyframes blobfloat {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(6vmax, -4vmax) scale(1.15); }
}

/* =========================================================
   SPLASH
   ========================================================= */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 30% 20%, #3b1287 0%, #1a0b3d 55%, #12062e 100%);
  transition: opacity 0.6s ease, transform 0.6s ease;
  cursor: pointer;
  overflow: hidden;
}
#splash.leaving { opacity: 0; transform: scale(1.12); pointer-events: none; }
.splash-bg { position: absolute; inset: 0; }
.float-sym {
  position: absolute; font-weight: 900; opacity: 0.14;
  color: #fff; animation: floaty 7s ease-in-out infinite;
  font-size: clamp(2rem, 9vw, 5rem);
}
.s1 { top: 8%; left: 8%; animation-delay: 0s; color: var(--cyan); }
.s2 { top: 16%; right: 12%; animation-delay: -1.4s; color: var(--fuchsia); }
.s3 { bottom: 18%; left: 12%; animation-delay: -2.8s; color: var(--amber); }
.s4 { bottom: 10%; right: 9%; animation-delay: -4.2s; color: var(--lime); }
.s5 { top: 42%; left: 4%; animation-delay: -2.1s; }
.s6 { top: 60%; right: 6%; animation-delay: -3.5s; color: var(--cyan); }
.s7 { top: 28%; left: 30%; animation-delay: -5s; color: var(--fuchsia); }
.s8 { bottom: 30%; right: 26%; animation-delay: -0.7s; color: var(--amber); }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-26px) rotate(10deg); }
}
.splash-core { position: relative; text-align: center; padding: 24px; }
.splash-rocket {
  font-size: clamp(4rem, 18vw, 8rem);
  animation: rocket 2.4s ease-in-out infinite;
  filter: drop-shadow(0 12px 24px rgba(233, 53, 193, 0.45));
}
@keyframes rocket {
  0%, 100% { transform: translateY(6px) rotate(-42deg); }
  50% { transform: translateY(-18px) rotate(-52deg); }
}
.splash-title {
  margin: 8px 0 4px;
  font-size: clamp(2.2rem, 10vw, 4.6rem);
  font-weight: 900; letter-spacing: 0.02em; line-height: 1.05;
}
.splash-title span {
  display: inline-block;
  background: linear-gradient(180deg, #fff 20%, #f9a8d4 60%, #c084fc 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  animation-delay: calc(var(--i) * 0.07s + 0.3s);
}
.splash-title .gap { margin-left: 0.35em; }
@keyframes pop {
  0% { transform: scale(0) translateY(40px) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) translateY(0) rotate(0); opacity: 1; }
}
.splash-tag {
  color: var(--txt-dim); font-size: clamp(0.95rem, 3.4vw, 1.25rem); font-weight: 600;
  margin: 6px 0 26px; animation: fadeup 0.8s ease 1.2s both;
}
@keyframes fadeup { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.splash-bar {
  width: min(280px, 62vw); height: 12px; margin: 0 auto;
  background: rgba(255, 255, 255, 0.12); border-radius: 99px; overflow: hidden;
  animation: fadeup 0.6s ease 1.4s both;
}
.splash-bar-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: var(--grad-main);
  animation: loadbar 2.1s cubic-bezier(0.4, 0, 0.2, 1) 1.5s forwards;
}
@keyframes loadbar { to { width: 100%; } }
.splash-hint {
  margin-top: 18px; font-size: 0.8rem; color: rgba(255, 255, 255, 0.35);
  animation: blink 1.6s ease infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

/* =========================================================
   LAYOUT / SCREENS
   ========================================================= */
#app { position: relative; z-index: 1; min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; animation: screenin 0.35s cubic-bezier(0.2, 0.9, 0.3, 1); }
.screen.active { display: block; }
@keyframes screenin { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--top-safe)) 14px 10px;
  background: rgba(26, 11, 61, 0.72);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}
.topbar.simple { justify-content: center; border-bottom: none; background: none; }
.logo-mini { font-weight: 900; font-size: 1.15rem; background: linear-gradient(90deg, #f9a8d4, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-title { flex: 1; text-align: center; font-weight: 800; font-size: 1.08rem; }
.topbar-xp { font-weight: 800; font-size: 0.9rem; background: var(--card); border: 1px solid var(--stroke); padding: 6px 12px; border-radius: 99px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; font-size: 1.25rem;
  background: var(--card); border: 1px solid var(--stroke);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s;
}
.icon-btn:active { transform: scale(0.9); }
.back-btn { font-size: 1.5rem; font-weight: 800; }
.pad { padding: 16px 16px calc(28px + var(--bot-safe)); max-width: 980px; margin: 0 auto; }
.screen-title { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 900; margin: 10px 0 18px; text-align: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; border-radius: 18px;
  font-weight: 800; font-size: 1.02rem;
  transition: transform 0.12s, filter 0.15s;
  box-shadow: var(--shadow-3d);
  min-height: 52px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn-primary { background: var(--grad-main); color: #fff; }
.btn-warm { background: var(--grad-warm); color: #43140a; }
.btn-cool { background: var(--grad-cool); color: #06202a; }
.btn-green { background: var(--grad-green); color: #0c2b18; }
.btn-ghost { background: var(--card); border: 1px solid var(--stroke); box-shadow: none; color: var(--txt); }
.btn-big { width: 100%; font-size: 1.15rem; padding: 18px; }
.btn:disabled { filter: grayscale(0.7) brightness(0.7); pointer-events: none; }

/* =========================================================
   USER SELECT
   ========================================================= */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-bottom: 16px; }
.user-card {
  background: var(--card); border: 2px solid var(--stroke); border-radius: var(--radius);
  padding: 18px 10px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform 0.15s, border-color 0.15s;
  box-shadow: var(--shadow-3d);
}
.user-card:active { transform: scale(0.95); }
.user-card:hover { border-color: var(--violet); }
.user-avatar {
  width: 64px; height: 64px; border-radius: 50%; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.user-card .uname { font-weight: 800; font-size: 1rem; }
.user-card .uxp { font-size: 0.78rem; color: var(--txt-dim); font-weight: 700; }
.user-card .ulock { font-size: 0.7rem; color: var(--amber); font-weight: 700; }
.user-add-card { flex-direction: column; gap: 6px; font-size: 1.9rem !important; background: rgba(139, 92, 246, 0.14); border: 2px dashed rgba(139, 92, 246, 0.6); box-shadow: none; min-height: 130px; border-radius: var(--radius); }
.user-add-card span { font-size: 1rem; }

/* =========================================================
   HOME
   ========================================================= */
.user-chip {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--stroke);
  padding: 6px 14px 6px 6px; border-radius: 99px; max-width: 420px; margin: 0 auto;
}
.user-chip .user-avatar { width: 40px; height: 40px; font-size: 1.3rem; }
.user-chip .uc-name { font-weight: 800; font-size: 0.95rem; line-height: 1.1; }
.user-chip .uc-xp { font-size: 0.75rem; color: var(--txt-dim); font-weight: 700; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-tile {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 12px 8px; text-align: center;
}
.stat-tile .st-val { font-size: 1.35rem; font-weight: 900; }
.stat-tile .st-lab { font-size: 0.7rem; color: var(--txt-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-tile.up .st-val { color: var(--green); }
.stat-tile.down .st-val { color: var(--red); }

.goal-card {
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.35), rgba(233, 53, 193, 0.28));
  border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 14px;
}
.goal-ring { position: relative; width: 64px; height: 64px; flex: none; }
.goal-ring svg { transform: rotate(-90deg); }
.goal-ring .gr-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.8rem; }
.goal-info { flex: 1; }
.goal-info .gi-title { font-weight: 900; font-size: 1rem; }
.goal-info .gi-sub { font-size: 0.8rem; color: var(--txt-dim); font-weight: 600; }
.goal-info .gi-sub b { color: var(--amber); }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.mode-card {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 22px 16px 18px; text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: var(--shadow-3d);
  transition: transform 0.15s;
  min-height: 140px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 3px;
}
.mode-card:active { transform: translateY(4px) scale(0.98); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.mode-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(90% 90% at 85% 10%, rgba(255, 255, 255, 0.28), transparent 55%);
}
.mode-emoji { position: absolute; top: 10px; right: 12px; font-size: 2.4rem; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(6deg); } }
.mode-name { font-weight: 900; font-size: 1.12rem; position: relative; }
.mode-desc { font-size: 0.78rem; font-weight: 600; opacity: 0.85; position: relative; }
.mc-game { background: linear-gradient(140deg, #8b5cf6, #6d28d9); }
.mc-practice { background: linear-gradient(140deg, #06b6d4, #2563eb); }
.mc-daily { background: linear-gradient(140deg, #f59e0b, #ef4444); }
.mc-board { background: linear-gradient(140deg, #ec4899, #a21caf); }
.mc-badges { background: linear-gradient(140deg, #10b981, #059669); }
.mc-teacher { background: linear-gradient(140deg, #64748b, #334155); }
.mode-card.done-daily::after { content: '✓'; position: absolute; top: 12px; left: 14px; font-size: 1.4rem; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.4); }

/* =========================================================
   LEVEL MAP
   ========================================================= */
#level-map { display: flex; flex-direction: column; align-items: center; gap: 0; padding-bottom: 40px; }
.world-banner {
  align-self: stretch; text-align: center; margin: 18px 0 10px;
  font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.8rem;
  color: var(--txt-dim);
}
.world-banner span { background: var(--card); border: 1px solid var(--stroke); padding: 6px 18px; border-radius: 99px; }
.lvl-row { display: flex; width: 100%; max-width: 560px; position: relative; padding: 9px 0; }
.lvl-row.left { justify-content: flex-start; }
.lvl-row.right { justify-content: flex-end; }
.lvl-row::before {
  content: ''; position: absolute; top: 50%; width: 60%; height: 5px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 12px, transparent 12px 24px);
  border-radius: 4px; z-index: 0;
}
.lvl-row.left::before { right: 8%; }
.lvl-row.right::before { left: 8%; }
.lvl-node {
  position: relative; z-index: 1;
  width: min(240px, 68%);
  background: var(--card-solid); border: 2px solid var(--stroke);
  border-radius: 22px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; text-align: left;
  box-shadow: var(--shadow-3d);
  transition: transform 0.14s;
}
.lvl-node:active { transform: scale(0.96); }
.lvl-node.unlocked { border-color: rgba(139, 92, 246, 0.8); background: linear-gradient(135deg, #4c1d95, #5b21b6); }
.lvl-node.completed { border-color: rgba(52, 211, 153, 0.65); }
.lvl-node.locked { filter: grayscale(0.85) brightness(0.62); pointer-events: none; }
.lvl-node.current { animation: pulse 1.8s ease infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow-3d), 0 0 0 0 rgba(233, 53, 193, 0.5); }
  50% { box-shadow: var(--shadow-3d), 0 0 0 12px rgba(233, 53, 193, 0); }
}
.lvl-emoji { font-size: 2rem; width: 52px; height: 52px; flex: none; border-radius: 16px; background: rgba(0, 0, 0, 0.25); display: flex; align-items: center; justify-content: center; }
.lvl-info { flex: 1; min-width: 0; }
.lvl-name { font-weight: 900; font-size: 0.98rem; display: flex; align-items: center; gap: 6px; }
.lvl-name .lvl-num { background: rgba(0, 0, 0, 0.3); border-radius: 8px; font-size: 0.68rem; padding: 2px 7px; font-weight: 800; }
.lvl-desc { font-size: 0.74rem; color: var(--txt-dim); font-weight: 600; margin-top: 2px; }
.lvl-stars { margin-top: 5px; font-size: 0.95rem; letter-spacing: 2px; }
.lvl-stars .on { color: var(--amber); text-shadow: 0 0 10px rgba(251, 191, 36, 0.7); }
.lvl-stars .off { color: rgba(255, 255, 255, 0.18); }

/* =========================================================
   PLAY SCREEN
   ========================================================= */
#screen-play { display: none; flex-direction: column; min-height: 100dvh; }
#screen-play.active { display: flex; }
.play-top { flex-wrap: nowrap; }
.play-meta { flex: 1; text-align: center; min-width: 0; }
.play-title { font-weight: 900; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lives { font-size: 1rem; letter-spacing: 2px; margin-top: 2px; }
.lives .lost { filter: grayscale(1) brightness(0.5); }
.combo-chip {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 99px;
  padding: 8px 12px; font-weight: 900; font-size: 0.85rem; min-width: 66px; text-align: center;
  transition: transform 0.15s;
}
.combo-chip.hot { background: var(--grad-warm); color: #43140a; transform: scale(1.08); }
.play-progress { height: 6px; background: rgba(255, 255, 255, 0.1); }
.play-progress-fill { height: 100%; width: 0; background: var(--grad-cool); transition: width 0.3s ease; }
.timer-bar { height: 5px; background: rgba(255, 255, 255, 0.07); }
.timer-fill { height: 100%; width: 100%; background: var(--lime); transition: width 0.2s linear, background 0.3s; }
.timer-fill.warn { background: var(--amber); }
.timer-fill.danger { background: var(--red); animation: blinkfast 0.5s linear infinite; }
@keyframes blinkfast { 50% { opacity: 0.4; } }

.play-area { flex: 1; display: flex; flex-direction: column; gap: 12px; max-width: 620px; width: 100%; }
.q-dots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.q-dot { width: 11px; height: 11px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); transition: all 0.2s; }
.q-dot.correct { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.8); }
.q-dot.wrong { background: var(--red); }
.q-dot.now { background: var(--amber); transform: scale(1.35); }

.question-card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 26px;
  padding: 22px 18px; text-align: center; position: relative; overflow: hidden;
  box-shadow: var(--shadow-3d);
  animation: qin 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes qin { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: none; } }
.question-card.shake { animation: shake 0.45s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); } 80% { transform: translateX(5px); }
}
.question-card.flash-good { animation: flashgood 0.5s; }
@keyframes flashgood { 30% { background: rgba(52, 211, 153, 0.35); transform: scale(1.02); } }
.question-card.flash-bad { animation: flashbad 0.5s; }
@keyframes flashbad { 30% { background: rgba(251, 94, 94, 0.35); } }
.q-tag {
  display: inline-block; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  background: rgba(139, 92, 246, 0.3); border: 1px solid rgba(139, 92, 246, 0.5);
  padding: 4px 12px; border-radius: 99px; color: #ddd6fe; margin-bottom: 12px;
}
.q-prompt { font-size: clamp(1.9rem, 8vw, 3rem); font-weight: 900; line-height: 1.35; word-break: break-word; }
.q-prompt .tok { display: inline-block; margin: 0 0.08em; }
.q-prompt .op { color: var(--amber); margin: 0 0.18em; }
.q-prompt .num.neg { color: #fca5a5; }
.q-hint { margin-top: 12px; font-size: 0.82rem; color: var(--txt-dim); font-weight: 600; display: none; }
.q-hint.show { display: block; animation: fadeup 0.3s; }
.hint-btn { margin-top: 10px; font-size: 0.78rem; color: var(--cyan); font-weight: 800; text-decoration: underline; }

.answer-zone { margin-top: auto; }
.answer-display {
  min-height: 64px; margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.3); border: 2px solid var(--stroke); border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 900; letter-spacing: 0.04em;
  padding: 6px 16px; overflow: hidden;
}
.answer-display .placeholder { color: rgba(255, 255, 255, 0.25); }
.answer-display.correct { border-color: var(--green); color: var(--green); animation: popscale 0.3s; }
.answer-display.wrong { border-color: var(--red); color: var(--red); }
@keyframes popscale { 50% { transform: scale(1.08); } }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  min-height: 58px; border-radius: 16px; font-size: 1.5rem; font-weight: 800;
  background: var(--card-solid); border: 1px solid var(--stroke);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s;
  display: flex; align-items: center; justify-content: center;
}
.key:active { transform: translateY(4px); box-shadow: none; }
.key.key-fn { background: rgba(251, 191, 36, 0.18); color: var(--amber); font-size: 1.25rem; }
.key.key-ok {
  grid-column: 1 / -1;            /* span all three keypad columns */
  background: var(--grad-green); color: #0c2b18;
  font-size: 1.7rem; min-height: 62px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
}
.key.key-neg { background: rgba(251, 94, 94, 0.18); color: #fca5a5; }

.choices { display: grid; grid-template-columns: 1fr; gap: 10px; }
.choice-btn {
  background: var(--card-solid); border: 2px solid var(--stroke); border-radius: 18px;
  padding: 16px; font-size: 1.06rem; font-weight: 800; text-align: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); transition: transform 0.1s;
  min-height: 56px;
}
.choice-btn:active { transform: translateY(3px); }
.choice-btn.good { background: rgba(52, 211, 153, 0.3); border-color: var(--green); }
.choice-btn.bad { background: rgba(251, 94, 94, 0.3); border-color: var(--red); animation: shake 0.4s; }
@media (min-width: 560px) { .choices { grid-template-columns: 1fr 1fr; } }

.float-fx { position: fixed; z-index: 60; font-weight: 900; font-size: 1.6rem; pointer-events: none; animation: floatup 1s ease-out forwards; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
@keyframes floatup { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-70px) scale(1.3); } }

/* =========================================================
   RESULT
   ========================================================= */
.result-pad { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding-top: 44px; min-height: 100dvh; justify-content: center; }
.result-emoji { font-size: clamp(4rem, 16vw, 6.5rem); animation: pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.result-title { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 900; margin: 0; }
.result-stars { font-size: clamp(2.4rem, 10vw, 3.6rem); letter-spacing: 8px; }
.result-stars span { display: inline-block; color: rgba(255, 255, 255, 0.15); }
.result-stars span.on { color: var(--amber); text-shadow: 0 0 22px rgba(251, 191, 36, 0.8); animation: starpop 0.55s cubic-bezier(0.2, 1.8, 0.4, 1) both; }
@keyframes starpop { 0% { transform: scale(0) rotate(-90deg); } 100% { transform: scale(1) rotate(0); } }
.result-stats { display: grid; grid-template-columns: repeat(2, minmax(130px, 170px)); gap: 10px; }
.rs-tile { background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; padding: 12px; }
.rs-tile .v { font-size: 1.4rem; font-weight: 900; }
.rs-tile .l { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--txt-dim); font-weight: 700; }
.result-badges { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 380px; }
.badge-earn {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: linear-gradient(120deg, rgba(251, 191, 36, 0.25), rgba(233, 53, 193, 0.2));
  border: 1px solid rgba(251, 191, 36, 0.5); border-radius: 16px; padding: 10px 14px;
  animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.badge-earn .be-ico { font-size: 1.8rem; }
.badge-earn .be-name { font-weight: 900; }
.badge-earn .be-desc { font-size: 0.75rem; color: var(--txt-dim); }
.result-compare { background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; padding: 10px 18px; font-size: 0.85rem; font-weight: 700; color: var(--txt-dim); }
.result-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 380px; margin-top: 6px; }

/* =========================================================
   PRACTICE CONFIG
   ========================================================= */
.cfg-group { margin-bottom: 18px; }
.cfg-label { font-weight: 900; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--txt-dim); margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px; border-radius: 99px; font-weight: 800; font-size: 0.92rem;
  background: var(--card); border: 2px solid var(--stroke); color: var(--txt-dim);
  transition: all 0.14s; min-height: 44px;
}
.chip.on { background: var(--grad-main); border-color: transparent; color: #fff; transform: scale(1.05); }
.chip .chip-sub { display: block; font-size: 0.65rem; font-weight: 600; opacity: 0.75; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; padding: 12px 16px; margin-bottom: 10px; font-weight: 800; }
.toggle { width: 54px; height: 32px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); position: relative; transition: background 0.2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(22px); }

/* =========================================================
   BADGES
   ========================================================= */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 18px;
  padding: 16px 12px; text-align: center; position: relative;
}
.badge-card .b-ico { font-size: 2.2rem; filter: grayscale(1) brightness(0.5); }
.badge-card.earned { background: linear-gradient(140deg, rgba(251, 191, 36, 0.22), rgba(233, 53, 193, 0.16)); border-color: rgba(251, 191, 36, 0.45); }
.badge-card.earned .b-ico { filter: none; animation: bob 3s ease-in-out infinite; }
.badge-card .b-name { font-weight: 900; font-size: 0.85rem; margin-top: 6px; }
.badge-card .b-desc { font-size: 0.7rem; color: var(--txt-dim); font-weight: 600; margin-top: 2px; }
.badge-card .b-date { font-size: 0.62rem; color: var(--amber); font-weight: 800; margin-top: 4px; }

.profile-hero {
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.4), rgba(233, 53, 193, 0.3));
  border: 1px solid var(--stroke); border-radius: 24px; padding: 20px; text-align: center; margin-bottom: 18px;
}
.profile-hero .user-avatar { width: 84px; height: 84px; font-size: 2.6rem; margin: 0 auto 10px; }
.profile-hero h3 { margin: 0; font-size: 1.4rem; font-weight: 900; }
.profile-hero .ph-sub { color: var(--txt-dim); font-weight: 700; font-size: 0.85rem; }

/* =========================================================
   LEADERBOARD
   ========================================================= */
.seg { display: flex; background: var(--card); border: 1px solid var(--stroke); border-radius: 99px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg-btn { flex: 1; padding: 10px; border-radius: 99px; font-weight: 800; font-size: 0.88rem; color: var(--txt-dim); min-height: 44px; }
.seg-btn.active { background: var(--grad-main); color: #fff; }
.lb-yesterday {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 18px;
  padding: 14px 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 14px;
}
.lb-yesterday .lyb-emoji { font-size: 1.9rem; }
.lb-yesterday .lyb-txt { font-size: 0.88rem; font-weight: 700; color: var(--txt-dim); }
.lb-yesterday .lyb-txt b { color: var(--txt); }
.lb-list { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--stroke); border-radius: 18px; padding: 10px 14px;
}
.lb-row.me { border-color: var(--fuchsia); background: linear-gradient(120deg, rgba(233, 53, 193, 0.22), rgba(139, 92, 246, 0.18)); }
.lb-rank { font-weight: 900; font-size: 1.1rem; width: 38px; text-align: center; flex: none; }
.lb-rank.gold { color: var(--amber); font-size: 1.5rem; }
.lb-rank.silver { color: #cbd5e1; font-size: 1.4rem; }
.lb-rank.bronze { color: #f59e0b; font-size: 1.35rem; }
.lb-row .user-avatar { width: 44px; height: 44px; font-size: 1.4rem; flex: none; }
.lb-name { flex: 1; font-weight: 800; min-width: 0; }
.lb-name .lb-sub { display: block; font-size: 0.72rem; color: var(--txt-dim); font-weight: 700; }
.lb-score { font-weight: 900; font-size: 1.05rem; text-align: right; flex: none; }
.lb-score .lb-delta { display: block; font-size: 0.72rem; font-weight: 800; }
.lb-score .lb-delta.up { color: var(--green); }
.lb-score .lb-delta.down { color: var(--red); }
.lb-score .lb-delta.flat { color: var(--txt-dim); }
.lb-empty { text-align: center; color: var(--txt-dim); font-weight: 700; padding: 40px 0; }

/* =========================================================
   TEACHER DASHBOARD
   ========================================================= */
.t-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.t-card { background: var(--card); border: 1px solid var(--stroke); border-radius: 18px; padding: 14px; text-align: center; }
.t-card .v { font-size: 1.5rem; font-weight: 900; }
.t-card .l { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--txt-dim); font-weight: 700; }
.t-learner {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--stroke); border-radius: 18px;
  padding: 12px 14px; margin-bottom: 10px; width: 100%; text-align: left;
  transition: transform 0.12s;
}
.t-learner:active { transform: scale(0.98); }
.t-learner .user-avatar { width: 48px; height: 48px; font-size: 1.5rem; flex: none; }
.tl-info { flex: 1; min-width: 0; }
.tl-name { font-weight: 900; }
.tl-sub { font-size: 0.74rem; color: var(--txt-dim); font-weight: 600; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.tl-sub b { color: var(--txt); }
.tl-spark { width: 96px; height: 36px; flex: none; }
.tl-arrow { color: var(--txt-dim); font-weight: 900; }

.t-detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.t-detail-head .user-avatar { width: 64px; height: 64px; font-size: 2rem; }
.t-detail-head h3 { margin: 0; font-weight: 900; font-size: 1.3rem; }
.t-detail-head .td-sub { color: var(--txt-dim); font-weight: 700; font-size: 0.82rem; }
.t-section { background: var(--card); border: 1px solid var(--stroke); border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.t-section h4 { margin: 0 0 12px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--txt-dim); }
.cat-row { display: grid; grid-template-columns: 150px 1fr 58px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.83rem; }
.cat-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar { height: 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 99px; }
.cat-pct { font-weight: 900; text-align: right; font-size: 0.82rem; }
.weak-nums { display: flex; flex-wrap: wrap; gap: 8px; }
.weak-num {
  background: rgba(251, 94, 94, 0.16); border: 1px solid rgba(251, 94, 94, 0.5);
  color: #fecaca; font-weight: 900; padding: 6px 12px; border-radius: 12px; font-size: 0.95rem;
}
.weak-num small { color: var(--txt-dim); font-weight: 700; margin-left: 4px; }
.t-chart { width: 100%; height: 130px; }
.t-sessions { display: flex; flex-direction: column; gap: 6px; }
.t-session { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: var(--txt-dim); background: rgba(0, 0, 0, 0.18); padding: 8px 12px; border-radius: 12px; }
.t-session b { color: var(--txt); }
.t-levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.t-level-cell { background: rgba(0, 0, 0, 0.2); border-radius: 12px; padding: 8px 10px; font-size: 0.75rem; font-weight: 700; }
.t-level-cell .stars { color: var(--amber); letter-spacing: 1px; }
.t-level-cell.notyet { opacity: 0.4; }
.t-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.t-toolbar .btn { flex: 1; min-width: 130px; }

/* =========================================================
   SETTINGS
   ========================================================= */
.set-card { background: var(--card); border: 1px solid var(--stroke); border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.set-card h4 { margin: 0 0 10px; font-weight: 900; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; font-weight: 700; font-size: 0.92rem; }
.set-row .btn { min-height: 44px; padding: 10px 16px; font-size: 0.88rem; }
.set-note { font-size: 0.75rem; color: var(--txt-dim); font-weight: 600; margin-top: 6px; }
input[type="text"], input[type="password"] {
  background: rgba(0, 0, 0, 0.3); border: 2px solid var(--stroke); border-radius: 14px;
  color: var(--txt); font-weight: 700; font-size: 1rem; padding: 12px 14px; width: 100%;
  font-family: inherit; outline: none;
}
input:focus { border-color: var(--violet); }

/* =========================================================
   MODAL / PIN OVERLAY / TOASTS
   ========================================================= */
.overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(10, 4, 30, 0.82);
  backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadein 0.2s;
}
@keyframes fadein { from { opacity: 0; } }
.pin-card, .modal-card {
  background: linear-gradient(160deg, #33166b, #241052);
  border: 1px solid var(--stroke); border-radius: 28px;
  padding: 26px 22px; width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-height: 90dvh; overflow-y: auto;
}
.modal-card { max-width: 420px; text-align: left; }
.modal-card h3 { margin: 0 0 14px; font-weight: 900; text-align: center; }
.pin-avatar { font-size: 2.6rem; margin-bottom: 4px; }
.pin-card h3 { margin: 4px 0 14px; font-weight: 900; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 18px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--txt-dim); transition: all 0.15s; }
.pin-dot.filled { background: var(--cyan); border-color: var(--cyan); transform: scale(1.15); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.pin-key {
  min-height: 58px; border-radius: 16px; font-size: 1.4rem; font-weight: 800;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--stroke);
  transition: transform 0.08s;
}
.pin-key:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.18); }
.pin-msg { min-height: 20px; font-size: 0.85rem; font-weight: 800; color: var(--red); margin: 8px 0 0; }
.pin-msg.ok { color: var(--green); }

#toast-area { position: fixed; top: calc(14px + var(--top-safe)); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast {
  background: linear-gradient(120deg, #4c1d95, #831843);
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 16px;
  padding: 12px 16px; font-weight: 800; font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastin 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), toastout 0.4s ease 2.6s forwards;
  display: flex; gap: 10px; align-items: center;
}
.toast .t-ico { font-size: 1.4rem; }
@keyframes toastin { from { opacity: 0; transform: translateY(-20px) scale(0.9); } }
@keyframes toastout { to { opacity: 0; transform: translateY(-14px); } }

#confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

/* avatar picker */
.avatar-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 10px 0; }
.av-opt {
  aspect-ratio: 1; border-radius: 16px; font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.07); border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.av-opt.sel { border-color: var(--cyan); background: rgba(34, 211, 238, 0.15); transform: scale(1.08); }
.color-picker { display: flex; gap: 8px; justify-content: center; margin: 10px 0 16px; flex-wrap: wrap; }
.col-opt { width: 38px; height: 38px; border-radius: 50%; border: 3px solid transparent; }
.col-opt.sel { border-color: #fff; transform: scale(1.15); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 0.8rem; font-weight: 800; color: var(--txt-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- responsive ---------- */
@media (max-width: 380px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .key { min-height: 52px; font-size: 1.3rem; }
  .cat-row { grid-template-columns: 110px 1fr 48px; }
}
@media (min-width: 760px) {
  .q-prompt { font-size: 3.2rem; }
  .keypad { max-width: 420px; margin: 0 auto; }
  .answer-display { max-width: 420px; margin: 0 auto 12px; }
  .choices { max-width: 560px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
