:root {
  --bg: #0b0f12;
  --surface: #121a1e;
  --text: #e9f1ef;
  --muted: #7f958f;
  --line: #1f2c33;
  --teal: #70c7ba;
  --teal-deep: #06201d;
  --teal-bright: #49eacb;
  --red: #ff6b5a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
button, input { font: inherit; }
button { cursor: pointer; }

.topbar { height: 64px; padding: 0 clamp(18px, 5vw, 64px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--text); text-decoration: none; display: flex; gap: 11px; align-items: center; font-size: 15px; font-weight: 700; letter-spacing: -.04em; }
.brand-mark { width: 28px; height: 28px; border: 1.5px solid var(--text); border-radius: 50%; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-17deg); }
.brand-mark i { display: block; width: 5px; height: 5px; background: var(--text); border-radius: 50%; }
.brand-mark i + i { background: var(--teal); }
.network { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.network-separator { color: var(--line); }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--teal-bright); box-shadow: 0 0 0 4px rgba(73,234,203,.16); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.wallet-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 12px; font-weight: 700; letter-spacing: .01em; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.wallet-button:hover { border-color: var(--teal); color: var(--teal); }
.wallet-button.connected { border-color: var(--teal); background: rgba(112,199,186,.14); color: var(--teal); }
.wallet-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal-bright); box-shadow: 0 0 0 3px rgba(73,234,203,.2); }
.wallet-notice { position: fixed; top: 74px; right: clamp(18px, 5vw, 64px); width: min(100% - 36px, 360px); z-index: 20; }
.wallet-notice:empty { display: none; }
.wallet-notice .notice { margin: 0; background: var(--surface); box-shadow: 0 12px 34px rgba(0,0,0,.5); }

main { width: min(100% - 36px, 460px); margin: 0 auto; padding: 44px 0 72px; flex: 1; }

.panel { padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.home-actions { display: grid; gap: 10px; }
.home-button { display: block; text-decoration: none; }
.home-button.primary, .home-button.outline { width: 100%; }
.panel-head { margin-bottom: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stage-rail { display: flex; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.stage-node { flex: 1; height: 3px; border-radius: 999px; background: var(--line); }
.stage-node.done { background: var(--teal); }
.stage-node.current { background: var(--teal-bright); }
h1 { margin: 0 0 8px; font-size: 40px; line-height: 1; letter-spacing: -.06em; font-weight: 800; }
h2 { margin: 0 0 10px; font-size: 32px; line-height: 1.05; letter-spacing: -.05em; font-weight: 800; }
.lead { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.lead strong { color: var(--text); }
.side-strong { text-transform: capitalize; }

.choice-group { border: 0; padding: 0; margin: 0 0 20px; }
legend { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { min-height: 70px; padding: 16px; border: 1.5px solid #33505a; border-radius: 10px; background: #162026; color: var(--text); font-size: 22px; letter-spacing: -.04em; text-transform: capitalize; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.choice:hover { border-color: var(--teal); background: #1b2c33; transform: translateY(-1px); }
.choice.selected { border-color: var(--teal); background: var(--teal); color: var(--teal-deep); }
.choice.selected:hover { background: var(--teal-bright); transform: none; }
.choice.num { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 96px; text-transform: none; }
.num-big { font-size: 40px; line-height: 1; font-weight: 700; letter-spacing: -.08em; }
.locked-number { display: grid; place-items: center; margin: 0 0 18px; }
.locked-number .choice { width: 96px; min-height: 96px; pointer-events: none; }

.stake-block { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.stake-label-row label { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.stake-input { width: 100%; padding: 14px 0 6px; margin-bottom: 6px; border: 0; border-bottom: 2px solid var(--text); border-radius: 0; background: transparent; color: var(--text); font-size: 44px; font-weight: 700; letter-spacing: -.05em; outline: none; }
.fate { color: var(--muted); font-size: 14px; line-height: 1.5; }

.notice { padding: 12px 14px; margin: 14px 0; border-left: 3px solid var(--teal); background: rgba(112,199,186,.14); font-size: 13px; line-height: 1.5; border-radius: 0 6px 6px 0; }
.notice strong { display: block; margin-bottom: 2px; font-size: 12px; }
.notice.error { border-color: var(--red); background: rgba(255,107,90,.13); }
.notice.warn { border-color: #d8a44a; background: rgba(216,164,74,.15); }
.notice .actions { margin-top: 10px; }

.actions { display: flex; gap: 10px; margin-top: 18px; }
.primary, .outline, .share-button { border: 0; border-radius: 10px; padding: 15px 18px; font-size: 14px; font-weight: 800; letter-spacing: .01em; text-align: center; width: 100%; transition: transform .15s ease, background .15s ease; }
.primary { background: var(--teal); color: var(--teal-deep); }
.primary:hover { background: var(--teal-bright); }
.primary:disabled { background: #1c262b; color: #55666a; cursor: default; }
.outline { background: transparent; color: var(--text); border: 1px solid var(--line); }
.outline:hover { border-color: var(--teal); }
.outline:disabled { color: #55666a; border-color: var(--line); cursor: default; }
.outline:disabled:hover { border-color: var(--line); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 20px; }
.back:hover { color: var(--text); }
.back.disabled { pointer-events: none; opacity: 0.5; }

.game-summary { margin-bottom: 20px; }
.game-side, .game-stake, .game-prize { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.game-stake, .game-prize { margin-top: 3px; }
.game-side strong, .game-stake strong, .game-prize strong { color: var(--text); font-weight: inherit; }
.game-side strong { text-transform: capitalize; }
.game-prize span { color: var(--muted); }
.game-summary .muted-note { margin-top: 4px; }

.invite-box { margin-bottom: 4px; }
.invite-box:not(:only-child) { margin-bottom: 20px; }
.waiting-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.waiting-text { color: var(--muted); font-size: 14px; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.large { width: 26px; height: 26px; border-width: 3px; }
.spinner.friend { border-color: var(--line); border-right-color: var(--teal); border-bottom-color: var(--teal); border-top-color: var(--teal); }
.spinner.confirm { border-color: var(--teal); border-bottom-color: transparent; border-radius: 3px; }
.header-loading { display: flex; align-items: center; gap: 14px; }
.header-loading h2 { margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .choice:hover { transform: none; } }
.share-button { border: 1px solid var(--teal); background: transparent; color: var(--teal); margin-top: 0; width: 100%; }
.share-button:hover { background: rgba(112,199,186,.12); }

.reveal-block { margin-top: 20px; }
.reveal-block .lead { margin-bottom: 14px; }
.safety { margin-top: 20px; }
.safety .lead { margin-bottom: 4px; }
.muted-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.clock { font-variant-numeric: tabular-nums; }

.result { margin-top: 20px; padding: 24px; border-radius: 12px; }
.result.winner { background: var(--teal); color: var(--teal-deep); }
.result.loser { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.result-title { margin: 0 0 18px; font-size: 18px; font-weight: 700; }
.result-title strong { font-weight: 800; }
.result-side { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 0; border-top: 1px solid rgba(255,255,255,.12); }
.result.winner .result-side { border-top-color: rgba(6,32,29,.22); }
.result-side-name { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.result-pick { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.result .primary { margin-top: 20px; }
.result.winner .primary { background: var(--teal-deep); color: var(--teal); }
.result.winner .primary:hover { background: #0a302b; color: var(--teal-bright); }

.proof { display: grid; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.proof-heading { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.proof-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.proof-label { color: var(--muted); font-size: 13px; }
.proof-tx { color: var(--teal); font-size: 13px; font-weight: 700; text-decoration: none; }
a.proof-tx:hover { text-decoration: underline; }
.result.winner .proof { border-top-color: rgba(6,32,29,.22); }
.result.winner .proof-heading, .result.winner .proof-label { color: rgba(6,32,29,.72); }
.result.winner .proof-tx { color: var(--teal-deep); }

.feedback-button, .telegram-button, .github-button { display: inline-flex; align-items: center; padding: 7px 14px; border: 1px solid rgba(112,199,186,.5); border-radius: 999px; background: rgba(112,199,186,.14); color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: .01em; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.feedback-button:hover, .telegram-button:hover, .github-button:hover { border-color: var(--teal-bright); background: rgba(112,199,186,.24); color: var(--teal-bright); }
a.telegram-button, a.github-button { text-decoration: none; padding: 7px; }
a.telegram-button svg, a.github-button svg { display: block; width: 16px; height: 16px; }
.feedback-dialog { width: min(100% - 32px, 440px); max-height: min(100% - 48px, 520px); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; }
.feedback-dialog::backdrop { background: rgba(4, 8, 10, .75); }
.feedback-form { padding: 28px; }
.feedback-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.feedback-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
.feedback-close { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; transition: background .1s ease, color .1s ease; flex-shrink: 0; }
.feedback-close:hover { background: rgba(255,255,255,.06); color: var(--text); }
.feedback-label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.feedback-form textarea { width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.6; resize: vertical; transition: border-color .15s ease; }
.feedback-form textarea:focus { border-color: var(--teal); outline: none; }
.feedback-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.feedback-actions { margin-top: 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px); padding: 12px 20px; border-radius: 8px; background: var(--surface); color: var(--teal); font-size: 14px; font-weight: 600; letter-spacing: -.01em; box-shadow: 0 12px 28px rgba(0,0,0,.45); opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; z-index: 40; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  main { width: min(100% - 24px, 460px); padding: 28px 0 56px; }
  .panel { padding: 22px; }
  .topbar { padding: 0 16px; }
  .network span:not(.pulse):not(:last-child) { display: none; }
}
