:root {
  --bg: #0c1410;
  --panel: #15211b;
  --panel-2: #1c2c24;
  --line: #2a3d33;
  --text: #e8f1ec;
  --muted: #8fa89a;
  --accent: #f2c14e;
  --good: #3ecf8e;
  --ok: #f2c14e;
  --bad: #ef5b5b;
  --felt: #155a3a;
  --felt-edge: #0e3d28;
  --fold: #3a4a42;
  --call: #2f7de1;
  --raise: #e0642f;
  --spade: #1b1b1f;
  --heart: #d6283a;
  --diamond: #2463d6;
  --club: #1f8a3c;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: var(--tg-viewport-stable-height, 100vh);
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); }

/* ---------- Шапка ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 8px; }
.stats { display: flex; gap: 6px; align-items: stretch; }
.stat {
  flex: 1; background: var(--panel); border-radius: 10px; padding: 6px 4px; text-align: center;
  display: flex; flex-direction: column;
}
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }
.icon-btn { width: 40px; background: var(--panel); border-radius: 10px; font-size: 18px; color: var(--muted); }
.tabs { display: flex; margin-top: 8px; background: var(--panel); border-radius: 10px; padding: 3px; }
.tabs button { flex: 1; padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--panel-2); color: var(--text); }

/* ---------- Стол ---------- */
.felt {
  position: relative;
  background: radial-gradient(ellipse at center, #1d7a4f 0%, var(--felt) 55%, var(--felt-edge) 100%);
  border: 6px solid #3b2a1a;
  border-radius: 120px / 90px;
  padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .4);
}
.seat { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.board { display: flex; gap: 5px; min-height: 58px; }
.pot { background: rgba(0, 0, 0, .35); padding: 3px 12px; border-radius: 20px; font-size: 13px; }
.pot b { color: var(--accent); }
.badge {
  background: rgba(0, 0, 0, .45); padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  letter-spacing: .3px;
}
.hero-badge { background: var(--accent); color: #2a1f00; }

/* ---------- Карты ---------- */
.cards { display: flex; gap: 5px; }
.card {
  width: 40px; height: 56px; border-radius: 6px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1; box-shadow: 0 2px 4px rgba(0, 0, 0, .35);
  user-select: none;
}
.card .r { font-size: 19px; }
.card .s { font-size: 17px; margin-top: 2px; }
.cards.big .card { width: 56px; height: 78px; border-radius: 8px; }
.cards.big .card .r { font-size: 27px; }
.cards.big .card .s { font-size: 23px; }
.card.s0 { color: var(--spade); }
.card.s1 { color: var(--heart); }
.card.s2 { color: var(--diamond); }
.card.s3 { color: var(--club); }
.card.back {
  background: repeating-linear-gradient(45deg, #a8323e 0 6px, #8c2530 6px 12px);
  border: 3px solid #fff;
}
.card.empty { background: rgba(255, 255, 255, .08); box-shadow: none; border: 1px dashed rgba(255, 255, 255, .25); }
.card.deal { animation: deal .25s ease-out; }
@keyframes deal { from { transform: translateY(-8px) scale(.9); opacity: 0; } }

/* ---------- Ситуация / инфо ---------- */
.situation {
  margin: 10px 0 8px; padding: 10px 12px; background: var(--panel); border-radius: var(--radius);
  font-size: 14px;
}
.situation .street { color: var(--accent); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.situation .prev { color: var(--muted); font-size: 13px; }

.info { background: var(--panel); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.info:empty { display: none; }
.eq-head { display: flex; justify-content: space-between; align-items: baseline; }
.eq-head b { font-size: 22px; }
.eq-sub { color: var(--muted); font-size: 12px; }
.bar { position: relative; height: 10px; border-radius: 6px; background: var(--panel-2); margin: 8px 0 4px; overflow: visible; }
.bar .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--call), var(--good)); }
.bar .mark { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.kv { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.kv span { display: block; font-size: 11px; color: var(--muted); }
.kv b { font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { background: var(--panel-2); border-radius: 20px; padding: 3px 9px; font-size: 12px; }
.chip b { color: var(--accent); }
.mini-label { font-size: 11px; color: var(--muted); margin-top: 10px; text-transform: uppercase; letter-spacing: .4px; }
.outs-cards { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.outs-cards .card { width: 24px; height: 32px; border-radius: 4px; }
.outs-cards .card .r { font-size: 12px; }
.outs-cards .card .s { font-size: 11px; margin: 0; }

/* ---------- Действия ---------- */
.actions { display: flex; gap: 8px; margin: 4px 0 8px; }
.actions button {
  flex: 1; padding: 15px 6px; border-radius: var(--radius); font-weight: 700; font-size: 15px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35); transition: transform .06s;
}
.actions button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.actions .fold { background: var(--fold); }
.actions .call { background: var(--call); }
.actions .raise { background: var(--raise); }
.actions .primary { background: var(--accent); color: #2a1f00; }

.feedback { border-radius: var(--radius); padding: 12px; margin-bottom: 8px; background: var(--panel); border-left: 4px solid var(--muted); }
.feedback.best { border-color: var(--good); }
.feedback.ok { border-color: var(--ok); }
.feedback.bad { border-color: var(--bad); }
.feedback h3 { margin: 0 0 4px; font-size: 17px; }
.feedback p { margin: 6px 0; font-size: 14px; }
.feedback .net { font-size: 22px; font-weight: 800; }
.feedback .net.plus { color: var(--good); }
.feedback .net.minus { color: var(--bad); }
.hint-note { color: var(--accent); font-size: 14px; }

.toggles { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.ghost { background: var(--panel); padding: 8px 12px; border-radius: 10px; font-size: 13px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { display: none; }
.switch span { width: 36px; height: 20px; border-radius: 20px; background: var(--panel-2); position: relative; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { left: 18px; background: #fff; }

/* ---------- Калькулятор ---------- */
.panel { background: var(--panel); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.label { font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.slot-group + .slot-group { margin-top: 10px; }
.slots { display: flex; gap: 6px; }
.slots .card { cursor: pointer; }
.slots .card.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.calc-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.calc-row > span { color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; background: var(--panel-2); border-radius: 10px; }
.stepper button { width: 34px; height: 34px; font-size: 18px; }
.stepper b { min-width: 18px; text-align: center; }
.picker { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; margin-bottom: 8px; }
.picker .card { width: auto; height: 38px; border-radius: 5px; cursor: pointer; }
.picker .card .r { font-size: 13px; }
.picker .card .s { font-size: 11px; margin: 0; }
.picker .card.used { opacity: .18; cursor: default; }
.potodds input {
  width: 80px; margin-left: 6px; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit;
}
.potodds label { color: var(--muted); font-size: 13px; }
.po-res { margin-top: 10px; font-size: 14px; }
.po-res b { color: var(--accent); font-size: 18px; }

@media (max-width: 360px) {
  .card { width: 34px; height: 48px; }
  .card .r { font-size: 16px; }
  .cards.big .card { width: 50px; height: 70px; }
  .actions button { font-size: 14px; padding: 13px 4px; }
}

/* ---------- Настройки / выбор ---------- */
.settings-bar {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 12px; margin-bottom: 8px;
  background: var(--panel); border-radius: 10px; font-size: 13px; color: var(--muted); text-align: left;
}
.settings-bar span { flex: 1; color: var(--text); }
.settings-bar i { font-style: normal; }
.panel .label:not(:first-child) { margin-top: 12px; }
.chips-select { display: flex; flex-wrap: wrap; gap: 5px; }
.chips-select button {
  padding: 7px 11px; border-radius: 9px; background: var(--panel-2); font-size: 13px; font-weight: 600; color: var(--muted);
}
.chips-select button.on { background: var(--accent); color: #2a1f00; }
.chips-select button:disabled { opacity: .3; }
.calc-row.inputs { margin-top: 0; }
.calc-row.inputs input { width: 72px; }
.calc-row input {
  margin-left: 4px; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit;
}
.calc-row label { color: var(--muted); font-size: 13px; }
.link { color: var(--accent); font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0 0 0 6px; text-decoration: underline; }
.actions .allin { background: #b3263a; }

/* ---------- Сетка 13×13 ---------- */
.hand-grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; }
.hand-grid.small { margin-top: 8px; }
.hand-grid button {
  aspect-ratio: 1; border-radius: 4px; font-size: 9.5px; font-weight: 700; padding: 0; letter-spacing: -.3px;
  background: var(--panel-2); color: var(--muted); overflow: hidden;
}
.hand-grid button.pair { color: var(--text); }
.hand-grid button.suited { background: #1f3329; }
.hand-grid button.a-fold { background: #26302b; color: #6c7f75; }
.hand-grid button.a-call { background: #2f7de1; color: #fff; }
.hand-grid button.a-raise { background: #e0642f; color: #fff; }
.hand-grid button.a-allin { background: #b3263a; color: #fff; }
.hand-grid button.sel { outline: 2px solid #fff; outline-offset: 1px; position: relative; z-index: 1; }
.legend { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 6px; vertical-align: -1px; }
.l-s { background: #1f3329; border: 1px solid #3c5a4a; }
.l-o { background: var(--panel-2); }
.actions-legend { display: block; margin: 8px 0 0; }
.l-fold { background: #26302b; } .l-call { background: #2f7de1; } .l-raise { background: #e0642f; } .l-allin { background: #b3263a; }

/* ---------- Вердикт «Мой спот» ---------- */
.verdict { background: var(--panel); border-radius: var(--radius); padding: 14px; border-left: 4px solid var(--accent); }
.verdict:empty { display: none; }
.verdict .big { font-size: 24px; font-weight: 800; margin: 2px 0 6px; }
.verdict .big.fold { color: #9fb3a8; } .verdict .big.call { color: #6aa8ff; }
.verdict .big.raise { color: #ff8a52; } .verdict .big.allin { color: #ff5a6e; }
.verdict p { margin: 6px 0; font-size: 14px; }

.grid-legend { display: block; margin: -2px 0 8px; }

/* ---------- Пояснения ---------- */
.q {
  display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; margin-left: 4px;
  border-radius: 50%; background: var(--panel-2); color: var(--accent); font-size: 11px; font-weight: 800;
  vertical-align: 1px; text-transform: none; letter-spacing: 0; border: 1px solid var(--line); padding: 0;
}
.stat[data-term] { cursor: pointer; }
#help-btn { color: var(--accent); font-weight: 800; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s;
}
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 82vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet h3 { margin: 0 30px 8px 0; font-size: 19px; }
.sheet h4 { margin: 16px 0 4px; font-size: 15px; }
.sheet p { margin: 6px 0; font-size: 14.5px; line-height: 1.45; }
.sheet .example { background: var(--panel-2); border-radius: 10px; padding: 9px 11px; margin: 10px 0; font-size: 14px; }
.sheet .example b { color: var(--accent); }
.sheet .muted { color: var(--muted); font-size: 13px; }
.sheet-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); color: var(--muted); }
.terms { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.terms button { background: var(--panel-2); border-radius: 9px; padding: 7px 10px; font-size: 13px; }
.sheet .primary-btn { width: 100%; margin-top: 16px; padding: 13px; border-radius: 12px; background: var(--accent); color: #2a1f00; font-weight: 700; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

/* ---------- Тариф ---------- */
.plan-bar {
  width: 100%; margin-top: 6px; padding: 7px 10px; border-radius: 10px; background: var(--panel);
  font-size: 12px; color: var(--muted); text-align: left; line-height: 1.35;
}
.plan-bar b { color: var(--accent); white-space: nowrap; margin-left: 4px; }
.feedback .primary-btn, .verdict .primary-btn { width: 100%; margin-top: 10px; padding: 13px; border-radius: 12px; background: var(--accent); color: #2a1f00; font-weight: 700; }

/* ---------- Компактный режим: тренажёр в один экран ---------- */
#app { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
.top { padding-bottom: 6px; }
.stats { gap: 5px; }
.stat { padding: 4px 2px; border-radius: 9px; }
.stat b { font-size: 15px; }
.stat span { font-size: 10px; }
.icon-btn { width: 38px; font-size: 16px; }
.plan-bar { margin-top: 5px; padding: 5px 9px; font-size: 11.5px; }
.tabs { margin-top: 6px; }
.tabs button { padding: 6px; font-size: 14px; }

.felt { padding: 8px 10px; gap: 6px; border-width: 4px; border-radius: 90px / 70px; }
.seat { flex-direction: row; gap: 8px; }
.cards { gap: 4px; }
.card { width: 32px; height: 45px; border-radius: 5px; }
.card .r { font-size: 16px; }
.card .s { font-size: 14px; margin-top: 1px; }
.cards.big .card { width: 42px; height: 59px; border-radius: 6px; }
.cards.big .card .r { font-size: 21px; }
.cards.big .card .s { font-size: 18px; }
.board { min-height: 45px; gap: 4px; }
.pot { font-size: 12px; padding: 2px 10px; }
.badge { font-size: 11px; padding: 2px 8px; }

.situation { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; padding: 7px 10px; font-size: 13px; line-height: 1.35; }
.situation > div { flex: 1; min-width: 0; }
.situation .street { font-size: 10.5px; }
.situation .prev { font-size: 12px; }
.hint-mini { width: 34px; height: 34px; border-radius: 9px; background: var(--panel-2); font-size: 16px; flex: none; }

.info { padding: 8px 10px; margin-bottom: 6px; }
.eq-head { gap: 8px; }
.eq-head b { font-size: 18px; }
.eq-head .eq-sub { text-align: right; font-size: 11px; }
.bar { height: 8px; margin: 5px 0 6px; }
.kv-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; }
.kv-row .kv { padding: 5px 7px; border-radius: 8px; min-width: 0; }
.kv-row .kv span { font-size: 10px; white-space: nowrap; }
.kv-row .kv b { display: block; font-size: 12.5px; line-height: 1.2; }
.kv-row .q { width: 14px; height: 14px; font-size: 9px; margin-left: 2px; }
.more { margin-top: 6px; font-size: 12px; color: var(--accent); padding: 2px 0; }

.actions { margin: 0 0 6px; gap: 6px; }
.actions button { padding: 12px 4px; font-size: 14px; }
.feedback { padding: 9px 11px; margin-bottom: 6px; }
.feedback h3 { font-size: 15px; }
.feedback p { font-size: 13px; margin: 4px 0; line-height: 1.4; }
.feedback .net { font-size: 19px; }

.settings-foot { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.settings-foot .primary-btn { margin-top: 0; flex: 1; }

/* «Мой спот» и калькулятор — плотнее */
.panel { padding: 10px; margin-bottom: 6px; }
.panel .label:not(:first-child) { margin-top: 9px; }
.label { margin-bottom: 5px; font-size: 11px; }
.chips-select { gap: 4px; }
.chips-select button { padding: 5px 9px; font-size: 12.5px; border-radius: 8px; }
.calc-row { margin-top: 8px; }
.calc-row input { padding: 5px 7px; }
.verdict { padding: 11px 12px; }
.verdict .big { font-size: 21px; }
.verdict p { font-size: 13.5px; }
.picker .card { height: 34px; }

.hero-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.hand-name { font-size: 11.5px; font-weight: 600; color: #e9f5ee; text-shadow: 0 1px 2px rgba(0,0,0,.5); max-width: 150px; line-height: 1.25; }
.hand-name .q { width: 14px; height: 14px; font-size: 9px; }
.eq-head { display: flex; align-items: center; }
.eq-head > div:first-child { white-space: nowrap; }
.eq-head .vs { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- «Мой спот» и калькулятор в один экран ---------- */
.panel.tight { padding: 8px 10px; }
.settings-bar { margin-bottom: 6px; padding: 8px 11px; }
.settings-bar b { color: var(--accent); }
.irow { display: flex; align-items: center; gap: 8px; }
.irow + .irow, .panel.tight > div + div { margin-top: 6px; }
.ilabel { flex: none; width: 66px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; line-height: 1.2; }
.ilabel .q { margin-left: 2px; }
.chips-select.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.chips-select.scroll::-webkit-scrollbar { display: none; }
.chips-select.scroll button { flex: none; }
.irow .size { flex: none; font-size: 12px; color: var(--muted); }
.irow .size input {
  width: 48px; margin-left: 3px; padding: 5px 6px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit;
}
.hand-head { display: flex; align-items: center; gap: 8px; }
.hand-head b { flex: 1; font-size: 15px; }
.ghost.small { padding: 6px 10px; font-size: 12.5px; }
.rank-row { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; margin-top: 6px; }
.rank-row button {
  height: 32px; border-radius: 7px; background: var(--panel-2); font-weight: 700; font-size: 13px; color: var(--muted); padding: 0;
}
.rank-row button.on { background: #fff; color: #111; }
#sp-suit { margin-top: 6px; }
#sp-suit button { flex: 1; }
.verdict-head { display: flex; align-items: center; gap: 12px; }
.verdict-head .big { margin: 0; flex: none; }
.verdict-head .eq-sub { font-size: 11.5px; line-height: 1.35; }
.verdict p { margin: 6px 0 0; font-size: 13px; line-height: 1.4; }

.calc-top { display: flex; gap: 12px; align-items: flex-end; }
.calc-top .label { margin-bottom: 4px; }
.calc-top .slots { gap: 4px; }
.calc-row > span { font-size: 12px; }
.stepper button { width: 30px; height: 30px; }
.picker { gap: 2px; margin-bottom: 6px; }
.picker .card { height: 33px; }
.ghost.wide { width: 100%; text-align: center; padding: 9px; }
.ilabel { width: 52px; font-size: 10.5px; }
.irow { gap: 6px; }
.irow .chips-select button { padding: 5px 7px; font-size: 12px; }
.kv-row .kv:last-child:not(:first-child) b { white-space: normal; }

/* Ползунки */
.slider { flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--panel-2); }
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--panel-2); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.5); border: 0;
}
.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 0; }
.sval { flex: none; min-width: 54px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
#sp-summary-btn { flex: none; padding: 4px 8px; }
.offer-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.offer-note a { color: var(--muted); }
.premium-btn { color: var(--accent); }
.premium-btn { flex: 0 0 auto; padding: 4px 7px; border: 1px solid var(--accent); }
.premium-btn b { color: var(--accent); font-size: 13px; }
.stat span { white-space: nowrap; }
.premium-btn { padding: 4px 6px; }
