/* ════════════════════════════════════════════════════════════════════
   BLACKJACK ODDS TRAINER
   Classic card-room felt × modern analytics. Sora / Hanken / Plex.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #0b120e;
  --bg-2: #101a14;
  --felt: #176048;
  --felt-deep: #0c3d2c;
  --felt-line: #2a7a5c;
  --gold: #c9a557;
  --gold-bright: #e8cb84;
  --gold-dim: #8a7340;
  --cream: #f4eddb;
  --cream-dim: #d8d0bb;
  --ink: #221d12;
  --red: #b8453a;
  --green-pos: #57c785;
  --red-neg: #e1685c;
  --card-w: clamp(58px, 13.5vw, 86px);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --font-display: 'Sora', -apple-system, sans-serif;
  --font-body: 'Hanken Grotesk', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2a20 0%, transparent 60%),
    var(--bg);
  color: var(--cream);
  min-height: 100vh;
  line-height: 1.45;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
body::after { /* grain */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
.mono { font-family: var(--font-mono); }
.evpos { color: var(--green-pos); }
.evneg { color: var(--red-neg); }
.goldtxt { color: var(--gold-bright); }
[hidden] { display: none !important; }

/* ══════════ HEADER ══════════ */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px clamp(12px, 3vw, 28px);
  background: linear-gradient(to bottom, rgba(11,18,14,.97), rgba(11,18,14,.88));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(201,165,87,.24);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { /* gold spade badge */
  width: 38px; height: 38px; display: grid; place-items: center;
  font-size: 20px; color: var(--ink); padding-bottom: 2px;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 55%, var(--gold-dim));
  border-radius: 11px;
  box-shadow:
    0 2px 10px rgba(201,165,87,.35),
    inset 0 1px 0 rgba(255,255,255,.5),
    inset 0 -2px 4px rgba(60,44,18,.3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--font-display); font-weight: 800; font-size: 16.5px;
  letter-spacing: .045em; text-transform: uppercase;
}
.brand-sub { font-size: 9px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); margin-top: 2px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.bankroll {
  display: flex; flex-direction: column; align-items: flex-end; margin-right: 6px;
  padding: 4px 12px; border: 1px solid rgba(201,165,87,.35); border-radius: 10px;
  background: rgba(201,165,87,.07);
}
@keyframes bankFlash {
  30% { background: rgba(232,203,132,.28); border-color: var(--gold-bright); transform: scale(1.05); }
}
.bankroll.flash { animation: bankFlash .55s ease; }
.bankroll-label { font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.bankroll-amt { font-family: var(--font-mono); font-weight: 600; font-size: 15px; }
.icon-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 10px; border-radius: 10px; color: var(--cream-dim);
  border: 1px solid transparent; transition: all .18s;
}
.icon-btn:hover { color: var(--gold-bright); border-color: rgba(201,165,87,.3); background: rgba(201,165,87,.07); }
.icon-label { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }

/* ══════════ LAYOUT ══════════ */
main { max-width: 1020px; margin: 0 auto; padding: clamp(10px, 2vw, 22px); display: flex; flex-direction: column; gap: 14px; }

/* ══════════ TABLE ══════════ */
.table-zone {
  position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--felt) 0%, var(--felt-deep) 78%);
  border-radius: 22px 22px 46% 46% / 22px 22px 13% 13%;
  padding: clamp(14px, 3vw, 26px) clamp(12px, 3vw, 30px) clamp(26px, 5vw, 44px);
  box-shadow: var(--shadow), inset 0 0 80px rgba(0,0,0,.3);
  overflow: hidden;
}
.table-zone::before { /* soft overhead spotlight */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(58% 42% at 50% 16%, rgba(255,255,255,.075), transparent 70%);
}
.table-rim {
  position: absolute; inset: 7px; pointer-events: none; z-index: 2;
  border: 2px solid rgba(201,165,87,.4);
  border-radius: 18px 18px 46% 46% / 18px 18px 13% 13%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.felt-print {
  text-align: center; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(9px, 1.8vw, 12px); letter-spacing: .26em; text-transform: uppercase;
  color: rgba(232,203,132,.5); margin: 12px 0 14px;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}

.shoe-meter {
  position: absolute; top: 14px; right: clamp(14px, 3vw, 26px);
  display: flex; align-items: center; gap: 7px; z-index: 3;
}
.shoe-label { font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: rgba(244,237,219,.55); }
.shoe-bar { position: relative; width: clamp(54px, 10vw, 90px); height: 7px; border-radius: 4px; background: rgba(0,0,0,.4); overflow: hidden; }
.shoe-fill { height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright)); border-radius: 4px; transition: width .5s, background .5s; }
.shoe-fill.low { background: linear-gradient(90deg, #8c3a32, var(--red-neg)); }
.shoe-cut { position: absolute; left: 25%; top: -1px; bottom: -1px; width: 2px; background: var(--red-neg); opacity: .85; }
.shoe-count { font-family: var(--font-mono); font-size: 11px; color: rgba(244,237,219,.65); min-width: 26px; }

.area-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.area-label {
  font-size: 10px; letter-spacing: .34em; text-transform: uppercase;
  color: rgba(244,237,219,.6);
}
.bust-chip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 20px;
  background: rgba(225,104,92,.16); color: var(--red-neg);
  border: 1px solid rgba(225,104,92,.4);
}
.dealer-area { display: flex; flex-direction: column; align-items: center; min-height: calc(var(--card-w) * 1.4 + 50px); }

/* ── cards ── */
.cards { display: flex; gap: clamp(4px, 1vw, 8px); justify-content: center; flex-wrap: wrap; min-height: calc(var(--card-w) * 1.4); }
.card {
  position: relative;
  width: var(--card-w); height: calc(var(--card-w) * 1.4);
  border-radius: calc(var(--card-w) * .09);
  background: linear-gradient(155deg, #fdf8ea 0%, var(--cream) 60%, #e7dec6 100%);
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.8);
  font-family: var(--font-display);
  flex-shrink: 0;
}
.card.red { color: var(--red); }
.card .corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 700; font-size: calc(var(--card-w) * .2); }
.card .corner i { font-style: normal; font-size: calc(var(--card-w) * .18); }
.card .corner.tl { top: 6%; left: 7%; }
.card .corner.br { bottom: 6%; right: 7%; transform: rotate(180deg); }
.card .pip {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--card-w) * .46); font-weight: 600; opacity: .9;
}
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(232,203,132,.16) 0 4px, transparent 4px 9px),
    repeating-linear-gradient(-45deg, rgba(232,203,132,.16) 0 4px, transparent 4px 9px),
    linear-gradient(155deg, #7d2f28, #5e201b);
  box-shadow: 0 4px 10px rgba(0,0,0,.45), inset 0 0 0 3px #4c1a16, inset 0 0 0 4px rgba(232,203,132,.4);
}
@keyframes dealIn {
  0%  { transform: translate(110px, -130px) rotate(14deg) scale(.9); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.card.dealt { animation: dealIn .42s cubic-bezier(.22,.9,.28,1.04) backwards; }
@keyframes flipIn {
  0%   { transform: perspective(600px) rotateY(88deg); }
  100% { transform: perspective(600px) rotateY(0); }
}
.card.flip { animation: flipIn .42s cubic-bezier(.3,.7,.3,1); transform-origin: center; }

/* ── seats / hands ── */
.seats { display: flex; justify-content: center; gap: clamp(10px, 2.5vw, 26px); flex-wrap: wrap; }
.seat-hands { display: flex; gap: clamp(8px, 2vw, 16px); flex-wrap: wrap; justify-content: center; }
.seat.empty .seat-spot {
  border: 2px dashed rgba(244,237,219,.25); border-radius: 14px;
  padding: clamp(20px, 5vw, 34px) clamp(26px, 6vw, 48px);
  color: rgba(244,237,219,.45); font-size: 13px; letter-spacing: .08em;
}
.hand {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 8px 8px; border-radius: 16px; border: 2px solid transparent;
  transition: border-color .25s, background .25s;
}
.hand.active {
  border-color: rgba(232,203,132,.75);
  background: rgba(232,203,132,.07);
  box-shadow: 0 0 24px rgba(232,203,132,.12);
  animation: activeGlow 2.2s ease-in-out infinite;
}
@keyframes activeGlow {
  50% { box-shadow: 0 0 34px rgba(232,203,132,.24); border-color: rgba(232,203,132,.95); }
}
.hand.dim { opacity: .55; }
.hand.won {
  border-color: rgba(232,203,132,.6);
  background: rgba(232,203,132,.06);
  box-shadow: 0 0 30px rgba(232,203,132,.2);
}
.hand-foot { display: flex; align-items: center; gap: 8px; }
.total-badge {
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  padding: 3px 11px; border-radius: 20px;
  background: rgba(0,0,0,.42); color: var(--cream);
  border: 1px solid rgba(244,237,219,.2);
}
.total-badge.busted { color: var(--red-neg); border-color: rgba(225,104,92,.45); }
.total-badge.bj { color: var(--gold-bright); border-color: rgba(232,203,132,.6); }
.dealer-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; min-height: 24px; }
.dealer-foot .dealer-total { margin-top: 0; }
@keyframes pop {
  0% { transform: scale(.55); }
  60% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
.total-badge.pop { animation: pop .32s cubic-bezier(.3,.8,.4,1); }
@keyframes popCentered {
  0% { transform: translateX(-50%) scale(.55); }
  60% { transform: translateX(-50%) scale(1.14); }
  100% { transform: translateX(-50%) scale(1); }
}
.result-badge.pop { animation: popCentered .42s cubic-bezier(.3,.8,.4,1); }
.dealer-total { margin-top: 8px; }
.bet-chip-tag {
  font-family: var(--font-mono); font-size: 11px; color: rgba(244,237,219,.75);
  padding: 2px 8px; border-radius: 14px; border: 1px dashed rgba(244,237,219,.3);
}
.result-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  z-index: 4; white-space: nowrap;
  font-weight: 800; font-size: 12px; letter-spacing: .04em;
  padding: 4px 13px; border-radius: 20px; box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.result-badge.win { background: linear-gradient(160deg, var(--gold-bright), var(--gold)); color: var(--ink); }
.result-badge.lose { background: #57302c; color: #f0b9b2; }
.result-badge.push { background: #3a4a42; color: var(--cream-dim); }

/* ══════════ INSIGHT ══════════ */
.insight {
  background: linear-gradient(170deg, var(--bg-2), #0d1510);
  border: 1px solid rgba(201,165,87,.28);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow);
  animation: rise .3s ease backwards;
}
.ev-cap {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin: 2px 0 8px; padding: 6px 10px;
  background: linear-gradient(90deg, rgba(201,165,87,.14), rgba(201,165,87,.05));
  border: 1px solid rgba(201,165,87,.3); border-left: 3px solid var(--gold);
  border-radius: 7px;
  font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-bright);
}
.ev-cap span:last-child { color: rgba(232,203,132,.8); font-weight: 600; text-align: right; }
.insight-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.insight-title { font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.book-action { font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 5vw, 30px); color: var(--gold-bright); letter-spacing: .02em; }
.insight-reason { font-size: 13.5px; color: var(--cream-dim); margin: 4px 0 10px; max-width: 70ch; }
.ev-rows { display: flex; flex-direction: column; gap: 5px; }
.ev-row { display: grid; grid-template-columns: 58px 1fr 72px; align-items: center; gap: 10px; }
.ev-row.book .ev-name { color: var(--gold-bright); font-weight: 700; }
.ev-name { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--cream-dim); }
.ev-track { position: relative; height: 9px; background: rgba(255,255,255,.07); border-radius: 5px; overflow: hidden; }
.ev-track::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(244,237,219,.3); }
.ev-track i { display: block; height: 100%; border-radius: 5px; transition: width .35s; }
.ev-track i.pos { background: linear-gradient(90deg, #2e7d54, var(--green-pos)); }
.ev-track i.neg { background: linear-gradient(90deg, #8c3a32, var(--red-neg)); }
.ev-val { font-size: 12px; text-align: right; }
.outcome-row { margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: var(--cream-dim); font-family: var(--font-mono); }
.quiz-note { font-size: 13px; color: var(--cream-dim); font-style: italic; }

/* ══════════ COUNT PANEL ══════════ */
.count-panel {
  background: linear-gradient(170deg, var(--bg-2), #0d1510);
  border: 1px solid rgba(201,165,87,.28);
  border-radius: var(--radius);
  padding: 14px 16px 13px;
  box-shadow: var(--shadow);
  animation: rise .3s ease backwards;
}
.count-big { font-size: 15px; font-weight: 700; color: var(--gold-bright); }
.count-cards { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.count-chip {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 14px; white-space: nowrap;
}
.count-chip.pos  { background: rgba(87,199,133,.14); color: var(--green-pos); border: 1px solid rgba(87,199,133,.4); }
.count-chip.neg  { background: rgba(225,104,92,.13); color: var(--red-neg); border: 1px solid rgba(225,104,92,.4); }
.count-chip.zero { background: rgba(244,237,219,.07); color: var(--cream-dim); border: 1px solid rgba(244,237,219,.2); }
.count-note { font-size: 12.5px; color: var(--cream-dim); margin-bottom: 4px; }
.count-rules { border-top: 1px solid rgba(255,255,255,.08); margin-top: 10px; padding-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.count-rule { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--cream-dim); }
.count-rule .count-chip { flex-shrink: 0; min-width: 64px; text-align: center; }
.count-rule b { color: var(--cream); }
.count-why { font-size: 12px; color: var(--cream-dim); margin-top: 4px; line-height: 1.55; }
.count-why b { color: var(--cream); }

/* ══════════ COACH ══════════ */
.coach { /* desktop: corner snackbar — never covers the controls */
  position: fixed; left: 22px; bottom: 22px; transform: translateY(10px);
  z-index: 60; width: min(380px, 46vw);
  display: flex; flex-direction: column; gap: 3px;
  padding: 11px 16px; border-radius: 12px;
  background: rgba(13,20,15,.96); backdrop-filter: blur(8px);
  border-left: 4px solid; box-shadow: 0 12px 36px rgba(0,0,0,.55);
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.coach.show { opacity: 1; transform: translateY(0); }
.coach.good { border-color: var(--green-pos); }
.coach.bad { border-color: var(--red-neg); }
.coach strong { font-size: 14px; }
.coach.good strong { color: var(--green-pos); }
.coach.bad strong { color: var(--red-neg); }
.coach span { font-size: 12.5px; color: var(--cream-dim); }

/* ══════════ CONTROLS ══════════ */
.control-zone { display: flex; flex-direction: column; gap: 12px; }

.bet-bar, .round-bar, .insurance-bar {
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.bet-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.bet-label { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: rgba(244,237,219,.55); display: block; }
.bet-amt { font-family: var(--font-mono); font-weight: 700; font-size: 24px; color: var(--gold-bright); }
.chip-rack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  width: 52px; height: 52px; border-radius: 50%; position: relative;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  border: 4px dashed rgba(255,255,255,.75); box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 0 0 4px rgba(0,0,0,.18);
  transition: transform .15s;
}
.chip:hover { transform: translateY(-3px); }
.chip:active { transform: translateY(0); }
.chip-5   { background: radial-gradient(circle at 35% 30%, #d8645a, #9c352c); color: #fff; }
.chip-25  { background: radial-gradient(circle at 35% 30%, #4f9e6e, #226243); color: #fff; }
.chip-100 { background: radial-gradient(circle at 35% 30%, #4d4d56, #1d1d24); color: #fff; }
.chip-500 { background: radial-gradient(circle at 35% 30%, #b09ad4, #5e3f8c); color: #fff; }
.chip-clear { font-size: 12px; color: var(--cream-dim); text-decoration: underline; padding: 6px; }
.chip-clear:hover { color: var(--cream); }
.seat-picker { display: flex; align-items: center; gap: 12px; }
.seat-btns { display: flex; gap: 6px; }
.seat-btn {
  width: 38px; height: 38px; border-radius: 10px; font-weight: 700; font-size: 15px;
  border: 1px solid rgba(255,255,255,.14); color: var(--cream-dim); transition: all .15s;
}
.seat-btn.active { background: rgba(201,165,87,.16); border-color: var(--gold); color: var(--gold-bright); }

.deal-btn {
  font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .05em;
  padding: 13px 30px; border-radius: 12px; color: var(--ink);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 60%, var(--gold-dim));
  box-shadow: 0 5px 16px rgba(201,165,87,.3), inset 0 1px 0 rgba(255,255,255,.55);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.deal-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(201,165,87,.4), inset 0 1px 0 rgba(255,255,255,.55); }
.deal-btn:disabled { filter: grayscale(.7) brightness(.6); }
.deal-btn.ghost {
  background: none; color: var(--cream-dim);
  border: 1px solid rgba(255,255,255,.18); box-shadow: none;
}
.deal-btn.ghost:hover { color: var(--cream); border-color: rgba(255,255,255,.4); }
.deal-btn.danger { color: var(--red-neg); border-color: rgba(225,104,92,.4); }

/* insurance */
.insurance-bar { border-color: rgba(201,165,87,.4); }
.ins-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.ins-text strong { font-family: var(--font-display); font-size: 18px; color: var(--gold-bright); }
.ins-text .mono { font-size: 12px; color: var(--cream-dim); }
.ins-verdict { font-size: 13px; }
.ins-btns { display: flex; gap: 10px; }

/* actions */
.action-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.action-bar { animation: rise .3s ease backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.action-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 6px 11px; border-radius: 14px;
  background: linear-gradient(170deg, #18241c, #101a14);
  border: 1px solid rgba(255,255,255,.1);
  transition: transform .14s, border-color .2s, box-shadow .2s;
}
.action-btn.book { animation: bookGlow 2.2s ease-in-out infinite; }
@keyframes bookGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(201,165,87,.14); }
  50% { box-shadow: 0 0 26px rgba(201,165,87,.38); }
}
.action-btn::after { /* continuous gold shimmer on the book play — linear, never stalls */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(112deg,
    transparent 0%, transparent 38%,
    rgba(232,203,132,.20) 50%,
    transparent 62%, transparent 100%);
  background-size: 230% 100%;
  opacity: 0; transition: opacity .25s;
}
.action-btn.book::after { opacity: 1; animation: sheen 2.1s linear infinite; }
@keyframes sheen { from { background-position: 115% 0; } to { background-position: -115% 0; } }
@media (hover: hover) and (pointer: fine) {
  #btnHit::before, #btnStand::before, #btnDouble::before, #btnSplit::before {
    position: absolute; top: 7px; right: 9px;
    font-family: var(--font-mono); font-size: 10px; color: rgba(244,237,219,.35);
    border: 1px solid rgba(244,237,219,.22); border-radius: 4px; padding: 0 4px;
  }
  #btnHit::before { content: 'H'; }
  #btnStand::before { content: 'S'; }
  #btnDouble::before { content: 'D'; }
  #btnSplit::before { content: 'P'; }
}
.action-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(244,237,219,.35); }
.action-btn:active:not(:disabled) { transform: translateY(0); }
.action-btn:disabled { opacity: .32; }
.action-btn .act-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(15px, 3.6vw, 19px); letter-spacing: .03em; }
.action-btn .act-ev { font-size: clamp(10px, 2.6vw, 11.5px); color: var(--cream-dim); min-height: 14px; }
.action-btn .act-avg { font-size: clamp(10px, 2.4vw, 11.5px); font-weight: 600; min-height: 14px; }
.action-btn .book-tag {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 10px; color: var(--ink);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  opacity: 0; transition: opacity .2s;
}
.action-btn.book { border-color: var(--gold); box-shadow: 0 0 18px rgba(201,165,87,.18); }
.action-btn.book .book-tag { opacity: 1; }
.action-btn.book .act-name { color: var(--gold-bright); }
.action-btn.slim { flex-direction: row; gap: 8px; padding: 10px 20px; }
.action-btn.slim small { color: var(--cream-dim); font-size: 11px; }
.action-btn.ghost { background: none; }

/* round over */
.round-bar { align-items: center; text-align: center; animation: rise .3s ease backwards; }
.round-results { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.round-net { font-family: var(--font-display); font-weight: 800; font-size: 34px; animation: pop .45s cubic-bezier(.3,.8,.4,1) backwards; }
.round-net.win { color: var(--gold-bright); }
.round-net.lose { color: var(--red-neg); }
.round-net.push { color: var(--cream-dim); }
.round-sub { font-size: 13px; color: var(--cream-dim); }
.round-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* stats */
.stats-line { display: flex; justify-content: center; gap: clamp(18px, 6vw, 54px); padding: 4px 0 8px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stat-val { font-size: 19px; font-weight: 600; color: var(--gold-bright); }
.stat-label { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: rgba(244,237,219,.5); }

/* ══════════ STRATEGY DRAWER ══════════ */
.drawer-scrim, .modal-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5,9,7,.65); backdrop-filter: blur(3px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95;
  width: min(440px, 100vw);
  background: linear-gradient(170deg, #131d16, #0d1510);
  border-left: 1px solid rgba(201,165,87,.3);
  box-shadow: -18px 0 50px rgba(0,0,0,.5);
  transform: translateX(102%); transition: transform .32s cubic-bezier(.25,.8,.3,1);
  display: flex; flex-direction: column;
  padding: 18px 18px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.drawer-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--gold-bright); }
.drawer-sub { font-size: 11.5px; color: var(--cream-dim); margin-top: 2px; }
.chart-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.chart-tab {
  flex: 1; padding: 9px; border-radius: 10px; font-weight: 700; font-size: 13px;
  letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid rgba(255,255,255,.12); color: var(--cream-dim); transition: all .15s;
}
.chart-tab.active { background: rgba(201,165,87,.15); border-color: var(--gold); color: var(--gold-bright); }

.chart { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; }
.chart th {
  padding: 5px 2px; font-size: 11px; color: var(--gold);
  font-family: var(--font-body); font-weight: 700;
}
.chart tbody th { text-align: right; padding-right: 7px; white-space: nowrap; }
.chart td {
  text-align: center; padding: 6px 2px; font-weight: 600;
  border: 1px solid rgba(11,18,14,.7); border-radius: 3px; color: #0d130f;
}
.c-H  { background: #4d8ec4; }
.c-S  { background: #c05a4e; }
.c-D  { background: #d8b35e; }
.c-Ds { background: #e7d49a; }
.c-P  { background: #9d7bc9; }
.chart td.now {
  outline: 3px solid #fff; outline-offset: -2px; position: relative; z-index: 2;
  animation: cellPulse 1.2s ease-in-out infinite;
}
@keyframes cellPulse { 50% { outline-color: rgba(255,255,255,.45); } }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px;
  font-size: 12px; color: var(--cream-dim);
}
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend small { opacity: .7; }
.lg { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.lg-H { background: #4d8ec4; } .lg-S { background: #c05a4e; } .lg-D { background: #d8b35e; }
.lg-Ds { background: #e7d49a; } .lg-P { background: #9d7bc9; }

/* ══════════ MODALS ══════════ */
.modal-scrim { display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal {
  width: min(540px, 100%); max-height: 86dvh; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: linear-gradient(170deg, #15201a, #0d1510);
  border: 1px solid rgba(201,165,87,.35); border-radius: 18px;
  padding: 22px; box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
/* lock the page behind any open modal or the strategy drawer —
   otherwise mobile scroll gestures grab the page instead of the panel */
body:has(.modal-scrim:not([hidden])), body:has(.drawer.open) { overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-family: var(--font-display); color: var(--gold-bright); }
.setting-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.07); cursor: pointer;
}
.setting-row strong { font-size: 14.5px; }
.setting-row p { font-size: 12px; color: var(--cream-dim); margin-top: 2px; max-width: 38ch; }
.setting-row input { width: 22px; height: 22px; accent-color: var(--gold); flex-shrink: 0; }
.settings-modal .deal-btn { margin-top: 18px; width: 100%; }

/* drills */
.drill-row { border-top: 1px solid rgba(255,255,255,.07); padding-top: 10px; }
.drill-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drill-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.drill-btn {
  padding: 7px 12px; border-radius: 9px; font-size: 12px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.14); color: var(--cream-dim); transition: all .15s;
}
.drill-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.count-toggle {
  font-size: 12px; color: var(--cream-dim); padding: 7px 12px;
  border: 1px dashed rgba(255,255,255,.18); border-radius: 9px; transition: all .15s;
}
.count-toggle:hover { color: var(--gold-bright); border-color: rgba(201,165,87,.5); }
.count-toggle.on { color: var(--gold-bright); border-color: var(--gold); background: rgba(201,165,87,.1); }
.drill-hud {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, rgba(201,165,87,.14), rgba(201,165,87,.04));
  border: 1px solid rgba(201,165,87,.35); border-radius: var(--radius);
  padding: 10px 14px;
}
.drill-info { display: flex; flex-direction: column; gap: 1px; }
.drill-info strong { font-family: var(--font-display); font-size: 15px; color: var(--gold-bright); }
.drill-info .mono { font-size: 12px; color: var(--cream-dim); }
.drill-hud .deal-btn { padding: 9px 18px; font-size: 14px; }

/* counting HUD */
.count-hud {
  position: absolute; top: 12px; left: clamp(12px, 3vw, 26px); z-index: 3;
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px; border-radius: 16px;
  background: rgba(0,0,0,.4); border: 1px solid rgba(201,165,87,.35);
}
.count-hud .mono { font-size: 11px; font-weight: 600; color: var(--gold-bright); min-width: 96px; }
.count-eye { display: grid; place-items: center; color: var(--cream-dim); padding: 2px; }
.count-eye:hover { color: var(--gold-bright); }

/* count quiz */
.quiz-modal { width: min(380px, 100%); text-align: center; }
.quiz-modal h2 { font-family: var(--font-display); color: var(--gold-bright); margin-bottom: 4px; }
.quiz-q { color: var(--cream-dim); font-size: 14px; margin-bottom: 16px; }
.quiz-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quiz-opt { font-family: var(--font-mono); font-size: 18px; }

/* mistake log */
.mist-title { font-family: var(--font-display); font-size: 17px; color: var(--gold-bright); margin: 20px 0 10px; }
.mist-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.mist-empty { color: var(--cream-dim); font-size: 13px; padding: 8px 2px; }
.mist-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07);
  border-left: 3px solid var(--red-neg); border-radius: 10px; padding: 9px 12px;
}
.mist-main { display: flex; flex-direction: column; gap: 1px; }
.mist-main b { font-size: 13.5px; }
.mist-main span { font-size: 11.5px; color: var(--cream-dim); }
.mist-out { font-style: italic; }
.mist-out.lucky { color: #c9b86a; }
.mist-out.hurt { color: var(--red-neg); }
.mist-count { font-size: 13px; color: var(--red-neg); font-weight: 700; flex-shrink: 0; }
#drillWeakBtn { width: 100%; }

/* settings extras */
.setting-head {
  font-size: 10px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--gold); margin: 14px 0 2px; font-weight: 800;
}
.mini-btns { display: flex; gap: 5px; flex-shrink: 0; }
.mini-btns button {
  min-width: 36px; padding: 8px 10px; border-radius: 9px; font-weight: 700; font-size: 13px;
  border: 1px solid rgba(255,255,255,.14); color: var(--cream-dim); transition: all .15s;
}
.mini-btns button.active { background: rgba(201,165,87,.16); border-color: var(--gold); color: var(--gold-bright); }

/* session history */
.stats-modal { width: min(640px, 100%); }
.chart-title { font-size: 13px; color: var(--cream-dim); margin-bottom: 8px; }
.chart-title b { font-size: 15px; }
.chart-area {
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 8px; overflow: hidden;
}
.chart-area svg { display: block; width: 100%; height: 190px; }
.bankline { fill: none; stroke: var(--gold-bright); stroke-width: 2; stroke-linejoin: round; }
.baseline { stroke: rgba(244,237,219,.35); stroke-width: 1; stroke-dasharray: 5 5; }
.dot-w { fill: var(--green-pos); } .dot-l { fill: var(--red-neg); } .dot-p { fill: #8aa098; }
.chart-empty { padding: 36px 16px; text-align: center; color: var(--cream-dim); font-size: 14px; }
.chart-keys { margin-top: 10px; }
.dot-key { border-radius: 50%; width: 10px; height: 10px; }
.dot-key-w { background: var(--green-pos); }
.dot-key-l { background: var(--red-neg); }
.dot-key-b { background: none; border-top: 2px dashed rgba(244,237,219,.5); height: 0; width: 16px; border-radius: 0; }
.sum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.sum-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; border-radius: 10px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07);
}
.sum-val { font-size: 18px; font-weight: 600; color: var(--gold-bright); }
.sum-key { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: rgba(244,237,219,.55); text-align: center; }
@media (max-width: 560px) { .sum-grid { grid-template-columns: repeat(2, 1fr); } }

/* tutorial */
.tut-modal { padding: 26px 26px 18px; }
.tut-step { font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.tut-slide { display: none; }
.tut-slide.active { display: block; animation: slideIn .35s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } }
.tut-slide h2 {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 5vw, 28px);
  line-height: 1.15; margin: 8px 0 12px; color: var(--cream);
}
.tut-slide p { font-size: 14.5px; color: var(--cream-dim); margin-bottom: 10px; }
.tut-slide b { color: var(--cream); }
.tut-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.tut-foot > div:last-child { display: flex; gap: 8px; }
.tut-dots { display: flex; gap: 6px; }
.tut-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(244,237,219,.25); transition: all .2s; }
.tut-dots i.active { background: var(--gold-bright); width: 20px; border-radius: 4px; }

/* ══════════ SHUFFLE ══════════ */
.shuffle-overlay {
  position: fixed; inset: 0; z-index: 110; display: grid; place-items: center;
  background: rgba(5,9,7,.82); backdrop-filter: blur(5px);
}
.shuffle-box { text-align: center; }
.shuffle-box h2 { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--gold-bright); margin: 16px 0 4px; }
.shuffle-box p { color: var(--cream-dim); font-size: 14px; }
.shuffle-cards { display: flex; justify-content: center; gap: 6px; height: 70px; }
.shuffle-cards i {
  width: 46px; height: 64px; border-radius: 6px;
  background: linear-gradient(155deg, #7d2f28, #5e201b);
  box-shadow: inset 0 0 0 2px #4c1a16, inset 0 0 0 3px rgba(232,203,132,.4), 0 4px 10px rgba(0,0,0,.4);
  animation: riffle 1s ease-in-out infinite;
}
.shuffle-cards i:nth-child(2) { animation-delay: .1s; }
.shuffle-cards i:nth-child(3) { animation-delay: .2s; }
.shuffle-cards i:nth-child(4) { animation-delay: .3s; }
.shuffle-cards i:nth-child(5) { animation-delay: .4s; }
@keyframes riffle {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-16px) rotate(6deg); }
}

/* ══════════ RESPONSIVE ══════════ */

/* phones & small tablets: pin the controls to the bottom of the screen so
   Hit / Stand / Double / Split are always one tap away — no scrolling */
@media (max-width: 700px) {
  main {
    padding-bottom: calc(var(--ctrl-h, 230px) + 6px); gap: 12px;
    /* felt stretches to exactly meet the pinned controls */
    min-height: calc(100dvh - var(--hdr-h, 54px));
  }
  .table-zone { flex: 1; display: flex; flex-direction: column; }
  .table-zone .seats { flex: 1; align-items: center; }
  .control-zone {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    gap: 8px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(9,14,11,.98), rgba(9,14,11,.9));
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(201,165,87,.28);
    box-shadow: 0 -10px 30px rgba(0,0,0,.4);
  }
  .action-bar { grid-template-columns: repeat(4, 1fr); gap: 7px; }
  .action-btn { padding: 10px 2px 8px; border-radius: 11px; gap: 2px; }
  .action-btn .act-name { font-size: 14px; }
  .action-btn .act-ev, .action-btn .act-avg { font-size: 9px; min-height: 12px; }
  .action-btn .book-tag { font-size: 8px; padding: 2px 7px; top: -8px; }
  .bet-bar, .round-bar, .insurance-bar { padding: 10px 12px; gap: 9px; border-radius: 12px; }
  .bet-amt { font-size: 20px; }
  .deal-btn { padding: 11px 22px; font-size: 16px; }
  .round-net { font-size: 26px; }
  .round-sub { font-size: 12px; }
  .stats-line { padding: 0; gap: 26px; }
  .stat-val { font-size: 14px; }
  .stat-label { font-size: 8px; letter-spacing: .12em; }
  .table-zone { padding: 12px 10px 22px; }
  .felt-print { font-size: 8.5px; letter-spacing: .18em; margin: 8px 0 10px; }
  .dealer-area { min-height: 0; }
  .insight { padding: 12px 13px 10px; }
  .insight-reason { font-size: 12.5px; margin-bottom: 8px; }
  .shoe-meter { top: 12px; right: 12px; gap: 5px; }
  .shoe-count { font-size: 10px; min-width: 20px; }

  /* table reads top-to-bottom: dealer → seats → house rules at the rim */
  .table-zone { padding-bottom: 30px; }
  .felt-print { order: 4; margin: 10px 6px 0; font-size: 8px; letter-spacing: .14em; }
  .seats { margin-top: 8px; }

  /* coach docks above the pinned controls — never over the dealer's cards */
  .coach {
    top: auto; left: 50%; bottom: calc(var(--ctrl-h, 230px) + 16px);
    width: calc(100vw - 18px); max-width: 470px;
    padding: 9px 13px;
    transform: translate(-50%, 10px);
  }
  .coach.show { transform: translate(-50%, 0); }
  .coach strong { font-size: 13px; }
  .coach span { font-size: 11.5px; }

  .insight .outcome-row { font-size: 11.5px; }
  .book-action { font-size: 24px; }

  /* counting mode: the count reads top-down — count first, then the book */
  .insight { order: 1; }
}

/* small phones: compact header so nothing wraps or clips */
@media (max-width: 560px) {
  .top { padding: 7px 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 31px; height: 31px; font-size: 16px; border-radius: 9px; }
  .brand-name { font-size: 13px; white-space: nowrap; }
  .brand-sub { font-size: 7.5px; letter-spacing: .22em; }
  .top-right { gap: 1px; }
  .bankroll { padding: 3px 8px; margin-right: 3px; border-radius: 8px; }
  .bankroll-label { font-size: 7.5px; letter-spacing: .16em; }
  .bankroll-amt { font-size: 12.5px; }
  .icon-btn { padding: 6px 5px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .icon-label { display: none; }
  .bet-row { justify-content: center; }
  .bet-display { text-align: center; width: 100%; }
  .chip-rack { justify-content: center; }
  .seat-picker { justify-content: center; }
  .deal-btn { width: 100%; }
  .chip { width: 44px; height: 44px; border-width: 3px; font-size: 12px; }
  .ins-btns { flex-direction: column; }
  .ins-text strong { font-size: 16px; }
  .ev-row { grid-template-columns: 50px 1fr 60px; gap: 7px; }
  .ev-cap { font-size: 9px; letter-spacing: .1em; }
}
@media (min-width: 880px) {
  main {
    display: grid; grid-template-columns: 1fr 340px; grid-auto-rows: min-content;
    align-items: start; gap: 16px;
  }
  .table-zone { grid-column: 1; grid-row: 1 / span 2; }
  .insight { grid-column: 2; grid-row: 1; }
  .count-panel {
    grid-column: 2; grid-row: 2; align-self: start;
    /* cap to the space left under the Book panel so the action buttons
       never get pushed below the fold — the panel scrolls internally */
    max-height: clamp(220px, calc(100dvh - 570px), 560px);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .control-zone { grid-column: 1 / -1; grid-row: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
