/* ============================================================
   Геометричний тренажер — редизайн (зін/енергійний стиль).
   Токени: ink-обведення 3px, офсет-тіні, ALL-CAPS, оранж/шавлія.
   Шрифти: Onest (UI і плитки результату) + Unbounded 700 (великі числа: XP/серія) + Gelasio (акценти). Завантажується останнім.
   ============================================================ */
:root {
    --ink: #2a2622;        --ink-2: #5c544c;
    --paper: #e9e3d9;      --surface: #fffdfb;   --surface-2: #f9f6f2;
    --sage: #7c9d85;       --sage-d: #5f8069;    --sage-tint: #a8d8b0;   --sage-soft: #eaf2e3;
    --orange: #ef8748;     --orange-d: #c96a2c;  --orange-tint: #fdf3ea; --orange-bd: #f3c9a5;
    --red: #dc4040;        --red-tint: #fbe3e3;
    --muted: #8a8177;      --muted-2: #a39a90;
    --sh-s: 4px 4px 0 var(--ink);
    --sh-l: 6px 6px 0 var(--ink);
    --out: 3px solid var(--ink);
}
* { box-sizing: border-box; }
body {
    font-family: var(--font-ui, 'Onest', system-ui, -apple-system, sans-serif) !important;
    background: var(--paper) !important;
    color: var(--ink) !important;
    -webkit-font-smoothing: antialiased;
}
/* Кнопки й поля не успадковують шрифт сторінки — без цього «←», ✕ тощо малюються системним Arial. Лише елементний селектор:
   будь-яке правило з класом (розмір, моно, Gelasio) лишається сильнішим. */
button, input, select, textarea { font-family: inherit; }

/* ── Верхня панель ── */
/* Панель — перший елемент сторінки, тож відступ від вирізу / Dynamic Island (iOS-застосунок, viewport-fit=cover) — тут,
   а не в .container: інакше «На головну» і серія ховаються під статус-бар, а під панеллю зяє порожня смуга */
.top-bar {
    background: var(--surface) !important;
    border-bottom: var(--out) !important;
    padding: calc(12px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
             12px calc(18px + env(safe-area-inset-left)) !important;
}
.top-bar h1 { font-size: 15px !important; font-weight: 800 !important; color: var(--ink) !important; letter-spacing: -.2px; }
.top-bar .back-link { color: var(--sage-d) !important; font-weight: 800 !important; text-decoration: none; }
.top-bar .streak {
    background: var(--orange) !important; color: var(--surface) !important;
    border: 2.5px solid var(--ink); border-radius: 999px !important;
    font-weight: 800 !important; box-shadow: 2px 2px 0 var(--ink);
}

/* ── Контейнер стежки: велика картка з обведенням ── */
/* Бокові відступи й нижня смужка (iOS-застосунок на весь екран, viewport-fit=cover); верхній виріз бере .top-bar */
.container {
    max-width: 1000px !important;
    padding: 22px calc(16px + env(safe-area-inset-right))
             calc(60px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)) !important;
}
#screenPath {
    background: var(--surface);
    border: var(--out);
    border-radius: 22px;
    box-shadow: var(--sh-l);
    position: relative;
    overflow: hidden;
    padding: 24px 26px 30px 30px;
}
/* Помаранчева лінія-нитка ліворуч (як у мокапі) */
#screenPath::before {
    content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px;
    background: rgba(239, 135, 72, .38);
}

/* ── Шапка стежки: XP / стрік як плитки ── */
.path-top {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 22px; padding-left: 8px;
}
.path-top .path-stat {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    border: 2.5px solid var(--ink); border-radius: 14px; padding: 9px 15px;
    background: var(--surface); min-width: 62px;
}
.path-top .path-stat:nth-of-type(1) { background: var(--ink); box-shadow: 3px 3px 0 var(--sage); transform: rotate(-2deg); }
.path-top .path-stat:nth-of-type(1) b { color: var(--surface); }
.path-top .path-stat:nth-of-type(1) .ps-lbl { color: var(--muted-2); }
.path-top .path-stat:nth-of-type(1) .ps-ico { display: none; }
.path-top .path-stat:nth-of-type(2) { background: var(--orange); box-shadow: 3px 3px 0 var(--ink); transform: rotate(2deg); }
.path-top .path-stat:nth-of-type(2) b { color: var(--surface); }
.path-top .path-stat:nth-of-type(2) .ps-lbl { color: #7d3f14; }
.path-top .path-stat:nth-of-type(2) .ps-ico { display: none; }
.path-top .path-stat b { font-family: var(--font-display, 'Unbounded', 'Onest', system-ui, -apple-system, sans-serif); font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.path-top .path-stat .ps-lbl { font-size: 8.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; margin-top: 2px; }
.path-top .btn-secondary#btnFreeMode {
    margin-left: auto; background: var(--surface) !important; color: var(--ink) !important;
    border: 2.5px solid var(--ink) !important; border-radius: 12px !important;
    font-weight: 800 !important; box-shadow: 3px 3px 0 var(--ink); font-size: 13px !important; padding: 9px 14px !important;
}
.path-top .sync-badge { font-size: 18px; }

/* ── Смуга «Робота над помилками» ── */
.mistakes-bar {
    display: flex; align-items: center; gap: 14px; width: 100%;
    background: var(--orange-tint); border: var(--out); border-radius: 18px;
    padding: 15px 18px; box-shadow: var(--sh-s); margin-bottom: 24px; cursor: pointer;
    font-family: inherit; text-align: left;
}
.mistakes-bar .mb-ico {
    width: 38px; height: 38px; border-radius: 12px; background: var(--orange);
    border: 2.5px solid var(--ink); display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex: none; color: #fff;
}
.mistakes-bar .mb-txt { flex: 1; font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: -.3px; }
.mistakes-bar .mb-count {
    background: var(--orange); color: #fff; border: 2px solid var(--ink); border-radius: 999px;
    padding: 2px 11px; font-size: 14px; font-weight: 800; flex: none;
}

/* ── Юніт стежки ── */
.path-body { display: flex; flex-direction: column; gap: 22px; }
.path-unit { padding-left: 8px; }
.unit-head { display: flex; align-items: center; gap: 13px; margin-bottom: 13px; }
.unit-head .unit-icon {
    width: 44px; height: 44px; border-radius: 14px; flex: none;
    background: var(--sage-soft); border: 2.5px solid var(--ink);
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.unit-info { min-width: 0; }
.unit-info h3 { font-size: 19px; font-weight: 800; text-transform: uppercase; letter-spacing: -.4px; margin: 0; overflow-wrap: break-word; }
.unit-info .unit-sub { font-size: 12px; font-weight: 700; color: var(--muted); }
/* Лінія-роздільник + відсоток замість кільця */
.unit-head .unit-ring {
    margin-left: auto; flex: none; width: auto; height: auto; background: none;
    font-size: 13px; font-weight: 800; color: var(--sage-d);
}
.unit-head .unit-ring::before {
    content: ""; display: inline-block; width: 60px; height: 3px; border-radius: 999px;
    background: var(--ink); vertical-align: middle; margin-right: 12px;
}
.unit-head .unit-ring span { position: static; }

/* ── Вузли-плитки ── */
/* Рядки розсунуто на 16px: мітка «тут ти» стирчить на 11px над вузлом і не має налазити на рядок вище */
.path-nodes { display: flex; gap: 16px 10px; flex-wrap: wrap; padding-left: 57px; }
.path-node {
    width: 56px; height: 56px; border: 3px solid var(--ink); border-radius: 16px;
    background: var(--surface); color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; font-weight: 800; cursor: pointer; position: relative;
    box-shadow: 3px 3px 0 var(--ink); transition: transform .12s;
    font-family: inherit;
}
.path-node svg { width: 22px; height: 22px; }
.path-node.done { background: var(--sage-tint); }
.path-node.done.perfect { background: var(--orange); color: var(--surface); }
.path-node.open { background: var(--surface); box-shadow: 5px 5px 0 var(--ink); transform: rotate(-2deg); }
.path-node.locked {
    background: transparent; border-style: dashed; border-color: var(--muted-2);
    color: var(--muted-2); box-shadow: none; cursor: not-allowed;
}
.path-node:not(.locked):active { transform: translateY(2px); box-shadow: 2px 2px 0 var(--ink); }
/* Мітка «тут ти» на першому відкритому вузлі */
.path-node.here::after {
    content: "тут ти"; position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
    font-size: 8px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--ink);
    background: var(--surface); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 6px; white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) { .path-node { transition: none; } }

/* ── Стежка на телефоні: одна колонка, вузли рівною сіткою під назвою юніта ── */
@media (max-width: 480px) {
    #screenPath { padding: 20px 14px 24px 26px; border-radius: 18px; }
    .path-unit { padding-left: 0; }
    .unit-head { gap: 11px; }
    .unit-head .unit-icon { width: 40px; height: 40px; font-size: 20px; }
    .unit-info h3 { font-size: 17px; }
    /* Лінія-роздільник не вміщається поруч із назвою (перекреслювала «ПЛАНІМЕТРІЇ») — лишаємо тільки відсоток */
    .unit-head .unit-ring::before { display: none; }
    /* 40 іконка + 11 проміжок = відступ під назву; 4 вузли по 52px у рядок на 390px */
    .path-nodes { padding-left: 51px; gap: 16px 8px; }
    .path-node { width: 52px; height: 52px; }
}

/* ============================================================
   ЕКРАН КВІЗА (одноколонковий зін — як мобільний мокап)
   ============================================================ */
#screenQuiz { max-width: 560px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.btn-back-path {
    width: 38px; height: 38px; border-radius: 12px; background: var(--surface);
    border: 2.5px solid var(--ink); display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; font-weight: 800; color: var(--ink); flex: none;
}
.quiz-lesson {
    font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
    color: #fff; background: var(--sage); border: 2.5px solid var(--ink); border-radius: 999px;
    padding: 5px 12px; transform: rotate(-1.5deg);
}
.lives-row { margin-left: auto; display: flex; gap: 4px; }
.lives-row .life svg { width: 19px; height: 19px; display: block; }

.retry-banner {
    background: var(--orange-tint); border: 2.5px solid var(--ink); border-radius: 14px;
    padding: 11px 14px; font-size: 13px; font-weight: 800; text-transform: uppercase;
    color: var(--orange-d); box-shadow: 3px 3px 0 var(--ink); margin-bottom: 16px;
}

/* Прогрес */
.progress-wrap { background: none !important; border: none !important; box-shadow: none !important; padding: 0 !important; margin-bottom: 20px; }
.progress-bar { height: 11px; background: var(--surface); border: 2.5px solid var(--ink); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { background: var(--sage) !important; }
.progress-text { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--muted); }

/* Картка твердження */
.stmt-card { background: var(--surface); border: var(--out); border-radius: 20px; box-shadow: var(--sh-l); padding: 22px; margin-bottom: 15px; }
.stmt-topic-tag {
    display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
    color: #fff; background: var(--sage); border: 2.5px solid var(--ink); border-radius: 999px;
    padding: 4px 11px; margin-bottom: 14px; transform: rotate(-2deg);
}
.stmt-intro { background: var(--orange-tint); border: 2.5px solid var(--orange-bd); border-radius: 14px; padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); line-height: 1.55; margin-bottom: 14px; }
.stmt-diagram { max-width: 210px; display: block; margin: 0 auto 15px; background: var(--surface); border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; }
.stmt-prompt { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--sage-d); margin-bottom: 8px; }
.stmt-text { font-size: 20px; font-weight: 700; line-height: 1.5; }

/* Вір / Не вір */
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 13px; }
.answer-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--surface); border: var(--out); border-radius: 16px; padding: 18px; cursor: pointer; font-family: inherit; box-shadow: var(--sh-s); transition: transform .1s; }
.answer-btn:not(:disabled):active { transform: translateY(2px); box-shadow: 2px 2px 0 var(--ink); }
.answer-btn .answer-emoji { font-size: 25px; font-weight: 800; line-height: 1; }
.answer-btn > span:last-child { font-size: 17px; font-weight: 800; text-transform: uppercase; }
.answer-btn.true .answer-emoji { color: var(--sage-d); }
.answer-btn.false .answer-emoji { color: var(--red); }
.answer-btn.correct { background: var(--sage-soft); }
.answer-btn.incorrect { background: var(--red-tint); }

/* Фідбек / вердикт */
.feedback { border: var(--out); border-radius: 20px; padding: 20px; box-shadow: var(--sh-l); margin-top: 8px; margin-bottom: 16px; }
.feedback.correct { background: #e7f0e2; }
.feedback.incorrect { background: var(--red-tint); }
.feedback-title { font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: -.4px; margin-bottom: 10px; }
.feedback-explanation { background: rgba(255,253,251,.72); border-radius: 13px; padding: 14px; font-size: 14px; font-weight: 600; line-height: 1.6; color: #3f3a33; margin-bottom: 10px; }
.feedback-source { font-size: 11px; font-weight: 700; color: var(--muted); }
.reason-ask { margin-top: 14px; }
.reason-q { font-size: 14px; font-weight: 800; text-transform: uppercase; margin-bottom: 9px; }
.reason-opts { display: flex; flex-direction: column; gap: 7px; }
.reason-opt { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 2.5px solid var(--ink); border-radius: 12px; padding: 12px; font-size: 13px; font-weight: 800; cursor: pointer; font-family: inherit; text-align: left; box-shadow: 2px 2px 0 var(--ink); }
.reason-opt.sel, .reason-opt:active { background: var(--sage-soft); }

.btn.next-btn { width: 100%; background: var(--sage) !important; color: #fff !important; border: 2.5px solid var(--ink) !important; border-radius: 14px !important; padding: 16px !important; font-size: 15px !important; font-weight: 800 !important; text-transform: uppercase; box-shadow: var(--sh-s); }

/* ============================================================
   ЕКРАН РЕЗУЛЬТАТУ (зін)
   ============================================================ */
#screenResults .results { background: var(--surface); border: var(--out); border-radius: 22px; box-shadow: var(--sh-l); padding: 30px 26px; text-align: center; max-width: 520px; margin: 0 auto; }
.results-icon { font-size: 52px; margin-bottom: 6px; }
#screenResults h2 { font-size: 30px; font-weight: 800; text-transform: uppercase; letter-spacing: -1px; margin-bottom: 20px; color: var(--ink); }
.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-bottom: 18px; }
.results-stats .stat { background: var(--surface); border: 3px solid var(--ink); border-radius: 16px; padding: 16px 8px; box-shadow: 3px 3px 0 var(--ink); }
.results-stats .stat:nth-child(1) { background: var(--sage-soft); }
/* Три плитки в ряд — Onest 900 з табличними цифрами (Unbounded тут дрібнішав до 19–21px). Колонки 1fr ростуть під вміст,
   тож влазити має сума «12/12 + 100% + 12» (≈7,3em) + відступи плиток (≈88px): 8vw − 6px дає 19,6px на 320, 22,8 на 360, 25,2 на 390. */
.results-stats .stat-value { font-family: var(--font-ui, 'Onest', system-ui, -apple-system, sans-serif); font-size: clamp(18px, calc(8vw - 6px), 30px); font-weight: 900; letter-spacing: -.02em; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.results-stats .stat-label { font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-top: 5px; }
.result-xp { background: var(--ink); color: #f5f0ec; border: 3px solid var(--ink); border-radius: 16px; padding: 14px; font-size: 15px; font-weight: 800; box-shadow: 4px 4px 0 var(--orange); margin-bottom: 18px; }
.results-actions { display: flex; flex-direction: column; gap: 10px; }
.results-actions .btn-primary#btnRestart { background: var(--sage) !important; color: #fff !important; border: 2.5px solid var(--ink) !important; border-radius: 14px !important; font-weight: 800 !important; text-transform: uppercase; box-shadow: var(--sh-s); }
.results-actions .btn-secondary { background: var(--surface) !important; color: var(--ink) !important; border: 2.5px solid var(--ink) !important; border-radius: 14px !important; font-weight: 800 !important; box-shadow: 3px 3px 0 var(--ink); }
