:root {
  --green: #58CC02; --green-dark: #46A302; --blue: #1CB0F6; --blue-dark: #1899D6;
  --red: #FF4B4B; --red-dark: #D33131; --yellow: #FFC800; --orange: #FF9600; --purple: #CE82FF;
  --bg: #FFFFFF; --bg2: #F7F7F7; --card: #FFFFFF; --text: #3C3C3C; --muted: #777777; --line: #E5E5E5;
  --shadow: 0 2px 0 var(--line);
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131F24; --bg2: #1B2A31; --card: #1F3038; --text: #F1F7FB; --muted: #9FB3BD; --line: #37464F; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; font-size: 17px; line-height: 1.4; }
body { padding-top: var(--safe-top); overscroll-behavior-y: none; }
#app { min-height: 100vh; padding-bottom: calc(84px + var(--safe-bottom)); }
.hidden { display: none !important; }
.center { text-align: center; padding: 40px 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1 { font-size: 24px; font-weight: 800; margin: 0 0 8px; }
h2 { font-size: 20px; font-weight: 800; margin: 0 0 8px; }
h3 { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.page { padding: 12px 16px; max-width: 560px; margin: 0 auto; }

/* ---------- кнопки ---------- */
.btn { display: block; width: 100%; border: none; border-radius: 16px; padding: 14px 18px; font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: #fff; background: var(--green); box-shadow: 0 4px 0 var(--green-dark); cursor: pointer; transition: transform .05s, box-shadow .05s; font-family: inherit; }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--green-dark); }
.btn:disabled { background: var(--line); box-shadow: 0 4px 0 #cfcfcf; color: #9a9a9a; cursor: default; }
@media (prefers-color-scheme: dark) { .btn:disabled { box-shadow: 0 4px 0 #27353d; color: #6a7a83; } }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.ghost { background: var(--card); color: var(--blue); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.sm { width: auto; display: inline-block; padding: 8px 14px; font-size: 13px; border-radius: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .btn { flex: 1; }
.spacer { flex: 1; }

/* ---------- верхняя панель ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 2px solid var(--line); }
.stat { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 16px; }
.stat.fire { color: var(--orange); } .stat.xp { color: var(--yellow); } .stat.crown { color: var(--yellow); }
.week-pill { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 14px; }
.week-nav { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 10px 0 6px; }
.week-nav button { background: none; border: none; font-size: 22px; color: var(--blue); cursor: pointer; padding: 4px 10px; }

/* ---------- прогресс ---------- */
.progress { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.progress.blue > i { background: var(--blue); }

/* ---------- путь по темам ---------- */
.topic { background: var(--card); border: 2px solid var(--line); border-radius: 20px; margin: 14px 0; overflow: hidden; }
.topic-head { padding: 14px 16px; color: #fff; display: flex; align-items: center; gap: 12px; }
.topic-head .emoji { font-size: 34px; }
.topic-head h2 { margin: 0; color: #fff; font-size: 18px; }
.topic-head .theme { opacity: .9; font-size: 13px; font-weight: 600; }
.topic-head .crowns { margin-left: auto; font-size: 14px; font-weight: 800; background: rgba(0,0,0,.18); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.path { display: flex; align-items: center; justify-content: space-around; padding: 16px 12px 8px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 30%; background: none; border: none; font-family: inherit; color: var(--text); cursor: pointer; }
.node .circle { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; background: var(--line); box-shadow: 0 6px 0 #cfcfcf; }
@media (prefers-color-scheme: dark) { .node .circle { box-shadow: 0 6px 0 #27353d; } }
.node.available .circle { background: var(--green); box-shadow: 0 6px 0 var(--green-dark); animation: bounce 1.6s infinite; }
.node.done .circle { background: var(--yellow); box-shadow: 0 6px 0 #d6a800; }
.node.joint .circle { background: var(--purple); box-shadow: 0 6px 0 #a35fd6; }
.node.joint.reported .circle { background: var(--yellow); box-shadow: 0 6px 0 #d6a800; }
.node.locked .circle { opacity: .7; }
.node:active .circle { transform: translateY(4px); box-shadow: none; }
.node .label { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.2; }
.node .sub { font-size: 11px; color: var(--muted); }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.badge.review { background: #FFE0E0; color: var(--red-dark); } .badge.challenge { background: #FFF3C4; color: #8a6d00; }
.tasks { padding: 4px 16px 14px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.task input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--green); }
.task.done span { text-decoration: line-through; color: var(--muted); }

/* ---------- урок ---------- */
.lesson-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.lesson-top .progress { flex: 1; }
.close { background: none; border: none; font-size: 26px; color: var(--muted); cursor: pointer; padding: 0 4px; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 20px; margin: 12px 0; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 12px; }
.card p { font-size: 17px; line-height: 1.5; }
.mascot { font-size: 44px; text-align: center; margin: 10px 0; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(14px + var(--safe-bottom)); background: var(--bg); border-top: 2px solid var(--line); max-width: 560px; margin: 0 auto; z-index: 6; }
.bottom.ok { background: #D7FFB8; border-color: #D7FFB8; } .bottom.bad { background: #FFDFE0; border-color: #FFDFE0; }
@media (prefers-color-scheme: dark) { .bottom.ok { background: #1e3a1a; border-color: #1e3a1a; } .bottom.bad { background: #3f1c1f; border-color: #3f1c1f; } }
.feedback { font-weight: 800; margin-bottom: 8px; display: flex; gap: 8px; align-items: flex-start; }
.feedback.ok { color: var(--green-dark); } .feedback.bad { color: var(--red-dark); }
@media (prefers-color-scheme: dark) { .feedback.ok { color: #9BE26A; } .feedback.bad { color: #FF9B9B; } }
.feedback-explain { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 10px; }
.q { font-size: 20px; font-weight: 800; margin: 14px 0 16px; }
.q-tag { font-size: 12px; font-weight: 800; color: var(--purple); text-transform: uppercase; letter-spacing: .5px; }
.opt { display: block; width: 100%; text-align: left; background: var(--card); color: var(--text); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; padding: 14px 16px; margin: 10px 0; font-size: 16px; font-weight: 600; font-family: inherit; cursor: pointer; }
.opt.selected { border-color: var(--blue); background: #DDF4FF; color: #1899D6; }
@media (prefers-color-scheme: dark) { .opt.selected { background: #1b3a4a; color: #7fd4ff; } }
.opt.correct { border-color: var(--green); background: #D7FFB8; color: var(--green-dark); }
.opt.wrong { border-color: var(--red); background: #FFDFE0; color: var(--red-dark); }
@media (prefers-color-scheme: dark) { .opt.correct { background: #1e3a1a; color: #9BE26A; } .opt.wrong { background: #3f1c1f; color: #FF9B9B; } }
.opt:disabled { cursor: default; }
.tf { display: flex; gap: 12px; } .tf .opt { text-align: center; font-size: 18px; }
.match { display: flex; gap: 12px; } .match > div { flex: 1; display: flex; flex-direction: column; }
.match .opt { font-size: 14px; min-height: 64px; display: flex; align-items: center; margin: 6px 0; }
.match .opt.matched { opacity: .45; border-color: var(--green); }
.result { text-align: center; padding: 30px 16px; }
.result .big { font-size: 72px; margin: 10px 0; }
.result .xp { font-size: 30px; font-weight: 900; color: var(--yellow); }
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 50; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .4; } }

/* ---------- семья / профиль ---------- */
.member { display: flex; align-items: center; gap: 12px; padding: 12px; border: 2px solid var(--line); border-radius: 16px; margin: 8px 0; background: var(--card); }
.member .avatar { font-size: 32px; }
.member .place { font-size: 20px; font-weight: 900; width: 28px; color: var(--muted); }
.member.me { border-color: var(--green); }
.joint-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 2px solid var(--line); border-radius: 16px; margin: 8px 0; background: var(--card); text-decoration: none; color: inherit; }
.joint-card .emoji { font-size: 28px; }
textarea, input[type=text], input[type=password], input[type=tel] { width: 100%; font: inherit; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); }
textarea { min-height: 120px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: center; padding: 8px 0; font-size: 15px; }
label.check input { width: 22px; height: 22px; accent-color: var(--green); margin: 0; }
.stars { display: flex; gap: 6px; font-size: 32px; justify-content: center; margin: 6px 0 12px; }
.stars span { cursor: pointer; filter: grayscale(1); opacity: .5; } .stars span.on { filter: none; opacity: 1; }
.step { padding: 12px 14px; border-left: 4px solid var(--purple); background: var(--bg2); border-radius: 0 12px 12px 0; margin: 10px 0; }
.step b { display: block; color: var(--purple); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.step ol { margin: 4px 0 0 18px; padding: 0; } .step li { margin: 6px 0; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.pill { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--bg2); border: 2px solid var(--line); }
.pill.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- логин ---------- */
.login { padding: 40px 24px; max-width: 420px; margin: 0 auto; text-align: center; }
.login .logo { font-size: 72px; }
.user-pick { display: flex; gap: 10px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.user-pick button { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 16px; padding: 12px; width: 100px; font-family: inherit; color: var(--text); font-weight: 700; cursor: pointer; }
.user-pick button.on { border-color: var(--green); background: #D7FFB8; }
@media (prefers-color-scheme: dark) { .user-pick button.on { background: #1e3a1a; } }
.user-pick .avatar { font-size: 36px; display: block; }
.pin { font-size: 28px; text-align: center; letter-spacing: 10px; margin: 10px 0 16px; }
.error { color: var(--red); font-weight: 700; margin: 8px 0; }

/* ---------- штаб ---------- */
table.sum { width: 100%; border-collapse: collapse; font-size: 13px; }
table.sum th, table.sum td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }
.score { display: inline-block; min-width: 40px; padding: 2px 6px; border-radius: 8px; font-weight: 800; color: #fff; }
.score.g { background: var(--green); } .score.y { background: var(--orange); } .score.r { background: var(--red); } .score.n { background: var(--line); color: var(--muted); }
details { margin: 8px 0; } summary { font-weight: 700; cursor: pointer; }
.report-box { background: var(--bg2); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 6px 0; white-space: pre-wrap; }

/* ---------- таббар ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around; background: var(--bg); border-top: 2px solid var(--line); padding: 8px 0 calc(8px + var(--safe-bottom)); z-index: 7; }
.tabbar a { text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 70px; text-transform: uppercase; }
.tabbar a .ico { font-size: 26px; }
.tabbar a.on { color: var(--blue); }
.toast { position: fixed; top: calc(12px + var(--safe-top)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 99; font-size: 14px; max-width: 90%; }
