@import url("https://fonts.googleapis.com/css2?family=Russo+One&family=Nunito:wght@400;600;700;800&display=swap");

:root {
  --red: #c8283a;
  --red-light: #d8394b;
  --red-dark: #8e1b2a;
  --gold: #ffe3a3;

  --bg: #fbf6ee;
  --surface: #ffffff;
  --text: #2a1726;
  --muted: #8a6f80;
  --accent: var(--red);
  --line: #f3ebe0;
  --border: #efe4d4;
  --soft: #fdf3e2;
  --tag-bg: #fff1d6;
  --tag-text: #9a5d00;
  --field: #fffdf9;
  --shadow: 0 2px 0 #eadfce, 0 6px 16px rgba(42, 23, 38, 0.06);

  --display: "Russo One", "Arial Black", sans-serif;
  --radius: 18px;
  --gap: 12px;
}

body.dark {
  --red: #e0485a;
  --red-light: #a52638;
  --red-dark: #5e101b;
  --bg: #1a1018;
  --surface: #261823;
  --text: #fbeee4;
  --muted: #b39aa9;
  --line: #352330;
  --border: #3a2735;
  --soft: #33202c;
  --tag-bg: #3d2c18;
  --tag-text: #ffcf75;
  --field: #1f141c;
  --shadow: 0 2px 0 #120a10, 0 6px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 0 88px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Nunito, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

/* ─── шатёр сверху ─────────────────────────── */
.bigtop {
  padding: 24px 16px 30px;
  text-align: center;
  color: #fff;
  background: repeating-linear-gradient(
    90deg,
    var(--red) 0 26px,
    var(--red-light) 26px 52px
  );
  border-radius: 0 0 50% 50% / 0 0 24px 24px;
}
body.dark .bigtop {
  background: repeating-linear-gradient(90deg, #8e1b2a 0 26px, #7a1724 26px 52px);
}

.bigtop h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 23px;
  line-height: 1.2;
  letter-spacing: 1px;
  margin: 0;
}

.bigtop p {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

#app { padding: 16px; max-width: 680px; margin: 0 auto; width: 100%; }
img, svg { max-width: 100%; }

h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 16px;
  margin: 24px 0 10px;
  letter-spacing: 0.3px;
}

p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.lead { margin: 2px 0 12px; }

.loader { display: flex; justify-content: center; padding: 70px 0; }
.spinner {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── карточка ─────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  min-width: 0;
  font-weight: 800;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-sub { margin-top: 2px; }

.card-desc {
  color: var(--muted);
  font-size: 14px;
  margin: 10px 0 0;
  white-space: pre-wrap;
}

.badge {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  white-space: nowrap;
}
.badge.gray { background: var(--line); color: var(--muted); }

.rows { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 9px; font-size: 14px; align-items: center; color: var(--muted); }
.row-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ─── призы ────────────────────────────────── */
.prizes { margin-top: 10px; }
.prize {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.prize:last-child { border-bottom: 0; }
.prize-place {
  flex: none;
  min-width: 40px;
  color: var(--accent);
  font-weight: 800;
}
.prize span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* ─── кнопки ───────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font: 800 16px/1.2 Nunito, sans-serif;
  cursor: pointer;
  margin-top: 14px;
  box-shadow: 0 3px 0 var(--red-dark);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-dark); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--border), 0 2px 0 var(--border);
}
.btn.secondary:active { box-shadow: inset 0 0 0 1.5px var(--border); }

.btn.slim { padding: 11px; font-size: 14px; margin-top: 8px; }

/* ─── участвую ─────────────────────────────── */
.joined {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 14px;
  font-weight: 700;
}
.joined .i { color: var(--accent); }
.joined b { color: var(--accent); }
.joined .muted { margin-left: auto; font-weight: 600; }

/* ─── статистика ───────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.stat-value { font-family: var(--display); font-size: 24px; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--muted); }

.chan-list { display: flex; flex-direction: column; gap: 8px; }
.chan {
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  background: var(--soft);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}
.chan .i { color: var(--accent); }
.chan .go { margin-left: auto; color: var(--muted); }

/* ─── победители ───────────────────────────── */
.winner {
  display: flex; gap: 10px; align-items: center;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.winner:last-child { border-bottom: 0; }
.winner-place {
  flex: none;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.winner-place.p1 { background: #ffd66b; color: #6b4300; }
.winner-place.p2 { background: #e3e3ea; color: #4a4a55; }
.winner-place.p3 { background: #f2c09a; color: #6e3a12; }
.winner-name { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.winner-prize { color: var(--muted); font-size: 13px; text-align: right; }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-title { color: var(--text); font-weight: 800; font-size: 17px; margin: 14px 0 4px; }
.empty-icon {
  display: inline-grid; place-items: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--accent);
}
.empty-icon .i { width: 30px; height: 30px; }

/* ─── формы ────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}
.field textarea { min-height: 78px; resize: vertical; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 700 13px/1.2 Nunito, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.chip .i { width: 16px; height: 16px; }
.chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.icon { padding: 8px; color: var(--muted); }

.prize-hint {
  display: flex;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
}
.prize-hint span:nth-child(1),
.prize-hint span:nth-child(2) { width: 54px; text-align: center; flex: none; }
.prize-hint span:nth-child(3) { flex: 1; }

.prize-edit { display: flex; gap: 8px; margin-bottom: 8px; }
.prize-edit input.place { width: 54px; text-align: center; flex: none; }
.prize-edit input.name { flex: 1; min-width: 0; }
.prize-edit button {
  width: 44px; flex: none;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.seg { display: flex; flex-direction: column; gap: 8px; }
.seg button {
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  padding: 12px 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.seg button .i { color: var(--muted); }
.seg button.is-on { border-color: var(--accent); background: var(--soft); }
.seg button.is-on .i { color: var(--accent); }

/* ─── нижнее меню ──────────────────────────── */
/* у .tab и .tabbar свой display, он перебивал атрибут hidden */
[hidden] { display: none !important; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  border: none; background: none;
  padding: 9px 4px 10px;
  color: var(--muted);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: Nunito, sans-serif;
}
.tab .i { width: 22px; height: 22px; transition: transform 0.15s ease; }
.tab.is-active { color: var(--accent); }
.tab.is-active .i { transform: translateY(-1px); }
.tab-label { font-size: 11px; font-weight: 700; }

/* ─── тост ─────────────────────────────────── */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 96px;
  max-width: 420px; margin: 0 auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  z-index: 60;
  animation: rise 0.22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ─── конфетти ─────────────────────────────── */
.confetti {
  position: fixed;
  top: -14px;
  width: 9px;
  height: 14px;
  z-index: 70;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(104vh) rotate(760deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .toast { animation: none; }
}

/* ─── картинка розыгрыша ───────────────────── */
.card-img {
  display: block;
  width: calc(100% + 32px);
  max-width: none;
  margin: -16px -16px 14px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--soft);
}

.field .upload {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 0;
  padding: 20px 14px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--field);
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
}
.upload .i { width: 26px; height: 26px; }
.upload.is-busy { color: var(--muted); cursor: default; }
.upload .muted { font-weight: 600; font-size: 12px; }
.spinner.small { width: 22px; height: 22px; border-width: 2.5px; }

.media-preview { position: relative; border-radius: 14px; overflow: hidden; background: var(--soft); }
.media-preview img, .media-preview video {
  display: block; width: 100%; max-height: 260px; object-fit: cover;
}
.media-remove {
  position: absolute; top: 8px; right: 8px;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(26, 16, 24, 0.7);
  color: #fff;
  cursor: pointer;
}

/* ─── капча ────────────────────────────────── */
.captcha-prompt {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800;
  font-size: 17px;
  margin: 2px 0 14px;
}
.captcha-prompt .i { color: var(--accent); width: 22px; height: 22px; }
.captcha-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.captcha-option {
  display: grid; place-items: center;
  aspect-ratio: 1;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.captcha-option .i { width: 34px; height: 34px; stroke-width: 1.8; }
.captcha-option:active { transform: scale(0.95); border-color: var(--accent); color: var(--accent); }

/* ─── админские строки ─────────────────────── */
.admin-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.admin-row-main { flex: 1; min-width: 0; }
.admin-row-title {
  font-weight: 800;
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-row-meta { font-size: 12px; color: var(--muted); }

/* динамика входов по дням: подпись дня, полоса, число — читается и без цвета */
.bars { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 36px; align-items: center; gap: 8px; font-size: 13px; }
.bar-day { color: var(--muted); }
.bar-track { height: 10px; }
.bar-fill { height: 100%; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-n { text-align: right; font-weight: 700; }
.split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn-row .btn { margin: 0; }
.media-attached { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1.5px dashed var(--border); border-radius: 14px; }
.media-attached .media-remove { position: static; margin-left: auto; }
#turnstile { display: flex; justify-content: center; min-height: 70px; margin: 8px 0 12px; }
.note { font-size: 13px; color: var(--muted); margin: -6px 0 16px; }

/* ---------- честный розыгрыш, топ, буст ---------- */
.hash { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.hash.block { display: block; padding: 10px; border-radius: 10px; background: var(--soft); user-select: all; }
.hash.pool { max-height: 120px; overflow-y: auto; }

.leaders { margin-top: 12px; padding: 12px; border-radius: 14px; background: var(--soft); }
.leaders-title { display: flex; align-items: center; gap: 6px; font-weight: 800; margin-bottom: 6px; }
.leader { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.leader-n { width: 22px; text-align: center; color: var(--muted); font-weight: 800; }
.leader-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.leader.me { color: var(--accent); font-weight: 800; }

.sheet {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(20, 8, 16, 0.55);
  animation: rise 0.25s ease-out;
}
.sheet-card {
  position: relative; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text);
}
.sheet-card h2 { margin-top: 0; padding-right: 44px; }
.sheet-x { position: absolute; top: 14px; right: 14px; }

.check { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin: 8px 0; border-radius: 12px; background: var(--soft); }
.check.ok { background: #e2f5e8; color: #17603a; }
.check.bad { background: #fde2e4; color: #9b1c2c; }
body.dark .check.ok { background: #16382a; color: #8be0ad; }
body.dark .check.bad { background: #44161f; color: #ffaab4; }
.proof-list { margin-top: 12px; }
.proof-how { margin-top: 12px; font-size: 14px; }
.proof-how summary { cursor: pointer; font-weight: 700; }

.reel-place { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; font-weight: 800; }
.reel {
  height: 56px; overflow: hidden; margin: 8px 0 4px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow), inset 0 0 0 2px var(--accent);
  -webkit-mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent);
          mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent);
}
.reel-item { height: 56px; display: flex; align-items: center; justify-content: center; font: 24px var(--display); }
.reveal { animation: rise 0.35s ease-out; }

.card.fraud { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
