@font-face {
  font-family: 'Inter Tight';
  src: url(vendor/fonts/inter-tight-cyrillic.woff2) format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter Tight';
  src: url(vendor/fonts/inter-tight-latin.woff2) format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url(vendor/fonts/jetbrains-mono-cyrillic.woff2) format('woff2');
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url(vendor/fonts/jetbrains-mono-latin.woff2) format('woff2');
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0a0a0a;
  --dock: 196px;
  --col: 560px; /* ширина колонки приложения */ /* высота раскрытой нижней панели в квизе с разбором в две строки */
  --surface: #121212;
  --fg: #f2f2ee;
  --muted: rgba(242, 242, 238, 0.52);
  --muted-inv: rgba(10, 10, 10, 0.55);
  --line-inv: rgba(10, 10, 10, 0.15);
  --faint: rgba(242, 242, 238, 0.28);
  --line: rgba(242, 242, 238, 0.13);
  --line-strong: rgba(242, 242, 238, 0.32);
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --gutter: 20px;
  --tap: 56px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

/* Плёночное зерно на фоне. Статичное и под контентом: подвижное зерно поверх текста
   меняет сглаживание краёв букв каждый кадр, и текст дрожит */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Мягкое неподвижное световое пятно на фоне */
.glow {
  position: fixed;
  top: -20vmax;
  left: 50%;
  width: 80vmax;
  height: 80vmax;
  margin-left: -40vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 16px)
    calc(env(safe-area-inset-right) + var(--gutter))
    calc(env(safe-area-inset-bottom) + 20px)
    calc(env(safe-area-inset-left) + var(--gutter));
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

svg { display: block; }

.label {
  font: 500 12px/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.label b { color: var(--fg); font-weight: 500; }
/* Ключа нет — статистика молча копится только в браузере; об этом говорим на главной */
.nokey {
  margin: -8px 0 24px;
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font: 400 15px/1.45 var(--sans);
  color: var(--fg);
}
.nokey p { margin: 0 0 12px; }
.nokey { display: flex; flex-wrap: wrap; gap: 10px; }
.nokey p { flex-basis: 100%; }
.nokey input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--fg);
  font: 500 20px/1 var(--mono);
  letter-spacing: 0.3em;
}
.nokey input::placeholder { color: var(--muted); letter-spacing: 0.1em; }
.nokey .btn { flex: 1; }
.login .nokey { margin: 32px 0 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  margin: 0 -8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { background: var(--line); }

.btn {
  position: relative;
  min-height: var(--tap);
  padding: 0 24px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn svg { width: 18px; height: 18px; }
.btn.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.wide { width: 100%; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 24px;
}
.actions .btn { flex: 1; }

/* ——— Главная ——— */
.logo { display: block; color: var(--fg); }
.logo svg { height: 26px; width: auto; }
.hero-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 24px 0 28px;
}

/* Плитки тем: две в ряд, нажатие по всей плитке — игра на 10 вопросов */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.card {
  position: relative;
  min-height: 176px;
  padding: 14px 14px 16px;
  border-radius: 22px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  display: flex;
  flex-direction: column;
}
/* Кнопка на всю плитку под содержимым; «Ошибки» лежат выше и нажимаются отдельно */
.card-hit {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.card-icon svg { width: 24px; height: 24px; opacity: 0.9; }
.card-title {
  padding-top: 16px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.card-foot { margin-top: auto; padding-top: 16px; }
.card-meta { display: grid; gap: 4px; }
.card-meta b { font-weight: 500; }
/* «Ошибки» — маленькая плашка в углу; зона нажатия шире видимой */
.card-errors {
  position: relative;
  z-index: 2;
  flex: none;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-errors::before { content: ''; position: absolute; inset: -8px -6px; }
.card-errors b { font-weight: 500; }
@media (max-width: 359px) {
  .card-errors-word { display: none; }
}

.meter {
  height: 2px;
  background: var(--line);
  margin: 12px 0 0;
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  background: var(--fg);
  transform-origin: left;
}

/* Экран раздела: заголовок и плитки подразделов */
.section-name {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 24px 0 24px;
}

/* Наведение и нажатие: прямая смена цветов. Не через белый слой с mix-blend-mode —
   инверсия уже сглаженного текста даёт кайму внутри букв */
.card:has(.card-hit:active) { background: var(--fg); color: var(--bg); }
.card:has(.card-hit:active) .label { color: var(--muted-inv); }
.card:has(.card-hit:active) .label b { color: var(--bg); }
.card:has(.card-hit:active) .meter { background: var(--line-inv); }
.card:has(.card-hit:active) .meter > i { background: var(--bg); }
.card-errors:active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
@media (hover: hover) and (pointer: fine) {
  .card:has(.card-hit:hover) { background: var(--fg); color: var(--bg); }
  .card:has(.card-hit:hover) .label { color: var(--muted-inv); }
  .card:has(.card-hit:hover) .label b { color: var(--bg); }
  .card:has(.card-hit:hover) .meter { background: var(--line-inv); }
  .card:has(.card-hit:hover) .meter > i { background: var(--bg); }
  .card-errors:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
}

@media (min-width: 640px) {
  .card { min-height: 196px; }
  .card-title { font-size: 26px; }
}

/* ——— Вопрос ——— */
.track {
  height: 2px;
  background: var(--line);
  margin: 8px 0 0;
  overflow: hidden;
}
.track > i {
  display: block;
  height: 100%;
  background: var(--fg);
  transform-origin: left;
  transform: scaleX(0);
}

.q-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.question {
  font-size: clamp(28px, 8.4vw, 40px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.035em;
  margin: 14px 0 28px;
  text-wrap: balance;
}
.q-num { margin-top: 36px; }
/* Кадр в «Угадай по кадру»: место под него занято сразу, вопрос не прыгает при загрузке */
.frame {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1; /* scripts/frames.py режет кадры ровно 2:1 */
  object-fit: cover;
  margin-top: 14px;
  border-radius: 16px;
  background: var(--line);
}
/* С кадром вопрос короткий («Что это за сериал?») — мельче и плотнее. На телефоне кадр всегда
   целиком 2:1: место под него дают варианты пониже и отступы поменьше — на 390×844 варианты
   над раскрытой панелью и после «Мимо». Не влезло — экран длиннее, кадр
   не режется. На ПК кадр по высоте окна — см. @media (min-width: 720px) */
.q-area > * { flex-shrink: 0; }
.q-num:has(+ .frame) { margin-top: 16px; }
.frame + .question { font-size: clamp(26px, 7.4vw, 34px); margin: 14px 0 16px; }
@media (max-width: 719px) {
  .q-num:has(+ .frame) { margin-top: 10px; }
  .frame + .question { margin: 10px 0 12px; }
  .frame ~ .options .option { min-height: 48px; padding-top: 8px; padding-bottom: 8px; }
}

.options {
  display: grid;
  gap: 8px;
  margin-top: auto;
}
.option {
  position: relative;
  overflow: hidden;
  min-height: 64px;
  padding: 14px 18px;
  border-radius: 18px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.option .key {
  flex: none;
  font: 500 12px/1 var(--mono);
  color: var(--muted);
  width: 14px;
}
.option .txt { position: relative; }
.option.wrong .strike { transform: none; }
.option.right { background: var(--fg); color: var(--bg); box-shadow: none; }
.option.right .key { color: var(--muted-inv); }
.option .strike {
  position: absolute;
  left: -4px;
  right: -4px;
  top: 52%;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
}
@media (hover: hover) and (pointer: fine) {
  .option:not(:disabled):hover { box-shadow: inset 0 0 0 1px var(--fg); }
}
.option:disabled { cursor: default; }
/* Отмеченный вариант в вопросе с несколькими верными — до проверки */
.option.picked { box-shadow: inset 0 0 0 1px var(--fg); }
.option.picked .key { color: var(--fg); }
.option.wrong { box-shadow: inset 0 0 0 1px var(--fg); }
.option.wrong .txt { color: var(--muted); }
.option.dim { opacity: 0.32; }

/* Нижняя панель прибита к низу экрана, как у Duolingo: до ответа в ней подсказка, после —
   вердикт, разбор и «Дальше» под большим пальцем. Место под раскрытую панель экран держит
   с самого начала (--dock), поэтому после ответа ничего не сдвигается, не прячется под
   панелью и страницу не надо крутить */
.screen.quiz { padding-bottom: calc(env(safe-area-inset-bottom) + var(--dock)); }
/* Панель — на всю ширину окна (на ПК обрубок шириной в колонку висел посреди экрана),
   содержимое — по колонке приложения (#app, --col) */
.dock {
  --side: calc((100% - var(--col)) / 2 + var(--gutter));
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding:
    0
    max(calc(env(safe-area-inset-right) + var(--gutter)), var(--side))
    calc(env(safe-area-inset-bottom) + 16px)
    max(calc(env(safe-area-inset-left) + var(--gutter)), var(--side));
}
.dock.open {
  padding-top: 14px;
  border-top: 1px solid var(--line-strong);
  background: var(--bg);
}
.hint {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hint[hidden] { display: none; }
.sheet[hidden] { display: none; }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.verdict { font-size: 26px; font-weight: 650; letter-spacing: -0.03em; }
.fact { margin: 4px 0 12px; color: var(--muted); font-size: 16px; }
.fact b { color: var(--fg); font-weight: 600; }


/* ——— Итог ——— */
.ring-wrap {
  position: relative;
  width: min(64vw, 260px);
  aspect-ratio: 1;
  margin: 32px auto 8px;
}
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-wrap circle { fill: none; stroke-width: 2; }
.ring-wrap .bg { stroke: var(--line); }
.ring-wrap .fg { stroke: var(--fg); stroke-linecap: round; }
.ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring-num .pct {
  font-size: clamp(56px, 18vw, 84px);
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ring-num .label { margin-top: 6px; }

.verdict-big {
  text-align: center;
  font-size: clamp(32px, 10vw, 46px);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 16px 0 6px;
}
.result-sub { text-align: center; color: var(--muted); }

.section-title { margin: 36px 0 4px; }
.rows { border-top: 1px solid var(--line-strong); margin-top: 10px; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row .main { min-width: 0; }
.row .title { font-weight: 500; }
.row .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.row .val { font: 500 14px/1.3 var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .w { text-decoration: line-through; text-decoration-thickness: 1px; }
.row .r { color: var(--fg); }

/* ——— Статистика ——— */
.stats-title {
  font-size: clamp(40px, 12vw, 60px);
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.045em;
  margin: 28px 0 24px;
}
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line-strong);
}
.tile {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
}
.tile:nth-child(odd) { padding-right: 16px; border-right: 1px solid var(--line); }
.tile:nth-child(even) { padding-left: 16px; }
.tile .num {
  font-size: clamp(34px, 10vw, 46px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-top: 10px;
}
.bar { height: 2px; background: var(--line); margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--fg); transform-origin: left; }

.empty { color: var(--muted); padding: 16px 0; }

.sync-note { margin-top: 40px; text-align: center; }
.danger {
  margin: 12px auto 0;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  color: var(--muted);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
}
.danger.armed { color: var(--bg); background: var(--fg); }



@media (min-width: 720px) {
  :root { --gutter: 32px; --dock: 128px; }
  /* Квиз с кадром шире: кадр забирает свободную высоту окна */
  :root:has(.frame) { --col: 720px; }
  /* Экран с кадром ровно в высоту окна: кадр забирает то, что осталось после вопроса, вариантов
     и места под панель, и на низком окне сжимается по высоте (обрезка по центру) — так варианты
     всегда целиком над панелью */
  .screen.quiz:has(.frame) { height: 100vh; height: 100dvh; min-height: 0; }
  .screen.quiz:has(.frame) .q-area { min-height: 0; }
  .q-area > .frame { flex-shrink: 1; min-height: 96px; }
  .screen { padding-top: 48px; padding-bottom: 48px; }
  /* Окно ПК низкое: панель — одной строкой (вердикт и разбор слева, «Дальше» справа),
     варианты к кадру — сеткой 2×2. Тогда кадру остаётся почти вся высота */
  .sheet:not([hidden]) {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 24px;
    align-items: center;
  }
  .sheet > :not([data-next]) { grid-column: 1; }
  .sheet > [data-next] { grid-column: 2; grid-row: 1 / span 2; width: 200px; }
  .sheet .fact { margin: 4px 0 0; }
  .sheet .fact.empty { display: none; }
  .frame ~ .options { grid-template-columns: 1fr 1fr; }
}

