/* «Норм или Стрём» — Telegram Mini App.
   Портировано из design/miniapp_design (handoff, high-fidelity).
   Отличия от макета: .scr тянется на вьюпорт (хром Telegram рисует сам клиент),
   кнопки — настоящие <button>/<a> с active-состояниями, шторка — fixed-оверлей. */

:root {
  --norm: #22C55E;
  --strem: #FF2E9E;
  --bg: #0B0C0F;
  --panel: #15171C;
  --panel-2: #1B1E24;
  --line: #262A32;
  --text: #F2F3F5;
  --muted: #9BA1AC;
  --tilt: 2.5deg;
  --glow-n: 0 0 24px color-mix(in srgb, var(--norm) 40%, transparent);
  --glow-s: 0 0 24px color-mix(in srgb, var(--strem) 40%, transparent);
  --head: "Unbounded", sans-serif;
  --body-f: "Manrope", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { background: var(--bg); }

.scr {
  width: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-f);
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  position: relative;
}
.scr-fixed { height: 100dvh; min-height: 0; overflow: hidden; }

.body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  min-height: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- атомы ---------- */

.ph {
  background: repeating-linear-gradient(45deg, #1A1D23 0 10px, #21252C 10px 20px);
  border: 1px dashed #3A404B;
  display: grid;
  place-items: center;
  color: #79808C;
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.card-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ava {
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--head);
  font-weight: 800;
  color: #fff;
  flex: none;
  overflow: hidden;
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava-d { background: linear-gradient(135deg, var(--norm), #0E7A38); }
.ava-a { background: linear-gradient(135deg, var(--strem), #8E1457); }
.ava-g { background: linear-gradient(135deg, #4A5160, #23262D); }

.coin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 12px;
}

.bbtn {
  width: 100%;
  height: 56px;
  flex: none;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bbtn-norm {
  background: var(--norm);
  color: #06140A;
  box-shadow: var(--glow-n), 0 5px 0 color-mix(in srgb, var(--norm) 40%, #000);
}
.bbtn-norm:active { transform: translateY(3px); box-shadow: var(--glow-n), 0 2px 0 color-mix(in srgb, var(--norm) 40%, #000); }
.bbtn-ghost {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
}
.bbtn-ghost:active { transform: scale(0.98); }

.splate {
  display: inline-block;
  font-family: var(--head);
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.1em 0.3em 0.16em;
  border-radius: 0.18em;
}
.splate-n { background: var(--norm); color: #06140A; transform: rotate(calc(var(--tilt) * -1)); box-shadow: var(--glow-n); }
.splate-s { background: var(--strem); color: #1F040C; transform: rotate(var(--tilt)); box-shadow: var(--glow-s); }

.sec-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- главная ---------- */

.greet { display: flex; align-items: center; gap: 12px; }

.result-top { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.greet .ava { width: 46px; height: 46px; font-size: 18px; }
.greet .g-text { flex: 1; min-width: 0; }
.greet .g-text h2 { margin: 0; font-family: var(--head); font-weight: 800; font-size: 18px; }
.greet .g-text p { margin: 0; font-size: 12px; color: var(--muted); }

.tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.tile {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  padding: 0;
}
.tile-big { grid-column: span 3; height: 128px; }
.tile-sm { grid-column: span 2; height: 106px; }
.tile .ph, .tile .card-img { position: absolute; inset: 0; border: none; font-size: 0; width: 100%; height: 100%; }
.tile .tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(11, 12, 15, 0.78);
  border-radius: 10px;
  padding: 5px 9px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 11px;
  transform: rotate(calc(var(--tilt) * -0.6));
  color: var(--text);
}
.tile.on { border: 2px solid var(--norm); box-shadow: var(--glow-n); }
.tile.on .tag { background: var(--norm); color: #06140A; }

.chips { display: flex; gap: 8px; }
.chip {
  flex: 1;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  font-family: var(--head);
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.chip.on {
  background: var(--norm);
  border-color: var(--norm);
  color: #06140A;
  transform: rotate(calc(var(--tilt) * -0.8));
  box-shadow: var(--glow-n);
}

.mytests { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 14px;
  width: 100%;
  text-align: left;
}
.row .r-emoji { font-size: 22px; flex: none; }
.row .r-main { flex: 1; min-width: 0; }
.row .r-main b { display: block; font-size: 14px; }
.row .r-main span { font-size: 12px; color: var(--muted); }
.row .arrow { color: var(--muted); font-size: 16px; }

.pct {
  font-family: var(--head);
  font-weight: 800;
  font-size: 14px;
  flex: none;
}
.pct-hi { color: var(--norm); text-shadow: var(--glow-n); }
.pct-mid { color: #FFC53B; }
.pct-lo { color: var(--strem); text-shadow: var(--glow-s); }

/* ---------- экран теста ---------- */

.t-top { flex: none; }
.t-top .t-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.t-top .t-label .cat { font-family: var(--head); font-weight: 700; font-size: 14px; }
.t-top .t-label .n { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.t-top .t-bar { height: 4px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.t-top .t-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--strem), var(--norm)); transition: width 0.25s ease; }

.t-stack { flex: 1; position: relative; margin: 18px 4px; min-height: 0; touch-action: pan-x; }
.t-card {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  overflow: hidden;
  background: var(--panel);
}
.t-card .ph { width: 100%; height: 100%; font-size: 12px; }
.t-card.gone { display: none; }
.t-card.b3 { transform: translateY(16px) scale(0.91); opacity: 0; z-index: 1; }
.t-card.b2 { transform: translateY(16px) scale(0.91) rotate(1.6deg); opacity: 0.4; z-index: 2; }
.t-card.b1 { transform: translateY(8px) scale(0.955) rotate(-1deg); opacity: 0.7; z-index: 3; }
.t-card.front { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); z-index: 4; }
.t-card.b1, .t-card.b2, .t-card.b3 { transition: transform 0.2s ease, opacity 0.2s ease; }
.t-card.front.animating { transition: transform 0.18s ease; }
.t-card.front.flyout { transition: transform 0.25s ease, opacity 0.25s ease; opacity: 0; }
.t-card.front.sw-r { border: 3px solid var(--norm); box-shadow: var(--glow-n); }
.t-card.front.sw-l { border: 3px solid var(--strem); box-shadow: var(--glow-s); }

.t-stamp {
  position: absolute;
  top: 22px;
  font-family: var(--head);
  font-weight: 900;
  font-size: 30px;
  text-transform: uppercase;
  border: 3.5px solid;
  border-radius: 12px;
  padding: 5px 14px;
  background: rgba(11, 12, 15, 0.55);
  opacity: 0;
}
.t-stamp.st-n { left: 16px; color: var(--norm); border-color: var(--norm); transform: rotate(-15deg); text-shadow: var(--glow-n); }
.t-stamp.st-s { right: 16px; color: var(--strem); border-color: var(--strem); transform: rotate(15deg); text-shadow: var(--glow-s); }

.t-btns { display: flex; gap: 12px; flex: none; }
.tb {
  flex: 1;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 16px;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}
.tb-strem {
  background: color-mix(in srgb, var(--strem) 15%, var(--panel));
  border: 1.5px solid color-mix(in srgb, var(--strem) 50%, transparent);
  color: var(--strem);
}
.tb-norm { background: var(--norm); color: #06140A; box-shadow: var(--glow-n); }
.tb.dim { opacity: 0.35; }
.tb.pressed, .tb:active { transform: scale(1.04); }
.tb-strem.solid { background: var(--strem); color: #1F040C; box-shadow: var(--glow-s); border: none; }

.t-hint {
  flex: none;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}

/* ---------- финиш / интро / центрированные ---------- */

.center-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0;
  min-height: 0;
}

.big-emoji { font-size: 56px; line-height: 1; }

.h-screen {
  font-family: var(--head);
  font-weight: 800;
  font-size: 24px;
  line-height: 1.2;
  text-transform: uppercase;
  margin: 18px 0 10px;
  text-wrap: balance;
}
.sub-screen { color: var(--muted); font-size: 14px; max-width: 30ch; margin: 0 auto; text-wrap: pretty; }

.invite-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  margin: 26px 0 0;
  position: relative;
  overflow: hidden;
}
.invite-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--strem), #FFC53B, var(--norm));
}
.invite-card .link {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px dashed #3A404B;
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  margin-top: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.invite-card .ic-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* Поле почты на экране финиша: не форма регистрации, а одна строка —
   поэтому выглядит как подпись с инпутом, а не как анкета. */
.notify-box {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
}
.notify-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.notify-row input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px; /* меньше — iOS зумит поле при фокусе */
}
.notify-row .bbtn { width: auto; min-width: 84px; height: 46px; min-height: 46px; }

.linkish {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text);
  text-decoration: underline;
  cursor: pointer;
}

.hint-foot {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 14px;
  text-wrap: pretty;
}

.badge-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  margin-top: 18px;
}

/* ---------- результат ---------- */

.gauge-m {
  position: relative;
  width: 232px;
  height: 232px;
  border-radius: 50%;
  /* --fill: % заполнения дуги (анимируется из gauge_controller) */
  background: conic-gradient(from 215deg, var(--strem) 0%, #FFC53B calc(var(--fill, 0%) * 0.55), var(--norm) var(--fill, 0%), #22262E calc(var(--fill, 0%) + 0.5%), #22262E 100%);
  display: grid;
  place-items: center;
  margin: 0 auto;
  transform: rotate(calc(var(--tilt) * -0.6));
  box-shadow: 0 0 48px color-mix(in srgb, var(--norm) 16%, transparent);
}
.gauge-m::before { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: var(--bg); }
.gauge-m .val { position: relative; text-align: center; }
.gauge-m .val .p { font-family: var(--head); font-weight: 900; font-size: 56px; line-height: 1; display: block; }
.gauge-m .val .c { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.pair { display: flex; justify-content: center; margin-top: -20px; position: relative; }
.pair .ava { width: 44px; height: 44px; font-size: 16px; border: 3px solid var(--bg); }
.pair .ava + .ava { margin-left: -10px; }

.verdict {
  display: inline-block;
  background: var(--norm);
  color: #06140A;
  font-family: var(--head);
  font-weight: 800;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 13px;
  transform: rotate(var(--tilt));
  box-shadow: var(--glow-n);
  margin-top: 14px;
}
.verdict-mid { background: #FFC53B; color: #1F1503; box-shadow: 0 0 24px color-mix(in srgb, #FFC53B 40%, transparent); }
.verdict-lo { background: var(--strem); color: #1F040C; box-shadow: var(--glow-s); }

.locked {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.locked .l-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--head);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
}
.locked .l-head .l-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 400; }
.locked .l-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.locked .l-grid .ph, .locked .l-grid .card-img { aspect-ratio: 1; border-radius: 10px; filter: blur(5px); font-size: 0; }
.locked .l-lock {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%) rotate(calc(var(--tilt) * -1));
  font-size: 26px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

/* ---------- расшифровка ---------- */

.acc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  flex: none;
}
.acc + .acc { margin-top: 10px; }
.acc .a-head {
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 14px;
}
.acc .a-head .chev { color: var(--muted); font-size: 13px; }
.acc.acc-n { border-color: color-mix(in srgb, var(--norm) 35%, transparent); }
.acc.acc-s { border-color: color-mix(in srgb, var(--strem) 35%, transparent); }
.acc .a-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 12px 12px; }
.acc.collapsed .a-grid { display: none; }
.acc .a-cell { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.acc .a-cell .ph, .acc .a-cell .card-img { width: 100%; height: 100%; font-size: 0; }
.acc .a-cell .duo {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  display: flex;
  gap: 3px;
}
.acc .a-cell .duo span {
  flex: 1;
  font-family: var(--mono);
  font-size: 9px;
  text-align: center;
  border-radius: 7px;
  padding: 3px 0;
  background: rgba(11, 12, 15, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc .a-cell .duo .d-n { color: var(--norm); }
.acc .a-cell .duo .d-s { color: var(--strem); }

/* ---------- результаты создателя ---------- */

.crt-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.crt-head .ph-sq, .crt-head .img-sq { width: 52px; height: 52px; border-radius: 14px; font-size: 0; flex: none; object-fit: cover; }
.crt-head h2 { margin: 0; font-family: var(--head); font-weight: 800; font-size: 17px; }
.crt-head p { margin: 0; font-size: 12px; color: var(--muted); }

.guest-list { display: flex; flex-direction: column; gap: 8px; }
.guest-list .row .ava { width: 38px; height: 38px; font-size: 14px; }

/* ---------- пополнение (шторка) ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: #15171C;
  border-radius: 28px 28px 0 0;
  border-top: 1px solid #2D323C;
  padding: 10px 18px calc(26px + env(safe-area-inset-bottom));
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(105%);
  transition: transform 0.25s ease;
  z-index: 50;
}
.sheet-open .sheet { transform: translateY(0); }
.sheet-open .sheet-overlay { opacity: 1; pointer-events: auto; }
.sheet .handle { width: 44px; height: 4px; border-radius: 99px; background: #3A404B; margin: 0 auto 18px; }

.balance-big { text-align: center; margin-bottom: 20px; }
.balance-big .b {
  font-family: var(--head);
  font-weight: 900;
  font-size: 40px;
  line-height: 1.1;
}
.balance-big .c { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.packs { display: flex; gap: 10px; margin-bottom: 16px; }
.pack {
  flex: 1;
  position: relative;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 18px 8px 14px;
  text-align: center;
}
.pack .p-coins { font-family: var(--head); font-weight: 800; font-size: 18px; display: block; }
.pack .p-price { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 6px; display: block; }
.pack.hot { border-color: var(--norm); box-shadow: var(--glow-n); transform: rotate(calc(var(--tilt) * -0.6)); }
.pack.hot .p-price { color: var(--text); }
.pack .hot-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(calc(var(--tilt) * -1));
  background: var(--norm);
  color: #06140A;
  font-family: var(--head);
  font-weight: 800;
  font-size: 9px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ---------- лоадер шелла ---------- */

.shell-loader {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100dvh;
}
.shell-loader .dot {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--norm), var(--strem));
  animation: pulse 1.1s ease-in-out infinite;
}
.shell-loader p { font-family: var(--mono); font-size: 12px; color: var(--muted); }
@keyframes pulse {
  0%, 100% { transform: scale(1) rotate(var(--tilt)); }
  50% { transform: scale(1.12) rotate(calc(var(--tilt) * -1)); }
}

/* ---------- утилиты ---------- */

.gap-6 { height: 6px; flex: none; }
.gap-10 { height: 10px; flex: none; }
.gap-14 { height: 14px; flex: none; }
.gap-18 { height: 18px; flex: none; }
.grow { flex: 1; min-height: 0; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--head);
  font-weight: 700;
  font-size: 13px;
  padding: 12px 20px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 60;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
