/* Квест по галерее: демо на телефоне посетителя.
   Мобильный экран первичен, десктоп это тот же кадр шириной до 480 px
   по центру. Цвета бренда учреждения задаются переменными на :root,
   ими же красится сертификат (app.js читает их через getComputedStyle). */

@font-face {
  font-family: "Piazzolla";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(/fonts/piazzolla-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Piazzolla";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(/fonts/piazzolla-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2116, U+2122;
}
@font-face {
  font-family: "Piazzolla";
  font-style: italic;
  font-weight: 300 900;
  font-display: swap;
  src: url(/fonts/piazzolla-italic-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Piazzolla";
  font-style: italic;
  font-weight: 300 900;
  font-display: swap;
  src: url(/fonts/piazzolla-italic-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(/fonts/golos-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(/fonts/golos-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2122;
}

:root {
  --accent: #7a1f2b;        /* бордо: цвет бренда галереи в демо */
  --accent-ink: #ffffff;
  --accent-soft: #f3e3e3;
  --paper: #f5f0e6;
  --paper-2: #fbf8f2;
  --ink: #1e1a16;
  --ink-2: #5d564d;
  --line: #d9d0c1;
  --gold: #b8955a;
  --ok: #2f7a4b;
  --ok-soft: #e0f0e6;
  --bad: #b3362b;
  --bad-soft: #f8e2df;
  --serif: "Piazzolla", "Times New Roman", serif;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 18px;
  --shadow: 0 14px 40px rgba(60, 40, 20, .14), 0 2px 6px rgba(60, 40, 20, .08);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
:root[data-accent="green"] { --accent: #1f5c46; --accent-soft: #dfeee6; }
:root[data-accent="blue"] { --accent: #1f3f7a; --accent-soft: #dfe6f3; }
:root[data-accent="ink"] { --accent: #1e1a16; --accent-soft: #e6e2dc; }
/* Внутри рамки-телефона на витрине сверху нарисована чёлка: шапку ниже,
   а полосу прокрутки прячем, чтобы кадр выглядел как экран телефона. */
:root.embed { --sat: 32px; scrollbar-width: none; }
:root.embed::-webkit-scrollbar { display: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.45 var(--sans);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; }
button, [role="button"], .letter { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Кадр приложения: на телефоне во всю ширину, на большом экране колонка 480 */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--paper);
}
@media (min-width: 520px) {
  body { background: #e9e2d5; }
  .app { box-shadow: 0 0 0 1px var(--line), 0 30px 80px rgba(60, 40, 20, .18); }
}

/* Экраны сменяют друг друга с лёгким подъёмом */
.screen { display: flex; flex-direction: column; flex: 1; animation: rise .42s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- шапка бренда ---------- */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + var(--sat)) 18px 12px;
  font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
}
.brand__mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand__mark::after { content: ""; position: absolute; inset: 6px; border: 1.5px solid var(--accent-ink); border-radius: 2px; opacity: .9; }
.brand__name { font-weight: 600; color: var(--ink); }
.brand__spacer { margin-left: auto; letter-spacing: 0; text-transform: none; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- стартовый экран ---------- */
.hero { padding: 6px 22px 10px; }
.hero__eyebrow { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hero h1 { font: 700 44px/1.02 var(--serif); letter-spacing: -.01em; margin: 10px 0 12px; }
.hero p { margin: 0 0 8px; color: var(--ink-2); }
.hero__meta { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0 4px; font-size: 14px; color: var(--ink-2); }
.hero__meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero__meta i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

.strip {
  margin: 14px 22px 0; border-radius: var(--r); overflow: hidden; position: relative;
  aspect-ratio: 16 / 9; background: #ddd2bd;
}
.strip img { width: 100%; height: 100%; object-fit: cover; }
.strip__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 14px 10px; font-size: 13px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .55)); }

.form { padding: 18px 22px 0; }
.field { display: block; }
.field span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 52px; padding: 0 16px; font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper-2); outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.hint-line { font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }

.actions { padding: 18px 22px calc(22px + var(--sab)); margin-top: auto; display: grid; gap: 10px; }
.btn {
  height: 56px; border-radius: 16px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600; font-size: 17px; letter-spacing: .01em;
  transition: transform .12s var(--ease), background .2s, box-shadow .2s;
  user-select: none;
}
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 24px rgba(60, 30, 20, .22); }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .btn--primary { box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 30%, transparent); }
}
.btn--ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn--soft { background: var(--accent-soft); color: var(--accent); }
.btn--sm { height: 44px; font-size: 15px; padding: 0 16px; border-radius: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- прогресс маршрута ---------- */
.rail { display: flex; align-items: center; gap: 5px; padding: 0 18px 10px; }
.rail i {
  flex: 1; height: 5px; border-radius: 3px; background: var(--line);
  transition: background .3s, transform .3s;
}
.rail i.done { background: var(--gold); }
.rail i.now { background: var(--accent); transform: scaleY(1.6); }
.rail b { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-left: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- карточка перехода ---------- */
.route { padding: 6px 22px 0; }
.route__hall { font: 700 40px/1 var(--serif); margin: 4px 0 6px; }
.route__where { color: var(--ink-2); margin: 0 0 18px; }
.route__card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: center;
}
.route__thumb { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; background: #ddd2bd; }
.route__title { font: 600 19px/1.2 var(--serif); margin: 0 0 4px; }
.route__artist { font-size: 14px; color: var(--ink-2); margin: 0; }
.route__tip { margin: 16px 0 0; font-size: 14px; color: var(--ink-2); display: flex; gap: 10px; align-items: flex-start; }
.route__tip svg { flex: none; width: 20px; height: 20px; color: var(--gold); margin-top: 1px; }

/* ---------- экспонат ---------- */
.art { margin: 0; padding: 0 22px; }
.art__frame {
  position: relative; border-radius: 6px; overflow: hidden; background: #cfc3ad;
  box-shadow: 0 0 0 5px #e8d9b6, 0 0 0 6px #b8955a, 0 0 0 9px #f2e8d3, 0 0 0 10px #a5834d, var(--shadow);
  margin: 10px 10px 16px;
  touch-action: manipulation;
}
/* Рамка держит пропорцию из data.js, картинка заполняет её целиком: тогда
   проценты целей «найди на картине» совпадают с тем, что видно. */
.art__frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art__frame--spot { cursor: crosshair; }
.art__zoom {
  position: absolute; right: 6px; bottom: 6px; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(30, 26, 22, .75); color: #fff; border: 0; display: grid; place-items: center; cursor: pointer;
}
.art__zoom svg { width: 20px; height: 20px; }
.art__cap { padding: 0 10px; }
.art__cap b { font: 600 20px/1.2 var(--serif); display: block; }
.art__cap span { font-size: 14px; color: var(--ink-2); }
.art__target {
  position: absolute; border: 3px solid var(--ok); border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(30, 26, 22, .28); animation: pop .5s var(--ease) both;
}
.spot__ring {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 3px solid var(--bad); pointer-events: none; animation: ring .5s var(--ease) both;
}
.spot__ring.ok { border-color: var(--ok); }
@keyframes ring { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.story { padding: 0 22px; color: var(--ink-2); margin: 0 0 14px; }

/* ---------- задание ---------- */
.task { padding: 0 22px; }
.task__q { font: 600 22px/1.25 var(--serif); margin: 0 0 14px; }
.options { display: grid; gap: 8px; }
.opt {
  min-height: 52px; padding: 12px 16px; text-align: left; border-radius: 14px; cursor: pointer;
  background: var(--paper-2); border: 1.5px solid var(--line); transition: background .2s, border-color .2s, transform .12s;
}
.opt:active { transform: scale(.99); }
.opt.ok { background: var(--ok-soft); border-color: var(--ok); }
.opt.bad { background: var(--bad-soft); border-color: var(--bad); animation: shake .4s; }
.opt[disabled] { cursor: default; }
.opt.dim { opacity: .45; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; align-items: center; margin-bottom: 10px; }
.stepper button { height: 64px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--paper-2); font-size: 30px; cursor: pointer; }
.stepper output { display: block; text-align: center; font: 700 52px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stepper.bad output { color: var(--bad); animation: shake .4s; }

.spot__note { font-size: 14px; color: var(--ink-2); margin: 0 0 10px; }

.feedback {
  margin: 12px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--ok-soft); color: var(--ok);
  font-weight: 600; display: flex; gap: 10px; align-items: flex-start;
}
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback svg { flex: none; width: 22px; height: 22px; }
.feedback small { display: block; font-weight: 400; color: var(--ink-2); margin-top: 2px; }
.hintbox { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--paper-2); border: 1px dashed var(--line); color: var(--ink-2); font-size: 15px; }

.fact { padding: 0 22px; margin: 14px 0 0; }
.fact p { margin: 0; padding: 14px 16px; border-left: 3px solid var(--gold); background: var(--paper-2); border-radius: 0 12px 12px 0; color: var(--ink-2); font-size: 15px; }

/* ---------- буквы ---------- */
.tray {
  position: sticky; bottom: 0; z-index: 3; margin-top: 0;
  padding: 10px 18px calc(10px + var(--sab)); background: rgba(248, 244, 236, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px;
}
.tray small { font-size: 12px; color: var(--ink-2); margin-right: 6px; white-space: nowrap; }
.tray__slots { display: flex; gap: 4px; flex: 1; min-width: 0; justify-content: flex-end; }
.letter {
  width: 28px; height: 34px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--paper-2);
  display: grid; place-items: center; font: 700 16px/1 var(--serif); color: var(--ink);
}
/* На узких телефонах десять плиток ужимаются, а не вылезают за край */
.tray__slots .letter { flex: 1 1 0; width: auto; min-width: 0; max-width: 28px; }
.letter.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); animation: pop .4s var(--ease) both; }
.letter.new { animation: flip .6s var(--ease) both; }
@keyframes flip { 0% { transform: rotateX(90deg); } 60% { transform: rotateX(-15deg); } 100% { transform: none; } }

/* ---------- слово ---------- */
.word { padding: 0 22px; }
/* Слово всегда в одну строку: сетка на столько колонок, сколько букв */
.word__slots { display: grid; grid-template-columns: repeat(var(--n, 10), 1fr); gap: 4px; margin: 12px 0 18px; min-height: 46px; }
.word__slots .letter { width: auto; height: 44px; font-size: 21px; cursor: pointer; }
.word__slots .letter:empty { background: transparent; border-style: dashed; }
.word__pool { display: flex; gap: 6px; flex-wrap: wrap; }
.word__pool .letter { width: 44px; height: 52px; font-size: 24px; cursor: pointer; }
.word__pool .letter.used { opacity: .25; pointer-events: none; }
.word__slots.bad .letter { animation: shake .4s; border-color: var(--bad); }
.word__slots.ok .letter { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- финал ---------- */
.final { padding: 6px 22px 0; text-align: center; }
.final__score { font: 700 84px/1 var(--serif); color: var(--accent); letter-spacing: -.02em; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.final__label { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.final__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 0; }
.final__stats div { background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; }
.final__stats b { display: block; font: 700 24px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.final__stats span { font-size: 12px; color: var(--ink-2); }

.board { margin: 22px 22px 0; text-align: left; }
.board h2 { font: 700 24px/1.1 var(--serif); margin: 0 0 4px; }
.board p { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.board ol { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--paper-2); }
.board li { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 15px; }
.board li:first-child { border-top: 0; }
.board li.me { background: var(--accent-soft); font-weight: 600; }
.board li span { min-width: 0; overflow-wrap: anywhere; }
.board li em { font-style: normal; color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 14px; }
.board li b { font-variant-numeric: tabular-nums; }
.board li i { font-style: normal; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.board__more { display: block; text-align: center; padding: 10px; font-size: 14px; color: var(--ink-2); }

.cert { margin: 22px 22px 0; text-align: left; }
.cert h2 { font: 700 24px/1.1 var(--serif); margin: 0 0 4px; }
.cert p { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.cert canvas { width: 100%; height: auto; border-radius: 12px; box-shadow: var(--shadow); background: #f6f1e7; }
.cert__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* ---------- лайтбокс ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 20; background: rgba(20, 16, 12, .96); overflow: auto;
  display: flex; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; animation: fade .2s both;
}
.lightbox img { width: 100%; height: auto; margin: auto; transition: width .25s var(--ease); }
.lightbox.x2 img { width: 220%; max-width: none; }
.lightbox__close { position: fixed; top: calc(12px + var(--sat)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 22px; cursor: pointer; }
.lightbox__tip { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--sab)); text-align: center; color: rgba(255, 255, 255, .7); font-size: 13px; pointer-events: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- шторка правил ---------- */
.sheet { position: fixed; inset: 0; z-index: 15; background: rgba(20, 16, 12, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s both; }
.sheet__in {
  width: 100%; max-width: 480px; background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 18px 22px calc(22px + var(--sab)); animation: rise .3s var(--ease) both;
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
}
.sheet__in h2 { font: 700 24px/1.1 var(--serif); margin: 4px 0 12px; }
.sheet__in ol { margin: 0 0 16px; padding-left: 20px; color: var(--ink-2); }
.sheet__in li { margin: 0 0 8px; }
.sheet__in li b { color: var(--ink); }

/* ---------- прочее ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.note { padding: 0 22px; font-size: 13px; color: var(--ink-2); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
