/* Шрифты 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: #1a110c;
  --wood: #6b3f24;
  --wood-lo: #3e2414;
  --brass: #e0b45c;
  --brass-lo: #9c7428;
  --cream: #f6ecd9;
  --red: #d8412f;
  --text: #f6ecd9;
  --text-soft: #d9c3a4;
  --glass: rgba(26, 17, 12, .58);
  --line: rgba(246, 236, 217, .16);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

/* Видео лежит под холстом: кадр зеркалится и рисуется на canvas вместе с листьями (так фото и клип совпадают с экраном) */
#cam { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; background: var(--bg); }

/* ===== Кнопки по краям ===== */
.col { position: fixed; top: calc(10px + var(--sat)); display: flex; flex-direction: column; gap: 8px; z-index: 5; transition: opacity .25s; }
.col.left { left: calc(10px + var(--sal)); }
.col.right { right: calc(10px + var(--sar)); }
.btn {
  width: 52px; min-height: 48px; padding: 6px 2px 5px; border-radius: 14px;
  display: grid; justify-items: center; gap: 2px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--cream); font-size: 9.5px; font-weight: 600; letter-spacing: .01em; line-height: 1.1;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: rgba(62, 36, 20, .8); border-color: rgba(224, 180, 92, .5); }
.btn:active { transform: scale(.94); }
.btn:focus-visible, .play:focus-visible, .link:focus-visible, .pal:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn[aria-pressed="true"], .btn[aria-expanded="true"] { color: var(--brass); border-color: rgba(224, 180, 92, .55); }
#btnSkel[aria-pressed="false"] { color: var(--text-soft); }
#btnSkel[aria-pressed="false"] svg { opacity: .55; }
.rec-dot { width: 16px; height: 16px; margin: 3px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px rgba(246, 236, 217, .85); }
#btnClip[aria-pressed="true"] { color: #fff; border-color: var(--red); background: rgba(120, 24, 16, .75); }
#btnClip[aria-pressed="true"] .rec-dot { border-radius: 4px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ===== Всплывающие панели ===== */
.pop {
  position: fixed; z-index: 6; right: calc(70px + var(--sar)); top: calc(10px + var(--sat));
  width: min(270px, calc(100vw - 90px - var(--sal) - var(--sar)));
  max-height: calc(100dvh - 20px - var(--sat) - var(--sab)); overflow: auto;
  padding: 8px; border-radius: 16px;
  background: rgba(30, 19, 12, .9); border: 1px solid rgba(224, 180, 92, .3);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  font-size: 13.5px;
}
.pal { display: grid; grid-template-columns: 34px 1fr; column-gap: 10px; align-items: center; width: 100%; padding: 7px 8px; border-radius: 11px; text-align: left; }
.pal i { grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18), 0 2px 6px rgba(0, 0, 0, .4); }
.pal b { font-weight: 600; }
.pal span { color: var(--text-soft); font-size: 12px; }
.pal:hover { background: rgba(246, 236, 217, .08); }
.pal[aria-checked="true"] { background: rgba(224, 180, 92, .16); }
.pal[aria-checked="true"] b { color: var(--brass); }
.prow { display: flex; align-items: center; gap: 10px; padding: 8px; min-height: 40px; }
.prow > span:first-child { flex: 1; }
.prow.chk { cursor: pointer; }
.prow.chk span { order: -1; flex: 1; }
.prow input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--brass); }
.prow input[type="range"] { width: 92px; accent-color: var(--brass); }
.prow output { width: 38px; text-align: right; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 6px 9px; font-size: 12.5px; color: var(--text-soft); }
.seg button[aria-pressed="true"] { background: var(--brass); color: #2a1a10; font-weight: 600; }
.prow.action { width: 100%; justify-content: center; margin-top: 4px; border-radius: 10px; background: rgba(224, 180, 92, .16); color: var(--brass); font-weight: 600; }

/* ===== Подсказка, сообщения ===== */
.tip {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: calc(14px + var(--sab)); width: fit-content;
  margin: 0 auto; padding: 9px 18px; border-radius: 999px; max-width: calc(100vw - 24px);
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: clamp(12px, 3.2vw, 14.5px); font-weight: 500; text-align: center; text-wrap: balance;
  pointer-events: none; transition: opacity .25s;
}
.toast {
  position: fixed; z-index: 8; left: 0; right: 0; top: calc(14px + var(--sat)); width: fit-content; margin: 0 auto;
  padding: 9px 16px; border-radius: 12px; max-width: calc(100vw - 150px);
  background: rgba(30, 19, 12, .9); border: 1px solid rgba(224, 180, 92, .4);
  font-size: 13.5px; text-align: center; pointer-events: none;
}
.fps { position: fixed; z-index: 9; left: 8px; bottom: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, .6); font: 600 12px/1.3 ui-monospace, Menlo, monospace; white-space: pre; pointer-events: none; }
.nocam {
  position: fixed; z-index: 5; left: 50%; bottom: calc(66px + var(--sab)); transform: translateX(-50%);
  width: min(520px, calc(100vw - 24px)); padding: 12px 40px 12px 16px; border-radius: 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: rgba(30, 19, 12, .92); border: 1px solid rgba(224, 180, 92, .4);
  font-size: 13.5px; line-height: 1.4;
}
.nocam p { margin: 0; flex: 1 1 240px; }
.nocam button:not(.x) { padding: 8px 14px; border-radius: 10px; background: var(--brass); color: #2a1a10; font-weight: 600; }
.nocam .x { position: absolute; right: 8px; top: 6px; width: 28px; height: 28px; font-size: 20px; color: var(--text-soft); }

/* ===== «Скрыть интерфейс»: только видео и листья ===== */
body.clean .ui, body[data-mode="idle"] .ui { opacity: 0; pointer-events: none; }
body.clean #scene { cursor: none; }
.show-ui { position: fixed; z-index: 7; right: calc(8px + var(--sar)); top: calc(8px + var(--sat)); width: 44px; height: 44px; }
.show-ui::after { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: rgba(246, 236, 217, .28); transition: .15s; }
.show-ui:hover::after { inset: 12px; background: rgba(246, 236, 217, .7); }

/* ===== Стартовый экран ===== */
.intro {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; overflow: auto;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: radial-gradient(900px 600px at 50% 40%, rgba(26, 17, 12, .25), rgba(26, 17, 12, .72));
}
.intro-card {
  width: min(560px, 100%); padding: clamp(20px, 4.5vw, 34px); border-radius: 26px; text-align: center;
  background: linear-gradient(180deg, rgba(62, 36, 20, .86), rgba(30, 19, 12, .92));
  border: 1px solid rgba(224, 180, 92, .38);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 240, 210, .12);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.title { margin: 0; font-family: "Playfair Display", Georgia, serif; font-style: italic; font-weight: 800; font-size: clamp(34px, 9vw, 56px); line-height: 1.05; color: var(--brass); text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.lead { margin: 12px auto 0; max-width: 430px; font-size: clamp(14px, 3.6vw, 16.5px); line-height: 1.45; color: var(--cream); text-wrap: balance; }
.how { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.how li { display: grid; justify-items: center; gap: 2px; padding: 12px 4px 10px; border-radius: 16px; background: rgba(246, 236, 217, .06); border: 1px solid var(--line); }
.how svg { width: 44px; height: 44px; margin-bottom: 4px; fill: none; stroke: var(--cream); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.how .spark { stroke: var(--brass); }
.how b { font-size: clamp(11.5px, 3vw, 13.5px); font-weight: 600; }
.how span { font-size: clamp(10.5px, 2.8vw, 12.5px); color: var(--text-soft); text-wrap: balance; }
.cta { margin-top: 22px; display: grid; justify-items: center; gap: 10px; }
.play {
  display: inline-block; min-width: 220px; padding: 15px 34px; border-radius: 999px; text-decoration: none; text-align: center;
  background: linear-gradient(180deg, #f1cc7c, var(--brass) 55%, var(--brass-lo));
  color: #2a1a10; font-weight: 700; font-size: 19px; letter-spacing: .01em;
  box-shadow: 0 8px 22px rgba(224, 180, 92, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .12s, filter .15s;
}
.play:hover { filter: brightness(1.07); }
.play:active { transform: scale(.97); }
.play[disabled] { filter: saturate(.5) brightness(.85); cursor: progress; }
.play.small { min-width: 0; padding: 11px 22px; font-size: 15px; }
.play.ghost { background: rgba(246, 236, 217, .1); color: var(--cream); box-shadow: inset 0 0 0 1px rgba(224, 180, 92, .5); }
.link { padding: 6px 8px; color: var(--text-soft); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(217, 195, 164, .4); }
.link:hover { color: var(--cream); }
.privacy { margin: 18px 0 0; display: flex; justify-content: center; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-soft); text-wrap: balance; }
.privacy svg { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--brass); stroke-width: 1.8; stroke-linecap: round; }

/* ===== Готовое фото / клип ===== */
.sheet, .fatal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(12, 7, 4, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet-card { width: min(520px, 100%); padding: 18px; border-radius: 22px; text-align: center; background: linear-gradient(180deg, #3e2414, #1e130c); border: 1px solid rgba(224, 180, 92, .38); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.sheet-card h2 { margin: 0 0 12px; font-family: "Playfair Display", Georgia, serif; font-style: italic; font-size: 24px; color: var(--brass); }
.sheet-card p { margin: 0 0 14px; line-height: 1.45; }
.preview { border-radius: 14px; overflow: hidden; background: #000; display: grid; place-items: center; }
.preview img, .preview video { display: block; max-width: 100%; max-height: min(56dvh, 520px); }
.sheet-btns { margin-top: 14px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.noscript { position: fixed; inset: auto 0 0; z-index: 30; margin: 0; padding: 14px; background: #3e2414; text-align: center; }

/* ===== Невысокий экран (телефон горизонтально) ===== */
@media (max-height: 520px) {
  .col { gap: 5px; top: calc(6px + var(--sat)); }
  .btn { min-height: 0; width: 46px; padding: 5px 2px 4px; }
  .btn span { display: none; }
  #btnClip #clipLbl { display: block; }
  .intro-card { width: min(720px, 100%); padding: 16px 22px; }
  .title { font-size: clamp(26px, 8vh, 40px); }
  .lead { margin-top: 6px; max-width: none; font-size: 13.5px; }
  .how { margin-top: 10px; }
  .how li { grid-template-columns: auto 1fr; column-gap: 8px; justify-items: start; text-align: left; padding: 7px 10px; }
  .how svg { grid-row: span 2; width: 32px; height: 32px; margin: 0; }
  .cta { margin-top: 12px; grid-auto-flow: column; justify-content: center; align-items: center; }
  .play { padding: 11px 30px; font-size: 17px; min-width: 180px; }
  .privacy { margin-top: 10px; }
  .tip { bottom: calc(6px + var(--sab)); padding: 6px 14px; }
  .nocam { bottom: calc(46px + var(--sab)); }
}
@media (max-width: 420px) {
  .how li { padding: 10px 2px 8px; }
  .how svg { width: 36px; height: 36px; }
  .tip { max-width: calc(100vw - 16px); padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
