/* BestCas mini app.
   Mobile-only. Always dark. Palette and type scale follow design-ref/Style.dc.html:
   near-black surfaces, gold for points/offers, orange for the streak, white
   primary buttons. Red appears only as --danger in game results and "What
   doesn't" lists. Telegram's theme is deliberately not applied. */

:root {
  --bg: #0A0C10;
  --bg-2: #12151C;
  --bg-3: #1A1E28;
  --bg-4: #0F1218;      /* inset stat tiles */
  --line: #1E2330;
  --line-2: #262C3A;    /* ghost button / pill border */
  --accent: #E9B949;    /* gold */
  --accent-2: #FF7A45;  /* streak */
  --text: #F2F4F8;
  --text-2: #C9CFDB;
  --hint: #8A93A6;
  --hint-2: #6B7386;    /* tab labels, dividers in buttons */
  --off: #5C6477;       /* disabled text, footer */
  --partner-bg: #15130F;
  --partner-line: #3A3220;
  --success: #34D399;
  --danger: #F87171;
  --ok: var(--success);
  --gold: var(--accent);
  --r: 20px;
  --r-btn: 14px;
  --r-sm: 10px;
  --r-tile: 14px;
  --top-h: 52px;
  --tab-h: 72px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* Class display rules below (.tabbar{display:flex} etc.) would otherwise beat
   the UA's [hidden]{display:none}. Every show/hide in app.js relies on this. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.4;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
img { max-width: 100%; display: block; }
a { color: var(--text); text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: inline-block; vertical-align: middle; flex: none; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.body { font-size: 15px; line-height: 1.4; color: var(--text-2); }
.hint { color: var(--hint); font-size: 13px; line-height: 1.4; }
.muted { color: var(--text-2); }
.label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--hint); }
.gold { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.bold { font-weight: 700; }

.app { min-height: 100%; display: flex; flex-direction: column; }
.view { flex: 1; padding: 8px 16px calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.loading { padding: 60px 0; text-align: center; color: var(--hint); }

/* --- top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: var(--bg);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.brand svg { width: 28px; height: 28px; }
.topstats { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px 0 9px;
  border-radius: 999px; background: #151924; border: 1px solid #232A38;
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text);
}
.pill svg { width: 13px; height: 13px; }

/* --- tab bar ------------------------------------------------------------ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  display: flex; background: #0C0E14; border-top: 1px solid var(--bg-3);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; font-size: 11px; font-weight: 600; color: var(--hint-2);
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--text); }

/* --- cards, rows, chips ------------------------------------------------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card-partner { background: var(--partner-bg); border-color: var(--partner-line); }
.card-row { display: flex; align-items: center; gap: 12px; padding: 12px; }
a.card { color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.col-3 { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line-2); font-size: 12px; font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip-muted { color: var(--hint); }
.chip svg { width: 11px; height: 11px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.divider { height: 1px; background: var(--bg-3); }
.rule { border-bottom: 1px solid var(--bg-3); }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s; }
.badge-partner {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.badge-partner.boxed { padding: 3px 7px; border: 1px solid var(--partner-line); border-radius: 6px; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tag-ok { color: var(--success); }

/* --- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 50px; padding: 0 20px; border-radius: var(--r-btn);
  border: 1px solid transparent; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform .06s, opacity .15s, background-color .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-ghost { background: var(--bg-3); color: var(--text); border-color: var(--line-2); }
.btn-off, .btn[disabled], .btn.disabled { background: var(--bg-2); color: var(--off); border-color: var(--line); cursor: default; transform: none; }
.btn-sm { height: 36px; padding: 0 14px; border-radius: var(--r-sm); font-size: 14px; width: auto; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn .dot-sep { color: var(--hint-2); font-weight: 600; }

/* --- segmented control & filter chips ---------------------------------- */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-4); border: 1px solid var(--bg-3); }
.seg button { height: 28px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--hint); font-size: 13px; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--text); color: var(--bg); }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid #232A38; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--hint); white-space: nowrap; cursor: pointer; flex: none;
}
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* --- home --------------------------------------------------------------- */
.hero { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.hero .points { display: flex; align-items: baseline; gap: 8px; }
.hero .points .num { font-size: 48px; font-weight: 800; line-height: 1; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--bg-3); color: var(--text); }
.task:last-child { border-bottom: 0; }
.task .check {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid #343B4A; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--bg);
}
.task.done .check { background: var(--success); border-color: var(--success); }
.task .title { font-size: 15px; font-weight: 600; }
.task.done .title { color: var(--hint); text-decoration: line-through; }
.task .chev { color: var(--hint-2); width: 18px; height: 18px; }
.link-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.link-card .chev { color: var(--hint-2); width: 18px; height: 18px; }

/* --- casinos ------------------------------------------------------------ */
.casino { display: flex; gap: 12px; align-items: flex-start; padding: 14px; }
.tile {
  width: 48px; height: 48px; border-radius: var(--r-tile); display: grid; place-items: center; flex: none;
  font-weight: 800; font-size: 10px; text-align: center; line-height: 1.1; overflow: hidden; background: var(--bg-3);
}
.tile img { width: 100%; height: 100%; }
.tile-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 13px; }
.tile-sm { width: 44px; height: 44px; border-radius: 13px; font-size: 9px; }
.tile-xs { width: 18px; height: 18px; border-radius: 5px; font-size: 0; }
.casino .name { font-size: 16px; font-weight: 700; }
.casino .feat { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.casino .offer { font-size: 13px; font-weight: 700; color: var(--accent); }
.casino .lic { font-size: 12px; color: var(--hint); }
.rate {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 8px;
  background: var(--bg-3); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; flex: none;
}
.rate svg { width: 12px; height: 12px; }
.rate-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rate-inline svg { width: 14px; height: 14px; }
.detail-head { display: flex; gap: 14px; align-items: center; }
.verdict { font-size: 16px; font-weight: 600; line-height: 1.35; }
.offer-card { display: flex; flex-direction: column; gap: 6px; }
.offer-card .big { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 3px; padding: 12px; border-radius: 14px; background: var(--bg-4); border: 1px solid var(--bg-3); }
.stat .v { font-size: 15px; font-weight: 700; }
.li { display: flex; gap: 10px; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.li .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 6px; }
.li .dot.ok { background: var(--success); }
.li .dot.bad { background: var(--danger); }
.fine { font-size: 12px; color: var(--hint); padding: 0 4px; line-height: 1.4; }

/* --- games -------------------------------------------------------------- */
.game { display: flex; flex-direction: column; gap: 14px; }
.game .ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.game .ico svg { width: 26px; height: 26px; }
.game .ico.bj { background: #1B2433; color: #9DB7FF; }
.game .ico.trap { background: #2A1E14; color: #FFB070; }
.game .ico.rtp { background: #13271F; color: #6EE7B7; }
.game .title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.tries { display: flex; gap: 4px; }
.tries span { width: 18px; height: 5px; border-radius: 999px; background: var(--accent); }
.tries span.off { background: var(--line-2); }
.sponsor { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hint); padding: 0 4px; }
.sponsor b { color: var(--text-2); font-weight: 600; }
.sponsor .tile-xs { background: var(--bg-3); }

.round-head { display: flex; justify-content: space-between; align-items: baseline; }
.round-head .title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.segs { display: flex; gap: 4px; }
.segs span { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.segs span.on { background: var(--accent); }

.table {
  border-radius: 24px; background: #0F1A16; border: 1px solid #173126; padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.table .label { color: #6E8A7C; }
.hand-block { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hand { display: flex; gap: 10px; }
.cardface {
  width: 84px; height: 118px; border-radius: 12px; background: #F7F5EE; color: #141414;
  display: flex; flex-direction: column; justify-content: space-between; padding: 8px 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.45); font-weight: 800; font-size: 26px; letter-spacing: -.02em; line-height: 1;
}
.cardface .suit { font-size: 22px; align-self: flex-end; line-height: 1; }
.cardface.red { color: #D9342B; }
.cardface.back {
  background: var(--line); border: 1px solid #2A3141; padding: 0; justify-content: center; align-items: center;
}
.cardface.back::before {
  content: ""; width: 60px; height: 94px; border-radius: 8px; border: 1px solid #343B4A;
  background: repeating-linear-gradient(135deg, #1E2330 0 4px, #262C3A 4px 8px);
}
.total { display: flex; align-items: baseline; gap: 6px; }
.total .num { font-size: 30px; font-weight: 800; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn { height: 54px; }
.actions .btn-main { background: var(--text); color: var(--bg); }
/* After an answer app.js tags the best move btn-primary and a wrong pick
   btn-danger; inside the blackjack actions those read as result tints. */
.bj-actions .btn.btn-primary { background: #0F2A20; color: var(--success); border-color: #1F6B4B; }
.bj-actions .btn.btn-danger { background: #2A1416; color: var(--danger); border-color: #7A2E33; }
.bj-actions .btn[disabled] { opacity: 1; }

.prompt { display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 2px; }
.prompt .big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 16px;
  border-radius: 16px; background: var(--bg-2); border: 1px solid var(--line);
  font-size: 15px; font-weight: 600; color: var(--text); text-align: left; cursor: pointer;
}
.opt:active { transform: scale(.99); }
.opt .n { width: 26px; height: 26px; border-radius: 8px; background: var(--bg-3); color: var(--hint); font-size: 12px; font-weight: 800; display: grid; place-items: center; flex: none; }
.opt .txt { flex: 1; min-width: 0; }
.opt .sub { display: block; font-size: 13px; color: var(--hint); font-weight: 400; margin-top: 2px; }
.opt::after { margin-left: auto; font-size: 12px; font-weight: 700; white-space: nowrap; }
.opt.right { background: #0F2A20; border-color: #1F6B4B; }
.opt.right .n { background: var(--success); color: #06281B; }
.opt.right::after { content: attr(data-ok); color: var(--success); }
.opt.wrong { background: #2A1416; border-color: #7A2E33; }
.opt.wrong .n { background: var(--danger); color: #3A0C0E; }
.opt.wrong::after { content: attr(data-bad); color: var(--danger); }
.opt.dim { opacity: .45; }
.opt[disabled] { cursor: default; }

.feedback { padding: 14px 16px; border-radius: 16px; background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.feedback b { font-size: 14px; font-weight: 700; }
.feedback.ok b { color: var(--success); }
.feedback.bad b { color: var(--danger); }
.feedback .why { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.result { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 24px 16px 16px; }
.result .num { font-size: 48px; font-weight: 800; line-height: 1; }
.result .earned { font-size: 15px; font-weight: 700; color: var(--accent); }

/* --- rewards ------------------------------------------------------------ */
.balance { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.balance .num { font-size: 28px; font-weight: 800; line-height: 1; }
.balance .bar { height: 5px; background: #2A2518; }
.reward { display: flex; gap: 12px; align-items: center; padding: 14px; }
.reward .title { font-size: 15px; font-weight: 700; }
.reward .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.price { display: inline-flex; align-items: baseline; gap: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price b { font-size: 16px; font-weight: 800; color: var(--accent); }
.price small { font-size: 11px; color: var(--hint); }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; letter-spacing: .08em;
  padding: 12px; border-radius: 11px; text-align: center; background: var(--bg-4); border: 1px dashed var(--line-2);
  color: var(--text); user-select: all;
}
.mono {
  flex: 1; min-width: 0; height: 40px; border-radius: 11px; background: var(--bg-4); border: 1px solid var(--bg-3);
  display: flex; align-items: center; padding: 0 12px; font-size: 13px; color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow: hidden; white-space: nowrap;
}

/* --- profile ------------------------------------------------------------ */
.who { display: flex; align-items: center; gap: 14px; padding: 4px 0; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--line-2);
  display: grid; place-items: center; font-size: 20px; font-weight: 800; color: var(--accent); flex: none;
}
.who .name { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.stat-grid { display: flex; gap: 8px; }
.stat-grid .stat { flex: 1; }
.stat-grid .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 5px; }
.stat-grid .v svg { width: 14px; height: 14px; }
.switch { width: 46px; height: 28px; border-radius: 999px; background: var(--line-2); position: relative; border: 0; cursor: pointer; flex: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--success); }
.switch.on::after { left: 21px; }
.lb { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--bg-3); font-size: 15px; }
.lb:last-child { border-bottom: 0; }
.lb .rank { width: 22px; color: var(--hint-2); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.lb .streak { display: inline-flex; align-items: center; gap: 4px; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.lb .streak svg { width: 11px; height: 11px; }
.lb .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb.me { margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 10px; background: var(--bg-3); border-bottom: 0; }
.lb.me .rank { color: var(--accent); }
.lb.me .name { font-weight: 700; }
.lb.me .pts { color: var(--accent); }
.hist { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--bg-3); font-size: 15px; }
.hist:last-child { border-bottom: 0; }
.hist .d { font-weight: 800; font-variant-numeric: tabular-nums; }
.hist .d.pos { color: var(--success); } .hist .d.neg { color: var(--danger); }
.card-list { padding: 16px 16px 4px; }

/* --- toast & modal ------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-weight: 700; font-size: 14px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  max-width: 90vw; text-align: center;
}
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.7); display: grid; place-items: end center; }
.modal .sheet {
  width: 100%; max-width: 520px; background: var(--bg-2); border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); animation: up .18s ease-out;
}
.modal .sheet h2 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.modal .sheet .body { margin-bottom: 4px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.rg { font-size: 11px; color: var(--off); text-align: center; padding: 6px 8px 0; line-height: 1.45; }
.rg a { color: var(--hint); text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
