:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #007aff);
  --button: var(--tg-theme-button-color, #007aff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --sep: color-mix(in srgb, var(--hint) 28%, transparent);
  --danger: #ff3b30;
  --ok: #34c759;
  --radius: 14px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  /* Как в Telegram на iPhone: SF Pro через системный стек */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "SF UI Text", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
  font-optical-sizing: auto;
}
body {
  padding: 10px 16px calc(22px + env(safe-area-inset-bottom));
  font-size: 17px;
  line-height: 1.29;
  letter-spacing: -0.022em;
  font-weight: 400;
}

.app {
  width: min(420px, 100%);
  margin: 0 auto;
  animation: rise 0.38s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hero {
  text-align: center;
  padding: 4px 0 14px;
}
.lottie {
  width: 112px;
  height: 112px;
  margin: 0 auto 2px;
}
.lottie.sm {
  width: 40px;
  height: 40px;
  margin: 0;
  flex: 0 0 auto;
}
.brand {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.08px;
  color: var(--hint);
}
h1 {
  margin: 4px 0 2px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.36px;
  line-height: 1.14;
}
.lead {
  margin: 0;
  color: var(--hint);
  font-size: 15px;
  line-height: 1.33;
  letter-spacing: -0.24px;
  font-weight: 400;
}

.stats {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 12px 6px;
  margin-bottom: 6px;
}
.stat {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.stat-divider {
  width: 1px;
  background: var(--sep);
  margin: 2px 0;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--hint);
  letter-spacing: -0.01em;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chance-hint {
  margin: 0 0 12px;
  text-align: center;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.3;
  min-height: 17px;
}

.panel {
  background: var(--secondary);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  animation: rise 0.36s var(--ease) both;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.panel h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.hint {
  margin: 2px 0 0;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.3;
}
.ends .panel-head { margin-bottom: 0; }

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.winners-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: win;
}
.winners-list li {
  counter-increment: win;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 0.33px solid var(--sep);
  font-size: 16px;
  font-weight: 500;
}
.winners-list li:last-child { border-bottom: 0; }
.winners-list li::before {
  content: counter(win);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}
.winners-list li.gold::before {
  background: #ffd60a;
  color: #1c1c1e;
}
.winners-empty {
  margin: 0;
  color: var(--hint);
  font-size: 15px;
}
.winner-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.winner-name {
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.winner-id {
  font-size: 12px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}
.verify-note {
  margin: 12px 0 0;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.3;
}

.subs {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.subs li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  margin: 0 -10px;
  border-radius: 10px;
  font-size: 16px;
}
.subs li + li { margin-top: 4px; }
.subs li.sub-bad {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.subs li.sub-ok {
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}
.subs a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.mark {
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
}
.mark.bad { transform: scale(1.05); }
.mark.ok { transform: none; }

.captcha-q {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.captcha-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.captcha-grid button {
  min-height: 64px;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  font-size: 30px;
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.captcha-grid button:active { transform: scale(0.97); }
.captcha-grid button.picked {
  box-shadow: 0 0 0 2px var(--button);
}

.steps {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--hint);
  background: var(--secondary);
  border-radius: 999px;
  padding: 7px 4px;
  transition: background 0.28s var(--ease), color 0.28s var(--ease), transform 0.28s var(--ease);
}
.step.on {
  color: var(--button-text);
  background: var(--button);
  transform: translateY(-1px);
}
.step.done {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
}

.step-panel {
  animation: rise 0.42s var(--ease) both;
}
.panel.celebrate {
  background: color-mix(in srgb, var(--ok) 12%, var(--secondary));
}
.pulse-in {
  animation: pulse-pop 0.55s var(--ease) both;
}
@keyframes pulse-pop {
  0% { transform: scale(0.96); opacity: 0.55; }
  55% { transform: scale(1.02); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

.link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-bottom: 8px;
}

.footer {
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, transparent, var(--bg) 28%);
}
.btn {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: transform 0.16s var(--ease), opacity 0.16s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.42; cursor: default; }
.btn.primary {
  background: var(--button);
  color: var(--button-text);
}
.btn.secondary {
  background: var(--bg);
  color: var(--link);
}
.btn.accent {
  background: #ff9500;
  color: #fff;
}
.status {
  min-height: 18px;
  margin: 10px 0 0;
  text-align: center;
  color: var(--hint);
  font-size: 13px;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.screen { animation: rise 0.36s var(--ease) both; }
.hero.tight { padding-top: 0; }
.topbar { margin-bottom: 10px; }
.page-title {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.link-back {
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.quote {
  background: color-mix(in srgb, #ff2d55 10%, var(--secondary));
  border-left: 3px solid #ff2d55;
  border-radius: 12px;
  padding: 14px 14px 14px 16px;
  margin: 0 0 14px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.quote.compact { font-size: 14px; }
.section-label {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.menu { display: flex; flex-direction: column; gap: 10px; }
.btn.menu-btn {
  min-height: 54px;
  border-radius: 14px;
  color: #fff;
  text-align: left;
  padding: 0 18px;
  font-size: 17px;
}
.btn.menu-btn.violet {
  background: linear-gradient(135deg, #af52de, #5856d6);
}
.btn.menu-btn.rose {
  background: linear-gradient(135deg, #ff2d55, #ff375f);
}
.list { display: flex; flex-direction: column; gap: 8px; }
.contest {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--secondary);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.16s var(--ease);
}
.contest:active { transform: scale(0.985); }
.contest-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.contest-meta {
  font-size: 13px;
  color: var(--hint);
}
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
}
.badge.on {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}
.badge.off {
  background: color-mix(in srgb, var(--hint) 18%, transparent);
  color: var(--hint);
}
.profile-line {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.profile-line:last-child { margin-bottom: 0; }

[hidden] { display: none !important; }
