/* ============================================================================
   Лучик — вёрстка экранов и игровых элементов.
   ========================================================================== */

/* ---------- Шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.top__in { display: flex; align-items: center; gap: 14px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.28rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand__sun { width: 38px; height: 38px; flex: none; }
.brand__sub { font-size: .62rem; font-weight: 800; color: var(--ink-soft); letter-spacing: .1em;
  text-transform: uppercase; display: block; margin-top: -4px; }
.top__nav { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: var(--tap); padding: 0 14px;
  border-radius: var(--r-btn); border: 2px solid transparent; background: transparent;
  color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.nav-btn:hover { background: var(--surface); border-color: var(--line); }
.nav-btn.is-on { background: var(--accent); color: var(--accent-ink); }
.nav-btn__ic { font-size: 1.1em; }
.counters { display: flex; gap: 8px; align-items: center; }
.counter { display: inline-flex; align-items: center; gap: 6px; font-weight: 900;
  padding: 6px 12px; border-radius: var(--r-chip); background: var(--surface); border: 2px solid var(--line); }
.counter--coins { color: #C77A00; }
html.mode-teen .counter--coins { color: var(--star); }
.counter--streak { color: var(--sun-3); }

/* ---------- Экраны ---------- */
.screen { padding: 26px 0 70px; }
.screen__title { margin-bottom: 6px; }
.screen__lead { color: var(--ink-soft); font-size: 1.06rem; max-width: 62ch; margin-bottom: 22px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px;
  font-weight: 700; color: var(--ink-soft); font-size: .95rem; }
.crumbs button { background: none; border: 0; font: inherit; color: var(--accent);
  font-weight: 800; cursor: pointer; padding: 2px 0; }
.crumbs button:hover { text-decoration: underline; }

/* ---------- Главный герой ---------- */
.hero { display: grid; grid-template-columns: 1.25fr .75fr; gap: 26px; align-items: center; padding: 30px 0 10px; }
.hero__sun { max-width: 260px; margin: 0 auto; }
.hero__tag { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; font-size: .86rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.hero h1 { margin-bottom: 14px; }
.hero h1 em { font-style: normal; background: linear-gradient(180deg, var(--sun-1), var(--sun-3));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
html.mode-mid .hero h1 em, html.mode-teen .hero h1 em {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; }
.hero__lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 52ch; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.hero__facts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ---------- Сетки ---------- */
.grid { display: grid; gap: 16px; }
.grid--grades { grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); }
.grid--subjects { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); }
.grid--topics { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }

/* ---------- Плитка ---------- */
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 18px; background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-2); cursor: pointer;
  font: inherit; color: var(--ink); min-height: var(--tap);
  transition: transform var(--dur), box-shadow var(--dur), border-color var(--dur);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); border-color: var(--accent); }
.tile__ic { font-size: 2rem; line-height: 1; }
.tile__ic--svg { width: 40px; height: 40px; }
.tile__t { font-weight: 900; font-size: 1.05rem; }
.tile__d { font-size: .88rem; color: var(--ink-soft); font-weight: 600; }
.tile__go { margin-top: auto; font-weight: 900; color: var(--accent); font-size: .9rem; }
.tile--grade { align-items: center; text-align: center; min-height: 132px; justify-content: center; }
.tile--grade .tile__n { font-size: 2.5rem; font-weight: 900; line-height: 1; }
.tile--done { border-color: var(--good); }
.tile__badge { position: absolute; top: 10px; right: 10px; font-size: 1.1rem; }
.tile__bar { margin-top: 8px; }

/* ---------- Строка темы ---------- */
.topic-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--r-card); cursor: pointer; font: inherit;
  color: var(--ink); text-align: left; width: 100%; }
.topic-row:hover { border-color: var(--accent); }
.topic-row__ic { font-size: 1.7rem; flex: none; width: 40px; text-align: center; }
.topic-row__main { flex: 1; min-width: 0; }
.topic-row__t { font-weight: 900; }
.topic-row__meta { font-size: .86rem; color: var(--ink-soft); font-weight: 700; }

/* ---------- Задание ---------- */
.task-card { max-width: 760px; margin: 0 auto; }
.task-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.task-head .bar { flex: 1; min-width: 140px; }
.task-q { font-size: clamp(1.3rem, 3.6vw, 1.9rem); font-weight: 900; line-height: 1.35; margin: 18px 0 22px; }
html.mode-young .task-q { font-family: var(--font-play); }
.opts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.opt {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: calc(var(--tap) + 8px); padding: 12px 18px;
  font: inherit; font-weight: 800; font-size: 1.15rem; color: var(--ink);
  background: var(--surface); border: 3px solid var(--line); border-radius: var(--r-btn);
  box-shadow: 0 4px 0 0 var(--line); cursor: pointer; text-align: center;
  transition: transform var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.opt:hover { transform: translateY(-2px); border-color: var(--accent); }
.opt:active { transform: translateY(2px); box-shadow: 0 1px 0 0 var(--line); }
.opt.is-right { border-color: var(--good); box-shadow: 0 4px 0 0 var(--good);
  background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.opt.is-wrong { border-color: var(--bad); box-shadow: 0 4px 0 0 var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.opt[disabled] { cursor: default; }

.answer-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.answer-in {
  flex: 1; min-width: 190px; min-height: calc(var(--tap) + 8px); padding: 10px 18px;
  font: inherit; font-weight: 900; font-size: 1.5rem; text-align: center;
  color: var(--ink); background: var(--surface);
  border: 3px solid var(--line); border-radius: var(--r-btn);
}
.answer-in:focus { border-color: var(--accent); outline: none; }
.task-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }

/* ---------- Обратная связь и разбор ---------- */
.fb { margin-top: 20px; padding: 18px; border-radius: var(--r-card); border: 3px solid var(--line);
  background: var(--surface-2); animation: fbIn .3s ease; }
.fb--good { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.fb--bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.fb__head { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 1.2rem; margin-bottom: 10px; }
.fb__steps { margin: 10px 0 0; padding-left: 22px; }
.fb__steps li { margin-bottom: 6px; font-weight: 700; }
.fb__hint { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface);
  border: 2px dashed var(--line); font-weight: 700; }
@keyframes fbIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Результат ---------- */
.result { max-width: 640px; margin: 0 auto; text-align: center; }
.result__sun { max-width: 190px; margin: 0 auto 6px; }
.result__score { font-size: 3.2rem; font-weight: 900; line-height: 1; }
.result__stars { font-size: 2.6rem; letter-spacing: .1em; margin: 8px 0; }
.rewards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 18px 0 8px; }
.reward { padding: 12px 18px; border-radius: var(--r-card); background: var(--surface);
  border: 2px solid var(--line); font-weight: 900; }
.reward b { display: block; font-size: 1.5rem; }

/* ---------- Игры ---------- */
.game-stage { position: relative; border-radius: var(--r-card); overflow: hidden;
  border: 3px solid var(--line); background: var(--surface-2); }
.game-stage canvas { display: block; width: 100%; height: auto; touch-action: none; }
.game-hud { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.game-hud .spacer { flex: 1; }
.pairs-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); }
.pair-card {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; border-radius: var(--r-btn);
  border: 3px solid var(--line); background: var(--surface-2); color: transparent;
  cursor: pointer; transition: transform var(--dur), background var(--dur);
}
.pair-card.is-open { background: var(--surface); color: var(--ink); border-color: var(--accent); }
.pair-card.is-done { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--ink); }

/* ---------- Модальное окно ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 18px;
  background: rgba(20, 14, 6, .5); backdrop-filter: blur(3px); }
.modal__box { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--r-card);
  border: 2px solid var(--line); box-shadow: var(--shadow-3); padding: 24px; max-height: 88vh; overflow: auto; }
.modal__close { position: absolute; top: 14px; right: 16px; }

/* ---------- Профиль и родительский отчёт ---------- */
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-sun { width: 110px; flex: none; }
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.stat { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-card); padding: 16px; }
.stat b { display: block; font-size: 1.9rem; font-weight: 900; line-height: 1.1; }
.stat span { font-size: .86rem; font-weight: 800; color: var(--ink-soft); }
.table { width: 100%; border-collapse: collapse; font-size: .96rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--line); }
.table th { font-weight: 900; color: var(--ink-soft); font-size: .84rem; text-transform: uppercase; letter-spacing: .05em; }
.table tr:last-child td { border-bottom: 0; }
.rank-list { display: flex; gap: 10px; flex-wrap: wrap; }
.badge-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.badge { text-align: center; padding: 16px; border-radius: var(--r-card); border: 2px solid var(--line);
  background: var(--surface); }
.badge--locked { opacity: .45; filter: grayscale(1); }
.badge__ic { font-size: 2rem; }
.badge__t { font-weight: 900; margin-top: 6px; }
.badge__d { font-size: .84rem; color: var(--ink-soft); font-weight: 700; }

/* ---------- Формы входа ---------- */
.form { display: grid; gap: 14px; max-width: 400px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 800; font-size: .92rem; }
.field input, .field select {
  min-height: var(--tap); padding: 10px 14px; font: inherit; font-weight: 700;
  color: var(--ink); background: var(--surface);
  border: 3px solid var(--line); border-radius: var(--r-btn);
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field small { color: var(--ink-soft); font-weight: 700; }
.form__error { color: var(--bad); font-weight: 800; }
.form__note { font-size: .86rem; color: var(--ink-soft); font-weight: 700; }

/* ---------- Служебные утилиты ---------- */
.hidden { display: none !important; }
/* Подпись для скринридера: озвучивается, но не занимает места на экране. */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-soft); }

/* ---------- Печать отчёта родителю ---------- */
@media print {
  .top, .foot, .task-tools, .crumbs, .toast { display: none !important; }
  .card { box-shadow: none; border-color: #bbb; }
  body { background: #fff; }
}

/* ---------- Секции главной ---------- */
.section { padding: 34px 0 6px; }
.section__head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.section__head h2 { margin: 0; }
.section__head .spacer { flex: 1; }
.mode-card { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); }
.mode-card .card h3 { margin-bottom: 6px; }
.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature__ic { font-size: 1.6rem; flex: none; }
.feature h3 { font-size: 1.05rem; margin-bottom: 2px; }
.feature p { margin: 0; font-size: .94rem; color: var(--ink-soft); font-weight: 600; }

/* ---------- Подвал ---------- */
.foot { border-top: 2px solid var(--line); margin-top: 40px; padding: 26px 0 34px;
  color: var(--ink-soft); font-size: .9rem; font-weight: 700; }
.foot__in { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.foot a { color: var(--ink-soft); }
.heart { color: #FF4D6D; display: inline-block; animation: beat 1.4s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 25% { transform: scale(1.22); } 45% { transform: scale(1); } }

/* ---------- Адаптив ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero__sun { order: -1; max-width: 190px; }
  .hero__lead { margin-inline: auto; }
  .hero__cta, .hero__facts { justify-content: center; }
  .top__nav .nav-btn__txt { display: none; }
  .top__nav .nav-btn { padding: 0 12px; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .screen { padding: 18px 0 60px; }
  .card { padding: 16px; }
  .opts { grid-template-columns: 1fr; }
  .grid--grades { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .counters { gap: 6px; }
  .counter { padding: 5px 9px; font-size: .88rem; }
  .brand__name { font-size: 1.1rem; }
}
/* Телефон: шапка в две строки — значки отдельно, счётчики рядом с брендом */
@media (max-width: 640px) {
  .top__in { flex-wrap: wrap; row-gap: 6px; padding: 8px 0; min-height: 0; gap: 8px; }
  .top__nav { order: 3; width: 100%; margin-left: 0; justify-content: space-between; gap: 4px; }
  .counters { order: 2; margin-left: auto; }
  .nav-btn--acc { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 420px) {
  .brand__sub { display: none; }
  .brand__sun { width: 32px; height: 32px; }
  .counter { padding: 4px 8px; font-size: .84rem; gap: 4px; }
  .top__nav .nav-btn { padding: 0 10px; }
}
