/* ============ Snaccly - soft pastel design system ============ */
:root {
  --bg: #f8f1e6;
  --card: #fffdf8;
  --white: #ffffff;
  --ink: #35312a;
  --ink-soft: #8f887a;
  --primary: #ef7d4f;
  --primary-deep: #d8643a;
  --accent: #f9a03f;
  --accent-soft: #fde3c8;
  --gold: #f7c948;
  --gold-soft: #fdeeb5;
  --mint: #bfe6ba;
  --mint-dark: #2c6e3a;
  --rose: #f5b8bd;
  --rose-dark: #a03340;
  --red: #e2555f;
  --line: #ece3d2;
  --radius: 22px;
  --shadow: 0 2px 10px rgba(93, 75, 51, .08);
  --shadow-lift: 0 6px 18px rgba(93, 75, 51, .13);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ---------- Top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
}
.brand { font-weight: 900; font-size: 20px; letter-spacing: -0.5px; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.brand span:last-child { color: var(--primary); }
.brand-logo { width: 28px; height: 28px; }
.mascot-svg { width: 1em; height: 1.1em; object-fit: contain; vertical-align: -0.15em; }
.stats { display: flex; gap: 8px; }
.stat {
  font-weight: 800; font-size: 14px; cursor: default;
  background: var(--white); border-radius: 999px; padding: 5px 12px;
  box-shadow: var(--shadow);
}
.stat b { color: var(--ink); }
.stat.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.3); } }

/* ---------- Main ---------- */
#view { flex: 1; padding: 14px 16px 96px; }

/* ---------- Tab bar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  display: flex; z-index: 50;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 16px rgba(28, 70, 80, .10);
  padding: 6px 10px 8px;
}
.tab {
  flex: 1; padding: 8px 0 6px; border: none; background: none;
  font-family: inherit; font-weight: 800; font-size: 12px; color: var(--ink-soft);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-radius: 16px;
}
.tab span { font-size: 22px; }
.tab.active { color: var(--ink); background: var(--accent-soft); }

/* ---------- Daily goal card ---------- */
.goal-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--white);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.goal-ring { width: 56px; height: 56px; flex-shrink: 0; }
.goal-ring circle { fill: none; stroke-width: 7; }
.goal-ring .bgc { stroke: #f3ead9; }
.goal-ring .fgc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.goal-text b { font-size: 15px; }
.goal-text p { font-size: 13px; color: var(--ink-soft); font-weight: 700; }

/* ---------- Track sections & path ---------- */
.track-section { margin-bottom: 10px; }
.track-header {
  border-radius: var(--radius); padding: 15px 18px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.track-header .t-emoji { font-size: 28px; }
.track-header h2 { font-size: 17px; font-weight: 900; }
.track-header p { font-size: 12px; opacity: .8; font-weight: 700; }
.track-header .t-progress { margin-left: auto; font-weight: 900; font-size: 13px; background: rgba(255,255,255,.6); border-radius: 999px; padding: 4px 11px; }
.track-locked-note {
  text-align: center; color: var(--ink-soft); font-weight: 700; font-size: 13px;
  padding: 10px 0 22px;
}

.path { display: flex; flex-direction: column; align-items: center; padding: 4px 0 28px; }
.node-row { display: flex; justify-content: center; width: 100%; }
.node-row.offset-l { transform: translateX(-58px); }
.node-row.offset-r { transform: translateX(58px); }
.node {
  width: 68px; height: 68px; border-radius: 50%;
  border: none; cursor: pointer; margin: 8px 0;
  font-size: 26px; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: var(--shadow-lift);
  transition: transform .1s ease;
  background: var(--white);
}
.node:active { transform: scale(.94); }
.node.locked { background: #efe9dc; box-shadow: var(--shadow); cursor: not-allowed; opacity: .8; }
.node.done { background: var(--gold-soft); }
.node.active-node { animation: pulse 1.6s infinite; outline: 4px solid var(--white); }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.07);} }
.node .n-label {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 800; color: var(--ink-soft);
  white-space: nowrap; pointer-events: none;
}
.node .start-tag {
  position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: var(--card);
  font-size: 11px; font-weight: 900; padding: 4px 12px; border-radius: 999px;
  animation: floaty 1.6s ease-in-out infinite; white-space: nowrap;
  box-shadow: var(--shadow);
}
@keyframes floaty { 50% { transform: translate(-50%, -4px); } }

/* ---------- Lesson ---------- */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lesson-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink-soft); font-weight: 900; }
.progress-outer { flex: 1; height: 12px; background: var(--white); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(93,75,51,.1); }
.progress-inner { height: 100%; background: var(--accent); border-radius: 999px; width: 0; transition: width .4s ease; }
.lesson-hearts { font-weight: 900; font-size: 15px; color: var(--red); }

.byte-card {
  background: var(--card); border-radius: var(--radius);
  padding: 28px 22px; text-align: center;
  box-shadow: var(--shadow);
}
.byte-timer { width: 84px; height: 84px; margin: 0 auto 12px; position: relative; }
.byte-timer svg { transform: rotate(-90deg); }
.byte-timer .tbg { fill: none; stroke: #f3ead9; stroke-width: 6; }
.byte-timer .tfg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
.byte-timer .t-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 22px; color: var(--accent);
}
.byte-chip { display: inline-block; font-size: 12px; font-weight: 900; border-radius: 999px; padding: 5px 13px; margin-bottom: 12px; }
.byte-card h1 { font-size: 26px; font-weight: 900; margin-bottom: 14px; }
.byte-def { font-size: 16px; line-height: 1.55; margin-bottom: 16px; }
.byte-analogy {
  background: var(--gold-soft); border-radius: 16px;
  padding: 15px; font-size: 15px; line-height: 1.5; text-align: left;
  display: flex; gap: 10px;
}
.byte-analogy .a-icon { font-size: 22px; }
.byte-analogy b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #9a7108; margin-bottom: 2px; }

.quiz-q { font-size: 20px; font-weight: 900; margin: 6px 0 18px; line-height: 1.35; }
.opt {
  display: block; width: 100%; text-align: left;
  background: var(--white); border: 2px solid transparent;
  border-radius: 16px; padding: 15px 17px; margin-bottom: 10px;
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--ink);
  cursor: pointer; transition: background .12s, border-color .12s;
  box-shadow: var(--shadow);
}
.opt:hover { border-color: #e6d7bf; }
.opt.sel { border-color: var(--primary); }
.opt.correct { border-color: var(--mint-dark); background: var(--mint); color: var(--mint-dark); }
.opt.wrong { border-color: var(--rose-dark); background: var(--rose); color: var(--rose-dark); }
.opt:disabled { cursor: default; }

.feedback {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; padding: 20px 16px 22px; z-index: 60;
  border-top-left-radius: 26px; border-top-right-radius: 26px;
  animation: slideup .25s ease;
  box-shadow: 0 -6px 22px rgba(93,75,51,.16);
}
@keyframes slideup { from { transform: translate(-50%, 100%);} to { transform: translate(-50%, 0);} }
.feedback.good { background: var(--mint); }
.feedback.bad { background: var(--rose); }
.feedback h3 { font-size: 18px; font-weight: 900; }
.feedback.good h3 { color: var(--mint-dark); }
.feedback.bad h3 { color: var(--rose-dark); }
.feedback p { font-size: 14px; margin-top: 4px; color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; width: 100%;
  background: var(--primary); color: var(--card);
  border: none; border-radius: 999px;
  padding: 15px; font-family: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-lift);
  transition: transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.blue { background: var(--ink); color: var(--card); }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost {
  background: var(--white); color: var(--ink);
  box-shadow: var(--shadow);
}
.btn:disabled { background: #d8d0c2; box-shadow: none; cursor: not-allowed; }
.btn + .btn { margin-top: 10px; }

/* ---------- Complete screen ---------- */
.complete { text-align: center; padding-top: 30px; }
.complete .mascot-big { font-size: 84px; animation: bounce .8s ease infinite alternate; display: inline-block; }
@keyframes bounce { to { transform: translateY(-10px); } }
.complete h1 { font-size: 26px; font-weight: 900; margin: 10px 0 6px; color: var(--primary); }
.complete .sub { color: var(--ink-soft); font-weight: 700; margin-bottom: 20px; }
.reward-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 26px; }
.reward {
  border-radius: 18px; overflow: hidden; min-width: 104px;
  box-shadow: var(--shadow);
}
.reward .r-top { background: var(--accent); color: #fff; font-size: 11px; font-weight: 900; padding: 5px; text-transform: uppercase; }
.reward .r-val { padding: 11px; font-size: 20px; font-weight: 900; color: var(--accent); background: var(--white); }
.reward.blue-r .r-top { background: var(--ink); }
.reward.blue-r .r-val { color: var(--ink); }

/* ---------- Mascot modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(56, 45, 32, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 26px; padding: 30px 24px;
  max-width: 380px; width: 100%; text-align: center;
  animation: pop .25s ease;
  box-shadow: var(--shadow-lift);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.modal .m-mascot { font-size: 76px; display: inline-block; margin-bottom: 8px; }
.modal .m-mascot.sad { animation: wobble 1.2s ease infinite; }
@keyframes wobble { 0%,100% { transform: rotate(-6deg);} 50% { transform: rotate(6deg);} }
.modal h2 { font-size: 20px; font-weight: 900; margin-bottom: 8px; }
.modal p { font-size: 15px; color: var(--ink-soft); font-weight: 700; margin-bottom: 20px; line-height: 1.5; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 120; width: 100%; max-width: 480px; padding: 0 16px; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--card); border-radius: 999px; padding: 12px 18px;
  font-weight: 800; font-size: 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
  animation: toastin .3s ease;
  box-shadow: var(--shadow-lift);
}
@keyframes toastin { from { transform: translateY(-16px); opacity: 0; } }
.toast .t-emoji { font-size: 20px; }

/* ---------- Challenge ---------- */
.challenge-hero {
  background: #d7d0f5;
  color: #4a3d8f; border-radius: var(--radius); padding: 26px 20px; margin-bottom: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.challenge-hero h1 { font-size: 24px; font-weight: 900; }
.challenge-hero p { font-weight: 700; font-size: 14px; opacity: .85; margin-top: 4px; }
.vs-row { display: flex; align-items: center; justify-content: space-around; margin: 18px 0; }
.vs-player { text-align: center; }
.vs-player .v-avatar { font-size: 44px; }
.vs-player .v-name { font-weight: 900; font-size: 14px; margin-top: 4px; }
.vs-player .v-score { font-size: 22px; font-weight: 900; color: var(--accent); }
.vs-mid { font-size: 26px; font-weight: 900; color: var(--red); }
.pick-track {
  display: flex; align-items: center; gap: 13px; width: 100%;
  background: var(--white);
  border: none; border-radius: 18px; padding: 12px 14px; margin-bottom: 10px;
  font-family: inherit; font-size: 15px; font-weight: 800; color: var(--ink); cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
}
.pick-track:hover { box-shadow: var(--shadow-lift); }
.pick-track .p-emoji {
  font-size: 22px; width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.pick-track small { display: block; color: var(--ink-soft); font-weight: 700; }
.qtimer { height: 8px; background: var(--white); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.qtimer div { height: 100%; background: var(--accent); width: 100%; }
.qtimer div.run { transition: width linear; width: 0; }

/* ---------- Profile ---------- */
.profile-head { text-align: center; padding: 18px 0 8px; }
.profile-head .p-mascot { font-size: 84px; }
.profile-head h1 { font-size: 22px; font-weight: 900; margin-top: 4px; }
.profile-head p { color: var(--ink-soft); font-weight: 800; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.stat-card {
  background: var(--white); border-radius: 18px;
  padding: 13px 15px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
}
.stat-card .s-emoji { font-size: 26px; }
.stat-card b { display: block; font-size: 17px; }
.stat-card small { color: var(--ink-soft); font-weight: 800; font-size: 11px; text-transform: uppercase; }
.section-title { font-size: 16px; font-weight: 900; margin: 20px 0 10px; }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge {
  background: var(--white); border-radius: 16px;
  padding: 11px 4px; text-align: center;
  box-shadow: var(--shadow);
}
.badge .b-emoji { font-size: 26px; display: block; }
.badge small { font-size: 10px; font-weight: 800; color: var(--ink-soft); line-height: 1.1; display: block; margin-top: 4px; }
.badge.locked-b { opacity: .4; filter: grayscale(1); }
.track-bars .tb { margin-bottom: 12px; }
.track-bars .tb-top { display: flex; justify-content: space-between; font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.track-bars .tb-bar { height: 12px; background: var(--white); border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(93,75,51,.1); }
.track-bars .tb-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }

/* ---------- Term lookup: FAB + bottom sheet ---------- */
#fab {
  position: fixed; bottom: 92px; right: max(16px, calc(50% - 264px));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 22px;
  border: none; cursor: pointer; z-index: 55;
  box-shadow: var(--shadow-lift);
  transition: transform .1s ease;
}
#fab:active { transform: scale(.92); }
body.hide-fab #fab { display: none; }
#sheet-backdrop {
  position: fixed; inset: 0; background: rgba(56, 45, 32, .45);
  z-index: 95; display: none;
}
#sheet-backdrop.open { display: block; animation: fadein .2s ease; }
#sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; max-height: 70vh; overflow-y: auto;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 12px 16px 26px; z-index: 96; display: none;
  box-shadow: 0 -6px 22px rgba(93, 75, 51, .16);
}
#sheet.open { display: block; animation: slideup .25s ease; }
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
.sheet-search {
  width: 100%; padding: 13px 18px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--white); color: var(--ink);
  font-family: inherit; font-weight: 700; font-size: 15px; outline: none;
}
.sheet-search:focus { border-color: var(--primary); }
.lookup-hint { text-align: center; color: var(--ink-soft); font-weight: 700; font-size: 13px; padding: 16px 0 6px; }
.lookup-row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: var(--white); border: none; border-radius: 16px;
  padding: 10px 12px; margin-top: 8px;
  font-family: inherit; font-size: 15px; font-weight: 800; color: var(--ink);
  cursor: pointer; text-align: left; box-shadow: var(--shadow);
}
.lookup-row:hover { box-shadow: var(--shadow-lift); }
.lookup-row .l-emoji {
  font-size: 19px; width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.lookup-row small { display: block; color: var(--ink-soft); font-weight: 700; font-size: 12px; }

/* ---------- Paywall: track tags, upgrade, tiers ---------- */
.t-tag {
  font-size: 10px; font-weight: 900; letter-spacing: .5px; vertical-align: middle;
  background: rgba(255,255,255,.7); border-radius: 999px; padding: 2px 8px; margin-left: 4px;
}
.t-tag.pro { background: var(--ink); color: var(--gold); }
.track-locked-note {
  display: block; width: 100%; border: 2px dashed var(--line); background: transparent;
  cursor: pointer; margin-bottom: 22px;
}
.track-locked-note:hover { border-color: var(--primary); color: var(--primary); }
.pro-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  background: linear-gradient(100deg, #ffdca8, #ffb877); color: #6b4310;
  border: none; border-radius: 18px; padding: 14px 18px; margin: 6px 0 4px;
  font-family: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow);
}
.pro-banner b { font-size: 15px; display: block; }
.pro-banner small { font-size: 12px; font-weight: 700; opacity: .85; }
.pro-banner span { font-weight: 900; font-size: 14px; white-space: nowrap; }
.tier-card {
  background: var(--white); border-radius: 18px; padding: 16px 18px; margin-bottom: 12px;
  box-shadow: var(--shadow); position: relative;
}
.tier-card.accent { border: 2px solid var(--primary); }
.tier-badge {
  position: absolute; top: -10px; right: 16px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 900; padding: 3px 12px; border-radius: 999px;
}
.tier-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.tier-top b { font-size: 18px; font-weight: 900; }
.tier-price { font-size: 22px; font-weight: 900; color: var(--primary); }
.tier-price small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.tier-perks { list-style: none; margin: 0 0 14px; }
.tier-perks li { font-size: 14px; font-weight: 700; padding: 5px 0 5px 24px; position: relative; }
.tier-perks li::before { content: "✓"; position: absolute; left: 0; color: var(--mint-dark); font-weight: 900; }

/* ---------- Confetti canvas ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; }

/* ---------- Small screens ---------- */
@media (max-width: 400px) {
  .node-row.offset-l { transform: translateX(-44px); }
  .node-row.offset-r { transform: translateX(44px); }
}
