/* ============================================================
   QR-КВЕСТ — общий стиль на все страницы
   Geocities 1998, но тёплый и уютный.
   Мобильный first (Samsung Galaxy / Chrome), десктоп вторично.
   Никакой логики на :hover. Никаких скруглений и мягких теней.
   ============================================================ */

/* ---------- 1. Шрифты (локально, без CDN) ---------- */

/* Balsamiq Sans вместо Comic Neue: у Comic Neue нет кириллицы вообще,
   на русском тексте он бы не применился ни разу.
   Файлы урезаны до латиницы, кириллицы и нужных значков — по ~35 КБ.
   Лицензия OFL, текст лежит рядом в fonts/OFL.txt. */

@font-face {
  font-family: "Balsamiq Sans";
  src: url("../fonts/BalsamiqSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Balsamiq Sans";
  src: url("../fonts/BalsamiqSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. Переменные ---------- */

:root {
  /* базовая (нейтральная) тема — заглушка и всё, что без темы */
  --paper:        #fffcf0;
  --paper-warm:   #fff4d6;
  --accent:       #c0395c;
  --accent-dark:  #8f2743;
  --check:        rgba(140, 100, 60, 0.07);   /* клетка фона */
  --tint:         #f6e2c8;                    /* пастельный контур и скотч */

  /* текст и линии: тёплые, не чёрные */
  --ink:          #3a2a18;
  --ink-soft:     #6b5540;
  --line:         #6b4a2b;
  --line-soft:    #8a6a48;

  /* вспомогательные заливки блоков */
  --yellow:       #ffe066;
  --lilac:        #e5d4f5;
  --mint:         #d6f2e0;
  --accent-2:     #1f7a5e;

  /* рамки и грубые тени */
  --bd:           4px solid var(--line);
  --bd-thin:      3px solid var(--line);
  --shadow:       6px 6px 0 var(--line);
  --shadow-sm:    4px 4px 0 var(--line);
  --ring:         0 0 0 3px var(--tint);      /* второй, пастельный контур */

  --gap:          16px;
  --gap-lg:       26px;
  --radius:       0px;
  --tap:          44px;
  --sag:          30px;       /* насколько провисает гирлянда */

  --font: "Balsamiq Sans", "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  --fs-base: 19px;
}

/* ---------- 2b. Темы этапов: у каждой страницы свой цвет ---------- */

.theme-1 {  /* персик */
  --paper: #fff4ea; --paper-warm: #ffe6d2;
  --accent: #c2562f; --accent-dark: #913c1d;
  --check: rgba(194, 86, 47, 0.08); --tint: #ffd9bd;
}

.theme-2 {  /* мята */
  --paper: #edf8f2; --paper-warm: #d9f0e4;
  --accent: #1f7a5e; --accent-dark: #145743;
  --check: rgba(31, 122, 94, 0.08); --tint: #bfe8d5;
}

.theme-3 {  /* лаванда */
  --paper: #f4efFB; --paper-warm: #e7dcf8;
  --accent: #6b4bb0; --accent-dark: #4e3486;
  --check: rgba(107, 75, 176, 0.08); --tint: #d9c9f2;
}

.theme-4 {  /* лимон */
  --paper: #fffbe8; --paper-warm: #fff2c2;
  --accent: #9a6a00; --accent-dark: #6f4c00;
  --check: rgba(154, 106, 0, 0.09); --tint: #ffe9a8;
}

.theme-5 {  /* небо */
  --paper: #edf4fd; --paper-warm: #d9e8fb;
  --accent: #2f6bb0; --accent-dark: #204d80;
  --check: rgba(47, 107, 176, 0.08); --tint: #c6dcf7;
}

.theme-6 {  /* роза */
  --paper: #fdf0f4; --paper-warm: #fbdfe7;
  --accent: #c0395c; --accent-dark: #8f2743;
  --check: rgba(192, 57, 92, 0.08); --tint: #f7ccd8;
}

.theme-7 {  /* финал: праздничный */
  --paper: #fff6ec; --paper-warm: #ffe8cc;
  --accent: #b23a7a; --accent-dark: #85285a;
  --check: rgba(178, 58, 122, 0.08); --tint: #ffd9ec;
}

.theme-egg { /* пасхалка: бирюза */
  --paper: #eaf6f6; --paper-warm: #d4ecec;
  --accent: #176b6b; --accent-dark: #0f4c4c;
  --check: rgba(23, 107, 107, 0.09); --tint: #bde3e3;
}

/* ---------- 3. Сброс и база ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Атрибут hidden обязан выигрывать у display из классов:
   у .btn стоит inline-flex, и без этого правила спрятанная
   кнопка продолжала бы отображаться. */
[hidden] {
  display: none !important;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 0 40px;
  min-height: 100%;
  overflow-x: hidden;

  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--ink);

  /* фон-гингем нарисован CSS-ом, файла не требует.
     Если появится img/bg-tile.png — просто раскомментируй две строки
     ниже и удали background-image с градиентами. */
  /* background-image: url("../img/bg-tile.png"); */
  /* background-repeat: repeat; */
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 0 13px, var(--check) 13px 26px),
    linear-gradient(0deg,  transparent 0 13px, var(--check) 13px 26px);
  background-size: 26px 26px;
  background-attachment: fixed;
}

img {
  max-width: 100%;
  height: auto;
  border: 0;
  image-rendering: -webkit-optimize-contrast;
}

a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  cursor: pointer;
}

a:active { color: var(--accent); }

p { margin: 0 0 0.9em; }
p:last-child { margin-bottom: 0; }

/* ---------- 4. Каркас и появление блоков ---------- */

.wrap {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 12px 0;
}

.tilt-l { transform: rotate(-0.7deg); }
.tilt-r { transform: rotate(0.8deg); }

/* Блоки въезжают снизу по очереди — страница «собирается» при открытии.
   Исключены двое: у финального текста своя анимация появления, а у
   заголовка к появлению добавлено бесконечное дыхание тенью — его список
   анимаций объявлен целиком у него самого. Если объявить вторую анимацию
   шорткатом в правиле послабее, это правило перебьёт имя, но оставит
   чужой infinite — и анимация появления зациклится. */
/* ВАЖНО: здесь нельзя писать шорткат animation — он сбросил бы
   animation-delay из правил nth-child ниже и убил бы всю очередь.
   Поэтому только длиннописные свойства, кроме delay. */
.wrap > *:not(.final-text):not(.stage-title) {
  animation-name: block-in;
  animation-duration: 0.5s;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}

.wrap > *:nth-child(1) { animation-delay: 0s; }
.wrap > *:nth-child(2) { animation-delay: 0.08s; }
.wrap > *:nth-child(3) { animation-delay: 0.16s; }
.wrap > *:nth-child(4) { animation-delay: 0.24s; }
.wrap > *:nth-child(5) { animation-delay: 0.32s; }
.wrap > *:nth-child(6) { animation-delay: 0.40s; }
.wrap > *:nth-child(7) { animation-delay: 0.48s; }
.wrap > *:nth-child(8) { animation-delay: 0.56s; }
.wrap > *:nth-child(9)  { animation-delay: 0.64s; }
.wrap > *:nth-child(10) { animation-delay: 0.72s; }
.wrap > *:nth-child(11) { animation-delay: 0.80s; }
.wrap > *:nth-child(12) { animation-delay: 0.88s; }
.wrap > *:nth-child(13) { animation-delay: 0.96s; }
.wrap > *:nth-child(n+14) { animation-delay: 1.04s; }

/* важно: в кадре to не объявляем transform — иначе он затрёт
   наклоны .tilt-l / .tilt-r после конца анимации */
@keyframes block-in {
  from { opacity: 0; transform: translateY(22px) scale(0.965) rotate(-0.8deg); }
  60%  { opacity: 1; }
  to   { opacity: 1; }
}

/* ---------- 4b. Конфетти при открытии страницы ----------
   Восемнадцать бумажек падают сверху один раз при загрузке.
   Чистый CSS: работает даже с выключенным JS.
   -------------------------------------------------------- */

.pageconf {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;      /* ни пикселя горизонтального скролла */
  pointer-events: none;
  z-index: 5;
}

.pageconf i {
  position: absolute;
  top: -26px;
  width: 9px;
  height: 14px;
  background: var(--accent);
  animation: conf-fall 3.4s linear forwards;
}

@keyframes conf-fall {
  0%   { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  7%   { opacity: 1; }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), 102vh) rotate(var(--spin)); }
}

.pageconf i:nth-child(1)  { left:  3%; --drift:  22px; --spin: 520deg; animation-delay: .05s; animation-duration: 3.6s; background: var(--accent); }
.pageconf i:nth-child(2)  { left:  9%; --drift: -18px; --spin: -430deg; animation-delay: .40s; animation-duration: 3.1s; background: var(--yellow); width: 11px; height: 11px; }
.pageconf i:nth-child(3)  { left: 15%; --drift:  30px; --spin: 610deg; animation-delay: .95s; animation-duration: 4.0s; background: var(--accent-2); }
.pageconf i:nth-child(4)  { left: 21%; --drift: -26px; --spin: -560deg; animation-delay: .20s; animation-duration: 3.3s; background: var(--lilac); width: 8px; height: 16px; }
.pageconf i:nth-child(5)  { left: 27%; --drift:  14px; --spin: 470deg; animation-delay: 1.30s; animation-duration: 3.7s; background: var(--accent-dark); }
.pageconf i:nth-child(6)  { left: 33%; --drift: -32px; --spin: -640deg; animation-delay: .65s; animation-duration: 2.9s; background: var(--mint); width: 12px; height: 9px; }
.pageconf i:nth-child(7)  { left: 39%; --drift:  24px; --spin: 500deg; animation-delay: 1.65s; animation-duration: 3.5s; background: var(--accent); }
.pageconf i:nth-child(8)  { left: 45%; --drift: -12px; --spin: -520deg; animation-delay: .10s; animation-duration: 4.1s; background: var(--yellow); width: 9px; height: 9px; }
.pageconf i:nth-child(9)  { left: 51%; --drift:  34px; --spin: 590deg; animation-delay: 1.05s; animation-duration: 3.2s; background: var(--accent-2); width: 8px; height: 15px; }
.pageconf i:nth-child(10) { left: 57%; --drift: -22px; --spin: -480deg; animation-delay: .50s; animation-duration: 3.8s; background: var(--lilac); }
.pageconf i:nth-child(11) { left: 63%; --drift:  16px; --spin: 660deg; animation-delay: 1.85s; animation-duration: 3.0s; background: var(--accent-dark); width: 11px; height: 10px; }
.pageconf i:nth-child(12) { left: 69%; --drift: -30px; --spin: -540deg; animation-delay: .30s; animation-duration: 3.6s; background: var(--mint); }
.pageconf i:nth-child(13) { left: 75%; --drift:  26px; --spin: 450deg; animation-delay: 1.45s; animation-duration: 3.4s; background: var(--accent); width: 10px; height: 16px; }
.pageconf i:nth-child(14) { left: 81%; --drift: -16px; --spin: -600deg; animation-delay: .80s; animation-duration: 3.9s; background: var(--yellow); }
.pageconf i:nth-child(15) { left: 87%; --drift:  20px; --spin: 530deg; animation-delay: 2.10s; animation-duration: 3.1s; background: var(--accent-2); width: 9px; height: 9px; }
.pageconf i:nth-child(16) { left: 93%; --drift: -24px; --spin: -470deg; animation-delay: .15s; animation-duration: 3.5s; background: var(--lilac); }
.pageconf i:nth-child(17) { left: 12%; --drift:  28px; --spin: 570deg; animation-delay: 2.40s; animation-duration: 3.3s; background: var(--accent-dark); width: 8px; height: 13px; }
.pageconf i:nth-child(18) { left: 66%; --drift: -20px; --spin: -510deg; animation-delay: 2.65s; animation-duration: 3.7s; background: var(--accent); }

/* ---------- 5. Значки на полях ---------- */


/* значки по бокам — только на широких экранах, чтобы
   на телефоне не появилось ни пикселя горизонтального скролла */
.doodles { display: none; }

/* ---------- 6. Гирлянда флажков ---------- */

.bunting {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;

  position: relative;
  margin: 0 0 var(--gap);
  padding: 0 2px;
}

/* Верёвка провисает, а не идёт по линейке.
   Рисуем квадратичной кривой в SVG прямо в CSS (data-URI, файла не нужно):
   у скруглённой рамки линия истончалась к краям, у обводки толщина ровная.
   Цвет зашит потому, что --line одинаков во всех темах; если поменяешь
   переменную — поправь и stroke здесь. */
.bunting::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--sag) + 3px);

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 33' preserveAspectRatio='none'%3E%3Cpath d='M0 1.5 Q50 61.5 100 1.5' fill='none' stroke='%236b4a2b' stroke-width='3'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.bunting span {
  position: relative;   /* чтобы флажки рисовались поверх верёвки */
  display: block;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 20px solid var(--accent);
  transform-origin: top center;
}

/* Каждый флажок опускается на глубину дуги в своей точке.
   Отступ, а не transform: transform занят анимацией качания.
   Глубина считается по той же параболе, что рисует верёвку. */
.bunting span:nth-child(1),
.bunting span:nth-child(10) { margin-top: 0; }
.bunting span:nth-child(2),
.bunting span:nth-child(9)  { margin-top: calc(var(--sag) * 0.40); }
.bunting span:nth-child(3),
.bunting span:nth-child(8)  { margin-top: calc(var(--sag) * 0.69); }
.bunting span:nth-child(4),
.bunting span:nth-child(7)  { margin-top: calc(var(--sag) * 0.89); }
.bunting span:nth-child(5),
.bunting span:nth-child(6)  { margin-top: calc(var(--sag) * 0.99); }

.bunting span:nth-child(2n) { border-top-color: var(--yellow); }
.bunting span:nth-child(3n) { border-top-color: var(--accent-2); }
.bunting span:nth-child(4n) { border-top-color: var(--lilac); }

/* флажки качаются от сквозняка, каждый со своей задержкой */
.bunting span:nth-child(odd)  { animation: flag-sway-l 4.2s ease-in-out infinite; }
.bunting span:nth-child(even) { animation: flag-sway-r 4.8s ease-in-out infinite; }

.bunting span:nth-child(2)  { animation-delay: -0.4s; }
.bunting span:nth-child(3)  { animation-delay: -0.9s; }
.bunting span:nth-child(4)  { animation-delay: -1.3s; }
.bunting span:nth-child(5)  { animation-delay: -1.8s; }
.bunting span:nth-child(6)  { animation-delay: -2.2s; }
.bunting span:nth-child(7)  { animation-delay: -2.7s; }
.bunting span:nth-child(8)  { animation-delay: -3.1s; }
.bunting span:nth-child(9)  { animation-delay: -3.6s; }
.bunting span:nth-child(10) { animation-delay: -4.0s; }

@keyframes flag-sway-l {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(4deg); }
}

@keyframes flag-sway-r {
  0%, 100% { transform: rotate(8deg); }
  50%      { transform: rotate(-4deg); }
}

/* ---------- 7. Бегущая строка (CSS-анимация, без <marquee>) ---------- */

.marquee {
  position: relative;
  overflow: hidden;
  margin: 0 0 var(--gap);
  padding: 8px 0;
  border-top: var(--bd-thin);
  border-bottom: var(--bd-thin);
  background: var(--yellow);
}

.marquee__track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 18s linear infinite;
  will-change: transform;
}

/* Копий в ленте четыре, а сдвиг за цикл — ровно половина, то есть две.
   Чтобы в конце цикла не открывалась пустота, две копии обязаны
   перекрывать полосу целиком. Полоса не шире 596 px (--wrap 620 минус
   поля), значит копия должна быть не уже 298. Берём 300: при
   box-sizing: border-box в это число уже входят боковые поля. */
.marquee__item {
  flex: 0 0 auto;
  min-width: 300px;
  padding: 0 30px;
  text-align: center;
  white-space: nowrap;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}

@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---------- 8. Лента прогресса из сердечек ---------- */

.progress {
  margin: 0 0 var(--gap);
  padding: 8px 10px;
  text-align: center;
  letter-spacing: 0.18em;
  font-size: 22px;
  line-height: 1;

  background: var(--paper);
  border: var(--bd-thin);
  box-shadow: var(--shadow-sm);
}

.progress__heart {
  display: inline-block;
  color: var(--tint);
}

/* закрашенные сердца бьются волной слева направо */
.progress__heart.is-done {
  color: var(--accent);
  animation: heart-beat 3.2s ease-in-out infinite;
}

.progress__heart:nth-child(2) { animation-delay: 0.16s; }
.progress__heart:nth-child(3) { animation-delay: 0.32s; }
.progress__heart:nth-child(4) { animation-delay: 0.48s; }
.progress__heart:nth-child(5) { animation-delay: 0.64s; }
.progress__heart:nth-child(6) { animation-delay: 0.80s; }
.progress__heart:nth-child(7) { animation-delay: 0.96s; }
.progress__heart:nth-child(8) { animation-delay: 1.12s; }

@keyframes heart-beat {
  0%, 62%, 100% { transform: scale(1); }
  70%           { transform: scale(1.28); }
  78%           { transform: scale(1.04); }
  86%           { transform: scale(1.16); }
}

/* Восьмое сердце — намёк на страницу, которой в квесте «нет».
   Стоит на всех страницах бирюзовым, чтобы отличаться от остальных,
   и приглушено, пока пасхалка не найдена. */
.progress__heart--secret {
  color: var(--accent-2);
  opacity: 0.4;
  /* кегль и выключка — как у остальных сердец, иначе восьмое
     выглядит мельче и сидит ниже строки */
  font-size: inherit;
  vertical-align: baseline;
}

/* на самой пасхалке — в полную силу и с пульсом */
.progress__heart--secret.is-done {
  color: var(--accent-2);
  opacity: 1;
  animation: heart-beat 2.2s ease-in-out infinite;
}


/* ---------- 9. Заголовки ---------- */

.stage-title {
  margin: 0 0 var(--gap);
  padding: 10px 14px;

  font-size: 27px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;

  color: #fffdf5;
  background: var(--accent);
  border: var(--bd);
  box-shadow: var(--ring), var(--shadow);
  text-shadow: 2px 2px 0 var(--accent-dark);
  /* Сначала появление, потом бесконечное дыхание тенью.
     Дышит именно тень, а не масштаб: transform занят наклоном
     .tilt-l / .tilt-r и любая анимация его затрёт.
     Снова без шортката — чтобы задержка из nth-child уцелела. */
  animation-name: block-in, title-breathe;
  animation-duration: 0.5s, 5.5s;
  animation-timing-function: ease-out, ease-in-out;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: both, none;
}

@keyframes title-breathe {
  0%, 100% { box-shadow: var(--ring), 6px 6px 0 var(--line); }
  50%      { box-shadow: var(--ring), 8px 8px 0 var(--line); }
}

.stage-title small {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
  text-shadow: none;
  opacity: 0.92;
}

.h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-dark);
}

/* ---------- 10. Рамка-блок + скотч по углам ---------- */

.frame {
  position: relative;
  margin: 0 0 var(--gap-lg);
  padding: 18px 16px;

  background: var(--paper-warm);
  border: var(--bd);
  box-shadow: var(--ring), var(--shadow);
}

/* скотч-васи: по диагонали, чтобы не задеть ярлык в левом верхнем углу */
.frame::before,
.frame::after {
  content: "";
  position: absolute;
  width: 56px;
  height: 19px;

  background-color: var(--tint);
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.55) 0 4px,
    transparent 4px 8px
  );
  border: 1px solid rgba(107, 74, 43, 0.35);
  opacity: 0.9;
}

.frame::before {
  top: -10px;
  right: 12px;
  transform: rotate(19deg);
}

.frame::after {
  bottom: -10px;
  left: 12px;
  transform: rotate(19deg);
}

.frame--mint  { background: var(--mint); }

.frame--double {
  padding: 8px;
  background: var(--accent);
  border: var(--bd);
}

.frame--double > .frame__inner {
  padding: 16px 14px;
  background: var(--paper);
  border: var(--bd-thin);
}

/* Главный блок страницы — загадка. После того как с этапов ушли
   заголовок и подписи, акцент держит он один, поэтому крупнее,
   просторнее и с более тяжёлой тенью, чем у остальных рамок. */
.frame--hero {
  margin-bottom: var(--gap-lg);
  box-shadow: var(--ring), 9px 9px 0 var(--line);
}

.frame--hero > .frame__inner {
  padding: 22px 16px 20px;
}

/* тетрадная линовка под текстом загадки */
.lined {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 calc(1.7em - 1px),
    rgba(107, 74, 43, 0.16) calc(1.7em - 1px) 1.7em
  );
  background-position: 0 0.5em;
}

.frame__label {
  display: inline-block;
  margin: -30px 0 12px -4px;
  padding: 3px 10px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--yellow);
  border: var(--bd-thin);
  transform: rotate(-1.5deg);
  position: relative;
  z-index: 1;
  /* стикер чуть покачивается, будто приклеен не насмерть */
  animation: sticker-rock 5s ease-in-out infinite;
}

@keyframes sticker-rock {
  0%, 100% { transform: rotate(-1.5deg); }
  50%      { transform: rotate(-3.4deg); }
}

/* ---------- 11. Текст загадки ---------- */

.hint {
  margin: 0;
  font-size: 24px;
  line-height: 1.65;
  text-align: center;
}

.hint em {
  font-style: normal;
  background: var(--yellow);
  padding: 0 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.note {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- 12. Подсказка 2: кнопка -> подтверждение -> текст ----------
   Нарочно не похожа на «Подсказку 1»: та — плотная рамка в рамке,
   эта — лёгкий пунктирный блок. Кнопка стоит по центру внутри него,
   текст раскрывается там же, под пунктирной чертой.
   ----------------------------------------------------------------------- */

.hint2 {
  margin: 0 0 var(--gap-lg);
  padding: 20px 14px;
  text-align: center;

  background: var(--paper);
  border: 4px dashed var(--accent);
  box-shadow: var(--shadow-sm);
}

.hint2__body {
  margin-top: 4px;
  animation: fade-up 0.5s ease-out both;
}

.hint2__body:focus { outline: none; }

/* ---------- 13. Окно подтверждения ---------- */

.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 22px 18px 18px;

  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  text-align: center;

  background: var(--paper-warm);
  border: var(--bd);
  box-shadow: var(--ring), var(--shadow);
}

.modal::backdrop {
  background: rgba(58, 42, 24, 0.55);
}

.modal__warn {
  margin: 0 0 18px;
  font-size: 19px;
  font-weight: 700;
  color: var(--accent-dark);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn--ghost {
  background: var(--paper);
  font-weight: 400;
}

/* ---------- 14. Разделители ---------- */

.divider {
  display: block;
  margin: 0 auto var(--gap-lg);
  text-align: center;
}

.divider img {
  display: block;
  margin: 0 auto;
  max-width: 90%;
}

/* разделитель из сердечек и цветочков — работает без картинок */
.divider--hearts {
  color: var(--accent);
  font-size: 18px;
  letter-spacing: 0.5em;
  line-height: 1;
}

.divider--hearts::before {
  content: "♥ ✿ ♥ ✿ ♥";
  display: inline-block;
  animation: divider-pulse 4.5s ease-in-out infinite;
}

@keyframes divider-pulse {
  0%, 100% { opacity: 0.75; letter-spacing: 0.5em; }
  50%      { opacity: 1;    letter-spacing: 0.62em; }
}


/* ---------- 15. Тематическая картинка этапа ---------- */

.photo {
  margin: 0 0 var(--gap-lg);
  text-align: center;
}

/* Обёртка нужна, чтобы позиционировать подпись поверх картинки.
   Ширина во весь контейнер — картинка идёт вровень с блоками выше.
   Покачивание висит именно здесь, а не на самой картинке: так подпись
   качается вместе с ней, будто приклеена. */
.photo__frame {
  position: relative;
  width: 100%;
  margin: 0 auto;
  animation: sway 6s ease-in-out infinite;
  transform-origin: top center;
}

.photo img,
.photo .imgslot {
  display: block;
  width: 100%;
  margin: 0 auto;
  padding: 8px;
  background: var(--paper);
  border: var(--bd);
  box-shadow: 5px 5px 0 var(--accent);
}

@keyframes sway {
  0%, 100% { transform: rotate(-1.1deg); }
  50%      { transform: rotate(1.1deg); }
}

.photo figcaption {
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ---------- 16. Слот под картинку (пока файла нет) ----------
   Когда картинка появится в img/ — меняем <div class="imgslot"> на <img>.
   ------------------------------------------------------------ */

.imgslot {
  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0 auto;
  padding: 10px 12px;

  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--ink-soft);

  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0 10px,
    rgba(107, 74, 43, 0.08) 10px 20px
  );
  border: 3px dashed var(--line-soft);
}

.imgslot--square { width: 100%; aspect-ratio: 1 / 1; }
.imgslot--icon   { width: 160px; max-width: 100%; aspect-ratio: 1 / 1; }
.imgslot--game   { width: 100%; aspect-ratio: 1 / 1; padding: 4px; font-size: 12px; letter-spacing: 0; }

/* ---------- 17. Подпись поверх картинки ---------- */

.photo__bubble {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 1;

  margin: 0;
  padding: 10px 12px;

  font-size: 16px;
  line-height: 1.45;
  text-align: center;

  background: var(--paper);
  border: var(--bd-thin);
  box-shadow: var(--shadow-sm);
  /* никакого собственного поворота: подпись лежит ровно по рамке
     картинки и качается только вместе с ней */
}

/* ---------- 18. Кнопка (тапабельная, минимум 44×44) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 22px;

  font-family: var(--font);
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);

  background: var(--yellow);
  border: var(--bd);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);

  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--line);
}

/* ---------- 19. Заглушка «под конструкцией» ---------- */

.under-construction {
  max-width: 520px;
  margin: 0 auto var(--gap-lg);
  padding: 24px 18px;
  text-align: center;
  background: var(--paper-warm);
  border: var(--bd);
  box-shadow: var(--ring), var(--shadow);
}

.under-construction img { display: block; margin: 0 auto 16px; }
.under-construction .stage-title { margin-top: 18px; }
.under-construction .divider--hearts { margin-top: 20px; }

/* ---------- 20. Финальная мини-игра ---------- */

.game {
  margin: 0 0 var(--gap-lg);
}

.game__col-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  text-align: center;
}

/* две картинки в ряд */
.game__images {
  display: flex;
  gap: 12px;
  margin: 0 0 var(--gap-lg);
}

.game__images .card {
  flex: 1 1 50%;
  min-width: 0;
}

/* слова плиткой, по две в ряд на телефоне */
.game__words {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.game__words .card {
  flex: 1 1 calc(50% - 5px);
  min-width: 0;
}

/* счётчик найденных слов в углу картинки */
.card__count {
  position: absolute;
  right: -6px;
  bottom: -10px;

  padding: 2px 7px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;

  color: #fffdf5;
  background: var(--line);
  border: 2px solid var(--paper);
  transform: rotate(-4deg);
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  min-height: var(--tap);
  padding: 6px;

  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);

  background: var(--paper);
  border: var(--bd);
  box-shadow: var(--shadow-sm);

  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.card--img { padding: 5px; min-height: 84px; }

.card--img img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.card--word {
  padding: 10px 8px;
  background: var(--paper-warm);
  word-break: break-word;
  hyphens: auto;
}

.card:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--line);
}

.card.is-selected {
  background: var(--yellow);
  box-shadow: 5px 5px 0 var(--accent);
  outline: 3px dashed var(--accent);
  outline-offset: 3px;
}

/* у каждой собранной пары свой цвет: к концу игры доска как коробка пастилы */
.pair-0 { --pair: #c0395c; --pair-bg: #ffe0ea; }
.pair-1 { --pair: #1f7a5e; --pair-bg: #d8f2e5; }
.pair-2 { --pair: #6b4bb0; --pair-bg: #e7dcf8; }
.pair-3 { --pair: #9a6a00; --pair-bg: #fff0bf; }
.pair-4 { --pair: #2f6bb0; --pair-bg: #dbe9fb; }

.card.is-solved {
  background: var(--pair-bg, var(--mint));
  border-color: var(--pair, var(--accent-2));
  box-shadow: 4px 4px 0 var(--pair, var(--accent-2));
  pointer-events: none;
  cursor: default;
  animation: pop 0.35s ease-out;
}

.card.is-solved::after {
  content: "♥";
  position: absolute;
  top: -12px;
  right: -10px;
  width: 28px;
  height: 28px;
  line-height: 26px;
  font-size: 16px;
  color: #fffdf5;
  background: var(--pair, var(--accent-2));
  border: 2px solid var(--line);
  transform: rotate(6deg);
}

.card.is-wrong {
  animation: wiggle 0.4s ease-in-out;
  background: #ffe0e6;
}

@keyframes pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.09) rotate(-1.5deg); }
  100% { transform: scale(1); }
}

@keyframes wiggle {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-7px) rotate(-1deg); }
  40%      { transform: translateX(6px) rotate(1deg); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}

/* конфетти на верной паре: контейнер добавляет final.js и убирает через 900 мс */
.confetti {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--pair, var(--accent));
  animation: confetti-fly 0.9s ease-out forwards;
}

.confetti i:nth-child(1) { --dx:  -46px; --dy: -34px; background: #c0395c; }
.confetti i:nth-child(2) { --dx:   44px; --dy: -30px; background: #1f7a5e; }
.confetti i:nth-child(3) { --dx:  -30px; --dy:  38px; background: #9a6a00; }
.confetti i:nth-child(4) { --dx:   34px; --dy:  40px; background: #6b4bb0; }
.confetti i:nth-child(5) { --dx:  -54px; --dy:   6px; background: #2f6bb0; }
.confetti i:nth-child(6) { --dx:   52px; --dy:   8px; background: #e0a33c; }
.confetti i:nth-child(7) { --dx:   -8px; --dy: -48px; background: #b23a7a; }
.confetti i:nth-child(8) { --dx:    6px; --dy:  50px; background: #176b6b; }

@keyframes confetti-fly {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  to   { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(220deg); }
}

.game__status {
  margin: 0 0 var(--gap);
  padding: 8px 12px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  background: var(--lilac);
  border: var(--bd-thin);
}

/* ---------- 21. Финальный текст ---------- */

.final-text {
  display: none;
  margin: 0 0 var(--gap-lg);
  padding: 20px 16px;

  font-size: 20px;
  line-height: 1.7;
  text-align: center;

  background: var(--paper-warm);
  border: var(--bd);
  box-shadow: var(--ring), var(--shadow);
}

.final-text.is-visible {
  display: block;
  animation: fade-up 0.9s ease-out both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 22. Служебное ---------- */

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

/* ---------- 23. Экраны пошире (десктоп — вторично) ---------- */

@media (min-width: 700px) {
  :root { --fs-base: 20px; }

  .wrap { padding-top: 26px; }

  .stage-title { font-size: 33px; }
  .hint { font-size: 27px; }

  .game { gap: 20px; }
  .card--img { min-height: 120px; }
  .card--word { font-size: 19px; }

  .photo__bubble { font-size: 18px; padding: 12px 16px; }

  /* значки на полях: места хватает только здесь */
  .doodles {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
  }

  .doodles span {
    position: absolute;
    font-size: 26px;
    color: var(--accent);
    opacity: 0.35;
  }

  .doodles span:nth-child(1) { top: 60px;  left: -42px;  transform: rotate(-12deg); }
  .doodles span:nth-child(2) { top: 260px; right: -44px; transform: rotate(14deg); }
  .doodles span:nth-child(3) { top: 520px; left: -46px;  transform: rotate(8deg); }
  .doodles span:nth-child(4) { top: 760px; right: -40px; transform: rotate(-10deg); }
}

/* ---------- 24. Уважение к prefers-reduced-motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .marquee__track {
    animation: none;
    transform: none;
  }

  .marquee__item + .marquee__item { display: none; }

  .wrap > *:not(.final-text) {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .photo__frame,
  .progress__heart.is-done,
  .progress__heart--secret.is-done,
  .divider--hearts::before {
    animation: none;
    transform: none;
  }

  /* у этих двух в базовом состоянии свой поворот — его сохраняем,
     убираем только анимацию */
  .stage-title { animation: none; }

  .frame__label {
    animation: none;
    transform: rotate(-1.5deg);
  }

  .hint2__body { animation: none; }

  .bunting span:nth-child(odd)  { animation: none; transform: rotate(-3deg); }
  .bunting span:nth-child(even) { animation: none; transform: rotate(3deg); }

  /* конфетти при открытии страницы не показываем вовсе */
  .pageconf { display: none; }

  .card.is-solved,
  .card.is-wrong,
  .final-text.is-visible,
  .hint2[open] .hint2__body {
    animation: none;
  }

  .final-text.is-visible {
    opacity: 1;
    transform: none;
  }

  .confetti { display: none; }

  .tilt-l, .tilt-r { transform: none; }

  * { transition: none !important; }
}
