:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --border: #e2dfd6;
  --text: #1b1c1f;
  --muted: #6a6b70;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfb;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --bad: #c2362f;
  --bad-soft: #fbe7e5;
  --warn: #a66a00;
  --warn-soft: #fbf0d9;
  --inno: #7a3fd1;
  --inno-soft: #efe7fb;
  --entre: #0f7f78;
  --entre-soft: #e0f3f1;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 4px 16px rgba(20, 20, 30, 0.05);
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e9eaee;
    --muted: #9a9ea8;
    --accent: #7c9cff;
    --accent-ink: #0d1020;
    --accent-soft: #1e2744;
    --ok: #4cc883;
    --ok-soft: #14301f;
    --bad: #ff7b72;
    --bad-soft: #3a1b1a;
    --warn: #f0b44a;
    --warn-soft: #362a12;
    --inno: #b48cff;
    --inno-soft: #2a2140;
    --entre: #4fd1c5;
    --entre-soft: #12302e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 650; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--text); color: var(--bg); font-size: 13px; letter-spacing: -0.02em;
}
.topnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a, .linklike {
  padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted);
  background: none; border: 0; cursor: pointer; font-size: 15px;
}
.topnav a:hover, .linklike:hover, .topnav a.active { color: var(--text); background: var(--surface-2); }
.who { font-size: 14px; color: var(--muted); margin-right: 4px; }

main { max-width: 860px; margin: 0 auto; padding: 24px 16px 80px; outline: none; }
.loading { color: var(--muted); }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 16px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.stack > * + * { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; color: var(--text);
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  min-height: 44px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

input[type="text"], select {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); min-height: 46px;
}
input[type="text"]:focus, select:focus, .btn:focus-visible, .option:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* login */
.login { max-width: 420px; margin: 8vh auto 0; }
.login form { display: flex; gap: 10px; margin-top: 16px; }
.login form input { flex: 1; }
.known { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; }

/* course cards */
.course { border-top: 4px solid var(--c); }
.course.innovation { --c: var(--inno); --c-soft: var(--inno-soft); }
.course.entrepreneurship { --c: var(--entre); --c-soft: var(--entre-soft); }
.course-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.course-head h2 { margin: 0; }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--c-soft, var(--surface-2)); color: var(--c, var(--muted)); font-weight: 600; white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .m { background: var(--c, var(--accent)); }
.bar .s { background: color-mix(in srgb, var(--c, var(--accent)) 35%, transparent); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.course .btn-row { margin-top: 16px; }

.topics { width: 100%; border-collapse: collapse; font-size: 14px; }
.topics td { padding: 8px 4px; border-top: 1px solid var(--border); vertical-align: middle; }
.topics td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.topics .bar { width: 100%; min-width: 60px; }
details.topic-details summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-top: 12px; }

/* setup */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 14px; min-height: 38px;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.setup-section + .setup-section { margin-top: 20px; }
.hint { font-size: 14px; color: var(--muted); }

/* quiz */
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.quiz-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.progress-line { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress-line i { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.case-box {
  background: var(--surface-2); border-left: 4px solid var(--c, var(--accent));
  border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; font-size: 15px; white-space: pre-wrap;
}
.case-box .case-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.question { font-size: 19px; line-height: 1.45; font-weight: 560; margin: 0 0 6px; white-space: pre-wrap; }
.qtype { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.qtype b { color: var(--warn); }
.options { display: grid; gap: 10px; }
.option {
  display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; text-align: left;
  padding: 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; line-height: 1.45; width: 100%;
}
.option:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.option .key {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--muted);
}
.option.multi .key { border-radius: 6px; }
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option[aria-pressed="true"] .key { background: var(--accent); color: var(--accent-ink); }
.option:disabled { cursor: default; }
.option.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.option.is-correct .key { background: var(--ok); color: #fff; }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.is-wrong .key { background: var(--bad); color: #fff; }
.option.is-missed { border-color: var(--ok); border-style: dashed; }
.option .tag { display: block; font-size: 12px; font-weight: 700; margin-top: 4px; }
.option.is-correct .tag { color: var(--ok); }
.option.is-wrong .tag { color: var(--bad); }
.option.is-missed .tag { color: var(--ok); }

.feedback { margin-top: 18px; border-radius: 12px; padding: 16px; border: 1px solid var(--border); background: var(--surface); }
.feedback.ok { border-color: var(--ok); }
.feedback.bad { border-color: var(--bad); }
.verdict { font-weight: 700; margin-bottom: 6px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.explanation { margin: 0; }
.source { font-size: 13px; color: var(--muted); margin-top: 8px; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); }
.shortcut-hint { font-size: 13px; color: var(--muted); }

.timer { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.exam-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.exam-nav button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums;
}
.exam-nav button.answered { background: var(--accent-soft); border-color: var(--accent); }
.exam-nav button.current { outline: 2px solid var(--text); outline-offset: 1px; }

/* results */
.score-big { font-size: 48px; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.review-item { border-top: 1px solid var(--border); padding: 14px 0; }
.review-item summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; list-style: none; }
.review-item summary::-webkit-details-marker { display: none; }
.mark { font-weight: 800; width: 18px; flex: none; }
.mark.ok { color: var(--ok); }
.mark.bad { color: var(--bad); }
.review-body { margin-top: 12px; padding-left: 28px; }
.review-body .options { gap: 6px; }
.review-body .option { padding: 10px; cursor: default; }

/* compare */
.versus { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.player h2 { display: flex; justify-content: space-between; align-items: baseline; }
.player .lead { font-size: 12px; font-weight: 700; color: var(--ok); text-transform: uppercase; letter-spacing: 0.06em; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cmp-table th, .cmp-table td { padding: 9px 6px; border-top: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.cmp-table th:first-child, .cmp-table td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.cmp-table thead th { border-top: 0; font-size: 13px; color: var(--muted); }
.cmp-table td.best { color: var(--ok); font-weight: 700; }
.table-wrap { overflow-x: auto; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 20;
}
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(480px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog textarea {
  width: 100%; min-height: 110px; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; resize: vertical;
}

@media (max-width: 560px) {
  h1 { font-size: 23px; }
  .question { font-size: 17px; }
  .card { padding: 16px; }
  .brand-text { display: none; }
  .kpi b { font-size: 17px; }
  .option { padding: 12px; gap: 10px; grid-template-columns: 28px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* login with password */
.login-form { display: grid; gap: 6px; margin-top: 16px; }
.login-form .field { margin: 8px 0 0; }
.login-form .btn { margin-top: 12px; }
input[type="password"] {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); min-height: 46px;
}
input[type="password"]:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.dialog-form { display: grid; gap: 10px; margin-top: 12px; }
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.who { font-weight: 600; }

/* overview */
.kpis.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .kpis.four { grid-template-columns: repeat(2, 1fr); } }
.overall { border-top: 4px solid var(--accent); --c: var(--accent); }
.blocks { display: grid; gap: 10px; margin-top: 12px; }
.block {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.block-title { font-weight: 620; margin-bottom: 8px; }
.block-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.block-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.block-stats small { font-size: 12px; }
.block-stats .warn b { color: var(--warn); }
.block-actions { display: flex; gap: 8px; }
@media (max-width: 560px) {
  .block { grid-template-columns: 1fr; }
  .block-actions .btn { flex: 1; }
}

/* ranking */
.rank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank-table th, .rank-table td { padding: 9px 8px; border-top: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-table thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.rank-table th:nth-child(-n+2), .rank-table td.rank, .rank-table td.name { text-align: left; }
.rank-table td.rank { width: 36px; color: var(--muted); }
.rank-table td.name { font-weight: 620; }
.rank-table tr.me td { background: var(--accent-soft); }
.rank-table td.best { color: var(--ok); font-weight: 700; }
.rank-table .cell-bar { display: inline-block; width: 56px; height: 6px; border-radius: 99px; background: var(--surface-2); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.rank-table .cell-bar i { display: block; height: 100%; background: var(--accent); }
.matrix th:first-child, .matrix td.topic-cell { text-align: left; white-space: normal; min-width: 180px; }
.matrix th { text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 8px; vertical-align: 1px; }
.dot.innovation { background: var(--inno); }
.dot.entrepreneurship { background: var(--entre); }

/* gamification */
.streak-pill {
  display: inline-flex; align-items: baseline; gap: 2px; padding: 3px 10px; border-radius: 99px;
  background: var(--surface-2); color: var(--text); font-size: 14px; white-space: nowrap;
}
.streak-pill b { font-variant-numeric: tabular-nums; }
.streak-pill small { color: var(--muted); font-size: 12px; }
.streak-pill.hot { background: linear-gradient(90deg, #ff8a00, #ff3d6e); color: #fff; }
.streak-pill.hot small { color: rgba(255, 255, 255, 0.85); }
.streak-pill.pop { animation: pop 0.45s ease-out; }
.streak-pill.broken { animation: shake 0.4s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.celebrate {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 30;
  display: grid; gap: 2px; text-align: center; min-width: 240px; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); animation: drop 0.35s ease-out; transition: opacity 0.4s, transform 0.4s;
}
.celebrate span { font-size: 13px; opacity: 0.8; }
.celebrate.out { opacity: 0; transform: translate(-50%, -10px); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }

.game { border-top: 4px solid #ff8a00; }
.game-top { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: center; }
@media (max-width: 700px) { .game-top { grid-template-columns: 1fr; } }
.level { display: flex; gap: 14px; align-items: center; }
.level > div:last-child { flex: 1; min-width: 0; }
.level-badge {
  flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #ffb300, #ff5e3a); color: #fff; font-size: 24px; font-weight: 800;
}
.level-title { font-weight: 700; margin-bottom: 6px; }
.xpbar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb300, #ff5e3a); }
.level .hint { font-size: 12px; margin-top: 6px; }
.streaks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach-details summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-top: 14px; }
.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 12px; }
.ach { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); opacity: 0.6; }
.ach.on { opacity: 1; border-color: color-mix(in srgb, #ff8a00 50%, var(--border)); background: color-mix(in srgb, #ff8a00 8%, var(--surface)); }
.ach-icon { font-size: 22px; line-height: 1; filter: grayscale(1); }
.ach.on .ach-icon { filter: none; }
.ach-text { display: grid; gap: 2px; min-width: 0; }
.ach-text b { font-size: 14px; }
.ach-text span, .ach-text small { font-size: 12px; color: var(--muted); }
.ach-bar { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.ach-bar i { display: block; height: 100%; background: #ff8a00; }
.badges { font-size: 12px; font-weight: 400; letter-spacing: 1px; }

/* ===== engagement layer ===== */
:root { --game: #e07400; --game-soft: #fff1df; --gold: #f2a900; }
@media (prefers-color-scheme: dark) { :root { --game: #ffa133; --game-soft: #33240f; --gold: #ffc940; } }

.linklike.inline { padding: 0; font-size: inherit; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.linklike.inline:hover { background: none; }
.sound-toggle { font-size: 17px; line-height: 1; padding: 6px 8px; }
.btn.big { min-height: 50px; padding: 12px 22px; font-size: 17px; }
.hello .sub { margin-bottom: 0; }
.title-chip { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--game-soft); color: var(--game); font-weight: 650; font-size: 14px; }

/* progress ring */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { display: block; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--game); transition: stroke-dasharray 0.6s ease-out; }
.ring.done .ring-fg { stroke: var(--ok); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ring-label small { font-size: 12px; color: var(--muted); }

/* today card */
.today { border-top: 4px solid var(--game); }
.today.reached { border-top-color: var(--ok); }
.today-top { display: flex; gap: 18px; align-items: center; }
.goal-ring-btn { background: none; border: 0; padding: 0; cursor: pointer; border-radius: 99px; }
.goal-ring-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.today-info { min-width: 0; flex: 1; }
.today-title { font-size: 19px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.today-info .hint { margin-top: 2px; }
.today-facts { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 3px; font-size: 14px; }
.today-cta { margin-top: 16px; }
.today-cta .btn { max-width: 100%; }
.today-cta .btn:not(.primary) { white-space: normal; text-align: left; }
@media (max-width: 560px) {
  .today-top { flex-direction: column; align-items: stretch; text-align: center; }
  .goal-ring-btn { align-self: center; }
  .today-facts { text-align: left; }
  .today-cta .btn { flex: 1 1 100%; }
}

/* quests */
.quests { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 10px; }
.quests.compact { margin-top: 0; border-top: 0; padding-top: 0; }
.quests-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.quests-head .hint { font-size: 13px; }
.quest { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; }
.quest-icon { font-size: 19px; text-align: center; }
.quest-label { font-size: 14px; font-weight: 550; line-height: 1.35; }
.quest.done .quest-label { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.qbar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 5px; }
.qbar i { display: block; height: 100%; background: var(--game); border-radius: 99px; transition: width 0.5s ease-out; }
.quest.done .qbar i { background: var(--ok); }
.quest-xp { font-size: 12px; font-weight: 650; color: var(--game); white-space: nowrap; font-variant-numeric: tabular-nums; }
.quest.done .quest-xp { color: var(--ok); }

/* race */
.race { border-top: 4px solid var(--accent); }
.race h2 { margin-bottom: 6px; }
.race-status { margin: 0 0 12px; font-weight: 600; font-size: 15px; }
.race-status.behind { color: var(--bad); }
.race-status.ahead { color: var(--ok); }
.racers { display: grid; gap: 8px; }
.racer { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); }
.racer.me { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.racer-rank { font-size: 20px; line-height: 1.3; text-align: center; color: var(--muted); font-weight: 700; }
.racer-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.racer-name small { color: var(--muted); font-size: 12px; }
.racer-sub { font-size: 13px; color: var(--muted); }
.racer-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.live { font-size: 12px; color: var(--ok); font-weight: 650; }
.feed-head { margin-top: 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.feed { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; font-size: 14px; }
.feed li { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: baseline; }
.feed-icon { text-align: center; }
.feed small { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* quiz HUD */
.hud { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -4px 0 12px; }
.goal-mini, .xp-mini { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 99px; background: var(--surface-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.xp-mini { padding-left: 10px; color: var(--game); font-weight: 650; }
.goal-mini small { font-size: 13px; }
.goal-mini.bump .ring { animation: pop 0.45s ease-out; }

/* floating +XP */
.xp-float {
  position: fixed; z-index: 35; pointer-events: none; transform: translate(-50%, -100%);
  font-weight: 800; font-size: 18px; color: var(--game); text-shadow: 0 1px 0 var(--surface);
  animation: xpUp 1.3s ease-out forwards;
}
.xp-float.ok { color: var(--ok); }
@keyframes xpUp {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -110%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 45; }
.celebrate.big { background: linear-gradient(135deg, #ff8a00, #ff3d6e); color: #fff; padding: 14px 22px; }
.celebrate.big b { font-size: 17px; }

/* rival notifications */
.pings { position: fixed; left: 12px; bottom: 12px; z-index: 25; display: grid; gap: 6px; max-width: min(360px, calc(100vw - 24px)); pointer-events: none; }
.ping {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  animation: slideIn 0.3s ease-out; transition: opacity 0.4s, transform 0.4s;
}
.ping.out { opacity: 0; transform: translateX(-12px); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

/* answer feedback chips */
.gains { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.gchip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.gchip.xp { background: var(--ok-soft); color: var(--ok); font-weight: 800; }
.gchip.hot { background: var(--game-soft); color: var(--game); }
.gchip.fix { background: var(--accent-soft); color: var(--accent); }
.gchip.learn { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); color: var(--text); }
.gchip.bad { background: var(--bad-soft); color: var(--bad); }

/* stars, crowns, boss */
.block-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.stars { display: inline-flex; gap: 1px; font-size: 15px; letter-spacing: 0; color: color-mix(in srgb, var(--muted) 45%, transparent); }
.stars .on { color: var(--gold); }
.crown { font-size: 15px; }
.block.complete { border-color: color-mix(in srgb, var(--gold) 60%, var(--border)); background: color-mix(in srgb, var(--gold) 7%, var(--surface)); }
.next-star { color: var(--game); }
.boss-btn { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.boss-btn.locked { opacity: 0.6; }
.boss-bar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-bottom: 16px; }
.hearts { display: inline-flex; gap: 2px; font-size: 18px; }
.heart.lost { opacity: 0.45; }
.boss-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.boss-track i { display: block; height: 100%; background: linear-gradient(90deg, #ff8a00, #ff3d6e); transition: width 0.4s ease-out; }
.boss-count { font-variant-numeric: tabular-nums; }
.boss-bar.hurt .hearts { animation: shake 0.4s ease-out; }
.boss-bar.hit .boss-count { animation: pop 0.45s ease-out; display: inline-block; }
.boss-rules { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* summary screens */
.summary { border-top: 4px solid var(--game); }
.summary.boss-won { border-top-color: var(--gold); }
.summary.boss-lost { border-top-color: var(--bad); }
.summary-head { display: flex; gap: 14px; align-items: center; }
.summary-head h1 { margin: 0; }
.summary-icon { font-size: 44px; line-height: 1; flex: none; }
.eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.score-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.score-line .sub { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { display: grid; justify-items: center; text-align: center; gap: 2px; padding: 12px 6px; border-radius: 12px; background: var(--surface-2); }
.tile-icon { font-size: 20px; }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile span:last-child { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, 1fr); } .summary-icon { font-size: 36px; } }
.goal-strip { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); }
.rank-title { font-size: 12px; font-weight: 500; color: var(--game); }

@media (prefers-reduced-motion: reduce) {
  .streak-pill.pop, .streak-pill.broken, .goal-mini.bump .ring, .boss-bar.hurt .hearts, .boss-bar.hit .boss-count { animation: none; }
  .celebrate, .ping { animation: none; }
  .xp-float { animation: xpFade 1.3s ease-out forwards; }
  @keyframes xpFade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
}

/* ===== audit fixes: hero, mobile quiz bar, profile ===== */
.hero-cta { display: grid; gap: 8px; margin-bottom: 16px; }
.hero-cta .btn.big { width: 100%; }
.hero-cta .weak-btn { justify-self: start; white-space: normal; text-align: left; }
@media (max-width: 560px) {
  .today-top { flex-direction: row; align-items: center; text-align: left; }
  .today-top .ring { width: 84px !important; height: 84px !important; }
  .today-top .ring svg { width: 84px; height: 84px; }
  .today-top .ring-label b { font-size: 24px; }
  .today-title { font-size: 16px; }
  .hero-cta .weak-btn { justify-self: stretch; }
}
.diff { margin-left: 8px; font-size: 11px; letter-spacing: 1px; color: var(--muted); white-space: nowrap; }
.diff.d3 { color: var(--bad); }
.diff.d1 { color: var(--ok); }
.gchip.hard { background: var(--bad-soft); color: var(--bad); }

/* topbar: long names must not wrap the whole bar */
.who { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) {
  .who { max-width: 34vw; }
  .topbar { gap: 6px; padding-top: 8px; padding-bottom: 8px; }
  .topnav { flex-wrap: nowrap; gap: 0; }
  .topnav a, .linklike { padding: 6px 7px; font-size: 14px; }
}

/* quiz on phones: keep Check/Next reachable and drop the keyboard hint on touch screens */
@media (hover: none) { .shortcut-hint { display: none; } }
@media (max-width: 560px) {
  article.card > .actions {
    position: sticky; bottom: 0; z-index: 5; background: var(--surface);
    margin: 12px -16px -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  }
  .actions .btn-row { flex: 1; justify-content: flex-end; flex-wrap: nowrap; }
  .actions .btn.primary { flex: 1; }
  .pings { bottom: 84px; }
}

/* profile */
.profile-top { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.profile-id { min-width: 0; flex: 1; }
.profile-id h1 { margin-bottom: 4px; overflow-wrap: anywhere; }
.profile .kpis { margin-bottom: 0; }
.profile-table td b { display: block; font-size: 15px; }
.cell-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.profile-table th, .profile-table td { padding: 8px 4px; }
.topic-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.topic-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: baseline; }
.topic-list small { color: var(--muted); }
.tl-name { min-width: 0; }
.day-bars { display: grid; gap: 6px; }
.day-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.day-row.today { font-weight: 700; }
.day-label { color: var(--muted); white-space: nowrap; }
.day-row.today .day-label { color: var(--text); }
.day-bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.day-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.day-num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.recent-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; font-size: 13px; }
.recent-list li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: baseline; }
.recent-list small { color: var(--muted); }
.account input[type="text"], .account input[type="password"] { max-width: 420px; }
.login .login-form { display: grid; } /* beats the older ".login form { display: flex }" */

/* gamification settings */
.fx-slider { width: 100%; accent-color: var(--game); margin: 6px 0 2px; min-height: 32px; }
.fx-stops { display: flex; justify-content: space-between; gap: 4px; font-size: 12px; color: var(--muted); }
.fx-stops span { flex: 1; text-align: center; }
.fx-stops span:first-child { text-align: left; }
.fx-stops span:last-child { text-align: right; }
.fx-stops span.on { color: var(--text); font-weight: 700; }
.fx-desc { margin: 10px 0 0; font-size: 14px; }
.switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.switch { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 14px; }
.switch input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.compare { border-top: 4px solid var(--accent); }

/* quiet celebration (pop-ups off): a small toast instead */
.celebrate.quiet { top: auto; bottom: 24px; min-width: 0; padding: 8px 14px; border-radius: 10px; font-size: 14px; animation: none; }
.celebrate.quiet b { font-weight: 600; }

/* animations switched off (gamification level or switch) */
.no-anim .streak-pill.pop, .no-anim .streak-pill.broken, .no-anim .goal-mini.bump .ring,
.no-anim .boss-bar.hurt .hearts, .no-anim .boss-bar.hit .boss-count, .no-anim .celebrate, .no-anim .ping { animation: none; }
.no-anim .xp-float { animation: xpFadeOnly 1.3s ease-out forwards; }
.no-anim .ring-fg, .no-anim .qbar i, .no-anim .boss-track i, .no-anim .progress-line i { transition: none; }
@keyframes xpFadeOnly { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.fx-stops { position: relative; display: block; height: 18px; }
.fx-stops span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.fx-stops span:nth-child(1) { left: 0; transform: none; }
.fx-stops span:nth-child(2) { left: 25%; }
.fx-stops span:nth-child(3) { left: 50%; }
.fx-stops span:nth-child(4) { left: 75%; }
.fx-stops span:nth-child(5) { left: auto; right: 0; transform: none; }
.compare .rank-table th:nth-child(n+2), .compare .rank-table td:nth-child(n+2) { text-align: right; }
@media (max-width: 560px) {
  #switch-user { display: none; } /* log out lives in the profile's Account section on phones */
  .topnav a, .topnav .linklike { white-space: nowrap; }
}
@media (max-width: 560px) {
  .profile-table { font-size: 13px; }
  .profile-table th, .profile-table td { padding: 7px 2px; }
  .profile-table thead th { font-size: 11px; }
  .profile-table td:first-child { max-width: 86px; overflow-wrap: anywhere; }
  .profile-table td b { font-size: 14px; }
  .cell-sub { font-size: 10px; }
}
