/* KostroGive — тёмный премиум-минимализм.
 *
 * Правила, которых держимся во всём файле:
 *   — никакого неона: ни text-shadow-свечения, ни цветных glow-теней,
 *     ни градиентных заливок по тексту. Текст всегда плотного цвета;
 *   — глубина создаётся плотностью фона, отступами и одной аккуратной
 *     тенью, а не подсветкой;
 *   — акцент один (сдержанный синий) плюс красный от галстука персонажа
 *     для победных состояний. Больше цветов не вводим;
 *   — палитра фиксированная, не из --tg-theme-*: миниапка должна выглядеть
 *     одинаково на любой клиентской теме Telegram.
 */

:root {
  /* фон и поверхности */
  --bg: #0d1117;
  --bg-deep: #090d13;
  --surface: #161c24;
  --surface-2: #1c232d;
  --surface-3: #222b36;
  --stroke: #262f3a;
  --stroke-2: #313c49;

  /* текст */
  --text: #e6e9ee;
  --text-2: #b7c0cd;
  --muted: #7d8794;

  /* акценты */
  --accent: #3d6fd4;
  --accent-hi: #4d80e6;
  --accent-ink: #ffffff;
  --red: #c8433c;
  --red-hi: #d9534c;
  --green: #3f9e6a;
  --gold: #a8874e;

  --radius: 16px;
  --radius-sm: 11px;
  --cell-w: 78px;

  /* одна тень на весь интерфейс, без цветных вариантов */
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 44px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================================================
   Живой фон
   Дрейфующие тёмные пятна: заметно, что картинка дышит, но это
   всё ещё графит, а не подсветка. Пятна намеренно тёмные и
   низкоконтрастные — они меняют плотность фона, а не светят.
   ============================================================ */

.fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--bg);
}

.fx-blob {
  position: absolute;
  width: 118vw;
  height: 118vw;
  border-radius: 46% 54% 52% 48% / 48% 46% 54% 52%;
  filter: blur(46px);
  will-change: transform;
}
.fx-blob-1 {
  top: -46vw; left: -34vw;
  background: radial-gradient(circle at 38% 38%, #1d2a3d 0%, rgba(29, 42, 61, .5) 46%, transparent 70%);
  animation: drift-1 34s ease-in-out infinite;
}
.fx-blob-2 {
  bottom: -54vw; right: -40vw;
  background: radial-gradient(circle at 60% 46%, #1a2534 0%, rgba(26, 37, 52, .46) 48%, transparent 72%);
  animation: drift-2 44s ease-in-out infinite;
}
.fx-blob-3 {
  top: 28vh; left: -30vw;
  width: 90vw; height: 90vw;
  background: radial-gradient(circle at 50% 50%, #21252e 0%, rgba(33, 37, 46, .4) 50%, transparent 74%);
  animation: drift-3 38s ease-in-out infinite;
}

@keyframes drift-1 {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  33%      { transform: translate3d(9vw, 7vh, 0) rotate(52deg) scale(1.09); }
  66%      { transform: translate3d(-5vw, 12vh, 0) rotate(122deg) scale(.96); }
}
@keyframes drift-2 {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  40%      { transform: translate3d(-11vw, -9vh, 0) rotate(-64deg) scale(1.11); }
  75%      { transform: translate3d(6vw, -4vh, 0) rotate(-128deg) scale(.94); }
}
@keyframes drift-3 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(14vw, -8vh, 0) scale(1.14); }
}

/* Плывущая диагональная штриховка — «ткань костюма». */
.fx-weave {
  position: absolute;
  inset: -60%;
  opacity: .5;
  background:
    repeating-linear-gradient(58deg, transparent 0 6px, rgba(255,255,255,.016) 6px 7px),
    repeating-linear-gradient(-58deg, transparent 0 9px, rgba(255,255,255,.011) 9px 10px);
  animation: weave 40s linear infinite;
  will-change: transform;
}
@keyframes weave {
  to { transform: translate3d(7%, 7%, 0); }
}

/* Виньетка прижимает края, чтобы пятна не выглядели наклейками. */
.fx-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 40%, rgba(9, 13, 19, .55) 100%),
    linear-gradient(180deg, transparent 55%, var(--bg-deep) 100%);
}

.app { position: relative; z-index: 1; }

/* ============================================================
   Типографика
   ============================================================ */

h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; font-weight: 640; letter-spacing: -.02em; }
h2 {
  font-size: 12px;
  margin: 26px 0 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}
p { margin: 0 0 10px; }

.muted { color: var(--muted); font-size: 13.5px; }
.center { text-align: center; }

/* ============================================================
   Загрузка
   ============================================================ */

.boot { padding: 90px 0; text-align: center; }
.boot-bar {
  width: 132px;
  height: 2px;
  margin: 0 auto 16px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.boot-bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--text-2);
  animation: boot-slide 1.1s ease-in-out infinite;
}
@keyframes boot-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.boot-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .28em;
  color: var(--muted);
}

.loader { display: flex; justify-content: center; padding: 60px 0; }
.spinner {
  width: 26px; height: 26px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Шапка с персонажем
   ============================================================ */

.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px 0;
  margin-bottom: 14px;
  min-height: 132px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-img {
  width: 104px;
  flex: 0 0 104px;
  display: block;
  margin-bottom: -2px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45));
  animation: hero-in .5s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes hero-in {
  from { opacity: 0; transform: translateY(12px); }
}
.hero-copy { padding-bottom: 16px; min-width: 0; }
.hero-kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.hero-title {
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -.025em;
  margin: 0 0 5px;
  color: var(--text);
}
.hero-sub { font-size: 13px; color: var(--text-2); margin: 0; }

@media (max-width: 359px) {
  /* на узких экранах кикер переносился в две строки и ломал ритм шапки */
  .hero { gap: 10px; padding: 12px 13px 0; min-height: 120px; }
  .hero-img { width: 84px; flex-basis: 84px; }
  .hero-kicker { display: none; }
  .hero-title { font-size: 21px; }
  .hero-sub { font-size: 12.5px; }
}

/* ============================================================
   Карточки
   ============================================================ */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 620; font-size: 16px; letter-spacing: -.01em; margin-bottom: 3px; }
.card-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-desc { color: var(--text-2); font-size: 13.5px; white-space: pre-wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--surface-3);
  border: 1px solid var(--stroke-2);
  color: var(--text-2);
  white-space: nowrap;
}
.chip.live::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-hi);
  animation: beat 2s ease-in-out infinite;
}
@keyframes beat { 50% { opacity: .3; } }
.chip.win { color: #a9dcc0; border-color: #2f5b45; background: #1a2c23; }
.chip.fake { color: #e0a5a1; border-color: #56302d; background: #2a1c1b; }

/* ============================================================
   Кнопки
   ============================================================ */

button {
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  width: 100%;
  transition: background .16s ease, transform .12s ease, border-color .16s ease;
}
button:not(:disabled):hover { background: var(--accent-hi); }
button:not(:disabled):active { transform: scale(.988); }
button:disabled { opacity: .45; cursor: default; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--stroke-2);
}
button.secondary:not(:disabled):hover { background: var(--surface-3); }

button.danger { background: var(--red); }
button.danger:not(:disabled):hover { background: var(--red-hi); }

button.slim { padding: 8px 12px; font-size: 13px; width: auto; border-radius: 9px; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}

.actions { display: grid; gap: 8px; margin-top: 14px; }
.row { display: flex; gap: 7px; flex-wrap: wrap; }

/* ============================================================
   Навигация
   ============================================================ */

.tabs {
  display: flex;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  padding: 4px;
  border-radius: 13px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 9px 6px;
  font-size: 13px;
  white-space: nowrap;
  border-radius: 9px;
  border: none;
}
.tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
.tabs button:not([aria-selected="true"]):hover { color: var(--text-2); background: var(--surface-2); }
@media (max-width: 380px) {
  .tabs button { font-size: 12px; padding: 9px 3px; }
}

/* ============================================================
   Обратный таймер
   ============================================================ */

.countdown { text-align: center; padding: 30px 0 18px; }
.countdown-value {
  font-size: 62px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  line-height: 1;
  color: var(--text);
}
.countdown-label {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--muted);
}
.countdown.urgent .countdown-value { color: var(--red-hi); }
.countdown.urgent .countdown-label { color: #b08582; }

/* ============================================================
   Рулетка
   ============================================================ */

.roulette { margin: 18px 0; }
.roulette-frame {
  position: relative;
  overflow: hidden;
  height: 96px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-2);
  background: var(--bg-deep);
  mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
}
/* окно под указателем — чуть светлее фона, без подсветки */
.roulette-frame::before {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: var(--cell-w);
  margin-left: calc(var(--cell-w) / -2);
  background: var(--surface-2);
  border-left: 1px solid var(--stroke-2);
  border-right: 1px solid var(--stroke-2);
}
.roulette-pointer {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--red);
  z-index: 3;
}
.roulette-track {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  will-change: transform;
}
.roulette-cell {
  flex: 0 0 var(--cell-w);
  width: var(--cell-w);
  text-align: center;
  font-size: 26px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  color: #55606e;
}
.roulette-cell.hit { color: var(--text); }
.roulette-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 12px; }

/* ============================================================
   Результат
   ============================================================ */

.result { text-align: center; padding: 8px 0 4px; animation: rise .34s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Ликующий персонаж — только когда пользователь выиграл. */
.result-hero { margin: 4px auto 10px; width: 150px; }
.result-hero img {
  width: 100%;
  display: block;
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, .5));
  animation: cheer .62s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes cheer {
  from { opacity: 0; transform: translateY(20px) scale(.9); }
}

.result-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  padding: 5px 12px;
  border: 1px solid var(--stroke-2);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 14px;
}
.result-badge.win { color: #b6e2c8; border-color: #326049; background: #1b2e24; }

.result-number {
  font-size: 74px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -.05em;
  color: var(--text);
}
.result-text { margin-top: 12px; color: var(--text-2); font-size: 14px; }
.result-proof {
  margin-top: 16px;
  padding: 11px 13px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
}
.result-proof a { color: #7ea6e8; text-decoration: underline; text-underline-offset: 2px; }

.draw-title { text-align: center; font-size: 23px; }
.draw-sub {
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--muted);
  margin-bottom: 2px;
}

/* ============================================================
   Призовые места
   ============================================================ */

.prizes-preview { display: flex; flex-direction: column; gap: 7px; margin: 16px 0 4px; }
.places { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; }

.prize-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 13px 11px 16px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  text-align: left;
  overflow: hidden;
}
/* планка ранга слева */
.prize-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--stroke-2);
}
.prize-row .place {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.prize-row .winner { font-weight: 640; font-variant-numeric: tabular-nums; color: var(--text); }
.prize-row .prize { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; color: var(--text-2); }

.prize-row.reveal { animation: rise .32s cubic-bezier(.2,.8,.2,1) backwards; }
.prize-row.reveal:nth-child(1) { animation-delay: .04s; }
.prize-row.reveal:nth-child(2) { animation-delay: .11s; }
.prize-row.reveal:nth-child(3) { animation-delay: .18s; }
.prize-row.reveal:nth-child(4) { animation-delay: .25s; }
.prize-row.reveal:nth-child(n+5) { animation-delay: .3s; }

/* 1-е место — приглушённое золото, без блеска */
.prize-row:first-child::before { background: var(--gold); }

/* Моя строка важнее золота, поэтому правило идёт после :first-child. */
.prize-row.me { border-color: #2f5b45; background: #16241d; }
.prize-row.me::before { background: var(--green); }

.draw-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}
.draw-meta span:not(:empty) {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 11px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--stroke);
}

/* ============================================================
   Формы
   ============================================================ */

label {
  display: block;
  margin: 13px 0 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}
input, textarea {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke-2);
  background: var(--bg-deep);
  color: var(--text);
  transition: border-color .16s ease;
}
input::placeholder, textarea::placeholder { color: #5d6775; }
input:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { min-height: 92px; resize: vertical; }

/* ============================================================
   Списки и статистика
   ============================================================ */

.list { display: grid; gap: 6px; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 27px;
  font-weight: 660;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  color: var(--text);
}
.stat-label {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}

/* ============================================================
   Тост
   ============================================================ */

.toast {
  position: fixed;
  left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 50;
  padding: 12px 15px;
  font-size: 14px;
  text-align: center;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--stroke-2);
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .24s cubic-bezier(.2,.9,.2,1);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } }

/* ============================================================
   Доступность: полностью гасим движение по системной настройке.
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fx-blob, .fx-weave { animation: none !important; }
}
