/* ==========================================================================
   Графический диктант — оформление.

   Порядок разделов: переменные → базовое → шапка и подвал → лендинг →
   каталог и карточки → страница рисунка → страница тега → игровой экран →
   всплывающие окна → лист печати → адаптив.

   Игровой экран сохраняет имена классов старого приложения (.steps-panel,
   .steps-matrix, .board, .tools): разметку для него строит gd-app.js, и
   расхождение имён ничего бы не дало, кроме лишней работы.
   ========================================================================== */

:root {
  --bg: #eef4ff;
  --card: #ffffff;
  --ink: #1e293b;
  --ink-soft: #64748b;
  --line: #dbe6f7;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --accent: #f59e0b;
  --green: #16a34a;
  --red: #ef4444;
  --pen: #2563eb;
  --radius: 18px;
  --shadow: 0 6px 18px rgba(30, 41, 59, .10);
  --shadow-lg: 0 18px 40px rgba(30, 41, 59, .18);
  --wrap: 1180px;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "SF Pro Rounded",
               "Segoe UI Variable", "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(1100px 600px at 10% -5%, #ffe9f3 0%, transparent 55%),
    radial-gradient(900px 500px at 95% 0%, #e0f2fe 0%, transparent 50%),
    var(--bg);
}

/* На игровом экране страница не должна тянуться и зумиться жестами:
   иначе рисование пальцем превращается в прокрутку. */
body.gd-playing {
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

img, svg { max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--primary); }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 calc(16px + env(safe-area-inset-left)) 0 calc(16px + env(safe-area-inset-right));
}
.wrap--narrow { max-width: 780px; }
.center { text-align: center; }
.muted { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
[hidden] { display: none !important; }

.site-main { display: block; padding-bottom: 40px; }

/* ------------------------------------------------------------------ кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid transparent;
  background: var(--card);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px; font-weight: 800;
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.ghost { background: rgba(255, 255, 255, .75); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn.big { padding: 13px 24px; font-size: 16px; border-radius: 14px; }
.btn.on { background: var(--primary); color: #fff; }

.icon-btn {
  border: none; background: rgba(255, 255, 255, .8);
  border-radius: 11px; width: 40px; height: 40px; font-size: 17px;
  box-shadow: var(--shadow); transition: transform .12s ease;
}
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn.off { opacity: .45; }

/* ------------------------------------------------------------ шапка и подвал */

.site-head {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.site-head-in {
  display: flex; align-items: center; gap: 20px;
  min-height: 60px; padding-top: 8px; padding-bottom: 8px;
  flex-wrap: wrap;
}
.site-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.site-logo-mark { font-size: 22px; }
.site-logo-text { font-weight: 900; font-size: 18px; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 800; font-size: 13.5px;
  padding: 7px 10px; border-radius: 10px; transition: background .12s ease, color .12s ease;
}
.site-nav a:hover { background: var(--primary-soft); color: var(--primary); }

/* Шапка меню и кнопки — только для развёрнутого меню на телефоне.
   На широком экране их нет: там навигация и так вся на виду. */
.site-nav-head, .nav-toggle, .nav-close { display: none; }

.site-foot {
  background: #0f172a; color: #cbd5e1; margin-top: 40px;
  padding: 34px 0 calc(30px + env(safe-area-inset-bottom));
}
.site-foot-in { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 26px; }
.site-foot a { color: #e2e8f0; text-decoration: none; }
.site-foot a:hover { color: #fff; text-decoration: underline; }
.foot-title { font-weight: 900; color: #fff; margin-bottom: 10px; font-size: 14px; }
.foot-col ul { list-style: none; margin: 0; padding: 0; font-size: 13.5px; line-height: 2; }
.foot-n { color: #64748b; font-size: 11px; margin-left: 4px; }
.foot-about p { font-size: 13.5px; line-height: 1.6; margin: 0 0 10px; }
.foot-small { color: #64748b; font-size: 12.5px; }

/* ------------------------------------------------------------- хлебные крошки */

.crumbs { font-size: 13px; font-weight: 700; color: var(--ink-soft); padding: 16px 0 4px; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--primary); }
.crumbs-sep { margin: 0 7px; opacity: .5; }
.crumbs-here { color: var(--ink); }

/* ------------------------------------------------------------------ лендинг */

.hero { padding: 30px 0 10px; }
.hero-in { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.hero h1 {
  font-size: clamp(30px, 4.4vw, 50px); letter-spacing: -.6px;
  background: linear-gradient(90deg, #4f46e5, #db2777 60%, #f59e0b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--ink-soft); font-size: 18px; font-weight: 600; line-height: 1.55; margin: 14px 0 0; }
.hero-cta { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.hero-note { color: var(--ink-soft); font-size: 13px; font-weight: 700; margin-top: 12px; }

.hero-demo { text-align: center; }
.demo-box {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 18px; display: inline-block; max-width: 100%;
}
.demo-box svg { display: block; width: 100%; height: auto; }
.demo-caption { color: var(--ink-soft); font-size: 13px; font-weight: 700; margin-top: 10px; }

.block { padding: 44px 0; }
.block h2 { font-size: clamp(22px, 3vw, 30px); text-align: center; margin-bottom: 26px; }
.block--develops, .block--faq { background: rgba(255, 255, 255, .5); }
.block--final { background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .7)); }
.block--final p { color: var(--ink-soft); font-weight: 600; font-size: 16px; }
.block--final p:last-child { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.tiles { display: grid; gap: 18px; }
.tiles--3 { grid-template-columns: repeat(3, 1fr); }
.tiles--4 { grid-template-columns: repeat(4, 1fr); }
.tile {
  position: relative; background: #fff; border-radius: var(--radius);
  padding: 22px 20px; box-shadow: var(--shadow);
}
.tile--plain { background: rgba(255, 255, 255, .75); box-shadow: none; border: 2px solid var(--line); }
.tile-step {
  position: absolute; top: 14px; right: 16px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 900; font-size: 13px; display: grid; place-items: center;
}
.tile-icon { font-size: 34px; line-height: 1; }
.tile h3 { font-size: 17px; margin: 10px 0 6px; }
.tile p { margin: 0; color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; font-weight: 600; }

.age-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.age-card {
  background: #fff; border-radius: 14px; padding: 18px 16px; text-decoration: none;
  box-shadow: var(--shadow); color: var(--ink); text-align: center;
  transition: transform .14s ease, box-shadow .14s ease;
}
.age-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.age-card b { display: block; font-size: 16px; }
.age-card span { color: var(--ink-soft); font-size: 13px; font-weight: 700; }

.numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; text-align: center; }
.number b { display: block; font-size: 40px; font-weight: 900; color: var(--primary); line-height: 1.1; }
.number span { color: var(--ink-soft); font-weight: 700; font-size: 14px; }

.faq details {
  background: #fff; border-radius: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow); overflow: hidden;
}
.faq summary {
  cursor: pointer; padding: 16px 20px; font-weight: 800; font-size: 16px;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; float: right; color: var(--primary); font-size: 22px; line-height: 1; }
.faq details[open] summary::after { content: '−'; }
.faq p { margin: 0; padding: 0 20px 18px; color: var(--ink-soft); font-weight: 600; line-height: 1.6; }

/* --------------------------------------------------------- каталог и карточки */

.catalog-head { text-align: center; padding: 18px 0 24px; }
.catalog-head h1 { font-size: clamp(26px, 4vw, 40px); }
.catalog-sub { color: var(--ink-soft); font-size: 16px; font-weight: 600; margin: 10px auto 0; max-width: 620px; }
.ver-line { margin-top: 8px; font-size: 12px; font-weight: 700; color: #94a3b8; min-height: 16px; }

.progress-wrap {
  max-width: 420px; margin: 18px auto 0;
  background: rgba(255, 255, 255, .8); border-radius: 999px; padding: 6px 8px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
}
.progress-track { flex: 1; height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #10b981); transition: width .5s ease;
}
.progress-text { font-weight: 800; font-size: 14px; color: var(--ink-soft); padding-right: 6px; }

.cards-divider {
  margin: 30px 0 14px; font-size: 20px; font-weight: 900;
  display: flex; align-items: center; gap: 12px;
}
.cards-divider::after {
  content: ''; flex: 1; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, #fecaca, transparent);
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 16px; }
.cards--small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

.card {
  position: relative; display: block;
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius);
  padding: 12px 12px 14px; box-shadow: var(--shadow);
  text-align: center; text-decoration: none; color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: var(--shadow-lg); border-color: #c7d2fe; }
.card-num {
  position: absolute; top: 10px; left: 10px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-size: 13px; font-weight: 900; display: grid; place-items: center;
}
.card-badge { position: absolute; top: 8px; right: 8px; font-size: 18px; }
.card-pic {
  display: grid; place-items: center;
  height: 104px; margin: 8px auto 10px;
}
.card-pic svg { max-height: 104px; width: auto; }
/* display: contents — чтобы обёртка не меняла раскладку .card-pic:
   картинка остаётся прямым элементом сетки, как и была. */
.card-real { display: contents; }
.card-secret {
  font-size: 54px; font-weight: 900; color: #c7d2fe;
  place-items: center; width: 100%; height: 100%;
  background: repeating-linear-gradient(0deg, #eef4ff 0 15px, transparent 15px 16px),
              repeating-linear-gradient(90deg, #eef4ff 0 15px, transparent 15px 16px);
  border-radius: 10px;
}
.card--started .card-secret { color: var(--accent); }
.card-name { display: block; font-weight: 900; font-size: 15.5px; }

/* Сюрприз — принадлежность режима ребёнка: картинка и имя открываются
   только у пройденных заданий. Взрослому прятать нечего, поэтому в
   обычном режиме карточка открыта вся.

   Оба варианта лежат в разметке, а выбирает CSS: класс gd-kid ставит
   скрипт в <head> до первой отрисовки, card--done дорисовывает gd-app.js
   по localStorage. Ответ не успевает мелькнуть. */
.card-secret, .card-name-secret { display: none; }
html.gd-kid .card--surprise:not(.card--done) .card-real,
html.gd-kid .card--surprise:not(.card--done) .card-name-real { display: none; }
html.gd-kid .card--surprise:not(.card--done) .card-secret { display: grid; }
html.gd-kid .card--surprise:not(.card--done) .card-name-secret { display: block; }
.card-meta { display: block; margin-top: 3px; }
.card-stars { color: var(--accent); font-size: 12.5px; letter-spacing: 1px; }
.card-steps { display: block; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.card--done { border-color: #86efac; background: linear-gradient(180deg, #f0fdf4, #fff 60%); }
.card--started { border-color: #fcd34d; background: linear-gradient(180deg, #fffbeb, #fff 60%); }

.catalog-tags { margin-top: 40px; }
.catalog-tags h2, .tag-siblings h2, .figure-tags h2, .page-next h2 { font-size: 20px; margin-bottom: 14px; }
.catalog-foot {
  margin-top: 30px; text-align: center; color: var(--ink-soft);
  font-size: 14px; font-weight: 600; line-height: 1.7;
}

.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chips--center { justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 2px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 800;
  text-decoration: none; color: var(--ink);
  transition: border-color .12s ease, transform .12s ease;
}
.chip:hover { border-color: var(--primary); transform: translateY(-2px); }
.chip-n {
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; padding: 1px 7px; font-size: 11.5px;
}
.chip--grade { border-color: #bfdbfe; }
.chip--theme { border-color: #fbcfe8; }
.chip--difficulty { border-color: #fed7aa; }
.chip--primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --------------------------------------------------------- страница рисунка */

.figure { padding-top: 6px; }
/* Заголовок над картинкой, а не сбоку: страницу открыли ради конкретного
   рисунка, и первым читается его название. Превью — иллюстрация к нему. */
.figure-head { margin-bottom: 28px; }
.figure-head h1 { font-size: clamp(24px, 3.4vw, 36px); margin-bottom: 18px; }
.figure-head-in { display: grid; grid-template-columns: 320px 1fr; gap: 32px; align-items: start; }
.figure-pic {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: grid; place-items: center;
}
.figure-pic svg { width: 100%; height: auto; }

.facts { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; padding: 0; }
.facts li {
  background: #fff; border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
}
.facts b { color: var(--ink); font-size: 15px; }

.figure-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.figure-text, .figure-howto, .figure-body, .prose, .tag-intro, .tag-body {
  font-size: 16px; line-height: 1.7; color: #334155;
}
.figure-text p, .prose p, .tag-intro p { margin: 0 0 14px; }
.figure-howto h2, .figure-steps h2, .figure-similar h2, .tag-print h2, .figure-body h2 {
  font-size: 22px; margin: 34px 0 12px;
}
.prose h2 { font-size: 24px; margin: 32px 0 12px; }
.prose ul, .prose ol, .figure-howto ul, .figure-howto ol { padding-left: 22px; }
.prose li, .figure-howto li { margin-bottom: 7px; }

.steps-static {
  list-style: none; margin: 14px 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px;
  counter-reset: st;
}
.steps-static li {
  counter-increment: st;
  background: #fff; border: 2px solid var(--line); border-radius: 11px;
  padding: 9px 12px; display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 14px;
}
.steps-static li::before {
  content: counter(st); color: #94a3b8; font-size: 11px; font-weight: 900; min-width: 16px;
}
.steps-static .s-arrow { font-size: 18px; color: var(--primary); }
.figure-print-hint { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.figure-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; margin-top: 40px; }
.fnav {
  background: #fff; border-radius: 14px; padding: 14px 18px; box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); display: block;
  transition: transform .12s ease;
}
.fnav:hover { transform: translateY(-2px); }
.fnav span { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.fnav b { font-size: 15px; }
.fnav--next { text-align: right; }
.fnav--all { text-align: center; }

/* ------------------------------------------------------------ страница тега */

.tag-head { padding: 10px 0 26px; }
.tag-head h1 { font-size: clamp(26px, 4vw, 40px); }
.tag-intro { max-width: 760px; margin-top: 16px; }
.tag-body, .tag-print, .tag-siblings { margin-top: 36px; }
.tag-body h2 { font-size: 22px; margin: 0 0 12px; }
.print-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.print-link {
  background: #fff; border: 2px solid var(--line); border-radius: 11px;
  padding: 8px 13px; font-size: 13.5px; font-weight: 800;
  text-decoration: none; color: var(--ink);
}
.print-link:hover { border-color: var(--primary); }

/* ------------------------------------------------------------------- реклама */

.ad-slot { margin: 28px 0; min-height: 0; text-align: center; }
.ad-slot:empty { display: none; }

/* --------------------------------------------------------------------- 404 */

.notfound { text-align: center; padding: 50px 0 30px; }
.notfound-emoji { font-size: 64px; }
.notfound h1 { font-size: 32px; margin: 12px 0 8px; }
.notfound p { color: var(--ink-soft); font-weight: 600; }
.notfound-popular { margin-top: 30px; }
.notfound-popular h2, .page-next h2 { font-size: 20px; margin-bottom: 14px; }
.page-next { margin-top: 36px; }

/* ==========================================================================
   Игровой экран. Разметку строит gd-app.js внутри #gd-play.
   ========================================================================== */

.gd-play:empty { display: none; }
.gd-play { margin: 26px 0; }

/* Шапка задания — одна строка и только одна. Перенос во вторую съедал
   высоту, которая нужна полю, поэтому здесь nowrap, а лишнее ужимается:
   название обрезается многоточием, у кнопки «назад» на узком экране
   прячется подпись. */
.taskbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: nowrap; min-width: 0;
}
.task-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 19px; font-weight: 900;
  flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-title .t-name { overflow: hidden; text-overflow: ellipsis; }
.task-title .stars { color: var(--accent); font-size: 15px; letter-spacing: 1px; flex: 0 0 auto; }
.taskbar .icon-btn, .taskbar .back-btn { flex: 0 0 auto; }
.back-btn .back-ico { font-size: 15px; }

.task-body { display: flex; flex-direction: column; gap: 16px; }

.board-wrap { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
.board {
  position: relative; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px;
  display: grid; place-items: center; overflow: hidden;
  width: max-content; max-width: 100%;
}
.board canvas { display: block; touch-action: none; }
/* До начала диктовки поле закрыто — курсор говорит об этом заранее. */
.board.locked canvas { cursor: not-allowed; }
.board .fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tools .sep { width: 1px; background: var(--line); margin: 4px 4px; }

.steps-panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 12px; }
.steps-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.steps-head h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.steps-head .count {
  font-size: 13px; font-weight: 800; background: var(--primary-soft); color: var(--primary);
  padding: 3px 10px; border-radius: 999px;
}
.modes { display: flex; gap: 6px; margin-left: auto; }
.modes button {
  border: 2px solid var(--line); background: #fff; border-radius: 9px;
  padding: 7px 11px; font-size: 12px; font-weight: 800; color: var(--ink-soft);
  transition: all .12s ease;
}
.modes button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.head-tools { display: flex; gap: 6px; }
.mode-hint { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; margin-top: 10px; text-align: center; }

.steps-matrix {
  list-style: none; margin: 0; padding: 2px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px;
  max-height: 38vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.steps-matrix li {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 4px 6px;
  background: #f8fbff; border: 2px solid var(--line); border-radius: 11px;
  font-weight: 900; font-size: 15px; cursor: pointer; user-select: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.steps-matrix li:hover { transform: translateY(-2px); border-color: #bfdbfe; background: #fff; }
.steps-matrix li:active { transform: scale(.96); }
.steps-matrix li .idx { position: absolute; top: 2px; left: 5px; font-size: 10px; font-weight: 900; color: #94a3b8; }
.steps-matrix li .arrow { font-size: 19px; line-height: 1; color: var(--primary); }
.steps-matrix li .txt { font-variant-numeric: tabular-nums; }
.steps-matrix li .full { display: none; }

.steps-matrix li.current {
  background: #fff7ed; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .16);
}
.steps-matrix li.current .idx { color: #b45309; }

/* вычеркнутый шаг — линия синей ручкой поверх, без затемнения */
.steps-matrix li.crossed::after {
  content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 4px;
  background: var(--pen); border-radius: 3px;
  transform: translateY(-50%) rotate(-7deg);
  animation: strike .22s ease-out; transform-origin: left center;
}
@keyframes strike { from { transform: translateY(-50%) rotate(-7deg) scaleX(0); } }


/* Режим диктовки: схемы не видно совсем — в этом весь режим.

   Второй селектор нужен только ради веса. На узком экране лента шагов
   объявлена правилом такого же веса ниже по файлу, и оно побеждало по
   порядку: на телефоне в режиме диктовки шаги было видно, а рядом с
   ними — надпись «шагов не видно».

   Кнопки выбора режима в шапке остаются — иначе из диктовки нечем выйти. */
.steps-panel.mode-dict .steps-matrix,
.steps-panel.mode-dict:not(.steps-open) .steps-matrix { display: none; }
.steps-panel.mode-dict .head-tools { display: none; }
.steps-panel.mode-dict .steps-head .count { display: none; }
.dict-setup, .dict-run { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dict-title { font-size: 17px; font-weight: 900; }
.dict-speed { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.dict-speed > span { font-size: 13.5px; font-weight: 800; color: var(--ink-soft); }
.speed-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.speed-buttons button {
  border: 2px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 800;
  transition: all .12s ease;
}
.speed-buttons button.on { background: var(--green); border-color: var(--green); color: #fff; }
.dict-start { font-size: 16px; padding: 11px 22px; }
.dict-progress { font-size: 18px; font-weight: 900; }
.dict-bar { width: min(420px, 90%); height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.dict-bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #2563eb); transition: width .3s linear;
}
.dict-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.countdown {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .82); font-weight: 900; color: var(--primary);
}
.countdown span { font-size: clamp(64px, 18vw, 150px); line-height: 1; animation: countPop .55s ease-out; }
@keyframes countPop {
  0% { transform: scale(.4); opacity: 0; }
  40% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ------------------------------------------- настройки перед занятием
   Родитель выставляет их один раз на экране заданий: режим ребёнка и
   способ показа шагов. Внутри самого задания настройкам не место. */

/* Карточка настройки занятия. Одна и та же на экране заданий и на
   странице рисунка: порядок действий сверху вниз — выбрать, как
   показывать шаги, и начать. Разложенные по колонкам, эти два шага
   читались как альтернатива друг другу. */
.setup-card {
  display: grid; justify-items: center; gap: 10px;
  background: #fff; border: 2px solid #c7d2fe; border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  text-align: center;
}
.catalog-setup { max-width: 620px; margin: 20px auto 0; }
.setup-note { color: var(--ink-soft); font-size: 13.5px; font-weight: 600; line-height: 1.5; margin: 0; max-width: 470px; }
.setup-label { font-weight: 900; font-size: 14px; margin-bottom: 0; }
.setup-start { min-width: 240px; margin-top: 6px; }
.modes--setup { margin-left: 0; }
.modes--setup button { padding: 9px 14px; font-size: 13px; }

/* Та же карточка на странице одного рисунка. Сюда приводит кнопка
   «Начать» из шапки: сперва родитель выбирает, как показывать шаги, и
   только потом начинает — второй кнопки «начать» ниже быть не должно. */
.task-setup { margin: 26px 0; }
.task-start { min-width: 240px; margin-top: 6px; }
/* Справка — обычная ссылка, а не кнопка: рядом с настройками занятия
   она не должна спорить за внимание с «Включить режим ребёнка». */
.setup-howto { margin: 10px 0 0; font-size: 13.5px; font-weight: 700; }

/* ------------------------------------------------ служебное в подвале */

.foot-tech {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: 12.5px; color: #64748b;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.foot-tech a { color: #94a3b8; text-decoration: none; }
.foot-tech a:hover { color: #e2e8f0; text-decoration: underline; }
.foot-tech-sep { opacity: .4; }

/* Версия сборки нужна разработчику, а не посетителю: под иконкой. */
.foot-version { position: relative; cursor: help; font-size: 14px; color: #64748b; }
.foot-version-tip {
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  background: #1e293b; color: #e2e8f0;
  border: 1px solid #334155; border-radius: 8px;
  padding: 5px 9px; font-size: 11.5px;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.foot-version:hover .foot-version-tip,
.foot-version:focus .foot-version-tip { opacity: 1; }
.foot-version.has-update { color: var(--accent); }

/* ------------------------------------- продающий блок на странице задания */

.pitch {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  background: linear-gradient(120deg, #eef2ff, #fdf2f8);
  border-radius: var(--radius); padding: 22px 26px; margin: 26px 0;
}
.pitch h2 { font-size: 20px; margin: 0 0 8px; }
.pitch p { margin: 0; color: #475569; font-size: 15px; line-height: 1.6; }
.pitch-points { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.pitch-point { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.pitch-point b { font-size: 18px; }
.pitch-cta { text-align: center; }
.pitch-note { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-top: 8px; max-width: 190px; }

/* ------------------------------------------ возрастной блок на теге */

.tag-age {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; margin: 24px 0;
}
.tag-age h2 { font-size: 20px; margin-bottom: 8px; }
.tag-age p { margin: 0; color: #475569; line-height: 1.65; }

/* --------------------------------- визуальные блоки «Как это работает» */

.prose .lead { font-size: 17px; line-height: 1.7; }
.howto-flow, .howto-modes, .howto-ages, .howto-need {
  display: grid; gap: 12px; margin: 16px 0 24px;
}
.howto-flow { grid-template-columns: repeat(4, 1fr); counter-reset: hs; }
.howto-modes { grid-template-columns: repeat(3, 1fr); }
.howto-ages { grid-template-columns: repeat(4, 1fr); }
.howto-need { grid-template-columns: repeat(2, 1fr); }

.howto-step, .howto-mode, .howto-age, .howto-item {
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  padding: 14px 16px;
}
.howto-step { position: relative; counter-increment: hs; }
.howto-step::after {
  content: counter(hs);
  position: absolute; top: 10px; right: 12px;
  font-size: 12px; font-weight: 900; color: #cbd5e1;
}
.howto-icon { font-size: 26px; line-height: 1; display: block; margin-bottom: 6px; }
.howto-step b, .howto-mode b, .howto-age b { display: block; font-size: 15px; margin-bottom: 4px; }
.howto-step span:not(.howto-icon),
.howto-mode span:not(.howto-icon),
.howto-age span { display: block; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; font-weight: 600; }
.howto-age { text-align: center; }
.howto-age b { font-size: 17px; color: var(--primary); }

.howto-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.howto-item .howto-icon { margin-bottom: 0; font-size: 22px; }
.howto-item span:not(.howto-icon) { font-size: 14px; font-weight: 600; color: #475569; }

@media (max-width: 860px) {
  .pitch { grid-template-columns: 1fr; text-align: center; }
  .pitch-points { justify-content: center; }
  .pitch-note { max-width: none; }
  .howto-flow, .howto-ages { grid-template-columns: repeat(2, 1fr); }
  .howto-modes, .howto-need { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Режим ребёнка

   С экрана уходит всё, что адресовано взрослому: ответ-превью, сложность,
   возраст, ссылки на печать, описания, подборки, шапка и подвал. Остаётся
   задание и переход к следующему — чтобы ребёнок шёл по списку сам.

   Класс висит на <html>, его ставит скрипт в <head> до первой отрисовки:
   иначе ответ успел бы мелькнуть, а именно его мы и прячем.
   ========================================================================== */

/* Переключатель режима — кнопка в углу экрана, а не пункт шапки: в
   режиме ребёнка шапки нет совсем, а в обычном кнопка терялась среди
   меню. Её ставит gd-app.js в body, поэтому она переживает смену экрана
   и видна с любого экрана приложения.

   Левый нижний угол выбран не случайно: сверху справа стоят звук и
   полный экран, снизу по центру всплывают подсказки. Здесь ничего
   не перекрывается, и ребёнок не жмёт её случайно. */
.kid-fab {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: calc(10px + env(safe-area-inset-left));
  z-index: 45;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 13px;
  border: 2px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 800; line-height: 1;
  transition: opacity .15s ease, border-color .15s ease;
}
.kid-fab-ico { font-size: 16px; line-height: 1; }
.kid-fab:hover { border-color: var(--primary); }

/* В самом режиме остаётся только замок: подписи здесь нет, и кнопка
   не отбирает место у поля для рисования. */
.kid-fab.on {
  width: 38px; padding: 0; justify-content: center;
  border-color: transparent; border-radius: 12px;
  background: rgba(255, 255, 255, .82);
  opacity: .5;
}
.kid-fab.on .kid-fab-text { display: none; }
.kid-fab.on:hover, .kid-fab.on:focus { opacity: 1; }

html.gd-kid .site-head,
html.gd-kid .site-nav,
html.gd-kid .site-foot,
html.gd-kid .crumbs,
html.gd-kid .ad-slot,
html.gd-kid .ver-line,
/* страница рисунка: всё, кроме самого задания */
html.gd-kid .figure-head,
html.gd-kid .pitch,
html.gd-kid .catalog-setup,
/* занятие уже началось — настраивать больше нечего */
html.gd-kid .task-setup,
html.gd-kid .figure-text,
html.gd-kid .figure-steps,
html.gd-kid .figure-howto,
html.gd-kid .figure-body,
html.gd-kid .figure-tags,
html.gd-kid .figure-similar,
html.gd-kid .figure-print-hint,
/* каталог: инструменты для родителя и хвост страницы */
html.gd-kid .catalog-tags,
html.gd-kid .catalog-foot,
html.gd-kid #gd-transfer-open,
html.gd-kid #gd-update,
/* сложность и длина задания — техническая информация */
html.gd-kid .card-meta,
html.gd-kid .facts,
/* Способ показа шагов выбирает родитель на экране заданий — внутри
   задания эти кнопки ребёнку не нужны и только занимают высоту. */
html.gd-kid .modes,
/* печать */
html.gd-kid .tag-print,
html.gd-kid .print-links,
html.gd-kid [data-act="print"],
/* имена соседних заданий раскрыли бы сюрприз */
html.gd-kid .fnav b {
  display: none !important;
}

html.gd-kid .site-head-in { min-height: 48px; }
/* Шапки в этом режиме нет, и без отступа кнопка «Задания» с названием
   упираются в самый верх экрана — на телефоне прямо в статус-бар. */
html.gd-kid .site-main { padding-top: calc(10px + env(safe-area-inset-top)); }
html.gd-kid .gd-play { margin-top: 6px; }
html.gd-kid .catalog-head { padding-bottom: 14px; }

/* Кнопка «дальше» — единственная навигация, которая ребёнку нужна.
   Держим её компактной: она делит экран с самим заданием. */
html.gd-kid .figure-nav { grid-template-columns: 1fr 1fr 1fr; margin-top: 8px; gap: 8px; }
html.gd-kid .fnav { text-align: center; font-weight: 900; padding: 9px 10px; }
html.gd-kid .fnav span { font-size: 13.5px; color: var(--ink); }

/* --------------------------------------------------------------- всплывашки */

.oops {
  position: fixed; left: 50%; top: 46%;
  transform: translate(-50%, calc(-50% - 10px)) scale(.9);
  z-index: 60; pointer-events: none;
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 3px solid var(--red); border-radius: 22px;
  padding: 16px 24px; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .18s ease, transform .18s ease;
  max-width: min(92vw, 460px);
}
.oops.show { opacity: 1; transform: translate(-50%, -50%) scale(1); animation: shake .45s ease both; }
.oops-emoji { font-size: 44px; line-height: 1; }
.oops-text { text-align: left; line-height: 1.35; }
.oops-text b { display: block; font-size: 22px; color: var(--red); }
.oops-text span { font-size: 16px; font-weight: 800; }

/* Вертикальный телефон: окно правила разворачиваем почти во всю ширину.
   При сжатии по содержимому текст ломался на три строки в узком столбце
   и читался как записка, а не как окрик. */
@media (max-width: 560px) {
  .oops {
    width: calc(100vw - 20px);
    max-width: none;
    padding: 14px 16px;
    gap: 12px;
  }
  .oops-emoji { font-size: 38px; }
  .oops-text b { font-size: 20px; }
  .oops-text span { font-size: 15px; }
}

@keyframes shake {
  0%, 100% { margin-left: 0; }
  20% { margin-left: -12px; }
  40% { margin-left: 10px; }
  60% { margin-left: -7px; }
  80% { margin-left: 4px; }
}

.steps-matrix li.nudge {
  animation: nudge .55s ease 2;
  border-color: var(--red) !important;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, .18) !important;
}
@keyframes nudge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.09); }
}

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 14px;
  font-weight: 800; box-shadow: var(--shadow-lg); z-index: 40;
  opacity: 0; pointer-events: none; transition: all .25s ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.good { background: #15803d; }
.toast.bad { background: #b91c1c; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .55);
  display: grid; place-items: center; padding: 20px;
  animation: fade .25s ease;
}
.modal-card {
  background: #fff; border-radius: 24px; padding: 26px 28px;
  text-align: center; box-shadow: var(--shadow-lg); max-width: 420px;
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
  max-height: 90vh; overflow-y: auto;
}
.modal-card .big { font-size: 62px; line-height: 1; }
.modal-card h2 { font-size: 26px; margin: 10px 0 4px; }
.modal-card p { color: var(--ink-soft); font-weight: 700; margin: 0 0 16px; }
.win-stars { font-size: 26px; color: var(--accent); letter-spacing: 3px; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* окно переноса прогресса */
.transfer-card { max-width: 460px; text-align: left; }
.transfer-card .big, .transfer-card h2 { text-align: center; }
.transfer-card p { font-size: 14px; line-height: 1.5; }
.transfer-block { margin: 14px 0; }
.transfer-label { font-size: 13px; font-weight: 800; color: var(--ink-soft); margin-bottom: 6px; }
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row code {
  flex: 1; min-width: 0; display: flex; align-items: center;
  font: 800 17px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 1px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 10px; padding: 10px 12px;
  overflow-x: auto; white-space: nowrap; user-select: all;
}
.code-row input {
  flex: 1; min-width: 0;
  font: 800 16px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fff; color: var(--ink);
}
.code-row input:focus { outline: none; border-color: var(--primary); }
.transfer-note {
  background: #f8fafc; border-radius: 10px; padding: 9px 12px;
  font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 12px 0 4px;
}

/* Лист для печати — готовый PDF (см. dictation/pdf.py), своей вёрстки
   у него нет. Здесь остаётся только приличный вид обычной страницы,
   если её всё-таки отправят в принтер. */
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; }
  .site-head, .site-foot, .no-print, .ad-slot, .kid-fab { display: none !important; }
  a[href]::after { content: none !important; }
}

/* ==========================================================================
   Узкий и низкий экран: шаги лентой

   На смартфоне полная матрица шагов съедает пол-экрана, и на поле для
   рисования места не остаётся. Поэтому шаги идут лентой: текущий шаг
   крупный и по центру, соседние видно краем глаза. Кнопка «Все шаги»
   разворачивает полный список, когда нужно посмотреть задание целиком.
   ========================================================================== */

.steps-expand { display: none; }

@media (max-width: 760px), (max-height: 560px) {
  .steps-expand { display: inline-flex; }

  /* На низком экране липкая шапка съедает восьмую часть высоты и налезает
     на ленту шагов. Пусть уезжает вместе со страницей. */
  .site-head { position: static; }

  /* На телефоне подпись у кнопки «назад» не нужна: стрелка понятна, а
     строка шапки должна остаться одна. */
  .taskbar { gap: 8px; }
  .back-btn { padding: 8px 11px; }
  .back-btn .back-lbl { display: none; }
  .back-btn .back-ico { font-size: 17px; }
  .task-title { font-size: 16px; }
  .task-title .stars { font-size: 13px; }

  /* Всё, что не поле для рисования, здесь ужимается: на телефоне шаги
     легко съедают половину экрана, и рисовать становится негде. */
  .steps-panel { padding: 8px 10px 6px; }
  .steps-head { margin-bottom: 6px; gap: 8px; }
  .steps-head h2 { font-size: 13px; }
  .steps-head .count { font-size: 12px; padding: 2px 8px; }

  .steps-panel:not(.steps-open) .steps-matrix {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    /* Лента длиннее экрана в разы. Без этих двух строк её ширина
       протекает наружу через расчёт min-content. */
    min-width: 0;
    max-width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    padding: 3px 2px 8px;
    /* полоса прокрутки на телефоне только мешает — лента ведётся сама */
    scrollbar-width: none;
  }
  .steps-panel:not(.steps-open) .steps-matrix::-webkit-scrollbar { display: none; }

  .steps-panel:not(.steps-open) .steps-matrix li {
    flex: 0 0 auto;
    min-width: 58px;
    min-height: 38px;
    font-size: 13px;
    scroll-snap-align: center;
    opacity: .55;
  }
  .steps-panel:not(.steps-open) .steps-matrix li .arrow { font-size: 15px; }
  .steps-panel:not(.steps-open) .steps-matrix li .idx { font-size: 9px; }
  /* Пройденные шаги гасим сильнее: ребёнок смотрит вперёд, а не назад. */
  .steps-panel:not(.steps-open) .steps-matrix li.crossed { opacity: .3; }

  .steps-panel:not(.steps-open) .steps-matrix li.current {
    min-width: 112px;
    min-height: 46px;
    font-size: 16px;
    opacity: 1;
  }
  .steps-panel:not(.steps-open) .steps-matrix li.current .arrow { font-size: 21px; }
  .steps-panel:not(.steps-open) .steps-matrix li.current .full {
    display: inline; font-size: 12.5px; color: var(--ink-soft);
  }

  /* Панель диктовки на телефоне. «Слушай и рисуй» — заголовок в две
     строки крупным кеглем: на 390 пикселях он выглядел плакатом и
     отодвигал поле вниз. */
  /* Шагов в этом режиме всё равно не видно, а заголовок «Шаги» занимает
     строку, которая на телефоне нужна полю. На широком экране он
     остаётся: там место есть, и панель без заголовка выглядит обрубком. */
  .steps-panel.mode-dict .steps-head h2 { display: none; }

  .dict-title { font-size: 14px; text-align: center; }
  .dict-setup, .dict-run { gap: 8px; }
  .dict-speed { gap: 6px; }
  .dict-speed > span { font-size: 12px; }
  .speed-buttons { gap: 5px; }
  .speed-buttons button { padding: 6px 10px; font-size: 12px; }
  .dict-start { font-size: 14px; padding: 9px 18px; }
  .dict-progress { font-size: 15px; }

  .steps-panel.steps-open .steps-matrix { max-height: 34vh; }

  /* Пройденные шаги убираются: лента всегда начинается с текущего.
     В развёрнутом списке они на месте — там как раз и смотрят целиком. */
  .steps-panel:not(.steps-open) .steps-matrix li.passed { display: none; }

  .mode-hint { margin-top: 6px; font-size: 11.5px; line-height: 1.35; }

  /* ------------------------------------------------ всё в один экран
     Режим ребёнка на телефоне: шапки нет, экран задания занимает окно
     целиком, доска забирает остаток. Ничего не уезжает за нижний край
     и не нужно прокручивать во время рисования. */

  /* Экран задания забирает всё, что осталось после кнопок перехода. */
  .gd-play--fit {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    gap: 6px;
  }
  /* Высоту раздаёт флекс от самого окна вниз до доски. Вычитать
     заранее известное число пикселей тут нельзя: отступы и высота
     кнопок разъезжаются между ориентациями, и страница то не дотягивает
     до края, то вылезает за него. */
  /* .site-main остаётся блоком намеренно. Флекс-контейнер здесь начинает
     учитывать в своей ширине ленту шагов (а она в три тысячи пикселей),
     страница раздувается вширь, и мобильный браузер отзумливает её
     целиком. Цепочку высот начинаем уровнем ниже, с .wrap: его ширину
     задаёт блочный родитель, и раздуть её нечем. */
  /* Отступ сверху переезжает внутрь .wrap: снаружи он прибавился бы к
     100dvh, и страница поехала бы на эти же пиксели. */
  html.gd-kid .site-main { padding-top: 0; padding-bottom: 0; }

  html.gd-kid .site-main > .wrap {
    padding-top: calc(8px + env(safe-area-inset-top));
    /* Поле здесь упирается в ширину экрана, а не в высоту: каждые
       отданные полям страницы 8px — это минус клетка на рисунке. */
    padding-left: calc(6px + env(safe-area-inset-left));
    padding-right: calc(6px + env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    /* Вот здесь и задаётся «один экран»: дальше высота раздаётся вниз
       по флексу, и ни одного магического числа не нужно.

       Именно height, а не min-height. Минимум задаёт только нижнюю
       границу: контейнер спокойно вырастает под содержимое, и сжиматься
       вложенным блокам не приходится — в горизонтальной ориентации
       страница из-за этого вылезала за экран. */
    height: 100vh;
    height: 100dvh;
    min-width: 0;
  }
  html.gd-kid .figure {
    flex: 1 1 auto;
    /* min-width: 0 обязателен. По умолчанию флекс-элемент не сжимается
       уже своего содержимого, а лента из сорока шагов шириной в три
       тысячи пикселей тянет за собой всю цепочку. */
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  html.gd-kid .figure { padding-top: 0; }
  html.gd-kid .gd-play { margin-top: 0; }
  /* Слева внизу висит переключатель режима — освобождаем ему место,
     иначе он ложится поверх кнопки «Предыдущее». */
  html.gd-kid .figure-nav { flex: 0 0 auto; padding-left: 46px; }

  .gd-play--fit .taskbar { margin-bottom: 0; flex: 0 0 auto; }
  .gd-play--fit .task-body { flex: 1 1 auto; min-width: 0; min-height: 0; gap: 8px; }
  .gd-play--fit .steps-panel { flex: 0 0 auto; min-width: 0; }
  .gd-play--fit .board-wrap { flex: 1 1 auto; min-width: 0; min-height: 0; justify-content: center; }
  .gd-play--fit .tools { flex: 0 0 auto; }
  .gd-play--fit .mode-hint { display: none; }
}

/* Горизонтальная ориентация телефона — самый тесный случай: высоты всего
   ~390px, а инструменты стоят колонкой сбоку. Колонка из пяти кнопок в
   обычном размере выше, чем всё окно, и растягивает экран. Поэтому здесь
   кнопки компактнее, а всем блокам разрешено сжиматься. */
@media (max-height: 560px) and (orientation: landscape) {
  .gd-play--fit .board-wrap {
    align-items: stretch;
    justify-items: center;          /* поле по центру своей колонки */
    grid-template-columns: minmax(0, 1fr) 104px;
    min-height: 0;
  }
  /* Только иконки, сеткой 2×3. В колонку одной лентой пять кнопок не
     влезают по высоте и переносятся во второй столбец за край экрана,
     а по ширине места здесь с запасом: поле всё равно ограничено высотой. */
  .gd-play--fit .tools {
    display: grid;
    grid-template-columns: repeat(2, 46px);
    gap: 6px;
    align-content: start;
    justify-content: center;
    min-height: 0;
    width: auto;
  }
  .gd-play--fit .tools .t-lbl { display: none; }
  .gd-play--fit .tools .sep { display: none; }
  .gd-play--fit .tools .btn {
    width: 46px; height: 46px; padding: 0;
    justify-content: center; font-size: 20px; border-radius: 12px;
  }
  /* Проверка — главная кнопка, ей вся ширина. */
  .gd-play--fit .tools .btn[data-act="check"] { grid-column: 1 / -1; width: 98px; }
  .gd-play--fit .board { padding: 4px; }

  .gd-play--fit .steps-panel { padding: 7px 10px 5px; }
  .gd-play--fit .steps-head { margin-bottom: 5px; }
  .gd-play--fit .steps-head h2 { font-size: 13px; }
  .gd-play--fit .taskbar { gap: 8px; }
  .gd-play--fit .taskbar .btn { padding: 6px 10px; font-size: 13px; }
  .gd-play--fit .icon-btn { width: 34px; height: 34px; font-size: 15px; }

  .gd-play--fit .steps-panel:not(.steps-open) .steps-matrix li { min-height: 34px; min-width: 54px; }
  .gd-play--fit .steps-panel:not(.steps-open) .steps-matrix li.current {
    min-height: 40px; min-width: 104px; font-size: 15px;
  }
  .gd-play--fit .steps-panel:not(.steps-open) .steps-matrix li.current .arrow { font-size: 19px; }
}

/* Вертикальная ориентация телефона в режиме ребёнка. Пять кнопок с
   подписями переносятся на две-три строки и забирают у поля треть
   высоты. Оставляем значки в одну строку, подпись — только у
   «Проверить»: это главное действие, и угадывать его по галочке
   ребёнок не должен. */
@media (max-width: 760px) and (orientation: portrait) {
  .gd-play--fit .tools { flex-wrap: nowrap; justify-content: center; gap: 6px; }
  .gd-play--fit .tools .sep { display: none; }
  .gd-play--fit .tools .t-lbl { display: none; }
  .gd-play--fit .tools .btn {
    width: 50px; height: 46px; padding: 0;
    justify-content: center; border-radius: 12px;
  }
  .gd-play--fit .tools .btn .t-ico { font-size: 20px; }
  .gd-play--fit .tools .btn[data-act="check"] { width: auto; padding: 0 14px; }
  .gd-play--fit .tools .btn[data-act="check"] .t-lbl { display: inline; font-size: 14px; }
  .gd-play--fit .tools .btn[data-act="check"] .t-ico { font-size: 16px; }
  .gd-play--fit .board { padding: 6px; }
}

/* ==========================================================================
   Бургер-меню

   Пункты меню занимали в шапке две строки и отжимали контент вниз. Здесь
   они прячутся под кнопку и по нажатию разворачиваются на весь экран —
   так в них попадают пальцем, а не пытаются.

   Порог не выдуман: логотип и шесть пунктов требуют 1020 пикселей. На
   планшете в портрете (768 или 834) строка переносится всегда, а в
   ландшафте (1024) держится с запасом в четыре пикселя — одного нового
   тега в меню хватит, чтобы она сломалась и там. Поэтому бургер берёт
   весь планшетный диапазон целиком.

   Число продублировано в static/js/gd-nav.js — там по нему закрывается
   меню, когда экран снова стал широким.

   Разметка одна и та же: список ссылок как был, так и остался в <nav>.
   Меняется только показ, поэтому боту по-прежнему видно всю навигацию.
   ========================================================================== */

@media (max-width: 1024px) {
  /* Размытие за шапкой снимаем не ради красоты: backdrop-filter делает
     элемент containing block для position: fixed внутри него, и меню
     разворачивалось не во весь экран, а во весь размер шапки. Взамен
     шапка становится плотнее — на телефоне так даже читабельнее. */
  .site-head { backdrop-filter: none; background: rgba(255, 255, 255, .95); }

  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto;
    width: 42px; height: 42px; padding: 0;
    border: none; border-radius: 12px;
    background: rgba(255, 255, 255, .8);
    box-shadow: var(--shadow);
  }
  /* Три полоски одним элементом: средняя — фон, крайние — тени. */
  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    content: ''; display: block;
    width: 20px; height: 2.5px; border-radius: 2px;
    background: var(--ink);
  }
  .nav-toggle-bars { position: relative; }
  .nav-toggle-bars::before { position: absolute; top: -7px; }
  .nav-toggle-bars::after { position: absolute; top: 7px; }

  .site-nav {
    position: fixed; inset: 0; z-index: 60;
    margin: 0; gap: 2px;
    display: flex; flex-direction: column; flex-wrap: nowrap;
    background: var(--bg);
    padding: calc(10px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    /* Закрытое меню убираем из потока целиком: иначе оно перехватывает
       касания поверх всей страницы. */
    visibility: hidden; opacity: 0;
    transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
  }
  .site-nav.open { visibility: visible; opacity: 1; transform: none; }

  .site-nav-head {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 44px; margin-bottom: 10px;
  }
  .site-nav-title { font-weight: 900; font-size: 18px; }
  .nav-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; padding: 0;
    border: none; border-radius: 12px; font-size: 18px;
    background: rgba(255, 255, 255, .8); box-shadow: var(--shadow);
  }

  /* Пункты крупные: по такому меню попадают пальцем с первого раза. */
  .site-nav a {
    font-size: 17px; padding: 15px 16px; border-radius: 14px;
    background: #fff; color: var(--ink); box-shadow: var(--shadow);
    margin-bottom: 8px;
  }

  /* Пока меню открыто, страница под ним не прокручивается. */
  body.nav-open { overflow: hidden; }
}

/* В режиме ребёнка шапки нет — значит, нет и кнопки меню. */
html.gd-kid .nav-toggle { display: none !important; }

/* ==========================================================================
   Адаптив
   ========================================================================== */

@media (max-width: 980px) {
  .hero-in { grid-template-columns: 1fr; gap: 26px; }
  .figure-head-in { grid-template-columns: 1fr; gap: 20px; }
  .figure-pic { max-width: 320px; }
  .site-foot-in { grid-template-columns: 1fr 1fr 1fr; }
  .tiles--4 { grid-template-columns: repeat(2, 1fr); }
  .age-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .tiles--3 { grid-template-columns: 1fr; }
  .numbers { grid-template-columns: repeat(2, 1fr); }
  .site-foot-in { grid-template-columns: 1fr 1fr; }
  .figure-nav { grid-template-columns: 1fr; }
  .fnav--next { text-align: left; }
  .task-title { font-size: 17px; }
  .modes { margin-left: 0; }
  .steps-matrix { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 5px; }
}

@media (max-width: 460px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
  .card-pic { height: 88px; }
  .card-pic svg { max-height: 88px; }
  .steps-matrix { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
  .steps-static { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

@media (pointer: coarse) {
  .steps-matrix li { min-height: 48px; font-size: 16px; }
  .steps-matrix li .arrow { font-size: 21px; }
  .icon-btn { width: 44px; height: 44px; }
}

@media (hover: none) {
  .btn:hover, .icon-btn:hover, .chip:hover, .fnav:hover, .age-card:hover { transform: none; }
  .card:hover { transform: none; box-shadow: var(--shadow); border-color: transparent; }
  .steps-matrix li:hover { transform: none; background: #f8fbff; border-color: var(--line); }
  .steps-matrix li.current:hover { background: #fff7ed; border-color: var(--accent); }
}

/* iPad в альбомной ориентации: инструменты уезжают вбок, поле крупнее */
@media (orientation: landscape) and (max-height: 900px) {
  .steps-panel { padding: 10px 12px 8px; }
  .steps-matrix { gap: 5px; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); max-height: 30vh; }
  .steps-matrix li { min-height: 38px; font-size: 15px; }
  .board { padding: 6px; }
  .board-wrap {
    display: grid; gap: 10px;
    grid-template-columns: minmax(0, auto) max-content;
    grid-template-areas: 'board tools';
    justify-content: center; align-items: start;
  }
  .board { grid-area: board; }
  .tools { grid-area: tools; flex-direction: column; width: 150px; }
  .tools .btn { width: 100%; justify-content: flex-start; }
  .tools .sep { width: 100%; height: 1px; margin: 3px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
