/* «Ректор, вы врёте!» — интерфейс новеллы.
   Сумеречная академия: чернильно-фиолетовый фон, полупрозрачные панели,
   тёплое золото акцента и закатные вспышки — всё на CSS, без картинок. */

:root {
  --bg: #140f24;
  --ink: #f1e6d6;
  --ink-soft: #d9c7a8;
  --ink-mute: #a8957a;
  --plate: rgba(31, 24, 56, 0.80);
  --plate-solid: #1f1838;
  --gold: #d4a861;
  --gold-soft: rgba(212, 168, 97, 0.42);
  --gold-faint: rgba(212, 168, 97, 0.16);
  --berry: #9e2f37;
  --berry-hi: #b93b44;
  --moss: #4f6b3a;
  --think: #c9a0dc;
  --sunset: #c46a5a;
  --radius: 16px;
  --gutter: 12px;
  --fade: 400ms;
  --font-text: "PT Serif", "Georgia", "Times New Roman", "Noto Serif", serif;
  --font-title: "Palatino Linotype", "Palatino", "Book Antiqua", "PT Serif Caption", "Georgia", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 18px;
  line-height: 1.55;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
img { display: block; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Сцена ------------------------------------------------------------ */

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

/* По бокам — тот же кадр, размытый и притемнённый. */
.backdrop { position: absolute; inset: 0; overflow: hidden; }
.backdrop__img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(24px) brightness(0.6) saturate(1.05);
  transform: scale(1.12);
}

.stage {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100vh;
  height: 100dvh;
  width: min(100vw, 100vh * 9 / 16);
  width: min(100vw, 100dvh * 9 / 16);
  overflow: hidden;
  background: var(--plate-solid);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.65);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.art { position: absolute; inset: 0; }
.art__layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--fade) ease;
}
.art__layer.is-on { opacity: 1; }

/* ---- Сцена диалога: фон локации + спрайты ------------------------------
   Включается с первой реплики персонажа в узлах со scene (см. engine.js).
   --sw/--sh — ширина/высота сцены. Спрайт (холст 2:3, фигура по колено) стоит
   на нижнем крае, срез колен/бёдер прячется под плашкой. Высота — min(0.8 высоты,
   1.75 ширины) сцены: макушки на 20–21 % от верха на 360–430 × 640–932 и на
   десктопе, ниже кнопки меню; на узких телефонах фигуры сильнее перекрываются,
   края холста чуть обрезаются (см. test/layout.test.mjs). --cx — центр фигуры в долях ширины сцены
   (холст шириной --h·2/3, фигура по его центру); left/height анимируются при
   входе/уходе персонажей. --k — нормировка роста образа (sprites/looks.mjs).
   Зеркалятся (.is-mirrored) только симметричные образы — решает check-story. */
.stage { --sw: min(100vw, 100vh * 9 / 16); --sh: 100vh; }
@supports (height: 100dvh) {
  .stage { --sw: min(100vw, 100dvh * 9 / 16); --sh: 100dvh; }
}
.scene {
  position: absolute; inset: 0;
  isolation: isolate; /* свой контекст: свечение правды — между фоном и спрайтами */
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--fade) ease, visibility 0s linear var(--fade), filter 0.35s ease;
  pointer-events: none;
  --size: min(var(--sh) * 0.8, var(--sw) * 1.75);
}
.scene.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--fade) ease, visibility 0s, filter 0.35s ease;
}
.scene__bg {
  position: absolute; inset: 0;
  z-index: -1;
  width: 100%; height: 100%;
  object-fit: cover;
}
.sprite {
  --h: calc(var(--size) * var(--k, 1));
  --cx: 0.5;
  position: absolute;
  bottom: 0;
  left: calc(var(--sw) * var(--cx) - var(--h) / 3);
  z-index: 1;
  height: var(--h);
  width: auto;
  aspect-ratio: 2 / 3;
  opacity: 0;
  filter: brightness(0.62) saturate(0.8);
  transition: opacity 350ms ease, filter 250ms ease, translate 450ms cubic-bezier(0.2, 0.7, 0.2, 1), height 450ms ease, left 450ms ease;
}
.sprite--left { --cx: 0.25; translate: -35% 0; }
.sprite--right { --cx: 0.75; translate: 35% 0; }
.sprite--center { z-index: 0; translate: 0 8%; }
/* вдвоём с центральным: центр сдвигается на свободную сторону */
.scene:not(.has-left) .sprite--center { --cx: 0.36; }
.scene:not(.has-right) .sprite--center { --cx: 0.64; }
/* трое на сцене: все чуть меньше, крайние ближе к краям, центральный — позади */
.scene.is-trio { --size: min(var(--sh) * 0.77, var(--sw) * 1.68); }
.scene.is-trio .sprite--left { --cx: 0.21; }
.scene.is-trio .sprite--right { --cx: 0.79; }
.sprite.is-mirrored { scale: -1 1; }
/* приглушённые — темнее, но не прозрачные */
.sprite.is-in { opacity: 1; translate: 0 0; }
.sprite.is-in.is-speaking { filter: none; z-index: 2; }
/* продолжение / переход по главам: сцена встаёт сразу, без кроссфейда и въезда */
.scene.is-instant, .scene.is-instant .sprite { transition: none; }
/* пока картинки сцены декодируются, прежний экран не принимает нажатий */
.stage[data-loading] .screen--title, .stage[data-loading] .screen--ending { pointer-events: none; }
.art { transition: filter 0.35s ease; }

/* ---- Лоадер: картинки следующей сцены ещё грузятся (дольше 300 мс) --------
   Прежний кадр размыт и притушен, плашка пуста, по центру кольцо. */
.stage[data-waiting] .art,
.stage[data-waiting] .scene { filter: blur(12px) brightness(0.7); }
.stage[data-waiting] .screen--title,
.stage[data-waiting] .screen--ending { opacity: 0.35; transition: opacity 0.35s ease; }
.loader {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--ink-soft);
  font-size: 0.95rem; letter-spacing: 0.04em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  pointer-events: none;
  z-index: 5;
}
.stage[data-waiting] .loader { opacity: 1; visibility: visible; transition: opacity 0.3s ease, visibility 0s; }
.loader__ring {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid var(--gold-faint);
  border-top-color: var(--gold);
  animation: loader-spin 0.9s linear infinite;
}
@keyframes loader-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loader__ring { animation: none; border-color: var(--gold-soft); }
  .stage[data-waiting] .art, .stage[data-waiting] .scene { transition: none; }
}

/* Мягкое затемнение снизу, чтобы плашка читалась на любом кадре. */
.stage::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 45%;
  background: linear-gradient(to top, rgba(10, 7, 22, 0.55), transparent);
  pointer-events: none;
}

.screen {
  position: absolute; inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding:
    calc(var(--gutter) + var(--safe-top))
    calc(var(--gutter) + var(--safe-right))
    calc(var(--gutter) + var(--safe-bottom))
    calc(var(--gutter) + var(--safe-left));
}

/* ---- Плашка ----------------------------------------------------------- */

.plate {
  position: relative;
  max-height: 62%;
  overflow-y: auto;
  padding: 18px 20px 20px;
  border-radius: var(--radius);
  background: var(--plate);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid var(--gold-soft);
  /* двойная кайма: тёмный зазор и тонкая золотая нить внутри */
  box-shadow:
    inset 0 0 0 3px rgba(16, 11, 34, 0.65),
    inset 0 0 0 4px var(--gold-faint),
    0 10px 30px rgba(0, 0, 0, 0.45);
  outline: none;
  scrollbar-width: thin;
}
/* ромбики-«стежки» по верхнему краю */
.plate::before {
  content: "";
  position: absolute;
  top: 7px; left: 50%;
  width: 64px; height: 6px;
  transform: translateX(-50%);
  background:
    radial-gradient(circle, var(--gold-soft) 1.6px, transparent 2px) 0 50% / 12px 6px repeat-x;
  opacity: 0.9;
  pointer-events: none;
}

.plate__who {
  display: inline-block;
  margin: 0 0 4px;
  padding-bottom: 1px;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.86em;
  letter-spacing: 0.06em;
  font-variant: small-caps;
  color: var(--who, var(--gold));
  color: color-mix(in oklab, var(--who, var(--gold)) 70%, #fff4e0);
  border-bottom: 2px solid var(--who, var(--gold));
}
.plate__who.is-thought {
  font-family: var(--font-text);
  font-weight: 400;
  font-style: italic;
  font-variant: normal;
  letter-spacing: 0.02em;
  font-size: 0.78em;
  color: var(--think);
  border-bottom: 0;
  opacity: 0.85;
}

.plate__text {
  margin: 0;
  font-size: 1em;
  line-height: 1.6;
  color: var(--ink);
  text-wrap: pretty;
  min-height: 1.6em;
}
.plate.is-thought .plate__text { font-style: italic; color: #f0dcd2; }
.plate.is-narration .plate__text { color: var(--ink-soft); }
.ghost { color: transparent; }

.plate__next {
  position: absolute;
  right: 14px; bottom: 8px;
  width: 10px; height: 10px;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  opacity: 0.8;
  animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { translate: 0 0; opacity: 0.55; }
  50% { translate: 0 3px; opacity: 1; }
}

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

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid var(--gold-soft);
  background: linear-gradient(to bottom, rgba(70, 44, 26, 0.92), rgba(44, 27, 16, 0.92));
  color: var(--ink);
  font-size: 1em;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.12), 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform 80ms ease, background-color 150ms ease, border-color 150ms ease;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.1), 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .segmented button:focus-visible, .album__cell:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.btn--primary {
  background: linear-gradient(to bottom, var(--berry-hi), var(--berry));
  border-color: rgba(255, 210, 160, 0.45);
  font-weight: 700;
}
.btn--quiet { background: rgba(30, 18, 10, 0.6); }
.btn--danger { border-color: rgba(201, 80, 80, 0.6); color: #f6d4cc; }

.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.slot:empty { display: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--gold-soft);
  background: rgba(31, 24, 56, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.menu-btn {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  z-index: 3;
}
.burger, .burger::before, .burger::after {
  display: block;
  width: 18px; height: 2px;
  border-radius: 1px;
  background: var(--ink);
}
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }

/* Звук: слева от ☰ в игре и финале, в углу на титуле. Значок — inline SVG в разметке. */
.sound-btn {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: calc(10px + 44px + 8px + var(--safe-right));
  z-index: 3;
}
.stage[data-screen="title"] .sound-btn { right: calc(10px + var(--safe-right)); }
.sound-ico { width: 22px; height: 22px; }
.sound-ico path { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-ico .sound-ico__body { fill: var(--ink); }
.sound-btn[aria-pressed="true"] .sound-ico__off,
.sound-btn[aria-pressed="false"] .sound-ico__waves { display: none; }
.sound-btn[aria-pressed="false"] { color: var(--ink-mute); }
.sound-btn[aria-pressed="false"] .sound-ico path { stroke: var(--ink-mute); }
.sound-btn[aria-pressed="false"] .sound-ico .sound-ico__body { fill: var(--ink-mute); }

/* ---- Выборы ----------------------------------------------------------- */

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.choice {
  justify-content: flex-start;
  text-align: left;
  font-size: 0.95em;
}
.choice__num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--gold-soft);
  color: var(--gold);
  font-size: 0.75em;
  font-family: var(--font-title);
}

/* Вспышка правды: значок на кнопке и 900 мс закатного (--sunset) свечения по краям сцены. */
.choice__spark { flex: none; color: var(--gold); }
.truth-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2; /* как .screen, но раньше в дереве: над картинкой, под плашкой и кнопками */
  pointer-events: none;
  box-shadow: inset 0 0 70px 18px rgba(196, 106, 90, 0.55);
  animation: truth-glow 900ms ease-out both;
}
/* В сцене со спрайтами свечение — над фоном локации, но под фигурами (лица не закрывает). */
.truth-flash .scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0; /* фон -1, центральный спрайт 0 (позже в дереве), крайние 1, говорящий 2 */
  pointer-events: none;
  box-shadow: inset 0 0 70px 18px rgba(196, 106, 90, 0.55);
  animation: truth-glow 900ms ease-out both;
}
.truth-flash:has(.scene.is-on)::before { content: none; }
.truth-flash .plate__text { animation: truth-shake 900ms linear both; }
@keyframes truth-glow { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
@keyframes truth-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-1.5px); }
  30% { transform: translateX(1.5px); }
  45% { transform: translateX(-1px); }
  60% { transform: translateX(1px); }
  75% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .truth-flash::before, .truth-flash .scene::before, .truth-flash .plate__text { animation: none; }
}

/* ---- Стартовый экран -------------------------------------------------- */

.screen--title {
  justify-content: space-between;
  background:
    linear-gradient(to bottom, rgba(10, 7, 22, 0.65), transparent 32%),
    linear-gradient(to top, rgba(10, 7, 22, 0.7), transparent 38%);
}
.title__head { text-align: center; padding-top: 6vh; padding-top: 6dvh; }
.title__name {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(34px, 10vw, 46px);
  line-height: 1.1;
  letter-spacing: 0.04em;
  font-variant: small-caps;
  color: #fbeed4;
  text-shadow: 0 2px 0 rgba(60, 25, 10, 0.8), 0 0 24px rgba(0, 0, 0, 0.7);
}
.title__and {
  display: block;
  font-style: italic;
  font-variant: normal;
  font-weight: 400;
  font-size: 0.55em;
  color: var(--gold);
}
.title__sub {
  margin: 8px 0 0;
  font-style: italic;
  color: var(--ink-soft);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.title__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 320px);
  margin: 0 auto 4vh;
  margin: 0 auto 4dvh;
}

/* ---- Финал ------------------------------------------------------------ */

/* Финал помещается в экран при любой высоте: эпилог прокручивается внутри
   плашки, кнопки — неподвижный низ плашки (2 колонки, «Вернуться к выбору» во всю ширину). */
.screen--ending { padding-top: calc(var(--gutter) + var(--safe-top) + 52px); }
.plate.plate--ending {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
  text-align: center;
  padding: 22px 16px 14px;
}
.ending__scroll {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0 4px;
  outline: none;
}
.ending__actions {
  flex: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--gold-faint);
}
.ending__actions .btn {
  min-height: 44px;
  padding: 6px 10px;
  font-size: 0.86em;
  line-height: 1.2;
}
.ending__actions .btn--wide { grid-column: 1 / -1; min-height: 48px; font-size: 1em; }
.ending__extra { display: contents; }
.ending__extra > .btn:only-child { grid-column: 1 / -1; }

.fork { flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; }
.fork .chapter__n { min-width: 0; }
.fork__words { font-size: 0.9em; font-style: italic; color: var(--ink-soft); }
.kicker {
  margin: 0;
  font-family: var(--font-title);
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 0.8em;
  color: var(--gold);
}
.ending__title {
  margin: 2px 0 10px;
  font-family: var(--font-title);
  font-size: 1.6em;
  line-height: 1.2;
  font-weight: 700;
  color: #fbeed4;
}
.ending__epilogue { text-align: left; }
.ending__epilogue p { margin: 0 0 0.6em; color: var(--ink-soft); }
.ending__epilogue p.is-thought { font-style: italic; }
.ending__count {
  margin: 4px 0 10px;
  font-size: 0.8em;
  color: var(--ink-mute);
  font-style: italic;
}

/* ---- Меню ------------------------------------------------------------- */

.screen--menu, .screen--confirm {
  z-index: 5;
  justify-content: center;
  background: rgba(8, 5, 3, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.screen--confirm { z-index: 6; }

.sheet {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--plate-solid) 96%, transparent);
  border: 1px solid var(--gold-soft);
  box-shadow: inset 0 0 0 3px rgba(16, 11, 34, 0.65), inset 0 0 0 4px var(--gold-faint), 0 18px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.sheet--small { padding: 20px; gap: 16px; }
.sheet__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--gold-faint);
}
.sheet__head .icon-btn { background: transparent; border-color: transparent; }
.sheet__title {
  flex: 1;
  margin: 0;
  padding-left: 8px;
  font-family: var(--font-title);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  font-size: 1.15em;
  color: var(--gold);
}
#menu-back:not([hidden]) + .sheet__title { padding-left: 0; }
.sheet__body {
  padding: 14px 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.panel-note { margin: 10px 0 0; font-size: 0.8em; color: var(--ink-mute); font-style: italic; }
#album-count { margin: 0 0 12px; }
.confirm__text { margin: 0; text-align: center; }

.chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chapters .btn { justify-content: flex-start; text-align: left; }
.chapter__n {
  flex: none;
  min-width: 2.4em;
  font-family: var(--font-title);
  color: var(--gold);
  font-size: 0.85em;
}
.chapter--locked {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px dashed var(--gold-faint);
  color: var(--ink-mute);
}

.album {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.album__cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
  cursor: default;
}
.album__frame {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--gold-soft);
  background: #160d07;
}
.album__frame img { width: 100%; height: 100%; object-fit: cover; }
/* силуэт ненайденного финала: тёмная фигурка девицы в арке */
.album__cell.is-locked .album__frame {
  border-style: dashed;
  border-color: var(--gold-faint);
  background:
    radial-gradient(ellipse 16% 9% at 50% 33%, #2c1d12 98%, transparent 100%),
    radial-gradient(ellipse 30% 34% at 50% 68%, #2c1d12 98%, transparent 100%),
    radial-gradient(ellipse 70% 60% at 50% 45%, #1f140c, #120b06);
}
.album__name { font-size: 0.72em; line-height: 1.25; color: var(--ink-soft); overflow-wrap: anywhere; }
.album__cell.is-locked .album__name { color: var(--ink-mute); letter-spacing: 0.2em; }
/* «В историю» (VK) под найденным финалом */
.album__extra:empty { display: none; }
.btn--small {
  min-height: 44px;
  padding: 4px 6px;
  border-radius: 10px;
  font-size: 0.72em;
}

/* ---- Ачивки -------------------------------------------------------------- */

.ach-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px 10px;
}
.ach {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.ach__img { width: 96px; height: 96px; }
/* закрытая: тёмный силуэт медальона, без цвета и деталей */
.ach__img.is-locked {
  filter: brightness(0) opacity(0.5);
}
.ach__title {
  font-family: var(--font-title);
  font-size: 0.82em;
  line-height: 1.25;
  color: var(--gold);
  overflow-wrap: anywhere;
}
.ach__desc { font-size: 0.7em; line-height: 1.3; color: var(--ink-soft); }
.ach.is-locked .ach__title, .ach.is-locked .ach__desc { color: var(--ink-mute); letter-spacing: 0.2em; }
.ach__extra { width: 100%; margin-top: 2px; }
.ach__extra:empty { display: none; }
.ach__extra .btn { width: 100%; }

/* Тост «Ачивка: …»: под рядом кнопок; тап по нему открывает ачивку в меню */
.toast {
  position: absolute;
  top: calc(10px + 44px + 8px + var(--safe-top));
  left: 12px;
  right: 12px;
  margin-inline: auto;
  width: fit-content;
  z-index: 7;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--plate-solid) 94%, transparent);
  border: 1px solid var(--gold-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--ink);
  font-size: 0.85em;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 250ms ease, transform 250ms ease;
}
.toast.is-on { opacity: 1; transform: none; pointer-events: auto; }
.toast__btn {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left;
  cursor: pointer;
}
.toast__btn::after { content: '›'; color: var(--gold); font-size: 1.3em; margin-left: 2px; }
.ach.is-flash { animation: ach-flash 1.6s ease; }
@keyframes ach-flash {
  0%, 60% { box-shadow: 0 0 0 2px var(--gold), 0 0 24px var(--gold-soft); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .ach.is-flash { animation: none; outline: 2px solid var(--gold); } }
.toast--notice { padding: 10px 16px; border-radius: 14px; max-width: 420px; }
.toast--notice .toast__btn::after { content: none; }
.toast__img { width: 44px; height: 44px; flex: none; }
.toast__text b { color: var(--gold); font-weight: 400; font-family: var(--font-title); }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history li { font-size: 0.9em; line-height: 1.5; color: var(--ink-soft); }
.history .h-who {
  display: block;
  font-family: var(--font-title);
  font-variant: small-caps;
  font-weight: 700;
  font-size: 0.85em;
  letter-spacing: 0.05em;
  color: var(--who, var(--gold));
  color: color-mix(in oklab, var(--who, var(--gold)) 70%, #fff4e0);
}
.history .is-thought { font-style: italic; color: var(--think); }
.history .is-choice { color: var(--gold); font-style: italic; }
.history .is-choice::before { content: "→ "; }
.history .is-empty { color: var(--ink-mute); font-style: italic; }

.field-label {
  margin: 0 0 8px;
  font-size: 0.85em;
  font-weight: 400;
  color: var(--ink-mute);
}
.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  container-type: inline-size;
  border-radius: 14px;
  border: 1px solid var(--gold-faint);
  background: rgba(10, 7, 22, 0.5);
}
.segmented--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented button {
  min-height: 44px;
  min-width: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: clamp(12px, 5.4cqw, 0.9em); /* от ширины самого переключателя, а не окна */
  white-space: nowrap;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] {
  background: linear-gradient(to bottom, var(--berry-hi), var(--berry));
  color: var(--ink);
  font-weight: 700;
}
#settings-extra { margin-bottom: 18px; }

/* Звук: строки каналов — название и переключатель, ниже ползунок громкости. */
.mix {
  display: grid;
  gap: 6px;
  padding: 4px 12px 8px;
  margin-bottom: 18px;
  border-radius: 14px;
  border: 1px solid var(--gold-faint);
  background: rgba(10, 7, 22, 0.5);
}
.mix-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name switch" "vol val";
  align-items: center;
  column-gap: 10px;
}
.mix-row + .mix-row { border-top: 1px solid var(--gold-faint); padding-top: 4px; }
.mix-name { grid-area: name; color: var(--ink-soft); font-size: 0.95em; }
.switch {
  grid-area: switch;
  position: relative;
  min-width: 44px;
  min-height: 44px;
  width: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.switch::before {
  content: "";
  position: absolute; left: 4px; right: 4px; top: 50%;
  height: 26px; margin-top: -13px;
  border-radius: 13px;
  border: 1px solid var(--gold-soft);
  background: rgba(10, 7, 22, 0.7);
  transition: background var(--fade);
}
.switch::after {
  content: "";
  position: absolute; left: 8px; top: 50%;
  width: 20px; height: 20px; margin-top: -10px;
  border-radius: 50%;
  background: var(--ink-mute);
  transition: transform var(--fade), background var(--fade);
}
.switch[aria-checked="true"]::before { background: linear-gradient(to bottom, var(--berry-hi), var(--berry)); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--ink); }
.switch:focus-visible, .mix-vol:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.mix-vol {
  grid-area: vol;
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  accent-color: var(--berry-hi);
  cursor: pointer;
}
.mix-val { grid-area: val; min-width: 3ch; text-align: right; color: var(--ink-mute); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.mix-row[data-on="false"] .mix-vol, .mix-row[data-on="false"] .mix-val { opacity: 0.45; }
.mix-row--switch { grid-template-areas: "name switch"; }
.mix-note { margin: -10px 0 18px; }
.link-btn {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-style: normal;
  text-decoration: underline;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) { .switch::before, .switch::after { transition: none; } }

.noscript {
  position: absolute; left: 16px; right: 16px; bottom: 24px; z-index: 9;
  padding: 16px; border-radius: var(--radius);
  background: var(--plate-solid); text-align: center;
}

/* ---- Размеры ---------------------------------------------------------- */

@media (max-width: 370px) {
  html, body { font-size: 17px; }
  .plate { padding: 16px 16px 18px; }
}
@media (min-width: 400px) and (min-height: 760px) {
  html, body { font-size: 18.5px; }
}
@media (min-width: 700px) {
  html, body { font-size: 19px; }
  .stage { border-left: 1px solid var(--gold-faint); border-right: 1px solid var(--gold-faint); }
}
@media (max-height: 560px) {
  .plate { max-height: 72%; }
  .title__head { padding-top: 2vh; }
}

/* ---- Меньше движения -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .art__layer, .scene, .scene.is-on, .sprite { transition: none; }
  .plate__next { animation: none; opacity: 0.8; }
  .btn { transition: none; }
  .toast { transition: none; }
}

/* ---- Мини-игры (public/games/ui.js) --------------------------------------
   Картинка 9:16 вписана по ширине сцены (сцена не шире 9:16), сверху — подсказка,
   цель и «Пропустить», снизу — лоток. Телефон в приоритете: кнопки не ниже 44px,
   клетка «три в ряд» на 360px — около 54px. На десктопе та же колонка, мышью. */
.stage[data-screen="mini"] .sound-btn { display: none; }
.stage[data-loading] .screen--mini { pointer-events: none; }
.stage[data-waiting] .screen--mini { opacity: 0.35; transition: opacity 0.35s ease; }
.screen--mini { padding: 0; justify-content: flex-start; background: var(--bg); }
.mini__bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(18px) brightness(0.42);
  transform: scale(1.12);
}
.mini__body { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.mini__top {
  position: absolute; z-index: 3;
  top: calc(8px + var(--safe-top));
  left: calc(8px + var(--safe-left)); right: calc(8px + var(--safe-right));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px;
}
.pill-btn {
  flex: none;
  min-height: 44px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  background: rgba(31, 24, 56, 0.84);
  color: var(--ink);
  font: inherit; font-size: 0.82em;
  cursor: pointer;
}
.pill-btn:disabled { opacity: 0.55; cursor: default; }
.pill-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mini__info {
  order: 3; flex: 1 0 100%; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(31, 24, 56, 0.84);
  border: 1px solid var(--gold-faint);
  text-align: center;
}
.mini__title { margin: 0; font: 400 0.9em var(--font-title); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini__goal { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 0.82em; min-height: 1.4em; white-space: nowrap; }
.mini__goal:empty { display: none; }
.mini__goal b { color: var(--ink); font-weight: 700; }
.mini__goal-icon { width: 20px; height: 20px; flex: none; }
.mini__goal-icon svg, .mini__goal-icon .game-img { width: 100%; height: 100%; display: block; object-fit: contain; }
.mini__bar { flex: 1; max-width: 70px; height: 6px; border-radius: 3px; background: rgba(244, 232, 210, 0.16); overflow: hidden; }
.mini__bar i { display: block; height: 100%; width: 0; background: var(--berry-hi); transition: width 200ms ease; }
.mini__moves { color: var(--ink-soft); white-space: nowrap; }

.mini__tray {
  position: absolute; z-index: 3;
  left: calc(8px + var(--safe-left)); right: calc(8px + var(--safe-right));
  bottom: calc(8px + var(--safe-bottom));
  padding: 9px 10px 10px;
  border-radius: var(--radius);
  background: var(--plate);
  border: 1px solid var(--gold-soft);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tray__head { display: flex; align-items: baseline; gap: 8px; font-size: 0.82em; color: var(--ink-soft); }
.tray__head--solo { display: block; line-height: 1.35; }
.tray__task { flex: 1; min-width: 0; }
.tray__count { color: var(--gold); white-space: nowrap; }
.tray__pips { color: var(--berry-hi); letter-spacing: 1px; white-space: nowrap; }
.tray__chips { display: flex; flex-wrap: wrap; gap: 5px 6px; margin-top: 8px; }
.tray__chips:empty { display: none; }
/* низкий экран: лоток в одну прокручиваемую строку, чтобы не закрывать предметы на картинке */
@media (max-height: 720px) {
  .tray__chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .tray__chips::-webkit-scrollbar { display: none; }
  .tray__chip { flex: none; }
}
.tray__chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 2px;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  background: rgba(244, 232, 210, 0.07);
  color: var(--ink);
  font-size: 0.8em;
  line-height: 1.35;
  white-space: nowrap;
}
.tray__chip--pic { padding: 2px; }
.tray__pic {
  position: relative; flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-color: #1f1838;
}
.tray__chip.is-found {
  border-color: rgba(156, 207, 106, 0.6);
  background: rgba(40, 70, 28, 0.55);
  color: #cfe8b8;
}
.tray__chip.is-found .tray__name { text-decoration: line-through; }
.tray__chip.is-found .tray__pic::after {
  content: '✓';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(40, 70, 28, 0.66);
  color: #e9ffd6; font-weight: 700;
}

.find { position: relative; width: 100%; aspect-ratio: 9 / 16; max-height: 100%; cursor: pointer; }
.find__pic { display: block; width: 100%; height: 100%; pointer-events: none; }
.find__ring, .find__hint, .find__miss { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.find__ring {
  aspect-ratio: 1; border-radius: 50%;
  border: 2px solid #e9ffd6;
  box-shadow: 0 0 0 2px rgba(60, 110, 40, 0.7), 0 0 14px rgba(190, 255, 150, 0.8);
  animation: find-pop 320ms ease-out;
}
.find__hint {
  aspect-ratio: 1; border-radius: 50%;
  border: 2px dashed var(--gold);
  box-shadow: 0 0 22px rgba(212, 168, 97, 0.75), inset 0 0 22px rgba(212, 168, 97, 0.35);
  animation: find-pulse 900ms ease-in-out infinite alternate;
}
.find__miss { color: #ffb4a8; font-size: 22px; font-weight: 700; text-shadow: 0 1px 4px #000; animation: find-fade 600ms ease-out forwards; }
.find__miss::before { content: '✕'; }
.find__miss--decoy::after { content: ' не то'; font-size: 13px; font-weight: 400; }
@keyframes find-pop { from { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } }
@keyframes find-pulse { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes find-fade { to { opacity: 0; transform: translate(-50%, -80%); } }

.m3-wrap { width: min(calc(100% - 20px), calc(var(--sh) * 0.56)); }
.m3 {
  position: relative;
  aspect-ratio: var(--cols) / var(--rows);
  border-radius: var(--radius);
  background: rgba(31, 24, 56, 0.78);
  border: 1px solid var(--gold-soft);
  overflow: hidden;
  touch-action: none;
  transition: opacity 180ms ease;
}
.m3.is-shuffling { opacity: 0.25; }
.m3__piece {
  position: absolute; left: 0; top: 0;
  width: calc(100% / var(--cols)); height: calc(100% / var(--rows));
  padding: 1.6%;
  transition: transform 160ms ease;
  cursor: pointer;
}
.m3__piece.is-new { transition: none; }
.m3__piece::before {
  content: ''; position: absolute; inset: 5%;
  border-radius: 20%;
  background: rgba(244, 232, 210, 0.09);
}
.m3__piece svg, .m3__piece .game-img {
  position: relative; display: block; width: 100%; height: 100%;
  padding: 9%;
  transition: transform 170ms ease, opacity 170ms ease;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}
.m3__piece .game-img { padding: 3%; object-fit: contain; } /* картинка фишки (Task 4b) крупнее плоского знака */
.m3__piece.is-gone svg, .m3__piece.is-gone .game-img { transform: scale(0.15); opacity: 0; }
/* особые фишки: линия (полоса вдоль строки или столбца) и вспышка (кольцо) */
.m3__piece[data-special]::after {
  content: ''; position: absolute; pointer-events: none;
  border-radius: 999px;
  background: #fff3c4;
  box-shadow: 0 0 8px 2px rgba(255, 226, 140, 0.95);
  animation: m3-special 900ms ease-in-out infinite alternate;
}
.m3__piece[data-special="row"]::after { left: 6%; right: 6%; top: 44%; height: 12%; }
.m3__piece[data-special="col"]::after { top: 6%; bottom: 6%; left: 44%; width: 12%; }
.m3__piece[data-special="burst"]::after { inset: 8%; background: none; border: 3px solid #fff3c4; }
@keyframes m3-special { from { opacity: 0.55; } to { opacity: 1; } }
/* покров клетки: золотистая рамка и лист в углу — фишка под ним видна; не ловит нажатия */
.m3__cover {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: calc(100% / var(--cols)); height: calc(100% / var(--rows));
  pointer-events: none;
  transition: opacity 180ms ease;
}
.m3__cover::before {
  content: ''; position: absolute; inset: 5%;
  border-radius: 20%;
  border: 2px solid rgba(226, 160, 60, 0.95);
  background: rgba(201, 134, 46, 0.3);
}
.m3__cover svg {
  position: absolute; left: -2%; top: -2%;
  width: 46%; height: 46%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.m3__cover.is-gone { opacity: 0; }
.m3__piece.is-selected::before { background: rgba(212, 168, 97, 0.42); box-shadow: 0 0 0 2px var(--gold); }
.m3__piece.is-hint svg, .m3__piece.is-hint .game-img { animation: m3-hint 500ms ease-in-out infinite alternate; }
@keyframes m3-hint { to { transform: scale(1.18); } }

.mini__result {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 7, 22, 0.62);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.mini__card {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 340px;
  padding: 18px 16px 16px;
  border-radius: var(--radius);
  background: var(--plate-solid);
  border: 1px solid var(--gold-soft);
  text-align: center;
}
.mini__result-title { margin: 0; font: 400 1.3em var(--font-title); color: var(--gold); }
.mini__result-text { margin: 0 0 4px; color: var(--ink-soft); line-height: 1.4; }
.mini__result-note { margin: 0; }
/* «Дорожки» (ui-lanes.js): поле между верхней полосой и лотком; в поле — кадр сцены (--scene)
   под затемнением ~50 % (контраст не зависит от картинки), мягкие полосы трёх дорожек, слой скорости
   (стволы / облака) и герой на PLAYER_Y (82 % высоты поля). Внизу — ◀ правило ▶, кнопки ≥ 56px. */
.lanes {
  position: absolute; z-index: 1;
  top: calc(108px + var(--safe-top)); bottom: calc(96px + var(--safe-bottom));
  left: calc(8px + var(--safe-left)); right: calc(8px + var(--safe-right));
  max-width: 460px; margin: 0 auto;
  border-radius: var(--radius);
  border: 1px solid var(--gold-faint);
  background: linear-gradient(rgba(12, 10, 26, 0.52), rgba(12, 10, 26, 0.52)), var(--scene, none) center / cover no-repeat, var(--bg);
  overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.lanes--dragon { background: linear-gradient(rgba(18, 22, 44, 0.48), rgba(18, 22, 44, 0.48)), var(--scene, none) center / cover no-repeat, var(--bg); }
/* фон сцены за полем: тот же кадр, сильнее размыт */
.screen--mini:has(.lanes) .mini__bg { filter: blur(18px) brightness(0.55); }
.lanes__track {
  position: absolute; inset: 0;
  /* три мягкие полосы с узкими тёмными зазорами — дорожки, а не разметка шоссе */
  background: linear-gradient(90deg,
    rgba(244, 232, 210, 0.07) 0 32%, transparent 32% 34.7%,
    rgba(244, 232, 210, 0.07) 34.7% 65.3%, transparent 65.3% 68%,
    rgba(244, 232, 210, 0.07) 68% 100%);
}
.lanes__para { position: absolute; inset: 0; background-repeat: repeat-y; pointer-events: none; }
.lanes__ob, .lanes__hero {
  position: absolute;
  width: min(calc(100% / var(--n) * 0.6), 76px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.lanes__ob::before {
  /* плашка-жетон под препятствием: читается на любом кадре */
  content: ''; position: absolute; inset: 4%;
  border-radius: 50%;
  background: rgba(10, 8, 22, 0.5);
  box-shadow: 0 0 0 1px rgba(244, 232, 210, 0.16), 0 0 10px rgba(10, 8, 22, 0.6);
}
.lanes__ob svg, .lanes__ob .game-img { position: relative; }
.lanes__ob svg, .lanes__hero svg, .lanes__ob .game-img, .lanes__hero .game-img { object-fit: contain; display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55)); }
/* волк Рэй на картинке — узкий силуэт сверху (≈ 0,37 ширины кадра): крупнее, чтобы читался как плоский знак */
.lanes--wolf .lanes__hero .game-img { transform: scale(1.4); }
/* тёмные герои-картинки на тёмном поле: светлый контур вокруг силуэта */
.lanes__hero .game-img { filter: drop-shadow(0 0 1.5px rgba(244, 232, 210, 0.8)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55)); }
.lanes__ob.is-hit { opacity: 0.35; }
.lanes__hero { width: min(calc(100% / var(--n) * 0.72), 88px); z-index: 1; transition: left 90ms ease-out; }
.lanes__hero.is-hit svg, .lanes__hero.is-hit .game-img { animation: lanes-blink 150ms steps(2) 3; }
.lanes__hero.is-hit::after {
  content: ''; position: absolute; inset: -6%;
  border-radius: 50%;
  border: 3px solid #ff8f7f;
  box-shadow: 0 0 0 2px rgba(120, 20, 20, 0.6);
}
.lanes.is-hit { animation: lanes-shake 300ms ease-out; box-shadow: inset 0 0 40px rgba(255, 90, 70, 0.55); }
@keyframes lanes-blink { 50% { opacity: 0.3; } }
@keyframes lanes-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.lanes__card {
  position: absolute; z-index: 2; left: 12px; right: 12px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  padding: 16px 14px 14px;
  border-radius: var(--radius);
  background: var(--plate-solid);
  border: 1px solid var(--gold-soft);
  text-align: center;
}
.lanes__card[hidden] { display: none; }
.lanes__card-title { margin: 0; font: 400 1.15em var(--font-title); color: var(--gold); }
.lanes__card-text { margin: 0 0 4px; color: var(--ink-soft); line-height: 1.4; overflow-wrap: anywhere; }
.lanes__ctl { display: flex; align-items: center; gap: 10px; }
.lanes__btn {
  flex: none; width: 64px; min-height: 56px;
  border-radius: 14px;
  border: 1px solid var(--gold-soft);
  background: rgba(244, 232, 210, 0.1);
  color: var(--ink);
  font: inherit; font-size: 1.4em;
  cursor: pointer;
  touch-action: manipulation;
}
.lanes__btn:active { background: rgba(212, 168, 97, 0.35); }
.lanes__btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.lanes__rule { flex: 1; min-width: 0; font-size: 0.8em; line-height: 1.35; color: var(--ink-soft); text-align: center; overflow-wrap: anywhere; }
.lanes__lives { color: var(--berry-hi); letter-spacing: 2px; font-size: 1.05em; }
.mini__bar.lanes__time { max-width: 90px; min-width: 60px; }
.lanes__time i { transition: none; background: var(--gold); }
/* «Заткни правду» (ui-hush.js): то же место, что у «дорожек», кадр бала под затемнением.
   Сверху — всплывшие признания, в центре — облачко реплики с именем, над кнопкой — подпись итога,
   внизу — большая кнопка «Тсс!» (нажатие в любом месте поля — то же самое). */
.hush {
  position: absolute; z-index: 1;
  top: calc(108px + var(--safe-top)); bottom: calc(84px + var(--safe-bottom));
  left: calc(8px + var(--safe-left)); right: calc(8px + var(--safe-right));
  max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-faint);
  background: linear-gradient(rgba(12, 10, 26, 0.66), rgba(12, 10, 26, 0.66)), var(--scene, none) center / cover no-repeat, var(--bg);
  overflow: hidden;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  cursor: pointer;
}
.screen--mini:has(.hush) .mini__bg { filter: blur(18px) brightness(0.55); }
.hush__pops {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0; flex: 0 1 auto; overflow: hidden;
}
.hush__pop {
  padding: 5px 9px;
  border-radius: 10px;
  background: rgba(158, 47, 55, 0.55);
  border: 1px solid rgba(255, 160, 150, 0.35);
  font-size: 0.78em; line-height: 1.3; color: var(--ink);
  overflow-wrap: anywhere;
  animation: hush-pop 380ms ease-out;
}
.hush__pop:not(:first-child) { opacity: 0.7; }
.hush__pop b { color: #ffd0c8; font-weight: 600; }
.hush__stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.hush__bubble {
  position: relative;
  width: 100%; max-width: 380px; min-height: 108px;
  padding: 12px 16px 16px;
  border-radius: 20px;
  background: #f4ead8;
  color: #2a2035;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: background-color 160ms ease;
}
.hush__bubble::after {
  /* хвостик облачка */
  content: ''; position: absolute; left: 34px; bottom: -11px;
  border: 12px solid transparent; border-bottom: 0; border-top-color: #f4ead8;
  transition: border-top-color 160ms ease;
}
.hush__who { margin: 0 0 4px; font: 600 0.82em var(--font-text); color: #8a5a1c; letter-spacing: 0.02em; }
.hush__text { margin: 0; font-size: 1.22em; line-height: 1.38; overflow-wrap: anywhere; min-height: 1.38em; }
.hush__w { display: inline-block; animation: hush-word 140ms ease-out; }
.hush__w.is-danger { color: var(--berry); font-weight: 700; }
.hush__cut { color: #8a5a1c; font-weight: 700; }
.hush__bubble.is-waiting .hush__text::before { content: '…'; color: #a08d74; }
.hush__bubble.is-early .hush__text::before { content: 'тсс… (а тут ещё тихо)'; color: #a08d74; font-style: italic; font-size: 0.85em; }
.hush__bubble.is-cut { background: #e6efd9; }
.hush__bubble.is-cut::after { border-top-color: #e6efd9; }
.hush__bubble.is-spill { background: #f7d9d3; }
.hush__bubble.is-spill::after { border-top-color: #f7d9d3; }
.hush__flash {
  margin: 0; min-height: 1.4em;
  text-align: center; font: 400 1.1em var(--font-title);
  opacity: 0; transition: opacity 120ms ease;
}
.hush__flash.is-on { opacity: 1; }
.hush__flash[data-kind="stopped"] { color: #bfe3a5; }
.hush__flash[data-kind="early"] { color: var(--ink-soft); }
.hush__flash[data-kind="late"] { color: #ff9d90; }
.hush__btn {
  flex: none; width: 100%; min-height: 76px;
  border-radius: 18px;
  border: 1px solid var(--gold);
  background: linear-gradient(rgba(212, 168, 97, 0.32), rgba(212, 168, 97, 0.18));
  color: var(--ink);
  font: 400 1.9em var(--font-title); letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}
.hush__btn:active { background: rgba(212, 168, 97, 0.5); }
.hush__btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.hush__btn:disabled { opacity: 0.5; cursor: default; }
.hush__card { cursor: default; }
.hush__rule { font-size: 0.8em; color: var(--ink-soft); text-align: center; }
.hush__count { color: var(--ink-soft); font-size: 0.85em; white-space: nowrap; }
.hush.is-late { animation: lanes-shake 300ms ease-out; box-shadow: inset 0 0 40px rgba(255, 90, 70, 0.5); }
@keyframes hush-word { from { opacity: 0; transform: translateY(4px); } }
@keyframes hush-pop { from { opacity: 0; transform: translateY(-8px); } }
/* итог: список вырвавшихся признаний */
.mini__result-extra { max-height: 38vh; overflow-y: auto; text-align: left; }
.mini__result-extra[hidden] { display: none; }
.hush-sum__title { margin: 0 0 4px; color: var(--gold); font-size: 0.9em; }
.hush-sum__none { margin: 0; color: var(--ink-soft); font-style: italic; text-align: center; }
.hush-sum__list { margin: 0; padding: 0 0 0 1.1em; display: flex; flex-direction: column; gap: 4px; font-size: 0.88em; line-height: 1.35; color: var(--ink); }
.hush-sum__list b { color: var(--ink-soft); font-weight: 600; }
/* «Руны» (ui-runes.js): то же место, что у «Заткни правду», кадр круга под затемнением.
   Сверху — табличка «Смотри» / «Повтори», в центре — медный круг: шесть рун-кнопок вокруг камня
   с волчьей лапой. Вспышка — яркость и свечение поверх (картинка руны или SVG — одинаково). */
.runes {
  position: absolute; z-index: 1;
  top: calc(108px + var(--safe-top)); bottom: calc(84px + var(--safe-bottom));
  left: calc(8px + var(--safe-left)); right: calc(8px + var(--safe-right));
  max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-faint);
  background: linear-gradient(rgba(12, 10, 26, 0.6), rgba(12, 10, 26, 0.6)), var(--scene, none) center / cover no-repeat, var(--bg);
  overflow: hidden;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.screen--mini:has(.runes) .mini__bg { filter: blur(18px) brightness(0.55); }
.runes__mode {
  flex: none; align-self: center; margin: 0;
  min-width: 9.5em; padding: 6px 18px;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  background: rgba(31, 24, 56, 0.85);
  font: 400 1.25em var(--font-title); text-align: center; color: var(--ink-soft);
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}
.runes[data-mode="input"] .runes__mode { color: #1f1838; background: var(--gold); border-color: var(--gold); }
.runes[data-mode="wait"] .runes__mode { color: #1f1838; background: #ffb4a8; border-color: #ffb4a8; }
.runes[data-mode="done"] .runes__mode, .runes[data-mode="win"] .runes__mode { color: #bfe3a5; border-color: #8fbf73; }
.runes[data-mode="wrong"] .runes__mode, .runes[data-mode="timeout"] .runes__mode, .runes[data-mode="again"] .runes__mode, .runes[data-mode="lose"] .runes__mode { color: #ffb4a8; border-color: rgba(255, 157, 144, 0.6); background: rgba(70, 18, 26, 0.92); }
.runes__stage {
  flex: 1 1 auto; min-height: 0;
  display: grid; place-items: center;
  container-type: size;
  outline: none;
}
.runes__circle {
  position: relative;
  width: min(100%, calc(100vh - 330px)); /* старые webview без container queries */
  width: min(100cqw, 100cqh, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  /* медный круг договора: кольцо по краю и тёмный пол внутри */
  background:
    radial-gradient(circle closest-side, transparent 0 93%, #c98a4a 93.5% 96%, #6e3f1c 96.5% 99%, transparent 99.5%),
    radial-gradient(circle closest-side, rgba(24, 18, 34, 0.82) 0 93.5%, transparent 94%);
}
.runes__stone {
  position: absolute; left: 50%; top: 50%;
  width: 30%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #3a3d4a;
  background: radial-gradient(circle at 40% 35%, #6c7181, #444857 70%);
  box-shadow: 0 0 0 4px rgba(212, 168, 97, 0.2), 0 4px 14px rgba(0, 0, 0, 0.5);
}
/* кольцо отсчёта: видно только последние секунды ожидания, обводка укорачивается */
.runes__stone .runes__ring { position: absolute; inset: -14%; width: 128%; height: 128%; overflow: visible; opacity: 0; transition: opacity 150ms ease; }
.runes__stone.is-warn .runes__ring { opacity: 1; }
.runes__ring circle { fill: none; stroke-width: 8; }
.runes__ring-track { stroke: rgba(255, 180, 168, 0.22); }
.runes__ring-bar { stroke: #ffb4a8; stroke-linecap: round; stroke-dasharray: 100 100; stroke-dashoffset: 0; }
.runes__stone svg { width: 66%; height: 66%; }
.runes[data-over="win"] .runes__stone { color: #ffe7a8; box-shadow: 0 0 0 4px var(--gold), 0 0 36px 10px rgba(255, 210, 120, 0.55); }
.runes__rune {
  --a: 0deg;
  position: absolute; left: 50%; top: 50%;
  width: 25%; aspect-ratio: 1;
  min-width: 48px; min-height: 48px;
  margin: 0; padding: 0;
  border: 0; border-radius: 50%;
  background: none;
  transform: translate(-50%, -50%) rotate(var(--a)) translateX(142%) rotate(calc(-1 * var(--a)));
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: filter 120ms ease, box-shadow 120ms ease;
}
.runes__svg, .runes__img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 50%; }
.runes__img { object-fit: contain; transform: scale(1.12); } /* камень на картинке ≈ 0,75–0,94 кадра: до края кнопки, без тёмного зазора под кольцом подсветки */
.runes__rune.has-img .runes__svg { visibility: hidden; }
.runes__rune:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
/* не время нажимать — чуть темнее; :where — вспышки ниже перекрывают это правило */
.runes:where([data-mode="watch"], [data-mode="done"], [data-mode="wrong"], [data-mode="timeout"], [data-mode="again"]) .runes__rune { cursor: default; filter: brightness(0.82); }
/* вспышка показа и нажатие игрока: ярче, золотое свечение; знак — светлый */
.runes__rune.is-lit, .runes__rune.is-press {
  filter: brightness(1.55) saturate(1.25);
  box-shadow: 0 0 0 4px #ffe7a8, 0 0 28px 10px rgba(255, 210, 120, 0.7);
}
.runes__rune.is-lit .runes__glyph, .runes__rune.is-press .runes__glyph { stroke: #fff6d8; }
.runes__rune.is-lit { animation: runes-pulse 600ms ease-out; }
.runes__rune.is-press { animation: runes-tap 250ms ease-out; }
/* ошибка: нажатая — красная, нужная — подсвечена контуром */
.runes__rune.is-wrong { filter: brightness(1.1) sepia(0.6) hue-rotate(-30deg) saturate(2.4); box-shadow: 0 0 0 4px #ff8a7a, 0 0 22px 6px rgba(255, 90, 70, 0.6); }
.runes__rune.is-want { filter: brightness(1.55) saturate(1.25); box-shadow: 0 0 0 4px #ffe7a8, 0 0 28px 10px rgba(255, 210, 120, 0.7); }
.runes__rune.is-want .runes__glyph { stroke: #fff6d8; }
/* картинка-камень меньше кнопки: зазор до кольца подсветки заливается свечением, а не тёмным полем */
.runes__rune.has-img:is(.is-lit, .is-press, .is-want) { background: radial-gradient(circle, rgba(255, 231, 168, 0.75) 55%, rgba(255, 210, 120, 0.55) 72%); }
.runes__rune.has-img.is-wrong { background: rgba(255, 138, 122, 0.55); }
.runes__rune.is-want { animation: runes-pulse 600ms ease-out; }
.runes[data-mode="wrong"], .runes[data-mode="timeout"] { box-shadow: inset 0 0 40px rgba(255, 90, 70, 0.4); }
.runes[data-mode="wrong"] .runes__circle { animation: lanes-shake 300ms ease-out; }
.runes[data-over="win"] .runes__rune { filter: brightness(1.45); box-shadow: 0 0 0 3px #ffe7a8, 0 0 20px 6px rgba(255, 210, 120, 0.55); }
.runes.is-paused .runes__rune.is-lit { filter: none; box-shadow: none; animation: none; }
.runes__card { cursor: default; }
.runes__rule { font-size: 0.8em; color: var(--ink-soft); text-align: center; }
.runes__count { color: var(--ink-soft); font-size: 0.85em; white-space: nowrap; }
@keyframes runes-pulse {
  from { transform: translate(-50%, -50%) rotate(var(--a)) translateX(142%) rotate(calc(-1 * var(--a))) scale(1); }
  35% { transform: translate(-50%, -50%) rotate(var(--a)) translateX(142%) rotate(calc(-1 * var(--a))) scale(1.12); }
  to { transform: translate(-50%, -50%) rotate(var(--a)) translateX(142%) rotate(calc(-1 * var(--a))) scale(1.04); }
}
@keyframes runes-tap {
  50% { transform: translate(-50%, -50%) rotate(var(--a)) translateX(142%) rotate(calc(-1 * var(--a))) scale(0.92); }
}
@media (prefers-reduced-motion: reduce) {
  .m3__piece, .m3__piece svg, .m3__piece .game-img, .mini__bar i { transition: none; }
  .find__ring, .find__hint, .m3__piece.is-hint svg, .m3__piece.is-hint .game-img { animation: none; }
  /* дорожки: без тряски и вспышек — только неподвижное кольцо на герое */
  .lanes__hero { transition: none; }
  .lanes__hero.is-hit svg, .lanes__hero.is-hit .game-img, .lanes.is-hit { animation: none; }
  .lanes.is-hit { box-shadow: none; }
  /* «Заткни правду»: без тряски и всплытия — только цвет облачка и подпись */
  .hush.is-late { animation: none; box-shadow: none; }
  .hush__w, .hush__pop { animation: none; }
  .hush__bubble, .hush__bubble::after, .hush__flash { transition: none; }
  /* «Руны»: без пульса, увеличения и тряски — вспышка только яркостью и заливкой */
  .runes__rune, .runes__mode { transition: none; }
  .runes__rune.is-lit, .runes__rune.is-press, .runes__rune.is-want, .runes[data-mode="wrong"] .runes__circle { animation: none; }
  .runes__stone .runes__ring { transition: none; }
  .runes[data-mode="wrong"], .runes[data-mode="timeout"] { box-shadow: none; }
}
