/* Chadface — «тепловизор подпольного риппердока»: чёрно-фиолетовая пустота, термо-шкала глубины (фиолетовый → розовый →
   оранжевый → жёлтый) как единственный цвет, лицо как технический чертёж. Tektur — заголовки и балл, Golos Text — текст,
   IBM Plex Mono — цифры замеров. */
:root {
  --void: #07060c; --panel: #110e1a; --line: #2a2538; --bone: #ece8f4; --dim: #8f88a6;
  --h0: #2b0a57; --h1: #7a1fd1; --h2: #ff2e88; --h3: #ff8a1f; --h4: #ffe45c;
  --heat: linear-gradient(90deg, var(--h0), var(--h1) 25%, var(--h2) 50%, var(--h3) 75%, var(--h4));
  --top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --bot: calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
  --display: 'Tektur', 'Golos Text', system-ui, sans-serif;
  --body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --cut: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--void); color: var(--bone); font: 400 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--h4); outline-offset: 3px; }
[hidden] { display: none !important; }

.screen { max-width: 480px; margin: 0 auto; padding: calc(var(--top) + 14px) 16px calc(var(--bot) + 24px); display: flex; flex-direction: column; gap: 16px; }

/* шапка */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand b { font: 700 22px/1 var(--display); letter-spacing: .08em; }
.brand span { font: 500 11px/1.2 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.spec { font: 500 11px/1.5 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); text-align: right; }

/* голограмма среднего лица */
.holo { margin: 0; position: relative; }
.holo canvas { display: block; width: 100%; aspect-ratio: 1 / 1.05; }
.holo figcaption { font: 500 12px/1.4 var(--mono); color: var(--dim); text-align: center; letter-spacing: .02em; margin-top: -6px; }

/* кнопки */
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn { display: flex; align-items: center; justify-content: center; min-height: 54px; padding: 0 20px; border: 0; cursor: pointer; text-align: center;
  font: 700 15px/1.2 var(--display); letter-spacing: .06em; text-transform: uppercase; transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--h4); color: var(--void); clip-path: var(--cut); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--panel); color: var(--bone); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--dim); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.busy { pointer-events: none; opacity: .7; }
.link { align-self: center; background: none; border: 0; padding: 6px 8px; cursor: pointer; color: var(--dim); font: 500 13px var(--body); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line); }
.link:hover { color: var(--bone); }
.link.small { font-size: 12.5px; }
.note { margin: 0; text-align: center; color: var(--dim); font-size: 13px; }

/* скан на весь экран */
.scan { position: fixed; inset: 0; max-width: none; padding: 0; display: block; background: #000; }
.scan canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scan video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--top) + 10px) 12px 10px; display: flex; align-items: center; gap: 10px;
  background: linear-gradient(rgba(7,6,12,.85), rgba(7,6,12,0)); }
.icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); background: rgba(17,14,26,.8); cursor: pointer; }
.pose { font: 500 11px/1.3 var(--mono); letter-spacing: .08em; color: var(--bone); opacity: .85; font-variant-numeric: tabular-nums; }
.guide { position: absolute; left: 50%; top: 46%; width: min(64vw, 300px); aspect-ratio: 3 / 4; transform: translate(-50%, -50%); border-radius: 50%;
  border: 1.5px dashed rgba(236,232,244,.45); transition: opacity .3s; pointer-events: none; }
.guide.off { opacity: 0; }
.dock { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(var(--bot) + 14px); display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: linear-gradient(rgba(7,6,12,0), rgba(7,6,12,.9) 40%); }
.hint { margin: 0; min-height: 22px; padding: 6px 12px; font: 600 14px/1.3 var(--body); background: rgba(17,14,26,.86); border: 1px solid var(--line); text-align: center; }
.hint.ok { border-color: var(--h4); color: var(--h4); }
.shutter { position: relative; width: 92px; height: 92px; border: 0; padding: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.shutter svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.shutter circle { fill: none; stroke-width: 5; }
.shutter .ring-bg { stroke: rgba(236,232,244,.25); }
.shutter .ring { stroke: var(--h4); stroke-dasharray: 289; stroke-dashoffset: 289; transition: stroke-dashoffset .1s linear; }
.shutter span { position: relative; width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: var(--h4); color: var(--void); font: 700 11px var(--display); letter-spacing: .08em; }
.shutter:disabled span { background: #3a3448; color: var(--dim); }
.shutter:disabled { cursor: default; }

/* результат */
.result { gap: 14px; }
.depth { display: flex; justify-content: space-between; font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding-top: 8px; border-top: 3px solid transparent;
  border-image: var(--heat) 1; }
.facepanel { width: 100%; aspect-ratio: 4 / 4.6; display: block; background: var(--panel); }
.warn { margin: 0; padding: 8px 12px; font-size: 13px; border-left: 3px solid var(--h3); background: rgba(255,138,31,.08); }
.score { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.big { display: flex; align-items: baseline; gap: 4px; }
.big b { font: 900 96px/.82 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-shadow: 0 0 28px currentColor; }
.big span { font: 700 22px var(--display); color: var(--dim); }
.tier { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 4px; max-width: 52%; }
.tier b { font: 700 22px/1.05 var(--display); letter-spacing: .06em; }
.tier span { font-size: 12.5px; color: var(--dim); line-height: 1.35; }
.meters { display: flex; flex-direction: column; gap: 12px; }
.meter header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.meter b { font: 600 14px var(--body); }
.meter small { color: var(--dim); font-size: 12px; margin-left: 6px; }
.meter em { font: 500 13px var(--mono); font-style: normal; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; height: 10px; }
.seg i { background: #1c1828; }
.sexsw { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.sexsw button { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; cursor: pointer; font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.sexsw button[aria-pressed="true"] { border-color: var(--h4); color: var(--h4); }
.sexsw i { font-style: normal; text-transform: none; letter-spacing: 0; font-family: var(--body); }
.sexsw.start { justify-content: center; }
.facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.facts div { background: var(--void); padding: 10px 12px; }
.facts dt { font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.facts dd { margin: 4px 0 0; font: 600 15px var(--body); }
.sec { margin: 6px 0 -4px; font: 700 13px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rows li { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline; }
.rows .n { font-size: 14px; }
.rows .v { font: 500 13px var(--mono); font-variant-numeric: tabular-nums; }
.rows .v small { color: var(--dim); font-size: 11.5px; }
.track { grid-column: 1 / -1; position: relative; height: 6px; background: linear-gradient(90deg, transparent 30%, rgba(236,232,244,.12) 30% 70%, transparent 70%), #16131f; }
.track i { position: absolute; top: -4px; width: 3px; height: 14px; margin-left: -1.5px; }
.track::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(236,232,244,.4); }

/* лист «как считаем» */
.sheet { max-width: 480px; width: calc(100% - 24px); max-height: calc(100dvh - 40px); border: 1px solid var(--line); background: var(--panel); color: var(--bone); padding: 20px 18px 18px; }
.sheet::backdrop { background: rgba(7,6,12,.75); }
.sheet h2 { margin: 0 0 10px; font: 700 20px var(--display); letter-spacing: .06em; }
.sheet p { margin: 0 0 10px; font-size: 14px; }
.sheet .small { font-size: 12px; color: var(--dim); }
.sheet .btn { width: 100%; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--bot) + 20px); transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px); padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--h4); color: var(--bone); font-size: 14px; text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* логотип в шапке: «чад» из точек + название с глитчем */
.logo-brand { flex-direction: row; align-items: center; gap: 10px; }
.logo-brand canvas { width: 52px; height: 52px; flex: none; }
.logo-brand > div { display: flex; flex-direction: column; gap: 2px; }
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.glitch::before { color: var(--h2); animation: gl1 4.2s infinite steps(1); }
.glitch::after { color: #25f4ee; animation: gl2 4.2s infinite steps(1); }
@keyframes gl1 { 0%, 86%, 100% { opacity: 0; transform: none; clip-path: none; } 87% { opacity: .9; transform: translate(-2px, -1px); clip-path: inset(0 0 55% 0); } 89% { opacity: .9; transform: translate(2px, 1px); clip-path: inset(40% 0 20% 0); } 91% { opacity: .8; transform: translate(-1px, 0); clip-path: inset(70% 0 0 0); } }
@keyframes gl2 { 0%, 86%, 100% { opacity: 0; transform: none; clip-path: none; } 87% { opacity: .9; transform: translate(2px, 1px); clip-path: inset(50% 0 0 0); } 89% { opacity: .9; transform: translate(-2px, 0); clip-path: inset(0 0 60% 0); } 91% { opacity: .7; transform: translate(1px, -1px); clip-path: inset(20% 0 50% 0); } }

/* заставка */
.splash { position: fixed; inset: 0; z-index: 50; background: var(--void); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity .4s, transform .4s; }
.splash canvas { width: min(84vw, 440px); aspect-ratio: 1 / 1; }
.splash-word { margin-top: 4px; min-height: 1.1em; font: 900 clamp(40px, 13vw, 76px)/1 var(--display); letter-spacing: .06em; color: var(--bone); text-shadow: 0 0 24px rgba(255,46,136,.35); }
.splash-word.glitch-on, .splash-word.glitch { text-shadow: -3px 0 #25f4ee, 3px 0 var(--h2); transform: translateX(1px); }
.splash-sub { margin-top: 10px; font: 500 12px var(--mono); letter-spacing: .3em; text-transform: uppercase; color: var(--dim); opacity: 0; transition: opacity .4s; }
.splash.sub-on .splash-sub { opacity: 1; }
.splash.out { opacity: 0; transform: scale(1.04); pointer-events: none; }

/* погрешность и лестница уровней */
.prec { margin: -4px 0 0; display: flex; align-items: baseline; gap: 8px; }
.prec b { font: 600 15px var(--mono); color: var(--bone); }
.prec span { font-size: 12.5px; color: var(--dim); }
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ladder li { position: relative; display: grid; grid-template-columns: 112px 1fr auto; align-items: baseline; gap: 10px; padding: 9px 12px 9px 14px; background: var(--panel); border: 1px solid var(--line); }
.ladder li::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); }
.ladder b { font: 700 14px var(--display); letter-spacing: .05em; }
.ladder span { font-size: 12.5px; color: var(--dim); }
.ladder em { font: 500 12px var(--mono); font-style: normal; color: var(--dim); font-variant-numeric: tabular-nums; }
.ladder li.me { border-color: var(--c); background: linear-gradient(90deg, color-mix(in srgb, var(--c) 18%, transparent), var(--panel) 70%); }
.ladder li.me b { color: var(--c); }
.ladder li.me i { position: absolute; right: 12px; top: -9px; padding: 1px 6px; font: 600 10px var(--mono); font-style: normal; letter-spacing: .08em; text-transform: uppercase; background: var(--c); color: var(--void); }
.ask-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.ask-row .btn { margin-top: 0; }
