:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14171a);
  --hint: var(--tg-theme-hint-color, #7a8590);
  --card: var(--tg-theme-secondary-bg-color, #f1f3f5);
  --btn: var(--tg-theme-button-color, #2a7ff0);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --good: #22a55b;
  --bad: #e5484d;
  --gold: #f5a524;
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, "SF Pro Text", Roboto, system-ui, sans-serif; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); overscroll-behavior: none; }
header { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
select { flex: 1; min-width: 0; appearance: none; border: 0; border-radius: 12px; padding: 10px 12px; background: var(--card); color: var(--text); font: inherit; font-weight: 600; }
.chip { white-space: nowrap; padding: 9px 14px; border-radius: 999px; background: var(--btn); color: var(--btn-text); font-weight: 700; font-variant-numeric: tabular-nums; }
main { padding: 14px 16px; max-width: 560px; margin: 0 auto; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav button { flex: 1; border: 0; background: none; color: var(--hint); padding: 8px 0 10px; font: 600 11px/1.2 inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; }
nav button span { font-size: 22px; }
nav button.on { color: var(--btn); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--hint); margin: 22px 0 8px; font-weight: 700; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); font-size: 14px; }
.big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 12px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--hint); }
.btn { border: 0; border-radius: 14px; padding: 13px 16px; background: var(--btn); color: var(--btn-text); font: 700 16px inherit; min-height: 48px; width: 100%; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; }
.btn.ghost { background: var(--card); color: var(--text); }
.btn.sm { width: auto; min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.bad { background: var(--bad); color: #fff; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--card); border-radius: 14px; margin-bottom: 6px; }
.rank { width: 26px; text-align: center; font-weight: 800; color: var(--hint); }
.rank.top { color: var(--gold); }
.av { width: 38px; height: 38px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 20px; flex: none; }
.name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--text); margin-top: 2px; }
.val { font-weight: 800; font-variant-numeric: tabular-nums; }
.val.neg { color: var(--bad); }
.chart { width: 100%; height: 90px; display: block; }
.quote { font-style: italic; }
.empty { text-align: center; color: var(--hint); padding: 40px 10px; }

/* казино */
.wheel-wrap { position: relative; width: 280px; height: 280px; margin: 10px auto 16px; }
.wheel-wrap::after { content: ""; position: absolute; top: -8px; left: 50%; margin-left: -12px; border: 12px solid transparent; border-top: 22px solid var(--text); z-index: 2; }
#wheel { width: 100%; height: 100%; border-radius: 50%; transition: transform 4.2s cubic-bezier(.12,.7,.1,1); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.bet { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0 12px; }
.bet button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); color: var(--text); font-size: 22px; font-weight: 800; }
.bet b { min-width: 80px; text-align: center; font-size: 22px; }
.reels { display: flex; gap: 10px; justify-content: center; margin: 10px 0 14px; }
.reel { width: 78px; height: 88px; border-radius: 16px; background: var(--bg); display: grid; place-items: center; font-size: 46px; border: 2px solid var(--line); }
.reel.spin { filter: blur(1.2px); }
.result { text-align: center; font-weight: 800; font-size: 18px; min-height: 28px; margin-top: 10px; }
.result.win { color: var(--good); }
.result.lose { color: var(--bad); }

/* арена */
.game-card { display: flex; gap: 10px; align-items: center; }
.game-card .ic { font-size: 30px; }
.hp { height: 14px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 6px; }
.hp i { display: block; height: 100%; background: linear-gradient(90deg, var(--bad), var(--good)); transition: width .5s; }
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duel .p { background: var(--card); border-radius: var(--r); padding: 12px; text-align: center; }
.duel .p.turn { outline: 2px solid var(--btn); }
.duel .face { font-size: 44px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 300px; margin: 12px auto; }
.ttt button { aspect-ratio: 1; border: 0; border-radius: 16px; background: var(--card); font-size: 44px; font-weight: 800; color: var(--text); }
.ttt button.X { color: var(--btn); }
.ttt button.O { color: var(--bad); }
.rps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.rps button { border: 0; border-radius: 16px; background: var(--card); font-size: 44px; padding: 14px 0; }
.rps button.sel { outline: 3px solid var(--btn); }
.log { font-size: 14px; color: var(--hint); margin-top: 12px; display: flex; flex-direction: column; gap: 3px; }
.banner { text-align: center; font-size: 22px; font-weight: 800; padding: 18px; border-radius: var(--r); margin: 12px 0; background: var(--card); }
.banner.win { background: color-mix(in srgb, var(--good) 22%, var(--card)); }
.banner.lose { background: color-mix(in srgb, var(--bad) 22%, var(--card)); }
.score { text-align: center; font-size: 28px; font-weight: 800; margin: 6px 0; }

/* профиль */
.ach { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.ach .ic { font-size: 26px; width: 36px; text-align: center; }
.ach.lock { opacity: .5; filter: grayscale(1); }
.bar { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--btn); }
.emojis { display: flex; flex-wrap: wrap; gap: 8px; }
.emojis button { width: 44px; height: 44px; font-size: 24px; border: 2px solid transparent; border-radius: 12px; background: var(--card); }
.emojis button.on { border-color: var(--btn); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; display: flex; align-items: flex-end; }
.modal.hidden, .toast.hidden { display: none; }
.sheet { position: relative; background: var(--bg); width: 100%; max-height: 88vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.close { position: absolute; right: 12px; top: 10px; border: 0; background: var(--card); color: var(--text); width: 34px; height: 34px; border-radius: 50%; font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; z-index: 30; font-weight: 600; max-width: 88vw; text-align: center; }
@media (prefers-reduced-motion: reduce) { #wheel, .hp i { transition: none; } }
.big.neg { color: var(--bad); }
.card .btn.ghost { background: var(--bg); }

/* мафия и задания */
.list-item.dead { opacity: .45; }
.timer { display: inline-block; margin-left: 6px; padding: 2px 10px; border-radius: 999px; background: var(--bg); font-size: 15px; font-variant-numeric: tabular-nums; }
.card.role.mafia { outline: 2px solid var(--bad); }
.card.role.doctor, .card.role.sheriff { outline: 2px solid var(--btn); }
nav button { font-size: 10.5px; }

/* главная: сводка, лента, ставки */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.tile { border: 0; border-radius: 14px; background: var(--card); color: var(--text); padding: 10px 6px; text-align: center; font: inherit; }
.tile b { display: block; font-size: 17px; }
.tile span { font-size: 12px; color: var(--hint); }
.tile.hot { outline: 2px solid var(--good); }
.feed { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed > span:first-child { font-size: 20px; }
.digest { font-size: 14.5px; line-height: 1.5; }
.chips { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; color: var(--hint); font-size: 14px; }
.chips button { width: 38px; height: 34px; border: 2px solid transparent; border-radius: 10px; background: var(--card); color: var(--text); font-weight: 700; }
.chips button.on { border-color: var(--btn); }

/* район */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bg); }
nav button { font-size: 10px; }
nav button span { font-size: 20px; }

.num { flex: 1; min-width: 0; border: 0; border-radius: 12px; padding: 10px 12px; background: var(--card); color: var(--text); font: inherit; font-weight: 600; }

/* покер */
.pk-board { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.pc { display: inline-grid; place-items: center; min-width: 38px; height: 52px; padding: 0 4px; border-radius: 8px; background: #fff; color: #14171a; font-weight: 800; font-size: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.pc.red { color: #d92d3a; }
.pc.back { background: var(--btn); color: var(--btn-text); font-size: 24px; }
.pc.empty { background: transparent; box-shadow: none; outline: 2px dashed var(--line); }
.pcs { display: flex; gap: 4px; }
.pcs .pc { min-width: 32px; height: 44px; font-size: 14px; }
.pk-seat.turn { outline: 2px solid var(--gold); }
