@font-face { font-family: 'Playfair Display'; src: url('fonts/playfair.woff') format('woff'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter.woff') format('woff'); font-weight: 100 900; font-display: swap; }

:root {
  --felt-1: #1d7a4f;
  --felt-2: #0f5a38;
  --felt-3: #083d26;
  --felt-edge: #052a1a;
  --rail: #4a2c1a;
  --rail-2: #2c190e;
  --gold: #d4af37;
  --gold-2: #f3d98b;
  --gold-3: #a8862a;
  --cream: #f7f1e1;
  --ink: #16181d;
  --red: #c8202f;
  --good: #3ecf7a;
  --bad: #ff5a5f;
  --warn: #ffbe3d;
  --panel: rgba(4, 24, 15, 0.55);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(212, 175, 55, 0.35);
  --text: #f4efe2;
  --muted: #bcd0c3;
  --card-w: 74px;
  --card-h: 104px;
  --tabbar-h: 62px;
  --topbar-h: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: #041a10;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; }
svg { fill: currentColor; }

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse 120% 70% at 50% 30%, rgba(255,255,255,0.07), transparent 60%),
    radial-gradient(ellipse 100% 100% at 50% 50%, var(--felt-2) 0%, var(--felt-3) 55%, var(--felt-edge) 100%);
}
#app::before { /* felt texture */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.18; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.7'/></svg>");
}

/* ---------- Top bar ---------- */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 6px) 12px 6px;
  min-height: calc(var(--topbar-h) + var(--safe-top));
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.05));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--gold-2);
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--gold); background: radial-gradient(circle at 40% 35%, #17643f, #07291a);
  box-shadow: inset 0 0 0 2px rgba(212,175,55,0.25);
}
.brand-text { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text em { font-style: italic; color: var(--gold-2); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.bankroll-pill {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05;
  padding: 4px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.25);
}
.pill-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
#bankroll-val { font-weight: 700; font-size: 15px; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--gold-2); }
.icon-btn:active { background: rgba(255,255,255,0.08); }

/* ---------- Views ---------- */
#views { position: relative; flex: 1; min-height: 0; z-index: 1; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view[hidden] { display: none; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: relative; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: linear-gradient(180deg, #1a100a, #0d0704);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0,0,0,0.35);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #a99880; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--gold-2); }
.tab.active svg { filter: drop-shadow(0 0 6px rgba(243,217,139,0.5)); }

/* ================= Cards ================= */
.card {
  --cw: var(--card-w); --ch: var(--card-h);
  width: var(--cw); height: var(--ch);
  position: relative; flex: 0 0 auto;
  perspective: 800px;
  border-radius: calc(var(--cw) * 0.09);
}
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(.2,.7,.2,1);
  border-radius: inherit;
}
.card.facedown .card-inner { transform: rotateY(180deg); }
.card-front, .card-back {
  position: absolute; inset: 0;
  border-radius: inherit;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,0.45), 0 1px 1px rgba(0,0,0,0.3);
}
.card-front {
  background: linear-gradient(160deg, #ffffff 0%, #f6f3ea 100%);
  border: 1px solid #d9d3c4;
  overflow: hidden;
}
.card-back {
  transform: rotateY(180deg);
  background: #7a1420;
  border: 2px solid #f4efe2;
  overflow: hidden;
}
.back-pattern {
  position: absolute; inset: 3px; border-radius: 4px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.18) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.18) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, #9b1c2b, #5e0f19);
  border: 1px solid rgba(243,217,139,0.7);
}
.back-logo {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--gold-2); font-size: calc(var(--cw) * 0.36); text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.card.red .card-front { color: var(--red); }
.card.black .card-front { color: var(--ink); }
.corner { position: absolute; display: flex; flex-direction: row; align-items: flex-start; gap: 1px; line-height: 0.9; }
.corner { width: 24%; }
.corner .rank { font-family: var(--font-display); font-weight: 800; font-size: calc(var(--cw) * 0.25); letter-spacing: -1px; white-space: nowrap; }
.corner .suit { width: calc(var(--cw) * 0.13); height: calc(var(--cw) * 0.13); margin-top: 2px; }
.corner.tl { top: 3.5%; left: 4%; }
.corner.br { bottom: 3.5%; right: 4%; transform: rotate(180deg); }
.pip-center { position: absolute; inset: 0; }
.pip-center.ace { display: grid; place-items: center; }
.pip-center.ace .suit { width: 46%; height: 46%; }
/* pip area sits between the corner indices */
.pip-center { position: absolute; inset: 0; }
.pip-center.ace { inset: 0; }
.pip { position: absolute; width: 22%; aspect-ratio: 1 / 1.08; transform: translate(-50%, -50%); display: block; }
.pip .suit { width: 100%; height: 100%; display: block; }
.pip.flip { transform: translate(-50%, -50%) rotate(180deg); }

.face-art { position: absolute; left: 22%; right: 22%; top: 21%; bottom: 21%; }
.face-panel {
  position: absolute; inset: 0; border-radius: 4px;
  border: 1.5px solid currentColor;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    linear-gradient(135deg, rgba(212,175,55,0.16), rgba(212,175,55,0.03)),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0 3px, transparent 3px 8px);
}
.face-mono { font-family: var(--font-display); font-weight: 800; font-size: calc(var(--cw) * 0.36); line-height: 1; }
.face-suit { width: calc(var(--cw) * 0.17); height: calc(var(--cw) * 0.17); margin-top: 2px; }

.pip-center { position: absolute; inset: 0; }
.pip-center.ace { display: grid; place-items: center; }
.pip-center.ace .suit { width: 46%; height: 46%; }
/* pip area sits between the corner indices */
.pip-center { position: absolute; inset: 0; }
.pip-center.ace { inset: 0; }
.pip { position: absolute; width: 22%; aspect-ratio: 1 / 1.08; transform: translate(-50%, -50%); display: block; }
.pip .suit { width: 100%; height: 100%; display: block; }
.pip.flip { transform: translate(-50%, -50%) rotate(180deg); }

/* dealing animation */
.card.deal-in { animation: dealIn 0.42s cubic-bezier(.2,.8,.25,1) both; }
@keyframes dealIn {
  0% { transform: translate(var(--dx, 0px), var(--dy, -36px)) rotate(var(--rot, 0deg)) scale(0.92); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
}
.card.to-discard { animation: toDiscard 0.5s ease-in both; }
@keyframes toDiscard {
  to { transform: translate(var(--tx, -200px), var(--ty, -200px)) rotate(-20deg) scale(0.6); opacity: 0; }
}

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px; border-radius: 14px;
  font-weight: 700; font-size: 16px; letter-spacing: 0.2px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn-gold { background: linear-gradient(180deg, #f1d27a, #c79b2e); color: #2a1d05; border-color: #f6e2a1; box-shadow: 0 3px 0 #7d5f17, 0 6px 14px rgba(0,0,0,0.35); }
.btn-green { background: linear-gradient(180deg, #3fbf76, #1f8a4f); color: #fff; border-color: #6fe0a0; box-shadow: 0 3px 0 #0f5530; }
.btn-red { background: linear-gradient(180deg, #e3525a, #a51e28); color: #fff; border-color: #f28a8f; box-shadow: 0 3px 0 #6b1018; }
.btn-blue { background: linear-gradient(180deg, #4f8fe6, #2459ad); color: #fff; border-color: #8db6f2; box-shadow: 0 3px 0 #153a75; }
.btn-ghost { background: rgba(0,0,0,0.25); border-color: var(--line); color: var(--cream); }
.btn-sm { min-height: 38px; font-size: 14px; padding: 0 12px; border-radius: 11px; }

/* ================= Play view ================= */
.play { display: flex; flex-direction: column; height: 100%; padding: 6px 10px 8px; gap: 6px; }
.table-info {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--muted);
}
.rules-chip { padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0,0,0,0.22); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 360px) {
  .brand-text { font-size: 16px; white-space: nowrap; }
  .rules-chip { font-size: 10px; }
}
.mini-toggles { display: flex; gap: 6px; }
.toggle-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16); background: rgba(0,0,0,0.25); font-size: 11px; font-weight: 600; color: var(--muted);
  min-height: 28px;
}
.toggle-chip.on { color: #1d1504; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: var(--gold-2); }

.table-arc {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 140%; height: 260px; border: 2px solid rgba(243,217,139,0.28); border-radius: 50%;
  pointer-events: none;
}

.dealer-zone, .player-zone { position: relative; display: flex; flex-direction: column; align-items: center; }
.zone-label {
  font-family: var(--font-display); letter-spacing: 3px; text-transform: uppercase; font-size: 11px; color: rgba(243,217,139,0.75);
  display: flex; align-items: center; gap: 8px;
}
.total-badge {
  font-family: var(--font-ui); letter-spacing: 0; text-transform: none;
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.45); color: var(--cream); border: 1px solid rgba(255,255,255,0.15);
}
.total-badge.bust { background: #7a1420; border-color: #c9484f; }
.total-badge.bj { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2a1d05; border-color: var(--gold-2); }

.hand-row { display: flex; justify-content: center; align-items: flex-start; position: relative; min-height: var(--card-h); margin-top: 4px; }
.hand-row .card + .card { margin-left: calc(var(--card-w) * -0.2); }
.hand-row .card { transition: margin 0.2s; }

/* dealing shoe: cards stacked inside a dark shoe box, tilted slightly */
.shoe {
  position: absolute; right: 8px; top: 4px; width: 70px; height: 64px; z-index: 0;
}
.shoe .shoe-box {
  position: absolute; right: 0; top: 8px; width: 62px; height: 50px;
  background: linear-gradient(160deg, #3a2416, #1d110a);
  border: 1px solid rgba(212,175,55,0.45); border-radius: 6px 6px 10px 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transform: skewX(-8deg);
}
.shoe .card { --cw: 38px; --ch: 54px; position: absolute; transform: rotate(8deg); }
.shoe .card:nth-child(2) { right: 14px; top: 0; }
.shoe .card:nth-child(3) { right: 17px; top: 3px; }
.shoe .card:nth-child(4) { right: 20px; top: 6px; }
.shoe .card .back-logo { font-size: 14px; }

/* discard tray: cards stack from the top down, like a real tray seen from above */
.discard-tray {
  position: absolute; left: 8px; top: 4px; width: 58px; height: 66px;
  border: 2px solid rgba(212,175,55,0.55); border-radius: 5px;
  background: linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0.25));
  overflow: hidden; box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
}
.discard-fill {
  position: absolute; left: 0; right: 0; top: 0;
  background: repeating-linear-gradient(180deg, #efe8d6 0 2px, #b3a687 2px 3px);
  border-bottom: 2px solid #8c1f2a;
  transition: height 0.4s ease;
}
.tray-caption {
  position: absolute; left: 0; right: 0; bottom: 2px; text-align: center;
  font-size: 8.5px; letter-spacing: 1px; text-transform: uppercase; color: rgba(243,217,139,0.8);
  text-shadow: 0 1px 2px #000;
}
.tray-marks { position: absolute; inset: 0; z-index: 2; }
.tray-marks i { position: absolute; right: 0; width: 8px; border-top: 1px solid rgba(243,217,139,0.7); }
.tray-marks i.half { width: 4px; opacity: 0.6; }

/* felt arcs behind dealer and player */
.dealer-zone::before, .player-zone::before {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  width: 118%; border: 1.5px solid rgba(243,217,139,0.16); border-radius: 50%;
  pointer-events: none; z-index: -1;
}
.dealer-zone::before { top: 22px; height: 230px; }
.player-zone::before { bottom: -60px; height: 250px; border-color: rgba(243,217,139,0.12); }
.dealer-zone, .player-zone, .center-zone { isolation: isolate; }
.dealer-zone { flex: 1 1 0; justify-content: center; padding-top: 2px; min-height: calc(var(--card-h) + 30px); }
.player-zone { flex: 1.15 1 0; justify-content: center; min-height: 0; }
.center-zone { flex: 0 0 auto; }

.hands-wrap { display: flex; justify-content: center; gap: 10px; width: 100%; margin-top: 4px; }
.player-hand { display: flex; flex-direction: column; align-items: center; padding: 4px 6px 2px; border-radius: 14px; border: 2px solid transparent; transition: border-color 0.2s, background 0.2s; }
.player-hand.active { border-color: rgba(243,217,139,0.8); background: rgba(243,217,139,0.06); box-shadow: 0 0 18px rgba(243,217,139,0.18); }
.player-hand .hand-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.bet-tag { font-size: 11px; color: var(--gold-2); font-weight: 700; }
.result-tag { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.5px; }
.result-tag.win, .result-tag.blackjack { background: var(--good); color: #05210f; }
.result-tag.lose, .result-tag.bust { background: var(--bad); color: #2b0304; }
.result-tag.push, .result-tag.surrender { background: #c9c2ad; color: #1c1a14; }

.center-zone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 76px; padding: 2px 0; }

.table-print {
  font-family: var(--font-display); text-align: center; color: rgba(243,217,139,0.55);
  letter-spacing: 2px; font-size: 13px; line-height: 1.35; text-transform: uppercase; pointer-events: none;
}
.table-print small { display: block; font-size: 10px; letter-spacing: 1.5px; }

/* betting circle */
.bet-circle {
  position: relative; width: 84px; height: 84px; border-radius: 50%;
  border: 2px dashed rgba(243,217,139,0.55);
  display: grid; place-items: center;
}
.bet-circle .chip { position: absolute; }

.bet-spot { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bet-spot .bet-circle {
  width: 118px; height: 118px; border-width: 2px;
  box-shadow: inset 0 0 0 6px rgba(0,0,0,0.08), inset 0 0 22px rgba(0,0,0,0.25);
}
.bet-spot .bet-circle::before {
  content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 1px solid rgba(243,217,139,0.3);
}
.bet-circle-label { font-family: var(--font-display); font-size: 12px; letter-spacing: 2px; color: rgba(243,217,139,0.6); text-align: center; line-height: 1.3; }
/* chips lying flat in the betting circle: stacked upward like a real stack */
.chip.mini {
  width: 58px; height: 58px; position: absolute; left: 50%; margin-left: -29px; pointer-events: none;
  border: 4px dashed rgba(255,255,255,0.85);
  box-shadow: 0 2px 0 rgba(0,0,0,0.35), 0 3px 6px rgba(0,0,0,0.35);
}
.chip.mini span { width: 30px; height: 30px; font-size: 12px; }
.bet-spot .bet-amount { position: static; font-size: 16px; }

.chip {
  width: 46px; height: 46px; border-radius: 50%; position: relative;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff;
  border: 3px dashed rgba(255,255,255,0.85);
  box-shadow: 0 3px 0 rgba(0,0,0,0.4), 0 5px 10px rgba(0,0,0,0.35);
}
.chip span { background: rgba(255,255,255,0.92); color: #222; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.chip-white { background: #d9d9d9; } .chip-white span { background: #fff; }
.chip-red { background: #b3232e; }
.chip-blue { background: #1f5fbf; }
.chip-green { background: #1d8a4e; }
.chip-black { background: #1c1c1c; }
.chip-purple { background: #5d2f91; }
.chip:active { transform: translateY(2px); }

.bet-controls { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.chip-row { display: flex; gap: 10px; justify-content: center; align-items: center; }
.bet-actions { display: flex; gap: 8px; width: 100%; max-width: 420px; }
.bet-actions .btn { flex: 1; }

.action-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; }
.action-bar .btn { padding: 0 4px; font-size: 15px; min-height: 52px; flex-direction: column; gap: 0; border-radius: 12px; }
.action-bar.four { grid-template-columns: repeat(4, 1fr); }

.bottom-panel { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }

/* coach feedback */
.coach {
  width: 100%; max-width: 520px; border-radius: 14px; padding: 8px 12px;
  background: rgba(3, 20, 12, 0.78); border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 13.5px; line-height: 1.35;
  animation: pop 0.25s ease both;
}
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.coach .coach-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.coach.good { border-color: rgba(62,207,122,0.7); }
.coach.good .coach-head { color: #7eeaa8; }
.coach.bad { border-color: rgba(255,90,95,0.75); }
.coach.bad .coach-head { color: #ff8d90; }
.coach.info .coach-head { color: var(--gold-2); }
.coach .coach-body { color: var(--cream); margin-top: 2px; }
.coach .dev { margin-top: 4px; padding-top: 4px; border-top: 1px dashed rgba(243,217,139,0.35); color: var(--gold-2); }
.coach-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; background: rgba(255,255,255,0.1); }

.round-banner { font-family: var(--font-display); font-size: 22px; font-weight: 800; text-align: center; text-shadow: 0 2px 6px rgba(0,0,0,0.6); }
.round-banner .net { display: block; font-family: var(--font-ui); font-size: 14px; font-weight: 700; }
.net.pos { color: #7eeaa8; } .net.neg { color: #ff8d90; }

/* count HUD */
.count-hud {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
}
.count-box {
  display: flex; flex-direction: column; align-items: center; min-width: 62px; padding: 3px 8px;
  border-radius: 10px; background: rgba(0,0,0,0.38); border: 1px solid var(--line);
}
.count-box .k { font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.count-box .v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cream); }
.count-box.suggest .v { color: var(--gold-2); }

/* ================= Generic panels/screens ================= */
.screen { padding: 12px 12px 48px; max-width: 980px; margin: 0 auto; }
.screen-title { font-family: var(--font-display); font-size: 24px; font-weight: 800; margin: 4px 0 2px; }
.screen-sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  backdrop-filter: blur(4px);
}
.panel + .panel { margin-top: 10px; }
.panel h3 { margin: 0 0 8px; font-size: 15px; font-family: var(--font-display); color: var(--gold-2); letter-spacing: 0.3px; }

.seg { display: flex; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 3px; gap: 3px; border: 1px solid rgba(255,255,255,0.08); }
.seg button { flex: 1; min-height: 38px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--muted); padding: 0 8px; }
.seg button.on { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241a04; }

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-card {
  text-align: left; padding: 14px 12px; border-radius: 16px; min-height: 118px;
  background: linear-gradient(160deg, rgba(255,255,255,0.07), rgba(0,0,0,0.25));
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px;
}
.menu-card:active { transform: scale(0.98); }
.menu-card .mc-icon { font-size: 24px; }
.menu-card .mc-title { font-weight: 800; font-size: 15px; color: var(--cream); }
.menu-card .mc-desc { font-size: 12px; color: var(--muted); line-height: 1.3; }
.menu-card .mc-stat { margin-top: auto; font-size: 11.5px; color: var(--gold-2); font-weight: 700; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-tile { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 8px; text-align: center; }
.stat-tile .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); }
.stat-tile .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-tile .v small { font-size: 12px; color: var(--muted); font-weight: 600; }

/* drill */
.drill-stage { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; }
.drill-dealer, .drill-player { display: flex; flex-direction: column; align-items: center; }
.hand-caption { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.drill-actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; margin-top: 6px; }
.drill-actions .btn { min-height: 54px; padding: 0 2px; font-size: 14.5px; }
.drill-actions.four { grid-template-columns: repeat(4, 1fr); }
.feedback {
  width: 100%; border-radius: 14px; padding: 10px 12px; margin-top: 8px; border: 1px solid var(--line);
  background: rgba(3, 20, 12, 0.78); font-size: 14px; line-height: 1.4; min-height: 64px;
}
.feedback.good { border-color: rgba(62,207,122,0.7); }
.feedback.bad { border-color: rgba(255,90,95,0.75); }
.feedback .fb-title { font-weight: 800; font-size: 16px; }
.feedback.good .fb-title { color: #7eeaa8; }
.feedback.bad .fb-title { color: #ff8d90; }

/* count drills */
.big-card-area { display: flex; justify-content: center; align-items: center; min-height: 170px; gap: 14px; position: relative; }
.big-card-area .card { --cw: 112px; --ch: 158px; }
.count-answer-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.count-answer-row.five { grid-template-columns: repeat(5, 1fr); }
.count-answer-row .btn { min-height: 60px; font-size: 22px; font-weight: 800; }
.progress-bar { height: 8px; border-radius: 999px; background: rgba(0,0,0,0.35); overflow: hidden; border: 1px solid rgba(255,255,255,0.08); }
.progress-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); width: 0; transition: width 0.2s; }

.num-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 8px auto 0; }
.num-pad .btn { min-height: 52px; font-size: 20px; font-weight: 800; }
.answer-display { font-size: 32px; font-weight: 800; text-align: center; min-height: 44px; font-variant-numeric: tabular-nums; letter-spacing: 1px; }

.tray-visual { display: flex; align-items: stretch; gap: 10px; justify-content: center; margin: 6px 0; }
.tray-big { position: relative; width: 120px; height: 150px; border: 2px solid rgba(243,217,139,0.6); border-radius: 8px; background: rgba(0,0,0,0.28); overflow: hidden; }
.tray-big .discard-fill { background: repeating-linear-gradient(90deg, #ece5d2 0 3px, #b9ad90 3px 4px); left: 0; top: 0; bottom: 0; right: auto; transition: width 0.4s; }

.tray-big { background: linear-gradient(90deg, #04190f, #072a1a); box-shadow: inset 0 2px 8px rgba(0,0,0,0.6); }
.tray-big .discard-fill { border-right: 2px solid #8c1f2a; box-shadow: 2px 0 6px rgba(0,0,0,0.5); }
.tray-big .tray-marks i { left: auto; top: 0; bottom: auto; right: auto; border-top: 0; border-left: 1px dashed rgba(243,217,139,0.6); height: 100%; z-index: 2; }
.tray-big .tray-marks span { z-index: 3; background: rgba(4,25,15,0.75); padding: 0 2px; border-radius: 3px; top: 3px; }
.tray-big .tray-marks span { position: absolute; top: 2px; font-size: 9px; color: rgba(243,217,139,0.9); transform: translateX(-50%); }
.tray-legend { display: flex; flex-direction: column; justify-content: center; gap: 6px; font-size: 13px; }
.tray-legend b { color: var(--gold-2); }

/* ================= Chart ================= */
.chart-wrap { overflow-x: auto; }
table.strategy { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 12.5px; table-layout: fixed; }
table.strategy th { font-weight: 700; color: var(--gold-2); padding: 4px 0; font-size: 12px; }
table.strategy td { text-align: center; padding: 6px 0; border-radius: 5px; font-weight: 800; color: #101010; position: relative; }
table.strategy td.rowh { background: transparent; color: var(--cream); font-weight: 700; text-align: right; padding-right: 6px; }
table.strategy .sec td { background: transparent; color: var(--gold-2); font-family: var(--font-display); text-align: left; font-size: 14px; padding-top: 8px; }
.c-H { background: #e8453c; color: #fff !important; }
.c-S { background: #f2d14a; }
.c-Dh { background: #3d6fd6; color: #fff !important; }
.c-Ds { background: #8fb4ee; }
.c-P { background: #35b46a; color: #fff !important; }
.c-Ph { background: #bfe8cf; }
.c-Pd { background: #a9c6f0; }
.c-Ps { background: #d6c7f0; }
.c-Rh, .c-Rs, .c-Rp, .c-Rn { background: #f4f1e8; }
td.miss { box-shadow: inset 0 0 0 3px #111, 0 0 0 2px #ff4fd8; z-index: 1; }
td.miss::after { content: attr(data-miss); position: absolute; top: -5px; right: -3px; background: #ff4fd8; color: #fff; font-size: 9px; border-radius: 999px; padding: 0 4px; line-height: 13px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 12px; margin-top: 8px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 22px; height: 16px; border-radius: 4px; display: inline-block; flex: 0 0 auto; }

/* ================= Stats ================= */
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-item .bl-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.bar { height: 10px; border-radius: 999px; background: rgba(0,0,0,0.35); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #2fa866, #7eeaa8); }
.bar.warn > i { background: linear-gradient(90deg, #d99a1e, #ffd36b); }
.bar.bad > i { background: linear-gradient(90deg, #b3232e, #ff8d90); }
.weak-list { display: flex; flex-direction: column; gap: 6px; }
.weak-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,0.28); font-size: 13.5px; }
.weak-item .w-miss { color: #ff8d90; font-weight: 800; }

/* ================= Settings sheet ================= */
.sheet-backdrop, .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 20; }
.sheet {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100%); z-index: 21;
  background: linear-gradient(180deg, #0d3a26, #062316);
  border-left: 1px solid var(--line); overflow-y: auto;
  padding: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 20px);
  animation: slideIn 0.25s ease both;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { font-family: var(--font-display); margin: 0; font-size: 24px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.setting { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.07); }
.setting .s-label { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; display: flex; justify-content: space-between; }
.setting .s-help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.15); flex: 0 0 auto; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #d8d2c2; transition: transform 0.2s; }
.switch.on { background: linear-gradient(180deg, #3fbf76, #1f8a4f); }
.switch.on::after { transform: translateX(20px); background: #fff; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.setting-row .s-label { margin: 0; }

.modal-backdrop { display: grid; place-items: center; padding: 16px; z-index: 30; }
.modal-backdrop[hidden], .sheet[hidden], .sheet-backdrop[hidden] { display: none; }
.modal {
  width: min(420px, 100%); background: linear-gradient(180deg, #0f4229, #07281a); border: 1px solid var(--gold-3);
  border-radius: 18px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: pop 0.2s ease both;
}
.modal h3 { font-family: var(--font-display); margin: 0 0 6px; font-size: 22px; color: var(--gold-2); }
.modal p { margin: 6px 0; font-size: 14px; line-height: 1.4; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal .modal-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: var(--cream); padding: 10px 14px; border-radius: 12px; z-index: 40;
  border: 1px solid var(--line); font-size: 14px; max-width: 90%;
}
.toast[hidden] { display: none; }

.spread-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.spread-table td, .spread-table th { padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.08); text-align: center; }
.spread-table input { width: 64px; text-align: center; background: rgba(0,0,0,0.35); color: var(--cream); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 16px; }
.index-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.index-table td, .index-table th { padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,0.08); text-align: left; }
.index-table td.idx { text-align: right; font-weight: 800; color: var(--gold-2); }

.note { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ================= Desktop ================= */
@media (min-width: 900px) {
  :root { --card-w: 96px; --card-h: 136px; }
  .play { max-width: 1100px; margin: 0 auto; width: 100%; padding: 10px 24px 14px; }
  .brand-text { font-size: 22px; }
  .dealer-zone { min-height: calc(var(--card-h) + 36px); }
  .action-bar { max-width: 640px; margin: 0 auto; }
  .bet-actions { max-width: 520px; }
}
@media (max-height: 700px) and (max-width: 899px) {
  :root { --card-w: 64px; --card-h: 90px; }
}
@media (max-width: 350px) {
  :root { --card-w: 62px; --card-h: 88px; }
  .action-bar .btn { font-size: 13px; }
}

/* ================= Print ================= */
@media print {
  body, #app { background: #fff !important; color: #000; position: static; }
  #app::before, .topbar, .tabbar, .no-print { display: none !important; }
  .view { position: static; overflow: visible; }
  .view[hidden] { display: none !important; }
  .panel { background: #fff; border-color: #999; }
  table.strategy td.rowh, table.strategy th, .screen-title, .screen-sub, .panel h3 { color: #000 !important; }
  table.strategy td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .c-H, .c-Dh, .c-P { color: #fff !important; }
}

.chipstack { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); filter: drop-shadow(0 4px 4px rgba(0,0,0,0.4)); overflow: visible; }

.tray-col { display: flex; flex-direction: column; }
.tray-scale { position: relative; height: 16px; width: 120px; }
.tray-scale span { position: absolute; transform: translateX(-50%); font-size: 10px; font-weight: 700; color: rgba(243,217,139,0.95); }
.tray-big .tray-marks i.half { height: 12%; top: 0; opacity: 0.55; border-left-style: dotted; }

.mc-icon { color: var(--gold-2); display: inline-flex; }
.mc-icon svg { width: 26px; height: 26px; }
@media (min-width: 900px) {
  .bet-spot .bet-circle { width: 150px; height: 150px; }
  .chipstack { transform: translateX(-50%) scale(1.25); transform-origin: bottom center; }
  .screen { padding-top: 20px; }
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
}

/* in-play count quiz: compact so the table stays visible */
.quiz-box { display: flex; flex-direction: column; gap: 6px; background: rgba(3,20,12,0.8); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.quiz-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.quiz-field { display: flex; flex-direction: column; align-items: center; padding: 4px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14); background: rgba(0,0,0,0.3); color: var(--muted); min-height: 48px; }
.quiz-field span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; }
.quiz-field b { font-size: 22px; color: var(--cream); line-height: 1.1; }
.quiz-field.on { border-color: var(--gold-2); background: rgba(212,175,55,0.16); }
.quiz-field.on b { color: var(--gold-2); }
.quiz-check { min-height: 48px; }
.quiz-pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.quiz-pad .btn { min-height: 42px; font-size: 18px; font-weight: 800; padding: 0; }
.quiz-result { margin-top: 0; }
.player-zone { overflow: visible; }

@media (min-width: 900px) {
  :root { --card-w: 112px; --card-h: 158px; }
  .dealer-zone::before { height: 300px; }
  .player-zone::before { height: 320px; }
  .bet-spot .bet-circle { width: 170px; height: 170px; }
  .action-bar .btn { min-height: 60px; font-size: 18px; }
}
@media (min-width: 900px) and (max-height: 760px) {
  :root { --card-w: 92px; --card-h: 130px; }
}

/* ---------- Layout fixes ---------- */
.rules-short { display: none; }
@media (max-width: 420px) { .rules-long { display: none; } .rules-short { display: inline; } }
@media (max-width: 360px) {
  .topbar { padding-left: 8px; padding-right: 8px; }
  .brand { gap: 6px; }
  .brand-mark { width: 30px; height: 30px; font-size: 15px; }
  .brand-text { font-size: 17px; }
  .bankroll-pill { padding-left: 8px; padding-right: 8px; }
}
.player-zone { min-height: calc(var(--card-h) + 48px); }
.dealer-zone { flex-shrink: 0; }
.play { overflow-y: auto; overflow-x: hidden; }
@media (max-height: 720px) and (max-width: 899px) {
  :root { --card-w: 64px; --card-h: 90px; }
  .center-zone { min-height: 0; }
}
@media (max-height: 600px) and (max-width: 899px) {
  :root { --card-w: 58px; --card-h: 82px; }
  .play { gap: 3px; padding-top: 4px; padding-bottom: 4px; }
  .table-info { font-size: 10px; }
  .dealer-zone { min-height: calc(var(--card-h) + 22px); }
  .coach { padding: 7px 10px; font-size: 13px; }
  .action-bar .btn { min-height: 46px; }
}
@media (max-height: 720px) {
  #view-drill .screen, #view-count .screen { padding-top: 8px; padding-bottom: 8px; }
  #view-drill .stat-row { margin-top: 6px !important; }
  #view-drill .stat-tile { padding: 5px 8px; }
  #view-drill .stat-tile .v { font-size: 18px; }
  #view-drill .drill-stage { gap: 2px; padding: 2px 0; }
  #view-drill .drill-actions .btn { min-height: 48px; }
  #view-drill .feedback { min-height: 0; padding: 8px 10px; margin-top: 6px; }
}
@media (max-height: 600px) {
  #view-drill { --card-w: 56px; --card-h: 80px; }
  #view-drill .screen-title { font-size: 22px; }
  #view-drill .drill-actions .btn { min-height: 44px; }
}
@media (max-height: 600px) {
  #view-drill .drill-divider { margin: 2px 0 !important; }
  #view-drill .zone-label, #view-drill .hand-caption { margin-top: 0; }
  #view-drill .drill-actions { margin-top: 2px; }
}
@media (max-height: 640px) {
  .drill-stage:not(.answered) .feedback { display: none; }
}
@media (max-height: 600px) {
  #view-drill { --card-w: 52px; --card-h: 74px; }
  #view-drill .drill-top .screen-title { font-size: 20px; }
  #view-drill .stat-row { margin-top: 4px !important; }
  #view-drill .drill-actions .btn { min-height: 42px; }
}
