/* Mini App розыгрышей rohub. Цвета — из темы Telegram (--tg-theme-*), запасные — свои; акцент rohub — фиолетовый. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #121218);
  --hint: var(--tg-theme-hint-color, #8b8b98);
  --link: var(--tg-theme-link-color, #7b4dff);
  --btn: var(--tg-theme-button-color, #7b4dff);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --sep: rgba(127, 127, 140, .18);
  --accent: #7b4dff;
  --accent-soft: rgba(123, 77, 255, .12);
  --ok: #2fb36b;
  --ok-soft: rgba(47, 179, 107, .13);
  --warn-bg: #fff6dc;
  --warn-text: #6b4a00;
  --warn-border: #f2c94c;
  --err-soft: rgba(229, 72, 77, .12);
  --radius: 14px;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  color-scheme: light;
}
:root[data-scheme="dark"] {
  --warn-bg: rgba(242, 201, 76, .14);
  --warn-text: #f3d27a;
  --warn-border: rgba(242, 201, 76, .45);
  --sep: rgba(200, 200, 215, .14);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --bg: var(--tg-theme-secondary-bg-color, #101014);
    --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c22));
    --text: var(--tg-theme-text-color, #f2f2f5);
    --hint: var(--tg-theme-hint-color, #8d8d9a);
    --warn-bg: rgba(242, 201, 76, .14);
    --warn-text: #f3d27a;
    --warn-border: rgba(242, 201, 76, .45);
    --sep: rgba(200, 200, 215, .14);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  min-height: var(--tg-viewport-height, 100vh);
}
a { color: var(--link); text-decoration: none; }
button { font: inherit; color: inherit; }
b, strong { font-weight: 650; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 28px) calc(var(--safe-left) + 12px);
}
.screen { display: flex; flex-direction: column; gap: 12px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Скелет загрузки */
.sk { background: linear-gradient(90deg, var(--sep) 25%, rgba(127,127,140,.08) 50%, var(--sep) 75%); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 10px; }
.sk-title { height: 26px; width: 70%; }
.sk-line { height: 14px; width: 92%; }
.sk-line.short { width: 55%; }
.sk-card { height: 110px; border-radius: var(--radius); }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Карточки и текст */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.flush { padding: 4px 0; gap: 0; }
.card.accent { background: var(--accent-soft); }
.card.okc { background: var(--ok-soft); }
.card.errc { background: var(--err-soft); }
.card.warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.card.highlight { outline: 2px solid var(--danger); outline-offset: -2px; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; font-weight: 700; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 6px 4px -4px; font-weight: 600; }
h3 { font-size: 17px; margin: 0; font-weight: 650; }
p { margin: 0; }
.hint { color: var(--hint); font-size: 13px; }
.center { text-align: center; }
.pre { white-space: pre-wrap; word-break: break-word; }
.big { font-size: 17px; }
.huge { font-size: 44px; line-height: 1; text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.brand img { width: 32px; height: 32px; }
.brand b { font-size: 17px; }

/* Шапка розыгрыша */
.hero { display: flex; flex-direction: column; gap: 8px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--hint); font-size: 13px; }
.stats b { color: var(--text); }

/* Призы */
.prize { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.prize + .prize { border-top: 1px solid var(--sep); }
.prize img.pi { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; }
.prize .place { font-size: 12px; color: var(--hint); }
.prize .ptitle { font-weight: 600; }
.prize .pval { font-size: 13px; color: var(--hint); }
.info-btn { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 50%; width: 22px; height: 22px; font-size: 13px; line-height: 22px; padding: 0; cursor: pointer; flex: none; }
.explain { font-size: 13px; color: var(--hint); padding: 0 14px 10px 66px; }

/* Чек-лист */
.check { display: flex; align-items: center; gap: 10px; padding: 11px 14px; min-height: 48px; }
.check + .check { border-top: 1px solid var(--sep); }
.check .st { width: 24px; text-align: center; font-size: 18px; flex: none; }
.check .ct { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.check.todo .ct { font-weight: 600; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; background: var(--btn); color: var(--btn-text); white-space: nowrap; min-height: 36px; text-align: center; }
.btn.block { display: flex; width: 100%; min-height: 46px; border-radius: 12px; font-size: 16px; }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--link); padding: 8px 6px; }
.btn.small { padding: 6px 12px; min-height: 32px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn:active:not([disabled]) { transform: scale(.98); }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }

/* Галочки согласий */
.consent { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; }
.consent + .consent { border-top: 1px solid var(--sep); }
.consent input { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--hint); flex: none; margin: 1px 0 0; display: grid; place-items: center; cursor: pointer; background: transparent; }
.consent input:checked { background: var(--accent); border-color: var(--accent); }
.consent input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

/* Поле ника */
.field { display: flex; flex-direction: column; gap: 6px; }
.input { width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--sep); background: var(--bg); color: var(--text); outline: none; }
.input:focus { border-color: var(--accent); }
.input.bad { border-color: var(--danger); }
.err { color: var(--danger); font-size: 13px; }
.okt { color: var(--ok); }

/* Капча */
.cbox { position: relative; width: 100%; max-width: 420px; margin: 0 auto; border-radius: 14px; overflow: hidden; background: #f6f6f8; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cimg { display: block; width: 100%; height: 100%; pointer-events: none; }
.cover { position: absolute; display: grid; }
.ccell { appearance: none; -webkit-appearance: none; margin: 0; padding: 0; border: 3px solid transparent; background: transparent; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; }
.ccell:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.ccell.on { border-color: var(--accent); background: rgba(123, 77, 255, .22); }
.ccell.on::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }

/* Чипы статусов */
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--sep); color: var(--text); white-space: nowrap; }
.chip.c-accent { background: var(--accent-soft); color: var(--accent); }
.chip.c-ok { background: var(--ok-soft); color: var(--ok); }
.chip.c-warn { background: var(--warn-bg); color: var(--warn-text); }
.chip.c-err { background: var(--err-soft); color: var(--danger); }
.chip.c-muted { background: var(--sep); color: var(--hint); }

/* Списки */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.item + .item { border-top: 1px solid var(--sep); }
.item .sub { font-size: 13px; color: var(--hint); }
.item .chev { color: var(--hint); font-size: 18px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--sep); }
.kv .k { color: var(--hint); flex: none; }
.kv .v { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.copy { cursor: pointer; border-bottom: 1px dashed currentColor; }
.empty { text-align: center; color: var(--hint); padding: 24px 12px; }

/* Победители */
.win { display: flex; gap: 12px; align-items: center; padding: 10px 14px; }
.win + .win { border-top: 1px solid var(--sep); }
.win .pl { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.win.me { background: var(--ok-soft); }

/* Полноэкранные сообщения */
.full-msg { min-height: 60vh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; text-align: center; padding: 24px 8px; }
.full-msg img { width: 64px; height: 64px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 18px); transform: translateX(-50%); max-width: calc(100% - 32px); background: rgba(20, 20, 26, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
.toast[hidden] { display: none; }

.fallback-main { position: sticky; bottom: calc(var(--safe-bottom) + 8px); margin-top: 6px; }

@media (min-width: 420px) {
  #app { padding-left: calc(var(--safe-left) + 16px); padding-right: calc(var(--safe-right) + 16px); }
}
