:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --tile: #eceef1;
  --ink: #0b0b0c;
  --muted: #8b9099;
  --line: #e2e5ea;
  --blue: #1a5cff;
  --blue-2: #3d7bff;
  --blue-soft: #e6eeff;
  --r: 22px;
  --font: -apple-system, "SF Pro Display", "Inter", "Helvetica Neue", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); overflow-x: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
i { font-style: italic; font-weight: 400; }
.blue { color: var(--blue); }

#app { max-width: 520px; margin: 0 auto; padding: 0 16px; }
.screen { display: none; animation: in .35s cubic-bezier(.2, .8, .2, 1); }
.screen.active { display: block; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }

/* мелкая служебная строка как в рефе */
.meta { display: flex; justify-content: space-between; padding: 14px 2px 0; font-size: 10px; letter-spacing: .04em; color: #b7bbc2; text-transform: uppercase; }

/* сетка справа от заголовка, как на слайдах */
.hero { position: relative; z-index: 0; padding: 26px 0 22px; }
.grid-bg::before {
  content: ""; position: absolute; inset: 0 -16px; z-index: -1;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: right top;
  -webkit-mask-image: linear-gradient(100deg, transparent 40%, #000 90%);
          mask-image: linear-gradient(100deg, transparent 40%, #000 90%);
}
h1 { margin: 0; font-size: 40px; line-height: 1.02; letter-spacing: -.045em; font-weight: 700; }
h1 i { font-weight: 400; letter-spacing: -.04em; }

.pill { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 9px 16px; border-radius: 99px; font-size: 14px; font-weight: 600; }
.pill.dark { background: var(--ink); color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #2ee07a; box-shadow: 0 0 0 4px rgba(46,224,122,.2); animation: pulse 1.8s infinite; }
.pill.waiting .dot { background: #ffb020; box-shadow: 0 0 0 4px rgba(255,176,32,.2); }
.pill.ended .dot { background: #8b9099; box-shadow: none; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(46,224,122,0); } }
.blue-pill { margin: 0; padding: 6px 12px; background: var(--blue); color: #fff; font-size: 13px; }

.card { position: relative; background: var(--card); border-radius: var(--r); padding: 18px; margin-bottom: 12px; overflow: hidden; }
.card.blue { background: var(--blue); color: #fff; }
.card.black { background: var(--ink); color: #fff; }
.label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.num { font-size: 10px; color: #c3c7ce; }

/* таймер */
.timer-card { padding: 20px 18px 18px; box-shadow: 0 14px 34px rgba(26,92,255,.32); }
.timer-card .glow { position: absolute; width: 220px; height: 220px; right: -60px; top: -80px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.35), transparent 65%); }
.timer-card .glow::after { content: ""; position: absolute; inset: 40px; border: 1.5px solid rgba(255,255,255,.18); border-radius: 50%; }
.timer-label { font-size: 14px; font-weight: 500; opacity: .85; }
.timer { display: flex; align-items: flex-start; gap: 4px; margin-top: 8px; }
.timer div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.timer b { font-size: 46px; font-weight: 600; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.timer small { font-size: 11px; opacity: .7; margin-top: 4px; }
.timer i { font-size: 34px; opacity: .45; line-height: 1.1; font-style: normal; }
.timer-dates { margin-top: 14px; font-size: 12px; opacity: .7; }

/* ссылка */
.link { font-size: 17px; font-weight: 600; letter-spacing: -.01em; padding: 14px; background: var(--tile); border-radius: 14px; word-break: break-all; }
.link.err { font-size: 14px; color: #d13b3b; font-weight: 500; }
.btns { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin-top: 10px; }
.btn { height: 50px; border-radius: 14px; font-weight: 600; font-size: 15px; transition: transform .12s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(26,92,255,.3); }
.btn.ghost { background: var(--tile); }
.hint { margin: 10px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.35; }

/* плитки «в цифрах» */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--tile); border-radius: 18px; padding: 14px 12px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; }
.tile b { font-size: 34px; font-weight: 600; letter-spacing: -.04em; line-height: 1; }
.tile span { font-size: 12px; color: #4a4f57; }
.tile.blue { background: var(--blue); color: #fff; }
.tile.blue span { color: rgba(255,255,255,.85); }

/* штриховой прогресс-бар */
.ticks { display: flex; gap: 6px; height: 30px; align-items: stretch; }
.ticks span { flex: 1; border-radius: 8px; background: #e4e7eb; transition: background .4s; }
.ticks span.tier { box-shadow: inset 0 0 0 2px #c9ceda; }
.ticks span.on { background: var(--blue); box-shadow: none; }
.tick-marks { position: relative; height: 34px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.tick-marks span { position: absolute; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.tick-marks span b { display: block; font-size: 13px; color: var(--ink); }
.tick-marks span.on b { color: var(--blue); }

/* правила */
.rules summary { list-style: none; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 16px; }
.rules summary::-webkit-details-marker { display: none; }
.chev { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin-top: -4px; }
.rules[open] .chev { transform: rotate(225deg); margin-top: 4px; }
.rules ol { list-style: none; margin: 14px 0 0; padding: 0; }
.rules li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.4; }
.rules li span { font-size: 10px; color: #b7bbc2; padding-top: 3px; }

/* рейтинг */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; align-items: end; margin: 4px 0 14px; }
.pod { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.pod .ava { width: 56px; height: 56px; font-size: 20px; margin-bottom: 8px; border: 3px solid #fff; box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.pod.p1 .ava { width: 70px; height: 70px; font-size: 24px; border-color: var(--blue); }
.pod .name { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .cnt { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.pod .bar { width: 100%; border-radius: 18px 18px 6px 6px; background: var(--card); display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; font-size: 34px; font-weight: 700; letter-spacing: -.04em; }
.pod.p1 .bar { height: 120px; background: var(--blue); color: #fff; box-shadow: 0 14px 30px rgba(26,92,255,.3); position: relative; }
.pod.p1 .cnt { margin-bottom: 20px; }
.pod.p2 .bar { height: 92px; }
.pod.p3 .bar { height: 72px; }
.pod.empty .ava { background: var(--tile); color: #c3c7ce; border-style: dashed; border-color: #d3d6db; box-shadow: none; }
.pod.me .name { color: var(--blue); }
.crown { position: absolute; top: -12px; left: 50%; transform: translateX(-50%) rotate(-8deg); background: var(--ink); color: #fff; font-size: 10px; font-weight: 600; letter-spacing: .04em; padding: 4px 9px; border-radius: 99px; }

.list { background: var(--card); border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .rk { width: 26px; font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .ava { width: 38px; height: 38px; font-size: 15px; }
.row .nm { flex: 1; font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .ct { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.row.me { background: var(--blue-soft); }
.row.me .nm::after { content: " · ты"; color: var(--blue); }
.empty-list { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.4; }

.ava { flex: none; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.ava img { width: 100%; height: 100%; object-fit: cover; }

.me-bar { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); margin-top: 12px; display: none; align-items: center; gap: 12px; padding: 12px 16px; background: var(--ink); color: #fff; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.me-bar.show { display: flex; }
.me-bar b { font-size: 20px; letter-spacing: -.03em; }
.me-bar span { flex: 1; font-size: 14px; opacity: .8; }

/* призы */
.counter { display: grid; grid-template-columns: auto 1fr; gap: 0 14px; align-items: center; padding-top: 14px; }
.counter .big { font-size: 84px; font-weight: 700; letter-spacing: -.06em; line-height: 1; color: var(--blue); }
.counter-side { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; font-size: 15px; color: #4a4f57; }
.counter .ticks, .counter .tick-marks { grid-column: 1 / -1; }
.counter .ticks { margin-top: 14px; }

.prize-note { margin: -4px 2px 12px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.prize-note.warn { color: #c2410c; background: #fff1e6; padding: 10px 12px; border-radius: 12px; margin-left: 0; margin-right: 0; }
.section-title { font-size: 26px; letter-spacing: -.04em; font-weight: 700; margin: 24px 2px 12px; }

.tier { display: flex; gap: 14px; align-items: center; }
.tier .need { flex: none; width: 58px; height: 58px; border-radius: 16px; background: var(--tile); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.tier .need small { font-size: 9px; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-top: 3px; }
.tier .info { flex: 1; min-width: 0; }
.tier .info b { display: block; font-size: 16px; letter-spacing: -.02em; }
.tier .info p { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.3; }
.tier .st { flex: none; font-size: 12px; font-weight: 600; padding: 7px 11px; border-radius: 99px; background: var(--tile); color: #4a4f57; }
.tier.done .need { background: var(--blue); color: #fff; }
.tier.done .need small { color: rgba(255,255,255,.75); }
.tier.done .st { background: var(--blue); color: #fff; }
a.st { text-decoration: none; }
.tier-card .num { position: absolute; top: 10px; right: 14px; }

.top-card { padding: 22px 18px 10px; margin-top: 20px; }
.top-card h2 { margin: 0 0 14px; font-size: 32px; line-height: 1; letter-spacing: -.045em; }
.badge { position: absolute; top: 22px; right: -6px; transform: rotate(-12deg); background: var(--blue); color: #fff; font-size: 12px; font-weight: 600; padding: 8px 18px; border-radius: 99px; box-shadow: 0 8px 20px rgba(26,92,255,.45); }
.tp { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid rgba(255,255,255,.12); }
.tp .pl { flex: none; width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,.08); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.tp:first-of-type .pl { background: var(--blue); }
.tp b { display: block; font-size: 16px; letter-spacing: -.02em; }
.tp p { margin: 3px 0 0; font-size: 13px; color: rgba(255,255,255,.55); }

/* таббар */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); width: calc(100% - 32px); max-width: 488px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; background: rgba(255,255,255,.86); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); border-radius: 22px; box-shadow: 0 10px 30px rgba(0,0,0,.1), inset 0 0 0 1px rgba(0,0,0,.04); z-index: 10; }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px; border-radius: 16px; font-size: 11px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { background: var(--blue); color: #fff; }

.toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -80px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 500; transition: transform .3s cubic-bezier(.2,.8,.2,1); z-index: 20; white-space: nowrap; }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 360px) {
  h1 { font-size: 34px; }
  .timer b { font-size: 38px; }
  .tile b { font-size: 28px; }
}
