/* Шрифты Playfair Display и Inter (Google Fonts, OFL) лежат рядом — с Google ничего не грузим */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/inter-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-cyrillic-wght-italic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-latin-wght-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Тёмное дерево, красный лак, золото, бумага васи */
:root {
  --bg: #120a06;
  --wood: #3a2213;
  --lacquer: #b3121c;
  --red: #e0342c;
  --red-hi: #f0513f;
  --red-lo: #7a0c12;
  --gold: #e0b45c;
  --gold-hi: #ffd26a;
  --cream: #f6ecd9;
  --text: #f6ecd9;
  --text-soft: #c2a98c;
  --glass: rgba(18, 10, 6, .8);
  --line: rgba(255, 255, 255, .13);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --cjk: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif CJK JP", "Noto Serif JP", "MS Mincho", serif;
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --gut: 14px;
  --brush: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }
kbd {
  display: inline-block; font: 600 11px/1 var(--sans); padding: 3px 6px 4px; border-radius: 5px; margin: 0 2px;
  border: 1px solid rgba(224, 180, 92, .55); color: var(--gold); background: rgba(224, 180, 92, .08);
}

/* ---------- сцена: видео рисуется в canvas, сам <video> скрыт ---------- */
#cam { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: 0; top: 0; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: crosshair; }

/* ---------- кнопки ---------- */
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--glass); display: grid; place-items: center; padding: 0; flex: none;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background .15s, border-color .15s, transform .08s;
}
.icon-btn:hover { background: rgba(52, 28, 16, .9); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { border-color: var(--gold); background: rgba(224, 180, 92, .2); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#btnCam .slash { stroke: #ff8a78; }
#btnCam.on .slash { display: none; }
#btnMute .x { display: none; }
#btnMute.on .x { display: block; stroke: #ff8a78; }
#btnMute.on .wave { display: none; }
#btnSkel.on { color: var(--gold-hi); }

.btn {
  height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(18, 10, 6, .72); font-weight: 600; white-space: nowrap; transition: filter .15s, transform .08s, background .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.btn:hover { background: rgba(52, 28, 16, .9); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.play {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  height: 60px; min-width: 260px; padding: 0 40px; border-radius: 999px; border: 0;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 50%, #a81c16);
  color: #fff; font-weight: 700; font-size: 19px; letter-spacing: .02em;
  box-shadow: 0 6px 0 #5e0d0a, 0 18px 36px -10px rgba(224, 52, 44, .7), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.play:hover { filter: brightness(1.08); }
.play:active { transform: translateY(4px); box-shadow: 0 2px 0 #5e0d0a, 0 8px 20px -8px rgba(224, 52, 44, .6), inset 0 1px 0 rgba(255, 255, 255, .35); }
.play.small { height: 48px; min-width: 0; padding: 0 26px; font-size: 16px; box-shadow: 0 4px 0 #5e0d0a, inset 0 1px 0 rgba(255, 255, 255, .35); }
.link {
  border: 0; background: none; color: var(--text-soft); font-size: 15px; padding: 10px 12px;
  text-decoration: underline; text-decoration-color: rgba(194, 169, 140, .45); text-underline-offset: 4px;
}
.link:hover { color: var(--cream); }

/* ---------- панель сверху справа ---------- */
.bar {
  position: fixed; z-index: 5; top: calc(var(--gut) + var(--st)); right: calc(var(--gut) + var(--sr));
  display: flex; gap: 8px; align-items: center;
}
.rec-btn {
  height: 42px; padding: 0 14px 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--glass); display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); white-space: nowrap; transition: background .15s, border-color .15s;
}
.rec-btn:hover { background: rgba(52, 28, 16, .9); }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: #ff4d3d; box-shadow: 0 0 0 3px rgba(255, 77, 61, .2); flex: none; }
body.recording .rec-btn { border-color: #ff4d3d; background: rgba(120, 16, 12, .75); }
body.recording .rec-dot { animation: recblink 1s steps(2, start) infinite; }
@keyframes recblink { 50% { opacity: .2; } }

/* ---------- настройки ---------- */
.pop {
  position: fixed; z-index: 6; top: calc(var(--gut) + var(--st) + 52px); right: calc(var(--gut) + var(--sr));
  width: min(360px, calc(100vw - 2 * var(--gut))); padding: 14px 16px 12px; border-radius: 16px;
  background: rgba(20, 11, 7, .94); border: 1px solid rgba(224, 180, 92, .35);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .8); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: grid; gap: 12px; max-height: calc(100vh - 90px); overflow: auto;
}
.prow { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; font-size: 14px; }
.prow > span { color: var(--text-soft); font-weight: 600; }
.prow input[type="range"] { grid-column: 1 / 2; width: 100%; accent-color: var(--red); }
.prow output { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); min-width: 3.2em; text-align: right; }
label.prow:first-child { grid-template-columns: 1fr auto; }
label.prow:first-child span { grid-column: 1 / 3; }
.prow.chk { grid-template-columns: auto 1fr; cursor: pointer; }
.prow.chk input { width: 18px; height: 18px; accent-color: var(--red); }
.prow.chk span { color: var(--cream); font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: rgba(255, 255, 255, .04); }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.seg button[aria-pressed="true"] { background: var(--red); color: #fff; }
.keys { margin: 0; font-size: 12px; color: var(--text-soft); line-height: 1.9; }

/* ---------- стартовый экран ---------- */
.intro {
  position: fixed; inset: 0; z-index: 4; display: grid; place-items: center; overflow: auto;
  padding: calc(64px + var(--st)) calc(var(--gut) + var(--sr)) calc(var(--gut) + var(--sb)) calc(var(--gut) + var(--sl));
  background: radial-gradient(120% 90% at 50% 45%, rgba(18, 10, 6, .35), rgba(10, 5, 3, .82));
}
.intro-card { width: min(820px, 100%); text-align: center; display: grid; justify-items: center; gap: 14px; }
.title { margin: 0; display: flex; align-items: center; justify-content: center; gap: 14px; line-height: 1; }
.title .brush {
  font: italic 900 clamp(38px, 7.2vw, 78px)/1.05 var(--serif); color: #fff4dc; letter-spacing: -.01em;
  padding: .22em .7em .3em; background: var(--brush) center / 100% 100% no-repeat;
  text-shadow: 0 2px 0 rgba(60, 6, 4, .6), 0 10px 30px rgba(0, 0, 0, .45);
}
.seal {
  flex: none; width: clamp(38px, 5.2vw, 56px); height: clamp(38px, 5.2vw, 56px); border-radius: 8px; display: grid; place-items: center;
  background: var(--red); color: #fff4e6; font: 700 clamp(22px, 3.2vw, 34px)/1 var(--cjk); transform: rotate(-6deg);
  box-shadow: inset 0 0 0 3px rgba(255, 244, 230, .85), inset 0 0 0 5px var(--red), 0 8px 18px -6px rgba(0, 0, 0, .6);
}
.lead { margin: 0; max-width: 34em; font-size: clamp(15px, 1.8vw, 18px); line-height: 1.45; color: rgba(246, 236, 217, .9); }
.steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.steps li {
  display: grid; justify-items: center; gap: 2px; padding: 10px 10px 12px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(40, 22, 12, .78), rgba(20, 11, 7, .78)); border: 1px solid rgba(224, 180, 92, .22);
  counter-increment: step; position: relative;
}
.steps li::before {
  content: counter(step); position: absolute; top: 8px; left: 10px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font: 700 12px/1 var(--sans); color: #fff; background: var(--red);
}
.steps b { font: italic 800 17px/1.2 var(--serif); color: var(--cream); margin-top: 2px; }
.steps span { font-size: 13px; color: var(--text-soft); }
.demo { width: 100%; max-width: 170px; height: auto; aspect-ratio: 3 / 2; overflow: visible; }
.hint, .privacy { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft); }
.hint svg, .privacy svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hint { color: var(--cream); font-weight: 600; }
.cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; margin-top: 4px; }
.privacy { font-size: 13px; }

/* анимированная инструкция */
.demo-hands .frame { fill: none; stroke: rgba(224, 180, 92, .7); stroke-width: 2; stroke-linecap: round; }
.demo .hand { fill: none; stroke: var(--cream); stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.demo-hands .hl { animation: rise 2.6s ease-in-out infinite; }
.demo-hands .hr { animation: rise 2.6s ease-in-out .15s infinite; }
@keyframes rise {
  0%, 12% { transform: translateY(30px); opacity: 0; }
  35%, 88% { transform: translateY(0); opacity: 1; }
  55% { transform: translateY(0) rotate(-8deg); }
  70% { transform: translateY(0) rotate(6deg); }
  100% { transform: translateY(0); opacity: 0; }
}
.demo-swipe .fr { fill: #1f6a24; }
.demo-swipe .fl { fill: #f6354e; }
.demo-swipe .whole { animation: whole 2.4s linear infinite; }
.demo-swipe .half { opacity: 0; }
.demo-swipe .top { animation: halfTop 2.4s ease-in infinite; }
.demo-swipe .bot { animation: halfBot 2.4s ease-in infinite; }
.demo-swipe .trail { fill: none; stroke: #ffd36b; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 30 100; stroke-dashoffset: 130; animation: trail 2.4s linear infinite; filter: drop-shadow(0 0 3px rgba(255, 210, 110, .9)); }
.demo-swipe .tip { fill: #fff; offset-path: path("M14 62C40 50 80 34 108 22"); offset-distance: 0%; opacity: 0; animation: tip 2.4s linear infinite; }
@keyframes whole { 0%, 44% { opacity: 1; } 45%, 100% { opacity: 0; } }
@keyframes halfTop { 0%, 44% { opacity: 0; transform: none; } 45% { opacity: 1; transform: none; } 90% { opacity: 1; transform: translate(-3px, -12px) rotate(-14deg); } 100% { opacity: 0; transform: translate(-4px, -14px) rotate(-16deg); } }
@keyframes halfBot { 0%, 44% { opacity: 0; transform: none; } 45% { opacity: 1; transform: none; } 90% { opacity: 1; transform: translate(4px, 16px) rotate(18deg); } 100% { opacity: 0; transform: translate(5px, 18px) rotate(20deg); } }
@keyframes trail { 0%, 25% { stroke-dashoffset: 130; opacity: 1; } 60% { stroke-dashoffset: 0; opacity: 1; } 75%, 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes tip { 0%, 30% { offset-distance: 0%; opacity: 0; } 31% { opacity: 1; } 60% { offset-distance: 100%; opacity: 1; } 61%, 100% { offset-distance: 100%; opacity: 0; } }
.demo-bomb .bomb { fill: #1b1b22; stroke: rgba(255, 255, 255, .25); stroke-width: 1.5; }
.demo-bomb .cap { fill: #7a7a86; }
.demo-bomb .fuse { fill: none; stroke: #caa062; stroke-width: 2.4; stroke-linecap: round; }
.demo-bomb .spark path { stroke: #ffd36b; stroke-width: 2; stroke-linecap: round; }
.demo-bomb .spark { animation: spark .35s ease-in-out infinite alternate; }
.demo-bomb .no { fill: none; stroke: var(--red); stroke-width: 4.5; stroke-linecap: round; animation: nope 2.4s ease-in-out infinite; }
@keyframes spark { from { transform: scale(.6) rotate(0); opacity: .7; } to { transform: scale(1.2) rotate(30deg); opacity: 1; } }
@keyframes nope { 0%, 30% { opacity: 0; } 45%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- меню: запасные кнопки ---------- */
.menu-keys {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sb));
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); white-space: nowrap;
}
.menu-keys button {
  height: 34px; padding: 0 12px 0 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass);
  font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
}
.menu-keys button:hover { border-color: var(--gold); }

/* ---------- итоги ---------- */
.res-btns { position: fixed; z-index: 3; display: flex; flex-wrap: wrap; gap: 10px; }
.res-btns .play { flex: 1 1 auto; }

/* ---------- строка состояния ---------- */
.status {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: calc(58px + var(--sb));
  max-width: calc(100vw - 2 * var(--gut)); padding: 10px 18px; border-radius: 999px; background: var(--glass);
  border: 1px solid rgba(224, 180, 92, .3); font-size: 14px; font-weight: 600; text-align: center;
  display: grid; gap: 7px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.status .sbar { display: none; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.status.has-bar .sbar { display: block; }
.status .sbar b { display: block; height: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
body[data-phase="idle"] .status { bottom: calc(18px + var(--sb)); }

/* ---------- окна ---------- */
.modal, .fatal {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: var(--gut);
  background: rgba(8, 4, 2, .68); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.card {
  width: min(440px, 100%); padding: 24px 24px 20px; border-radius: 20px; text-align: center;
  background: linear-gradient(180deg, #24140b, #150b06); border: 1px solid rgba(224, 180, 92, .4);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .9); position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 22px; right: 22px; top: 0; height: 4px; background: var(--lacquer); }
.card h2 { margin: 4px 0 10px; font: italic 900 30px/1.1 var(--serif); color: var(--cream); }
.card p { margin: 0 0 18px; color: rgba(246, 236, 217, .85); line-height: 1.5; font-size: 15px; }
.card .col { display: grid; gap: 10px; }
.card .row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.clip-card { width: min(560px, 100%); max-height: calc(100vh - 2 * var(--gut)); display: grid; gap: 10px; }
.clip-card video { width: 100%; max-height: 52vh; border-radius: 12px; background: #000; }
.clip-card .clip-info { margin: 0; font-size: 13px; color: var(--text-soft); }
.rotate .phone { width: 72px; height: 72px; fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

.toast {
  position: fixed; z-index: 9; left: 50%; top: calc(70px + var(--st)); transform: translate(-50%, -12px);
  max-width: calc(100vw - 2 * var(--gut)); padding: 11px 18px; border-radius: 12px; background: rgba(28, 15, 9, .96);
  border: 1px solid rgba(224, 180, 92, .45); font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- телефон горизонтально и небольшие экраны ---------- */
@media (max-height: 520px) {
  .intro { padding-top: calc(60px + var(--st)); place-items: start center; }
  .intro-card { gap: 8px; width: min(760px, calc(100% - 150px)); }
  .title .brush { font-size: clamp(28px, 5.4vw, 44px); }
  .seal { width: 34px; height: 34px; font-size: 20px; }
  .lead { display: none; }
  .steps { gap: 8px; }
  .steps li { padding: 6px 6px 8px; }
  .steps li::before { width: 18px; height: 18px; font-size: 11px; top: 5px; left: 6px; }
  .demo { max-width: 110px; }
  .steps b { font-size: 14px; }
  .steps span { font-size: 11px; }
  .hint { font-size: 12.5px; }
  .play { height: 50px; font-size: 17px; min-width: 220px; }
  .privacy { font-size: 12px; }
  .icon-btn { width: 38px; height: 38px; }
  .rec-btn { height: 38px; }
  .bar { gap: 6px; }
  .menu-keys > span { display: none; }
  .btn, .play.small { height: 42px; }
  .res-btns { gap: 8px; flex-wrap: nowrap; }
  .res-btns .btn { padding: 0 14px; font-size: 14px; }
  .res-btns .play.small { padding: 0 18px; font-size: 15px; }
}
@media (max-width: 720px) {
  .rec-btn span { display: none; }
  .rec-btn { width: 42px; padding: 0; justify-content: center; }
  body.recording .rec-btn { width: auto; padding: 0 12px; }
  body.recording .rec-btn span { display: inline; }
}
@media (max-width: 560px) and (min-height: 521px) {
  .steps { grid-template-columns: 1fr; }
  .steps li { grid-template-columns: 90px 1fr; justify-items: start; text-align: left; column-gap: 12px; }
  .steps li .demo { grid-row: 1 / 3; }
  .intro-card { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
