/* ---------- шрифты (лежат рядом, без внешних запросов) ---------- */
@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+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@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+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 200 700; font-display: swap;
  src: url("fonts/oswald-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: "Oswald"; font-style: normal; font-weight: 200 700; font-display: swap;
  src: url("fonts/oswald-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+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/caveat-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: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/caveat-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+2000-206F, U+20AC, U+2122, U+2212, U+2215; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url("fonts/golos-text-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: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url("fonts/golos-text-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+2000-206F, U+20AC, U+2122, U+2212, U+2215; }

/* ---------- основа ---------- */
:root {
  --paper: #FBF1E6;
  --paper-deep: #F4E1CF;
  --card: #FFFAF4;
  --ink: #2B1220;
  --ink-soft: #6E4F5E;
  --rose: #D63A6F;
  --rose-deep: #A81F52;
  --blush: #F8D3DA;
  --sun: #F7C548;
  --leaf: #4E8B5A;
  --line: rgba(43, 18, 32, 0.14);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cond: "Oswald", "Arial Narrow", sans-serif;
  --hand: "Caveat", "Segoe Script", cursive;
  --pad: clamp(20px, 6vw, 32px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- фон ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(60% 40% at 88% 4%, rgba(248, 211, 218, 0.95), transparent 70%),
    radial-gradient(50% 36% at 4% 96%, rgba(247, 197, 72, 0.28), transparent 70%),
    radial-gradient(70% 50% at 50% 50%, rgba(255, 250, 244, 0.9), transparent 75%),
    var(--paper);
}
.deco { position: absolute; opacity: 0.9; animation: drift 26s ease-in-out infinite alternate; }
.deco-1 { width: 132px; height: 132px; top: -38px; right: -34px; color: var(--rose); }
.deco-2 { width: 76px; height: 76px; top: 96px; right: 62px; color: var(--blush); --flower-core: #FFFFFF; animation-duration: 34s; animation-direction: alternate-reverse; }
.deco-3 { width: 150px; height: 150px; bottom: -58px; right: -50px; color: var(--sun); --flower-core: #E08A2E; animation-duration: 30s; }
.deco-4 { width: 54px; height: 54px; bottom: 96px; right: 28px; color: var(--rose); opacity: 0.55; animation-duration: 22s; animation-direction: alternate-reverse; }
/* На рабочих экранах цветы не должны спорить с текстом: остаётся один, в углу. */
body[data-screen]:not([data-screen="intro"]) :is(.deco-1, .deco-2, .deco-4) { display: none; }
body[data-screen]:not([data-screen="intro"]) .deco-3 { bottom: -84px; right: -78px; }
@keyframes drift { from { transform: rotate(-14deg) scale(1); } to { transform: rotate(18deg) scale(1.06); } }

/* ---------- каркас ---------- */
.app {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) var(--pad) max(28px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.topbar {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: baseline;
  padding-bottom: 18px;
}
.topbar-label, .topbar-step, .eyebrow {
  font: 500 12.5px/1.2 var(--cond); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft);
}
.topbar-step { font-variant-numeric: tabular-nums; }
.progress { grid-column: 1 / -1; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--rose); border-radius: inherit; transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1); }

.screen { display: none; flex: 1; flex-direction: column; }
.screen.is-active { display: flex; animation: enter 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.screen-center { justify-content: center; align-items: center; text-align: center; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

[data-screen="intro"] { justify-content: center; padding: 8vh 0 4vh; }
[data-screen="intro"] .fine { max-width: 24ch; }

/* ---------- типографика ---------- */
.eyebrow { margin: 0 0 14px; }
.eyebrow .remark { margin-left: 10px; font: italic 500 15px/1 var(--serif); letter-spacing: 0; text-transform: none; color: var(--rose-deep); }
.display { margin: 0 0 26px; font: 800 clamp(58px, 19vw, 92px)/0.92 var(--serif); letter-spacing: -0.02em; text-wrap: balance; }
.display em, .title em { font-style: italic; font-weight: 500; color: var(--rose); }
.title { margin: 0 0 12px; font: 700 clamp(28px, 8vw, 36px)/1.14 var(--serif); letter-spacing: -0.01em; text-wrap: balance; outline: none; }
.title-sm { font-size: clamp(24px, 6.6vw, 30px); }
.lead { margin: 0 0 12px; font-size: 19px; line-height: 1.45; font-weight: 500; max-width: 32ch; }
.body { margin: 0 0 18px; color: var(--ink-soft); max-width: 36ch; text-wrap: pretty; }
.body:empty { display: none; }
.fine { margin: 14px 0 0; font-size: 13.5px; line-height: 1.4; color: var(--ink-soft); }

/* ---------- кнопки ---------- */
.actions { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin-top: 22px; }
.actions-row { display: flex; flex-direction: row; gap: 10px; }
.actions-row .btn-primary { flex: 1; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 54px; padding: 14px 26px; border-radius: 999px;
  font: 600 17px/1.2 var(--sans); letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .link:focus-visible, .chip:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.btn-primary { background: var(--ink); color: var(--paper); box-shadow: 0 10px 24px -12px rgba(43, 18, 32, 0.7); }
.btn-primary:hover { background: #3d1b2e; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1.5px var(--ink-soft); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; }
.links-end { margin-top: 28px; }
.link {
  appearance: none; background: none; border: 0; padding: 8px 2px; cursor: pointer;
  font: 500 15px/1.2 var(--sans); color: var(--ink-soft);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px;
}
.link:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---------- игра ---------- */
.game-hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.game-count { font: 500 14px/1 var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft); }
.game-count b { font: 700 26px/1 var(--serif); letter-spacing: 0; color: var(--ink); margin-right: 2px; }
.game-dots { display: flex; gap: 5px; }
.game-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); transition: background-color 0.25s, transform 0.25s; }
.game-dots i.on { background: var(--rose); transform: scale(1.15); }
.game-stage {
  position: relative; border-radius: 24px; overflow: hidden;
  background: linear-gradient(180deg, #FFFDF9 0%, #FDEBE4 62%, #F8D3DA 100%);
  box-shadow: inset 0 0 0 1.5px var(--line), 0 24px 40px -30px rgba(43, 18, 32, 0.5);
  height: clamp(320px, 52dvh, 520px);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.game-stage canvas { display: block; width: 100%; height: 100%; }
.game-swipe {
  position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none;
  font: 500 14px/1 var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft);
  animation: sway 1.6s ease-in-out infinite alternate; transition: opacity 0.4s;
}
.game-swipe span { color: var(--rose); font-size: 18px; }
.game-swipe.is-gone { opacity: 0; }
@keyframes sway { from { transform: translateX(-16px); } to { transform: translateX(16px); } }
.game-done {
  position: absolute; left: 0; right: 0; top: 14%; text-align: center; pointer-events: none;
  animation: enter 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; color: var(--ink-soft);
}
.game-done p { margin: 0; }
.game-done-title { font: italic 700 34px/1.1 var(--serif); color: var(--rose-deep); margin-bottom: 6px !important; }

/* ---------- вопросы ---------- */
.field {
  width: 100%; min-height: 96px; resize: none; padding: 16px 18px;
  border: 1.5px solid var(--line); border-radius: 20px; background: var(--card); color: var(--ink);
  font: 500 18px/1.4 var(--sans);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field::placeholder { color: rgba(110, 79, 94, 0.6); font-weight: 400; }
.field:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 4px rgba(214, 58, 111, 0.14); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  appearance: none; cursor: pointer; padding: 9px 15px; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent;
  font: 500 15px/1.2 var(--sans); color: var(--ink);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.chip:active { transform: scale(0.95); }
.chip.is-on { background: var(--rose); border-color: var(--rose); color: #fff; }

/* ---------- селфи ---------- */
.frame {
  position: relative; align-self: center; width: min(100%, calc(50dvh * 1080 / 1520)); aspect-ratio: 1080 / 1520;
  border-radius: 22px; overflow: hidden; background: linear-gradient(160deg, #F8D3DA, #F4E1CF);
  box-shadow: 0 0 0 1.5px var(--line), 0 26px 44px -30px rgba(43, 18, 32, 0.6);
}
.frame video, .frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.frame video { transform: scaleX(-1); }
.frame[data-state="live"] video, .frame[data-state="counting"] video { display: block; }
.frame[data-state="shot"] canvas { display: block; }
.frame-guide {
  position: absolute; left: 30%; right: 30%; top: 24%; height: 36%; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 1px rgba(43, 18, 32, 0.12);
  display: none; align-items: flex-end; justify-content: center; pointer-events: none;
}
.frame-guide span { transform: translateY(150%); font: 500 12px/1 var(--cond); letter-spacing: 0.18em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.frame[data-state="live"] .frame-guide { display: flex; }
.frame-idle { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; text-align: center; }
.frame[data-state="idle"] .frame-idle { display: flex; }
.frame-flower { width: 92px; height: 92px; color: var(--rose); animation: drift 12s ease-in-out infinite alternate; }
.frame-note { margin: 0; font-size: 14px; line-height: 1.4; color: var(--ink-soft); max-width: 24ch; }
.frame-note:empty { display: none; }
.frame-count {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  font: 800 120px/1 var(--serif); color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}
.frame[data-state="counting"] .frame-count { display: flex; }
.frame-count.tick { animation: tick 0.9s ease-out both; }
@keyframes tick { from { transform: scale(1.5); opacity: 0; } 25% { opacity: 1; } to { transform: scale(0.9); opacity: 0.2; } }
.frame-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.frame-flash.go { animation: flash 0.5s ease-out; }
@keyframes flash { from { opacity: 0.95; } to { opacity: 0; } }
.btn-shutter { position: relative; padding-left: 52px; }
.btn-shutter::before { content: ""; position: absolute; left: 22px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); }

/* ---------- ожидание ---------- */
.press { position: relative; width: 150px; height: 150px; margin-bottom: 26px; }
.press-flower { position: absolute; animation: bloom 2.4s ease-in-out infinite; }
.press-flower.f1 { width: 96px; height: 96px; left: 27px; top: 20px; color: var(--rose); }
.press-flower.f2 { width: 58px; height: 58px; left: 0; top: 78px; color: var(--sun); --flower-core: #E08A2E; animation-delay: 0.3s; }
.press-flower.f3 { width: 50px; height: 50px; right: 0; top: 6px; color: var(--blush); --flower-core: #fff; animation-delay: 0.6s; }
@keyframes bloom { 0%, 100% { transform: scale(0.86) rotate(-10deg); } 50% { transform: scale(1.08) rotate(14deg); } }
[data-screen="loading"] .body { min-height: 3em; max-width: 26ch; }

/* ---------- обложка ---------- */
.cover { margin: 8px 0 0; }
.cover img {
  display: block; width: 100%; height: auto; border-radius: 6px; background: var(--paper-deep);
  box-shadow: 0 2px 4px rgba(43, 18, 32, 0.2), 0 30px 50px -24px rgba(43, 18, 32, 0.65);
  transform: rotate(-1.2deg); animation: reveal 1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  -webkit-touch-callout: default; user-select: auto;
}
@keyframes reveal { from { opacity: 0; transform: rotate(4deg) translateY(40px) scale(0.92); } to { opacity: 1; transform: rotate(-1.2deg); } }
#saveHint { text-align: center; margin-top: 2px; }

.letter { margin-top: 44px; padding-top: 30px; border-top: 1.5px solid var(--line); }
.reveal { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.reveal li { padding: 16px 18px; border-radius: 18px; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); }
.reveal .q { display: block; font-size: 14px; line-height: 1.35; color: var(--ink-soft); }
.reveal .a { display: block; margin: 6px 0 8px; font: 700 26px/1.1 var(--hand); color: var(--rose-deep); overflow-wrap: anywhere; }
.reveal .a:empty { display: none; }
.reveal .m { display: block; font: 700 18px/1.3 var(--serif); }
.reveal .m em { font-style: italic; color: var(--rose); }
.editorial { margin-top: 30px; padding: 22px 20px; border-radius: 18px; background: var(--ink); color: var(--paper); }
.editorial .eyebrow { color: var(--sun); margin-bottom: 10px; }
.editorial-text { margin: 0; font: italic 500 19px/1.45 var(--serif); }
.signoff { margin: 34px 0 6px; font: 700 clamp(26px, 7.4vw, 32px)/1.2 var(--serif); text-wrap: balance; }
.signature { margin: 0; font: 700 30px/1.2 var(--hand); color: var(--rose-deep); }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; display: none; }
.confetti.is-on { display: block; }

@media (min-width: 560px) {
  .app { padding-top: 40px; padding-bottom: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
