:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #f5f7ff;
  background: #060d20;
  --muted: #a9b9d8;
  --gold: #ffdc88;
  --blue-line: #283f68;
  --panel: #0b1730;
  --gold-fill: linear-gradient(150deg, #fff0b7, #f6c96b 53%, #c68c38);
}

* { box-sizing: border-box; }
body { min-height: 100svh; margin: 0; background: radial-gradient(ellipse at 50% 0%, #132a57 0%, transparent 55%); }
a { color: inherit; text-underline-offset: 4px; }
button, select, input { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #83d9ff; outline-offset: 3px; }

.top { background: #08132a; border-bottom: 1px solid #233c65; }
.shell, .top-inner { width: min(calc(100% - 32px), 1060px); margin-inline: auto; }
.shell { padding-bottom: 32px; }
.top-inner, .intro { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.top-inner { min-height: 66px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 1.15rem; font-weight: 800; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 33px; color: #302005; background: var(--gold-fill); border: 1px solid #ffe7a4; border-radius: 9px; font-size: 1.08rem; box-shadow: 0 0 17px #efc66a32; }
.header-link { text-decoration: none; border: 1px solid #344f7c; border-radius: 9px; padding: 8px 11px; font-size: .82rem; font-weight: 650; white-space: nowrap; }
.header-link:hover { border-color: var(--gold); color: var(--gold); }
.header-link span { margin-left: 3px; color: var(--gold); }
.header-actions { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 6px; }
.header-actions .header-link { min-height: 38px; padding: 7px 10px; display: inline-flex; align-items: center; }
button.header-link { color: var(--gold); background: #172547; }
.telegram-app { padding-inline: var(--tg-content-safe-area-inset-left, 0px) var(--tg-content-safe-area-inset-right, 0px); }
.telegram-app .shell { padding-bottom: calc(32px + var(--tg-content-safe-area-inset-bottom, 0px)); }

#invite-dialog { width: min(370px, calc(100% - 24px)); padding: 16px; border: 1px solid #947540; border-radius: 16px; background: var(--panel); color: inherit; }
#invite-dialog::backdrop { background: #030713c4; }
.invite-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.invite-header h2 { margin: 0; color: var(--gold); }
#invite-note { color: var(--muted); font-size: .85rem; }
#invite-qr { display: block; width: min(224px, 100%); height: auto; margin: 12px auto; border-radius: 8px; }
#invite-link { display: block; margin-bottom: 12px; color: #b9d8ff; overflow-wrap: anywhere; font-size: .78rem; }
#invite-copy { width: 100%; }

.intro { padding-block: 27px; }
h1 { margin: 0; font: 500 clamp(2.1rem, 5.8vw, 4rem)/.98 Georgia, serif; letter-spacing: -.055em; }
h1 em { color: var(--gold); font-weight: inherit; }
.balance { min-width: 155px; padding: 9px 14px; border: 1px solid #81683b; border-radius: 12px; background: linear-gradient(145deg, #192742, #0b142a); text-align: right; }
.balance span, .balance small { display: block; color: var(--muted); font-size: .72rem; }
.balance strong { display: block; margin: 1px 0 2px; color: var(--gold); font-size: clamp(1.25rem, 3vw, 1.66rem); font-variant-numeric: tabular-nums; }
.balance b { color: #e9efff; letter-spacing: .07em; }

.table { display: grid; grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr); overflow: hidden; border: 1px solid #4d6391; border-radius: 18px; background: var(--panel); box-shadow: 0 16px 50px #010612a8, 0 0 30px #3468d824; }
.stage { position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between; min-height: 320px; padding: clamp(15px, 3vw, 26px); border-right: 1px solid #304972; background: radial-gradient(ellipse at 50% 99%, #25499c, transparent 71%), linear-gradient(153deg, #101c40, #071429 75%); }
.stage::before { position: absolute; z-index: -1; inset: 0; content: ''; background: conic-gradient(from 157deg at 22% 0%, transparent, #60c0ff28 10deg, transparent 24deg), conic-gradient(from 169deg at 84% 0%, transparent, #e7ba7139 13deg, transparent 29deg); }
.stage::after { position: absolute; z-index: -1; inset: 16% 9% 8%; content: ''; border: 1px solid #7899dc38; border-radius: 50%; box-shadow: 0 0 48px #4164d02e; transform: rotate(-8deg); }
.stage[data-jackpot="true"] { background: radial-gradient(ellipse at 50% 95%, #806020, transparent 78%), linear-gradient(145deg, #202747, #11192d); }
.table-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 9px; color: #bcccde; font-size: .76rem; font-variant-numeric: tabular-nums; }
#time { color: var(--gold); text-align: right; }
.cards { display: flex; justify-content: center; align-items: center; gap: clamp(9px, 2vw, 17px); margin-block: 18px; min-height: 110px; }
.card { position: relative; display: grid; place-items: center; width: clamp(61px, 17vw, 100px); aspect-ratio: 3 / 4.2; border: 1px solid #fff8dd; border-radius: 11px; color: #152548; background: linear-gradient(150deg, #fffefa, #ece6d8); box-shadow: 0 8px 20px #02061799; }
.card:nth-child(2) { width: clamp(66px, 19vw, 109px); transform: translateY(-6px); }
.card-rank { position: absolute; top: 6px; left: 9px; font: 700 clamp(.85rem, 2vw, 1.16rem)/1 Georgia, serif; }
.card-emblem { font: 400 clamp(1.8rem, 6vw, 3.25rem)/1 Georgia, serif; }
.card.red { color: #a22845; }
.card.face-down { border: 1px solid #e5bd70; outline: 1px solid #ebc37744; outline-offset: 3px; color: #ffe0a5; background: repeating-linear-gradient(135deg, #79a8fb15 0 1px, transparent 1px 8px), linear-gradient(145deg, #254984, #0b204b); box-shadow: inset 0 0 19px #397cf167, 0 12px 28px #030913; }
.status { min-height: 1.35em; margin: 0; text-align: center; color: #eef3ff; font-size: .86rem; font-weight: 600; }

.wager { padding: clamp(13px, 2.5vw, 22px); }
.jackpot-panel { display: flex; align-items: center; gap: 9px; min-height: 59px; padding: 9px 11px; border: 1px solid #947540; border-radius: 11px; background: linear-gradient(107deg, #3c3020, #1d2640 65%); }
.jackpot-icon { display: grid; place-items: center; flex: 0 0 29px; height: 29px; border: 1px solid #b58c50; border-radius: 8px; color: var(--gold); background: #382a1f; }
.jackpot-copy strong, .jackpot-copy span { display: block; }
.jackpot-copy strong { color: var(--gold); font-size: .9rem; }
.jackpot-copy span { color: #ddc6a5; font-size: .7rem; margin-top: 2px; }
.jackpot-state { margin-left: auto; color: #e9d3aa; text-align: right; font-size: .72rem; line-height: 1.35; }
.jackpot-panel[data-active="true"] { color: #33200b; background: var(--gold-fill); border-color: #ffe5a6; box-shadow: 0 0 21px #f4c86b48; }
.jackpot-panel[data-active="true"] .jackpot-copy strong, .jackpot-panel[data-active="true"] .jackpot-copy span, .jackpot-panel[data-active="true"] .jackpot-state { color: inherit; }

.quote { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-block: 13px; }
.quote > div { display: grid; align-content: center; min-height: 54px; gap: 3px; padding: 6px 3px; border: 1px solid var(--blue-line); border-radius: 9px; background: #09142c; text-align: center; }
.quote span { color: var(--muted); font-size: .71rem; }
.quote strong { font-variant-numeric: tabular-nums; font-size: clamp(.88rem, 2.6vw, 1.04rem); overflow-wrap: anywhere; }
.quote > div:last-child strong { color: var(--gold); }

.actions, .issue { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-size: .84rem; color: #e0e8fb; }
input, select, button { min-height: 44px; border: 1px solid var(--blue-line); border-radius: 8px; padding: 7px 10px; }
input, select { width: 100%; color: inherit; background: #07132a; }
button { color: #2e1f0a; background: var(--gold-fill); border-color: #f6d68f; font-weight: 750; cursor: pointer; }
button:enabled:hover { filter: brightness(1.12); }
button.secondary { color: #e0ebff; background: #14284d; border-color: #385581; }
button:disabled { opacity: .52; cursor: default; }
.action-buttons { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; }
#stake-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
#stake-picker legend { margin-bottom: 7px; padding: 0; color: #e0e8fb; font-size: .84rem; }
.stakes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.stakes button[aria-pressed="true"] { color: var(--gold); border-color: #dbb86a; background: #2e2930; }
.fine, .notice { margin: 0; font-size: .77rem; line-height: 1.4; }
.fine { color: var(--muted); }
.reserve:empty, .notice:empty { display: none; }
.notice { color: #ffc6a0; margin-top: 10px; }

.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.panels section, .rules { padding: 13px 15px; border: 1px solid #263a61; border-radius: 12px; background: #0b1730; }
h2 { margin: 0 0 8px; font-size: .98rem; }
ul { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .81rem; }
li { padding-block: 7px; }
li + li { border-top: 1px solid #1d2f4d; }
.rules { margin-top: 12px; font-size: .82rem; }
.rules summary { cursor: pointer; font-weight: 650; }
.rules[open] summary { color: var(--gold); }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.rules-grid section { padding: 12px; border: 1px solid var(--blue-line); border-radius: 9px; background: #09142c; }
.rules h3 { color: var(--gold); font-size: .9rem; margin: 0 0 7px; }
.rules p, .rules ul { color: var(--muted); line-height: 1.55; margin: 0; }
.rules strong { color: #f5f7ff; }
.rules p + p, .rules ul + p { margin-top: 7px; }
.rules li { padding-block: 4px; }
.narrow { max-width: 480px; }
.narrow .table { display: block; }

@media (max-width: 760px) {
  .table { grid-template-columns: minmax(0, 1fr); }
  .stage { min-height: 205px; border-right: 0; border-bottom: 1px solid #304972; }
}
@media (max-width: 480px) {
  .shell, .top-inner { width: calc(100% - 22px); }
  .top-inner { min-height: 56px; }
  .intro { padding-block: 15px; }
  .balance { padding: 6px 9px; min-width: 0; }
  .panels, .rules-grid { grid-template-columns: minmax(0, 1fr); }
}
