/* ============================================================
   ТОКЕНЫ + ТЕМЫ (светлая / тёмная / авто-системная)
   Тема не сохраняется в хранилище — держим обещание «ничего не храним».
============================================================ */
:root{
  --bg:#F3EADC;          /* тёплый песок */
  --bg-2:#EFE3D1;        /* чуть глубже — карточки/панели */
  --text:#2B211A;        /* тёплый почти-чёрный */
  --muted:rgba(43,33,26,.55);
  --line:rgba(43,33,26,.20);   /* обводки полей */
  --line-soft:rgba(43,33,26,.10);
  --accent:#C5562F;      /* угль/охра — кровь без буквальной красноты */
  --accent-soft:rgba(197,86,47,.12);
  --good:#7C7A2E;        /* приглушённая олива — «живёшь» */
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme]){
    --bg:#1A1310; --bg-2:#221813; --text:#EFE5D8;
    --muted:rgba(239,229,216,.55); --line:rgba(239,229,216,.18);
    --line-soft:rgba(239,229,216,.09);
    --accent:#E1764E; --accent-soft:rgba(225,118,78,.14); --good:#B7B25A;
    color-scheme: dark;
  }
}
html[data-theme="light"]{
  --bg:#F3EADC; --bg-2:#EFE3D1; --text:#2B211A;
  --muted:rgba(43,33,26,.55); --line:rgba(43,33,26,.20); --line-soft:rgba(43,33,26,.10);
  --accent:#C5562F; --accent-soft:rgba(197,86,47,.12); --good:#7C7A2E; color-scheme:light;
}
html[data-theme="dark"]{
  --bg:#1A1310; --bg-2:#221813; --text:#EFE5D8;
  --muted:rgba(239,229,216,.55); --line:rgba(239,229,216,.18); --line-soft:rgba(239,229,216,.09);
  --accent:#E1764E; --accent-soft:rgba(225,118,78,.14); --good:#B7B25A; color-scheme:dark;
}

/* ============================================================
   FLUID SCALE — всё на rem от текучего корня.
   Меняется размер корня → пропорционально масштабируется ВСЁ.
============================================================ */
*{box-sizing:border-box; margin:0; padding:0;}
html{ font-size: clamp(16px, 1.12vw, 32px); }            /* 1280 → 4K, пропорция */
@media (max-width:1024px){ html{ font-size: clamp(16px, 2.0vw, 26px);} } /* планшет */
@media (max-width:640px){ html{ font-size: clamp(16.5px, 4.4vw, 22px);} } /* мобила */

body{
  background:var(--bg); color:var(--text);
  font-family:'Golos Text', system-ui, sans-serif;
  font-weight:400; line-height:1.5;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
  min-height:100vh; min-height:100dvh; overflow-x:hidden;
  transition: background .5s ease, color .5s ease;
}
::selection{ background:var(--accent); color:var(--bg); }

/* ============================================================
   КАРКАС
============================================================ */
.shell{ min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; }

header.top{
  position:relative; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding: 1.4rem 2rem;
}
.brand{
  font-family:'Unbounded', sans-serif; font-weight:600;
  font-size:1.05rem; letter-spacing:-.01em; line-height:1;
  display:inline-flex; align-items:center; gap:.55rem;
  cursor:pointer; user-select:none; color:var(--text);
  background:none; border:0;
}
.brand .ekg-mini{ width:1.7rem; height:1rem; color:var(--accent); }

.theme-btn{
  border:0; background:none; color:var(--text); cursor:pointer;
  display:grid; place-items:center; padding:.3rem;
  transition:opacity .2s ease, transform .2s ease;
}
.theme-btn:hover{ opacity:.65; }
.theme-btn:active{ transform:scale(.9); }
.theme-btn svg{ width:1.5rem; height:1.5rem; }

main.stage{ flex:1; display:grid; place-items:center; padding: 1rem 2rem 2rem; }
.card{
  width:100%; max-width:42rem; text-align:center;
}
@media (max-width:640px){ main.stage{ padding:.5rem 1.4rem 1.6rem; } header.top{ padding:1.2rem 1.4rem; } }

/* шаги переключаются с лёгким fade+lift */
.view{ animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise{ from{ opacity:0; transform:translateY(1.1rem);} to{opacity:1; transform:none;} }

/* ============================================================
   ИНТРО
============================================================ */
.eyebrow{
  font-size:.72rem; letter-spacing:.22em; text-transform:uppercase;
  color:var(--muted); margin-bottom:1.6rem;
}
h1.hero{
  font-family:'Unbounded', sans-serif; font-weight:600;
  font-size:clamp(2rem, 4.6vw, 3.4rem); line-height:1.04; letter-spacing:-.02em;
  margin-bottom:1.4rem;
}
h1.hero .em{ color:var(--accent); }
.lede{ font-size:1.05rem; color:var(--muted); max-width:30rem; margin:0 auto 2.4rem; line-height:1.6; }
@media (max-width:640px){ .lede{ margin-left:0; } }

.ekg-wrap{ width:min(28rem,100%); margin:0 auto 2.4rem; height:3rem; color:var(--accent); }
@media (max-width:640px){ .ekg-wrap{ margin-left:0; } }
.ekg-line{ stroke:currentColor; stroke-width:2.2; fill:none; stroke-linecap:round; stroke-linejoin:round;
  stroke-dasharray: 900; stroke-dashoffset:900; animation: draw 2.6s linear infinite; }
@keyframes draw{ to{ stroke-dashoffset:-900; } }

.btn{
  font-family:'Golos Text', sans-serif; font-weight:500;
  font-size:.95rem; letter-spacing:.02em;
  padding:1.05rem 2.4rem; border-radius:2rem;
  border:1px solid var(--text); background:var(--text); color:var(--bg);
  cursor:pointer; transition: transform .2s ease, opacity .2s ease, background .3s ease, color .3s ease, border-color .3s ease;
}
.btn:hover{ transform:translateY(-2px); }
.btn:active{ transform:translateY(0); }
.btn.ghost{ background:none; color:var(--text); border-color:var(--line); }
.btn.ghost:hover{ border-color:var(--text); }
.btn.accent{ background:var(--accent); border-color:var(--accent); color:#fff; }

.intro-note{ font-size:.78rem; color:var(--muted); margin-top:1.6rem; max-width:24rem; margin-left:auto; margin-right:auto; line-height:1.55; }
@media (max-width:640px){ .intro-note{ margin-left:0; } }

/* слот под медиа (мем/фото/видео) — подставляется по желанию */
.media-slot{
  width:min(30rem,100%); margin:2.2rem auto 0; aspect-ratio:16/10;
  border:1px dashed var(--line); border-radius:1rem;
  display:grid; place-items:center; color:var(--muted); font-size:.78rem;
  overflow:hidden; background:var(--bg-2);
}
.media-slot img, .media-slot video{ width:100%; height:100%; object-fit:cover; display:block; }
@media (max-width:640px){ .media-slot{ margin-left:0; } }

/* ============================================================
   ВОПРОСЫ
============================================================ */
.q-counter{ font-size:.7rem; letter-spacing:.18em; text-transform:uppercase; color:var(--muted); margin-bottom:1.2rem; }
h2.q{
  font-family:'Unbounded', sans-serif; font-weight:500;
  font-size:clamp(1.5rem, 3.2vw, 2.3rem); line-height:1.12; letter-spacing:-.015em;
  margin-bottom:.7rem;
}
.q-hint{ font-size:.85rem; color:var(--muted); margin-bottom:2rem; max-width:26rem; margin-left:auto; margin-right:auto; }
@media (max-width:640px){ .q-hint{ margin-left:0; } }

.options{ display:flex; flex-direction:column; gap:.9rem; max-width:30rem; margin:0 auto; }
.opt{
  font-family:'Golos Text',sans-serif; font-size:1rem; font-weight:400;
  text-align:left; padding:1.15rem 1.5rem; border-radius:1rem;
  border:1px solid var(--line); background:none; color:var(--text);
  cursor:pointer; transition: border-color .2s ease, background .25s ease, transform .12s ease;
  line-height:1.35;
}
.opt:hover{ border-color:var(--text); }
.opt:active{ transform:scale(.99); }
.opt.is-active{ border-color:var(--accent); background:var(--accent-soft); }

.field-wrap{ max-width:26rem; margin:0 auto; }
.field{
  width:100%; font-family:'Golos Text',sans-serif; font-size:1.4rem; font-weight:500;
  text-align:center; color:var(--text); background:none;
  border:1px solid var(--line); border-radius:1rem; padding:1.2rem 1.4rem;
  outline:none; transition:border-color .2s ease;
}
.field::placeholder{ color:var(--muted); font-weight:400; }
.field:focus{ border-color:var(--accent); }
.field::-webkit-outer-spin-button, .field::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
input.field[type=number]{ -moz-appearance:textfield; appearance:textfield; }
textarea.field{ text-align:left; font-size:0.9rem; font-weight:400; min-height:7rem; resize:vertical; line-height:1.5; }
.ai-tag{ display:inline-block; margin-top:.8rem; font-size:.62rem; letter-spacing:.16em; text-transform:uppercase; color:var(--muted); border:1px solid var(--line-soft); border-radius:1rem; padding:.35rem .8rem; }

/* навигация шага */
.nav{ display:flex; align-items:center; justify-content:center; gap:1.1rem; margin-top:2.4rem; }
.arrow{
  width:3.2rem; height:3.2rem; border-radius:50%;
  border:1px solid var(--line); background:none; color:var(--text);
  display:grid; place-items:center; cursor:pointer;
  transition:border-color .2s ease, background .25s ease, transform .15s ease, opacity .2s ease;
}
.arrow:hover:not(:disabled){ border-color:var(--text); }
.arrow:active:not(:disabled){ transform:scale(.92); }
.arrow:disabled{ opacity:.3; cursor:default; }
.arrow.next{ background:var(--text); color:var(--bg); border-color:var(--text); }
.arrow.next:disabled{ background:none; color:var(--text); }
.arrow svg{ width:1.5rem; height:1.5rem; }
.skip{ background:none; border:0; color:var(--muted); font-size:.8rem; cursor:pointer; text-decoration:underline; text-underline-offset:3px; margin-top:1.4rem; font-family:'Golos Text',sans-serif; }
.skip:hover{ color:var(--text); }

/* прогресс снизу */
.progress{ width:100%; max-width:42rem; margin:0 auto; padding:0 2rem 1.6rem; }
.progress .track{ height:2px; background:var(--line-soft); border-radius:2px; overflow:hidden; }
.progress .bar{ height:100%; width:0; background:var(--accent); transition:width .5s cubic-bezier(.2,.7,.2,1); }

/* ============================================================
   РЕЗУЛЬТАТ
============================================================ */
.verdict-eyebrow{ font-size:.72rem; letter-spacing:.22em; text-transform:uppercase; color:var(--muted); margin-bottom:1.4rem; }
.big-num{
  font-family:'Unbounded',sans-serif; font-weight:700;
  font-size:clamp(3.2rem, 8.5vw, 6rem); line-height:.9; letter-spacing:-.04em;
  color:var(--accent); margin-bottom:.3rem;
}
.big-num.good{ color:var(--good); }
.num-label{ font-size:1rem; color:var(--muted); margin-bottom:1.8rem; }
.verdict{
  font-family:'Unbounded',sans-serif; font-weight:500;
  font-size:clamp(1.3rem,3vw,2rem); line-height:1.18; letter-spacing:-.01em; margin-bottom:1.4rem;
}
.verdict-body{ font-size:1rem; color:var(--text); max-width:30rem; margin:0 auto 1.4rem; line-height:1.6; }
@media (max-width:640px){ .verdict-body{ margin-left:0; text-align:left; } }
.suspect{ font-size:.95rem; color:var(--muted); max-width:28rem; margin:0 auto 2rem; line-height:1.55; }
.suspect b{ color:var(--accent); font-weight:500; }
@media (max-width:640px){ .suspect{ margin-left:0; } }

.disclaimer{ font-size:.55rem; color:var(--muted); max-width:28rem; margin:2rem auto 0; line-height:1.55; padding-top:1.4rem; border-top:1px solid var(--line-soft); }
@media (max-width:640px){ .disclaimer{ margin-left:0; } }

/* надгробие (плохой исход) */
.grave{ width:min(12.5rem,44%); margin:0 auto 1.2rem; }
@media (max-width:640px){ .grave{ margin-left:0; } }

/* статистика */
.stats{ display:flex; flex-wrap:wrap; gap:1.4rem; justify-content:center; max-width:34rem; margin:2.4rem auto; }
.stat{ flex:1 1 9rem; }
.stat .n{ font-family:'Unbounded',sans-serif; font-weight:600; font-size:1.9rem; color:var(--text); line-height:1; }
.stat .t{ font-size:.78rem; color:var(--muted); margin-top:.5rem; line-height:1.4; }

/* материалы */
.materials{ display:flex; flex-direction:column; gap:.7rem; max-width:30rem; margin:0 auto 2.4rem; text-align:left; }
.material{ display:flex; align-items:center; gap:.8rem; padding:.95rem 1.2rem; border:1px solid var(--line); border-radius:.9rem; color:var(--text); text-decoration:none; font-size:.92rem; transition:border-color .2s ease; }
.material:hover{ border-color:var(--text); }
.material svg{ width:1.1rem; height:1.1rem; color:var(--accent); flex-shrink:0; }

/* шеринг */
.share-title{ font-size:.95rem; color:var(--muted); margin-bottom:1.2rem; }
.share{ display:flex; flex-wrap:wrap; gap:1rem; justify-content:center; margin-bottom:1.4rem; }
.share-btn{
  width:4rem; height:4rem; border-radius:1.2rem;
  border:1px solid var(--line); background:none; color:var(--text);
  display:grid; place-items:center; cursor:pointer;
  transition:border-color .2s ease, transform .15s ease, background .25s ease;
}
.share-btn:hover{ border-color:var(--text); transform:translateY(-2px); }
.share-btn:active{ transform:translateY(0); }
.share-btn svg{ width:1.8rem; height:1.8rem; }
.share-cap{ font-size:.6rem; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); margin-top:.5rem; }
.share-item{ display:flex; flex-direction:column; align-items:center; }
.restart{ margin-top:1.4rem; }

/* ============================================================
   ПОДВАЛ + МОДАЛКА
============================================================ */
footer.bottom{ padding:.85rem 2rem; display:flex; justify-content:space-between; align-items:center; gap:1rem; border-top:1px solid var(--line-soft); }
.foot-left{ flex:1 1 0; display:flex; gap:1.2rem; justify-content:flex-start; }
.foot-right{ flex:1 1 0; display:flex; justify-content:flex-end; }
footer.bottom button, .foot-link{ background:none; border:0; color:var(--muted); font-size:.7rem; cursor:pointer; font-family:'Golos Text',sans-serif; text-decoration:none; transition:color .2s ease; white-space:nowrap; }
footer.bottom button:hover, .foot-link:hover{ color:var(--text); text-decoration:underline; text-underline-offset:3px; }
.stats-line{ flex:0 0 auto; font-size:.7rem; color:var(--muted); letter-spacing:.01em; text-align:center; }
.stats-line b{ color:var(--text); font-weight:500; }
@media (max-width:640px){
  footer.bottom{ flex-wrap:wrap; justify-content:center; gap:.35rem .9rem; padding:.7rem 1.2rem; }
  .foot-left, .foot-right{ flex:0 1 auto; justify-content:center; }
  .stats-line{ order:-1; flex-basis:100%; }
}

/* мобилка — всё по центру */
@media (max-width:640px){
  .card, .warn, .verdict-body, .suspect, .sheet-in, .first-step{ text-align:center; }
  .lede, .ekg-wrap, .intro-note, .q-hint, .warn, .suspect, .disclaimer, .grave, .heart, .first-step{ margin-left:auto; margin-right:auto; }
}

.modal-bg{ position:fixed; inset:0; background:rgba(0,0,0,.4); display:none; place-items:center; z-index:100; padding:1.4rem; }
.modal-bg.open{ display:grid; animation: fade .3s ease both; }
@keyframes fade{ from{opacity:0;} to{opacity:1;} }
.modal{ background:var(--bg); border:1px solid var(--line); border-radius:1.4rem; max-width:30rem; width:100%; padding:2.4rem; }
.modal h3{ font-family:'Unbounded',sans-serif; font-weight:600; font-size:1.3rem; margin-bottom:1rem; }
.modal p{ font-size:.92rem; color:var(--text); line-height:1.6; margin-bottom:1rem; }
.modal .close{ margin-top:.6rem; }

/* ============================================================
   ФИНАЛ — режиссура, падение, мем, верхний попап
============================================================ */
.seq{ opacity:0; transform:translateY(1.2rem); }
.seq.in{ opacity:1; transform:none; transition:opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1); }

.grave.drop, .heart.drop{ animation: drop 1s cubic-bezier(.25,.6,.2,1) both; }
@keyframes drop{ 0%{ transform:translateY(-70vh); opacity:0; } 55%{ opacity:1; } 100%{ transform:translateY(0); opacity:1; } }

.count-label{ font-size:clamp(1.2rem,2.4vw,1.5rem); color:var(--muted); font-weight:500; margin-bottom:.4rem; letter-spacing:.005em; }
.big-num.tick{ transition: transform .16s ease; }
.big-num.pop{ transform:scale(1.08); }

.heart{ width:min(7rem,30%); margin:0 auto 1rem; color:var(--good); }
.heart svg{ width:100%; height:auto; display:block; animation: beat 1.15s ease-in-out infinite; transform-origin:50% 62%; }
@keyframes beat{ 0%,100%{ transform:scale(1);} 14%{ transform:scale(1.13);} 28%{ transform:scale(1);} 42%{ transform:scale(1.07);} 56%{ transform:scale(1);} }

.warn{ font-size:1rem; color:var(--text); max-width:28rem; margin:1.2rem auto 0; line-height:1.5; }
@media (max-width:640px){ .warn{ margin-left:0; text-align:left; } }
.final-actions{ display:flex; flex-direction:column; align-items:center; gap:.8rem; margin-top:1.6rem; }
.final-row{ display:flex; gap:.9rem; justify-content:center; flex-wrap:wrap; }
.final-row .btn{ font-size:.9rem; padding:.9rem 1.7rem; }
.mini-disc{ font-size:.72rem; color:var(--muted); margin-top:.2rem; }
.restart-link{ background:none; border:0; color:var(--muted); font-size:.78rem; text-decoration:underline; text-underline-offset:3px; cursor:pointer; font-family:'Golos Text',sans-serif; }
.restart-link:hover{ color:var(--text); }
.more-btn{ display:inline-flex; align-items:center; gap:.5rem; }
.more-btn svg{ width:1.1rem; height:1.1rem; }

/* голосовой ввод (ИИ-поле) */
.mic-row{ display:flex; flex-direction:column; align-items:center; gap:.8rem; margin-top:1.6rem; }
.mic{ position:relative; width:3.8rem; height:3.8rem; border-radius:50%; border:1px solid var(--line); background:none; color:var(--text); display:grid; place-items:center; cursor:pointer; transition:background .25s ease, color .25s ease, border-color .25s ease, transform .15s ease; }
.mic:hover:not(:disabled){ border-color:var(--text); }
.mic:active:not(:disabled){ transform:scale(.94); }
.mic svg{ width:1.6rem; height:1.6rem; }
.mic.rec{ background:var(--accent); color:#fff; border-color:var(--accent); }
.mic.rec::before,.mic.rec::after{ content:''; position:absolute; inset:-1px; border-radius:50%; border:2px solid var(--accent); animation: micring 1.6s ease-out infinite; }
.mic.rec::after{ animation-delay:.8s; }
@keyframes micring{ 0%{ transform:scale(1); opacity:.5;} 100%{ transform:scale(2.3); opacity:0;} }
.mic-label{ font-size:.72rem; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); transition:color .25s ease; }
.mic-label.on{ color:var(--accent); }

/* мем-видео снизу справа */
.meme{
  position:fixed; right:1.4rem; bottom:1.4rem; width:11rem; aspect-ratio:9/16;
  border-radius:1.1rem; overflow:hidden; border:1px solid var(--line);
  background:var(--bg-2); z-index:60; box-shadow:0 1rem 3rem rgba(0,0,0,.28);
  transform:translateY(135%); opacity:0;
  transition: transform .7s cubic-bezier(.2,.7,.2,1), opacity .5s ease;
}
.meme.in{ transform:none; opacity:1; }
.meme video{ width:100%; height:100%; object-fit:cover; display:block; }
.meme .m-ph{ width:100%; height:100%; display:grid; place-items:center; text-align:center; color:var(--muted); font-size:.68rem; padding:1rem; line-height:1.5; }
.meme .m-btn{ position:absolute; width:1.9rem; height:1.9rem; border-radius:50%; border:0; background:rgba(0,0,0,.5); color:#fff; display:grid; place-items:center; cursor:pointer; }
.meme .m-close{ top:.5rem; right:.5rem; }
.meme .m-sound{ bottom:.5rem; right:.5rem; }
.meme .m-btn svg{ width:1rem; height:1rem; }
@media (max-width:640px){ .meme{ width:7.6rem; right:.8rem; bottom:.8rem; } }

/* попап «что делать» — центрированное окно с крестиком */
.sheet-bg{ position:fixed; inset:0; background:rgba(0,0,0,.45); display:none; place-items:center; z-index:120; padding:1.4rem; }
.sheet-bg.open{ display:grid; animation: fade .3s ease both; }
.sheet{ position:relative; background:var(--bg); border:1px solid var(--line); border-radius:1.6rem; width:100%; max-width:34rem; max-height:88vh; overflow-y:auto; padding:2.8rem 2rem 2.4rem; transform:translateY(-1.4rem) scale(.98); opacity:0; transition: transform .4s cubic-bezier(.2,.7,.2,1), opacity .35s ease; }
.sheet-bg.open .sheet{ transform:none; opacity:1; }
.sheet-x{ position:absolute; top:.9rem; right:.9rem; width:2.6rem; height:2.6rem; border-radius:50%; border:1px solid var(--line); background:var(--bg); color:var(--text); display:grid; place-items:center; cursor:pointer; z-index:2; transition:border-color .2s ease, transform .15s ease; }
.sheet-x:hover{ border-color:var(--text); }
.sheet-x:active{ transform:scale(.92); }
.sheet-x svg{ width:1.3rem; height:1.3rem; }
.sheet-in{ text-align:center; }
.sheet h3{ font-family:'Unbounded',sans-serif; font-weight:600; font-size:clamp(1.4rem,3vw,1.9rem); margin-bottom:1.1rem; }
.first-step{ font-size:0.9rem; color:var(--text); background:var(--accent-soft); border:1px solid var(--line-soft); border-radius:1rem; padding:1rem 1.3rem; margin:0 auto 1.6rem; max-width:28rem; line-height:1.5; }
.sheet .stats{ margin:0 auto 1.4rem; }
.sheet .materials{ margin-bottom:0; }
.sheet .disclaimer{ margin-top:1.6rem; padding-top:1.2rem; }
@media (max-width:640px){ .sheet{ padding:2.4rem 1.4rem 1.8rem; } .sheet-in{ text-align:left; } .first-step{ margin-left:0; } }

/* попап «поделиться» */
.share-modal{ position:relative; max-width:24rem; text-align:center; }
.share-modal h3{ font-family:'Unbounded',sans-serif; font-weight:600; font-size:1.2rem; margin-bottom:1.6rem; }
.share-modal .share{ margin-bottom:0; }

/* экран ожидания ИИ */
.ai-loader{ display:flex; flex-direction:column; align-items:center; gap:1.6rem; padding:2rem 0; }
.ai-loader .ekg-wrap{ width:min(24rem,80%); color:var(--accent); margin:0; }
.ai-loader-text{ font-size:1.05rem; color:var(--muted); letter-spacing:.01em; }
.ai-dots::after{ content:'…'; }

.hidden{ display:none !important; }
@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001ms !important; transition-duration:.05ms !important; }
}
