/* REPLY — редакционная сетка: гигантские глифы как архитектура, волосяные линии,
   острые углы, без градиентов и теней. Ночь + бумага + один оранжевый сигнал. */
:root {
  --bg: #121011;           /* ночь */
  --raise: #1A1718;        /* панель клавиатуры, пузыри */
  --paper: #F4EFEA;        /* бумага */
  --ink: #121011;          /* текст на бумаге и оранжевом */
  --signal: #FF5A36;       /* единственный акцент */
  --text: #F4EFEA;
  --muted: #9A918B;
  --hair: rgba(244, 239, 234, .14);
  --hair-ink: rgba(18, 16, 17, .18);
  --danger: #FF7A7A;
  --display: 'Unbounded', 'Segoe UI', system-ui, sans-serif;
  --body: 'Golos Text', 'Segoe UI', system-ui, sans-serif;
  --g: 16px;               /* боковое поле */
  --r: 14px;               /* все скругления */
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.45; }
body { -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
[hidden] { display: none !important; }
button, a { touch-action: manipulation; }
p { margin: 0; }
b { font-weight: 600; }

.pad { padding: 36px var(--g); max-width: 560px; margin: 0 auto; }
.muted { color: var(--muted); }
.dot { color: var(--signal); }
.label { display: flex; gap: 12px; font-size: 13px; font-weight: 500; letter-spacing: .01em; margin-bottom: 18px; }
.idx { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- шапка (после записи) ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--g) 10px;
  background: var(--bg); border-bottom: 1px solid var(--hair);
}
body[data-screen="join"] .bar, body[data-screen="outside"] .bar, body[data-screen="loading"] .bar { display: none; }
.logo { font-family: var(--display); font-weight: 800; font-size: 15px; letter-spacing: -0.04em; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.live #live-n { color: var(--text); font-weight: 600; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); animation: pulse 1.6s steps(2, jump-none) infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- постер: гигантская R как каркас экрана ---------- */
.poster {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--paper); color: var(--ink);
  height: min(54vh, 430px); min-height: 330px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--g) 14px;
  display: grid; grid-template-rows: auto 1fr auto; gap: 12px;
}
.poster-glyph {
  position: absolute; z-index: -1; pointer-events: none;
  left: 30vw; top: -24vw;
  font-family: var(--display); font-weight: 800; font-size: 124vw; line-height: 1;
  color: var(--ink);
}
/* текст поверх глифа сам инвертируется: тёмный на бумаге, светлый на чёрном */
.poster-top, .poster-note, .poster-head { color: #fff; mix-blend-mode: difference; }
.poster-head { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(28px, 8.4vw, 40px); line-height: 1; letter-spacing: -0.055em; }
.poster-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; }
.poster-top .logo { font-size: 12px; }
.poster-note { align-self: start; max-width: 15.5em; font-size: 13px; line-height: 1.35; font-weight: 500; display: flex; gap: 10px; }
.poster-note .idx { color: inherit; opacity: .6; }
.poster-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-weight: 500; font-size: clamp(26px, 8.6vw, 40px); letter-spacing: -0.045em; line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 54px; padding: 0 22px; border: 0; border-radius: var(--r);
  background: var(--signal); color: var(--ink); text-decoration: none;
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
  transition: transform .1s var(--ease), background .15s;
}
.btn:active { transform: translateY(1px); background: #FF6B4A; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wide { width: 100%; }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--hair); }
.btn.danger { background: var(--danger); color: var(--ink); }

/* ---------- айфон с перепиской: та же печать, что у постера — бумага, чёрная краска, оранжевый ---------- */
/* высота постера — по его тексту, а не по экрану: телефон наезжает ровно на пустой низ */
#join .poster { height: auto; min-height: 0; padding-bottom: 128px; border-radius: 0 0 28px 28px; grid-template-rows: auto auto auto; }
#join .poster-line { display: none; }
.phone {
  position: relative; z-index: 2;
  width: min(calc(100vw - 2 * var(--g)), 400px); height: calc(100dvh - 236px); min-height: 440px; max-height: 820px;
  margin: -104px auto 24px; padding: 9px; border-radius: 52px; background: var(--ink);
  box-shadow: 0 0 0 1.5px var(--hair);
  animation: rise .6s var(--ease) both; animation-delay: var(--d, 0s);
}
@keyframes rise { from { opacity: 0; transform: translateY(40px); } }
.phone-scr { position: relative; height: 100%; border-radius: 43px; overflow: hidden; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; }
.phone-scr::after { content: ""; position: absolute; left: 50%; bottom: 7px; width: 110px; height: 4px; margin-left: -55px; border-radius: 3px; background: var(--ink); pointer-events: none; }
.phone-isl { position: absolute; top: 10px; left: 50%; width: 96px; height: 28px; margin-left: -48px; border-radius: 16px; background: var(--ink); z-index: 3; }
.phone-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 46px 16px 10px; border-bottom: 1px solid var(--hair-ink); }
.ph-ava { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--signal); color: var(--ink); font-family: var(--display); font-weight: 800; font-size: 16px; }
.ph-name { display: flex; flex-direction: column; font-size: 15px; line-height: 1.25; }
.ph-name b { font-family: var(--display); font-weight: 800; letter-spacing: -0.04em; }
.ph-name small { font-size: 12px; color: rgba(18, 16, 17, .55); }
.ph-name small.on { color: var(--signal); }

.chat {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: 14px 12px 14px 50px; display: flex; flex-direction: column; gap: 4px;
}
.chat::-webkit-scrollbar { display: none; }
.chat > :first-child { margin-top: auto; }
.msg {
  position: relative; max-width: 84%; padding: 9px 13px; border-radius: 18px;
  font-size: 15px; line-height: 1.4; overflow-wrap: anywhere;
  animation: pop .22s var(--ease) both;
}
.msg a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--signal); }
.msg.in { align-self: flex-start; background: var(--ink); color: var(--paper); border-bottom-left-radius: 6px; }
.msg.in.first { margin-top: 12px; }
.msg.in.first::before {
  content: "R"; position: absolute; left: -40px; bottom: 0;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--signal); color: var(--ink);
  font-family: var(--display); font-weight: 800; font-size: 14px;
}
.msg.out { align-self: flex-end; margin: 12px 0 2px; background: var(--signal); color: var(--ink); font-weight: 500; border-bottom-right-radius: 6px; }
.msg.is-typing { padding: 13px 14px; }
.typing { display: inline-flex; gap: 4px; vertical-align: middle; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--paper); animation: blink 1s infinite steps(2, jump-none); }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } }

/* ---------- клавиатура бота: плоские клавиши с чёткой чёрной гранью ---------- */
.kb { flex: none; border-top: 1px solid var(--hair-ink); padding: 8px 10px 22px; }
.kb-input {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 38px; padding: 0 4px 0 14px; border-radius: 19px; box-shadow: inset 0 0 0 1px var(--hair-ink);
  color: rgba(18, 16, 17, .5); font-size: 14px;
}
.kb-text { flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; outline: none; }
.kb-text:focus-visible { outline: none; }
.kb-text::placeholder { color: rgba(18, 16, 17, .5); }
.kb-text:disabled { -webkit-text-fill-color: rgba(18, 16, 17, .5); }
.kb-send { flex: none; width: 30px; height: 30px; border: 0; padding: 0; border-radius: 50%; background: var(--hair-ink); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.kb.open .kb-send { background: var(--signal); }
.kb.typing .kb-input { box-shadow: inset 0 0 0 1.5px var(--ink); }
.kb.typing .kb-send { background: var(--signal); }
.kb.typing .kb-send::after { content: "↑"; }
.kb-input.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.kb-keys {
  display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: 9px 8px;
  max-height: 250px; overflow-y: auto; counter-reset: k; padding: 10px 2px 6px;
}
.kb:not(.open) .kb-keys { display: none; }
.kb.open .kb-keys { animation: pop .25s var(--ease) both; }
.key {
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--ink); border-radius: 12px;
  background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink);
  font: inherit; font-size: 15px; font-weight: 500; line-height: 1.2; cursor: pointer;
  counter-increment: k;
  transition: transform .08s, box-shadow .08s, background .1s;
}
.key:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); background: var(--signal); }
.key.accent { justify-content: space-between; background: var(--signal); font-weight: 600; }
.key.accent::after { content: "→"; }

/* ---------- билет: огромный номер на оранжевом ---------- */
.ticket {
  position: relative; overflow: hidden; margin: 12px 10px 0; border-radius: 28px;
  background: var(--signal); color: var(--ink);
  padding: 14px var(--g) 18px;
  animation: slide .5s var(--ease) both;
}
@keyframes slide { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
.ticket-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; }
.ticket-no {
  font-family: var(--display); font-weight: 800; line-height: .78; letter-spacing: -0.075em;
  font-size: 66vw; margin: 6px 0 0 -2vw; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.ticket-no.long { font-size: 44vw; }
.ticket-cap { margin-top: 16px; font-size: 13px; font-weight: 600; }
.ticket-name { font-size: 30px; font-weight: 500; letter-spacing: -0.04em; margin-top: 18px; overflow-wrap: anywhere; }
.ticket-rows { margin: 14px 0 0; }
.ticket-rows div { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--hair-ink); font-size: 14px; }
.ticket-rows dt { opacity: .6; }
.ticket-rows dd { margin: 0; font-weight: 600; }
.perf { position: relative; margin: 6px calc(-1 * var(--g)) 12px; border-top: 1.5px dashed rgba(18, 16, 17, .35); }
.perf::before, .perf::after { content: ""; position: absolute; top: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); }
.perf::before { left: -10px; }
.perf::after { right: -10px; }
.ticket-stub { font-size: 13px; opacity: .7; }

/* ---------- отсчёт: электронное табло из сегментов ---------- */
.seg-clock { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 0 14px; border-block: 1px solid var(--hair); }
.seg-grp { display: flex; flex-direction: column; gap: 8px; }
.seg-grp span { font-size: 12px; color: var(--muted); }
.seg-digits { display: flex; gap: 5px; }
.seg { position: relative; width: 30px; height: 54px; transform: skewX(-7deg); }
.seg i { position: absolute; border-radius: 3px; background: rgba(244, 239, 234, .06); transition: background .14s; }
.seg i.on { background: var(--signal); }
.seg .a, .seg .g, .seg .d { left: 5px; right: 5px; height: 6px; }
.seg .a { top: 0; } .seg .g { top: 24px; } .seg .d { bottom: 0; }
.seg .b, .seg .c, .seg .e, .seg .f { width: 6px; height: 20px; }
.seg .f { left: 0; top: 5px; } .seg .b { right: 0; top: 5px; }
.seg .e { left: 0; bottom: 5px; } .seg .c { right: 0; bottom: 5px; }
.seg-colon { position: relative; width: 6px; height: 54px; flex: none; }
.seg-colon::before, .seg-colon::after { content: ""; position: absolute; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: colon 1s steps(1, end) infinite; }
.seg-colon::before { top: 15px; } .seg-colon::after { bottom: 15px; }
@keyframes colon { 50% { opacity: .15; } }
.vuz-now { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.vuz-n { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1; letter-spacing: -0.06em; color: var(--signal); }
.vuz-now p { font-size: 15px; line-height: 1.35; }

/* ---------- приглашения ---------- */
.invite { border-top: 1px solid var(--hair); display: flex; flex-direction: column; gap: 12px; }
.invite .label { margin-bottom: 6px; }
.invite-lead { font-size: 22px; font-weight: 500; line-height: 1.2; letter-spacing: -0.03em; }
.invite .btn { margin-top: 8px; }
.invite-lead b { color: var(--signal); font-weight: 600; }
.boosts { display: flex; gap: 8px; }
.boosts i { flex: 1; height: 10px; border-radius: 5px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--hair); transition: background .3s; }
.boosts i.on { background: var(--signal); box-shadow: none; }

/* ---------- бумага: игра ---------- */
.paper { background: var(--paper); color: var(--ink); margin: 0 10px; border-radius: 28px; }
.paper .idx { color: rgba(18, 16, 17, .5); }
.game { display: flex; flex-direction: column; gap: 12px; }
.game .label { margin-bottom: 4px; }
.game-sub { font-size: 22px; font-weight: 500; line-height: 1.2; letter-spacing: -0.03em; }
.g-who { font-size: 13px; font-weight: 600; margin-top: 10px; }
.g-facts { display: flex; flex-direction: column; border-bottom: 1px solid var(--hair-ink); counter-reset: f; }
.g-fact {
  display: flex; align-items: baseline; gap: 12px; width: 100%;
  min-height: 54px; padding: 14px 2px; border: 0; border-top: 1px solid var(--hair-ink); border-radius: 12px;
  background: transparent; color: var(--ink); text-align: left;
  font: inherit; font-size: 16px; font-weight: 500; line-height: 1.3; cursor: pointer;
  counter-increment: f; transition: background .15s, padding .15s var(--ease);
}
.g-fact::before { content: "(" counter(f) ")"; font-size: 12px; opacity: .5; flex: none; }
.g-fact .t { flex: 1; }
.g-fact .tag { font-size: 12px; font-weight: 600; flex: none; }
.g-fact:active { background: rgba(18, 16, 17, .05); }
.g-fact.is-lie { background: var(--signal); padding-inline: 10px; }
.g-fact.is-wrong { text-decoration: line-through; text-decoration-thickness: 1.5px; opacity: .55; }
.g-fact[disabled] { cursor: default; }
.g-result { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; animation: pop .25s var(--ease); }
.g-verdict { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -0.05em; }
.bubble { align-self: flex-start; max-width: 90%; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 18px 18px 18px 6px; font-size: 15px; line-height: 1.4; }
.paper .link { color: var(--ink); align-self: flex-start; }

/* ---------- гонка вузов ---------- */
.race-list { list-style: none; margin: 0; padding: 0; counter-reset: r; border-bottom: 1px solid var(--hair); }
.race-list li { display: grid; grid-template-columns: 36px 1fr auto; align-items: baseline; gap: 0 8px; padding: 12px 0 10px; border-top: 1px solid var(--hair); counter-increment: r; }
.race-list li::before { content: "(" counter(r, decimal-leading-zero) ")"; font-size: 12px; color: var(--muted); }
.race-list .r-name { font-weight: 500; }
.race-list .r-n { font-variant-numeric: tabular-nums; font-family: var(--display); font-weight: 700; font-size: 15px; }
.race-list .r-track { grid-column: 2 / 4; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 8px; background: var(--hair); }
.race-list .r-fill { height: 100%; background: var(--signal); transform-origin: left; animation: grow .7s var(--ease) both; }
.race-list li.mine .r-name::after { content: " — твой"; color: var(--signal); }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- главное правило ---------- */
.rules { border-top: 1px solid var(--hair); }
.rules-head { margin: 0 0 16px; font-family: var(--display); font-weight: 800; font-size: clamp(40px, 13vw, 64px); line-height: .95; letter-spacing: -0.06em; }
.rules-lead { font-size: 18px; line-height: 1.35; letter-spacing: -0.015em; }
.rules-lead b { color: var(--signal); font-weight: 600; }
.ladder { list-style: none; margin: 22px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ladder li { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--raise); font-size: 14px; line-height: 1.3; }
.l-t { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -0.03em; color: var(--signal); }
.rules-note { margin-top: 14px; font-size: 14px; color: var(--muted); }
.club { border-top: 1px solid var(--hair); }
.facts { margin: 0; border-bottom: 1px solid var(--hair); }
.facts div { display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; padding: 13px 0; border-top: 1px solid var(--hair); font-size: 14px; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; color: var(--muted); }

/* ---------- ссылки внизу ---------- */
.links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; border-top: 1px solid var(--hair); padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.link { background: none; border: 0; padding: 10px 0; min-height: 44px; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.danger { color: var(--danger); }
.confirm { width: 100%; box-shadow: inset 0 0 0 1px var(--hair); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- заставка ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  background: var(--paper); display: grid; place-items: center;
  animation: splash-failsafe 0s 9s forwards;   /* если скрипт упал — не держим экран вечно */
}
@keyframes splash-failsafe { to { visibility: hidden; } }
.splash-word { display: flex; align-items: baseline; font-family: var(--display); font-weight: 800; font-size: 13vw; line-height: 1; color: var(--ink); will-change: transform; }
.splash-word span { display: inline-block; clip-path: inset(100% 0 0 0); }
.splash-word .sdot { color: var(--signal); clip-path: none; transform: scale(0); }
.splash-status { position: absolute; left: var(--g); right: var(--g); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); font-size: 13px; color: var(--ink); text-align: center; }
.splashing .poster-glyph { visibility: hidden; }
.poster.enter .poster-top, .poster.enter .poster-head, .poster.enter .poster-note, .poster.enter .poster-line { animation: reveal .5s steps(5, end) both; animation-delay: var(--d, 0s); }
.poster.enter .poster-note { animation-delay: calc(var(--d, 0s) + .12s); }
.poster.enter .poster-line { animation-delay: calc(var(--d, 0s) + .24s); }
@keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

@media (min-width: 560px) {
  .poster-glyph { font-size: 700px; left: 170px; top: -190px; }
  .ticket-no { font-size: 370px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
