:root {
  color-scheme: dark;
  --bg: #100a1c;
  --bg-2: #1b1130;
  --card: rgba(43, 28, 67, 0.82);
  --card-solid: #2b1c43;
  --line: rgba(233, 199, 119, 0.22);
  --gold: #e9c777;
  --gold-2: #f6dfa6;
  --text: #f7f0e6;
  --muted: #b9a9cf;
  --green: #69d6a4;
  --red: #ff8f9b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 12% 0%, rgba(126, 74, 168, 0.42), transparent 42%),
    radial-gradient(circle at 92% 18%, rgba(199, 142, 63, 0.16), transparent 34%),
    linear-gradient(160deg, var(--bg-2), var(--bg) 58%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: break-word;
  scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }
:where(button, a):focus-visible { outline: 3px solid var(--gold-2); outline-offset: 3px; }
@media (pointer: coarse) {
  :where(button, a, [role="button"]) { min-block-size: 44px; min-inline-size: 44px; }
}
.app { width: min(100%, 560px); margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

.hero { position: relative; padding: 34px 8px 22px; text-align: center; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; width: 210px; height: 210px; left: 50%; top: -96px;
  transform: translateX(-50%); border: 1px solid var(--line); border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(233, 199, 119, 0.025), 0 0 0 48px rgba(233, 199, 119, 0.018);
  pointer-events: none;
}
.hero-mark { color: var(--gold); font-size: 34px; line-height: 1; text-shadow: 0 0 24px rgba(233, 199, 119, 0.5); }
.hero-kicker { margin-top: 10px; color: var(--gold); font-size: 10px; letter-spacing: 0.28em; font-weight: 700; }
h1 { margin: 8px 0 6px; font-size: clamp(26px, 7vw, 34px); line-height: 1.15; font-weight: 750; }
.prize { margin: 0 auto; max-width: 440px; color: var(--muted); white-space: pre-line; }
.status { display: inline-flex; align-items: center; gap: 7px; margin-top: 16px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--gold-2); font-size: 12px; background: rgba(16, 10, 28, 0.42); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.status.live { color: var(--green); }
.status.done { color: var(--muted); }
.status.cancelled { color: var(--red); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.card p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.loading-card { text-align: center; color: var(--muted); padding: 34px 18px; }
.spinner { width: 30px; height: 30px; margin: 0 auto 14px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 12px; border-radius: 14px; background: rgba(12, 7, 22, 0.34); border: 1px solid rgba(255,255,255,0.04); }
.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { margin-top: 3px; font-size: 19px; font-weight: 700; color: var(--gold-2); font-variant-numeric: tabular-nums; }

.conditions { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.conditions li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: rgba(12, 7, 22, 0.28); }
.conditions .dot { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: rgba(233,199,119,0.12); color: var(--gold); }
.conditions .ok { color: var(--green); background: rgba(105,214,164,0.12); }
.conditions .bad { color: var(--red); background: rgba(255,143,155,0.12); }

.btn { width: 100%; border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 700; cursor: pointer; transition: transform 0.12s ease, filter 0.12s ease; }
.btn:active { transform: scale(0.985); filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { color: #241527; background: linear-gradient(135deg, var(--gold-2), var(--gold)); box-shadow: 0 10px 26px rgba(233,199,119,0.16); }
.btn-ghost { color: var(--text); background: rgba(255,255,255,0.06); border: 1px solid var(--line); }
.btn-danger { color: var(--red); background: rgba(255,143,155,0.08); border: 1px solid rgba(255,143,155,0.22); }
.actions { display: grid; gap: 10px; margin-top: 16px; }
.notice { padding: 11px 13px; border-radius: 12px; background: rgba(233,199,119,0.07); border: 1px solid var(--line); color: var(--gold-2); font-size: 13px; }
.notice.error { background: rgba(255,143,155,0.07); border-color: rgba(255,143,155,0.22); color: #ffc0c7; }
.notice.ok { background: rgba(105,214,164,0.07); border-color: rgba(105,214,164,0.22); color: #b8f4d8; }

.winners { display: grid; gap: 8px; }
.winner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(12,7,22,0.3); }
.winner-medal { font-size: 20px; }
.winner-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.winner-state { color: var(--muted); font-size: 11px; }
.hash { display: block; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,0.28); color: var(--gold-2); font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; user-select: all; }
.ranking { max-height: 310px; overflow: auto; margin-top: 10px; border: 1px solid rgba(255,255,255,0.05); border-radius: 12px; }
.rank-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 12px; }
.rank-row:last-child { border-bottom: 0; }
.rank-pos { color: var(--gold); font-variant-numeric: tabular-nums; }
.rank-score { display: block; color: var(--muted); font: 9px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

.foot { padding: 22px 12px 4px; text-align: center; color: rgba(185,169,207,0.58); font-size: 11px; }

dialog.sheet { position: fixed; inset: 0; z-index: 20; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 16px; border: 0; background: transparent; overflow: auto; }
dialog.sheet[open] { display: grid; place-items: end center; }
dialog.sheet:modal { overscroll-behavior: contain; }
dialog.sheet::backdrop { overflow: hidden; overscroll-behavior: contain; background: rgba(6, 3, 12, 0.72); backdrop-filter: blur(6px); }
.sheet-card { width: min(100%, 480px); padding: 22px; border-radius: 24px 24px 20px 20px; background: var(--card-solid); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: center; }
.sheet-card h1 { margin: 0 0 6px; font-size: 20px; }
.sheet-card p { margin: 0 0 18px; color: var(--muted); }
.captcha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.captcha-item { min-height: 82px; border-radius: 16px; border: 1px solid var(--line); background: rgba(12,7,22,0.36); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.captcha-item tg-emoji { font-size: 34px; }
.text-btn { margin-top: 14px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 8px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 12px; background: #f3e6c9; color: #2a1935; font-size: 13px; box-shadow: var(--shadow); text-align: center; }
.hidden { display: none !important; }

@media (min-width: 520px) {
  .hero { padding-top: 42px; }
  .sheet { place-items: center; }
  .sheet-card { border-radius: 24px; }
}
