/* By the Book Blackjack.
   The look is a printed rule book: paper, ink and hairline rules, square corners, a serif
   for headings and figures, and a plain sans for everything else. Color is kept for the
   five plays (hit brick, stand ochre, double navy, split plum, surrender graphite) and is
   the same on the buttons, the tags and the chart.
   Every color is a token below, light first and then dark, so changing a token restyles
   the whole app. Text colors meet WCAG AA contrast on the surfaces they sit on. */

:root {
  --paper: #f4f2ec; --panel: #faf8f3; --raise: #fffefb; --ink: #1c1b18; --muted: #66625a;
  --line: #dcd7cb; --line-2: #bab4a6; --edge: #8a8578; --track: #e6e2d8;
  --felt: #1e4d3c; --felt-lo: #163a2d; --felt-ink: #f1ead6; --felt-dim: rgba(241, 234, 214, .72); --felt-line: rgba(217, 196, 138, .4);
  --print: #d9c48a; --back: #7a2230;
  --card: #fdfcf8; --card-ink: #1c1c1c; --card-red: #b02a2f;
  --hit: #a9432f; --stand: #c48d22; --double: #2d5b8e; --split: #694b8c; --surr: #6b6e70; --on-stand: #21180a; --on-act: #fff;
  --good: #2f7a4c; --bad: #b03a2c; --focus: #2d5b8e;
  --display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 2px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131412; --panel: #1a1b18; --raise: #1e1f1c; --ink: #e8e4d9; --muted: #9a968a;
    --line: #2e2f2a; --line-2: #4a4b43; --edge: #707168; --track: #272823;
    --felt: #1a4335; --felt-lo: #123228;
    --hit: #b9503a; --stand: #cf9a33; --double: #3e6ea6; --split: #7d5fa4; --surr: #6e7173;
    --good: #4f9c6c; --bad: #d0604f; --focus: #7aa3d6; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131412; --panel: #1a1b18; --raise: #1e1f1c; --ink: #e8e4d9; --muted: #9a968a;
  --line: #2e2f2a; --line-2: #4a4b43; --edge: #707168; --track: #272823;
  --felt: #1a4335; --felt-lo: #123228;
  --hit: #b9503a; --stand: #cf9a33; --double: #3e6ea6; --split: #7d5fa4; --surr: #6e7173;
  --good: #4f9c6c; --bad: #d0604f; --focus: #7aa3d6; color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
kbd { font: 500 11px/1 var(--mono); }
img, svg { max-width: 100%; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--r); text-decoration: none; font-weight: 500; }
.skip:focus { top: 12px; }
.app { max-width: 1200px; margin: 0 auto; padding: 6px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* Header */
.top { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 4px 22px; padding-top: 12px; border-bottom: 1px solid var(--ink); margin-bottom: 24px; }
.brand { display: flex; align-items: baseline; gap: 12px; margin-right: auto; min-width: 0; padding-bottom: 11px; }
.mark { font: 600 26px/1 var(--display); letter-spacing: -.01em; }
.mark em { font-style: italic; }
.sub { font-size: 13px; color: var(--muted); }
.tabs { display: flex; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tab { appearance: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font-weight: 500; font-size: 14px;
  padding: 10px 12px; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab:focus-visible { outline-offset: -2px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r); background: var(--bad); color: var(--paper); font: 600 11px/18px var(--body); text-align: center; }
.rules-chip { appearance: none; border: 1px solid var(--edge); background: transparent; border-radius: var(--r); padding: 5px 9px; font-size: 12.5px; font-weight: 500; line-height: 1.3;
  cursor: pointer; color: var(--ink); white-space: nowrap; margin-bottom: 9px; }
.rules-chip:hover { border-color: var(--ink); }
#rulesChip { font-family: var(--mono); font-size: 12px; }
@media (max-width: 1100px) { .sub { display: none; } }
@media (max-width: 720px) { .tabs { order: 3; width: 100%; } .mark { font-size: 24px; } .tab { font-size: 13.5px; padding: 9px; } }
@media (max-width: 520px) { .rules-chip { padding: 5px 8px; font-size: 11.5px; } .top { column-gap: 10px; } }

/* Layout */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.panel { border-top: 1px solid var(--ink); padding: 10px 0 2px; }
.panel.stack { display: flex; flex-direction: column; gap: 8px; }
.panel.center { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.eyebrow { font: 600 13px/1.3 var(--body); color: var(--ink); }
.panel > .eyebrow:first-child { margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.more { margin-top: 10px; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* The felt */
.felt { --cw: clamp(50px, 12.5vw, 78px); position: relative; color: var(--felt-ink); background: var(--felt); border-radius: 3px;
  padding: 24px 16px 30px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 390px; }
.felt.idle { min-height: 310px; }
.felt::before, .mini-felt::before { content: ""; position: absolute; inset: 9px; border: 1px solid var(--felt-line); border-radius: 2px; pointer-events: none; }
.felt-note { text-align: center; color: var(--felt-dim); max-width: 34ch; }
@media (max-width: 540px) { .felt { min-height: 330px; padding: 18px 8px 24px; } .felt::before { inset: 5px; } .tray { right: 14px; top: 14px; } .tc-badge { left: 14px; top: 14px; } }
.zone { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.zlabel { font: 500 11px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--felt-dim); }
.cards { display: flex; justify-content: center; min-height: calc(var(--cw) * 1.4); padding-right: 4px; }
.print { width: min(100%, 540px); height: auto; display: block; margin: -6px 0 -4px; pointer-events: none; }
.print text { fill: var(--print); font-family: var(--display); font-weight: 600; letter-spacing: .16em; font-size: 25px; }
.print text.fine { font-family: var(--body); font-weight: 500; font-size: 11.5px; opacity: .85; }
.hands { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 26px; width: 100%; }
.hand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 8px 6px; border-radius: var(--r); border: 1px solid transparent; min-width: 0; }
.hand.active { border-color: rgba(217, 196, 138, .75); background: rgba(0, 0, 0, .12); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 24px; }
.tot { font: 500 13px/1 var(--body); background: rgba(0, 0, 0, .26); color: var(--felt-ink); padding: 5px 8px; border-radius: var(--r); font-variant-numeric: tabular-nums; }
.out { font: 600 13px/1 var(--body); padding: 5px 8px; border-radius: var(--r); background: var(--felt-ink); color: var(--felt-lo); }
.out.lose { background: rgba(0, 0, 0, .45); color: var(--felt-ink); }
.out.win { background: var(--print); color: #24190a; }
.seats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; align-items: start; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.seat .cards { --cw: clamp(30px, 7vw, 46px); }
.seat.me .cards { --cw: clamp(44px, 10vw, 70px); }
.seat .hands { gap: 8px; }
.seat .hand { padding: 0 4px 4px; }
.seat .hand.active { padding: 4px; }
.tray { position: absolute; right: 22px; top: 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--felt-dim); }
.tray-box { display: block; width: 30px; height: 64px; border: 1px solid var(--felt-line); background: rgba(0, 0, 0, .2); }
.tray-box .tray-card { fill: var(--card); }
.tray-box .tray-fill { stroke: none; }
.tray-box line { stroke: rgba(0, 0, 0, .4); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tc-badge { position: absolute; left: 22px; top: 22px; background: rgba(0, 0, 0, .22); border: 1px solid var(--felt-line); border-radius: var(--r); padding: 6px 10px; text-align: center; line-height: 1.1; }
.tc-badge b { display: block; font: 600 24px/1 var(--display); color: var(--print); font-variant-numeric: tabular-nums; }
.tc-badge b.second { font-size: 18px; margin-top: 4px; }
.tc-badge span { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--felt-dim); }

/* Cards. d0–d8 stagger the deal so cards land one after another. */
.card { display: block; width: var(--cw); aspect-ratio: 5 / 7; border-radius: calc(var(--cw) * .07); background: var(--card); color: var(--card-ink); position: relative; flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .16), 0 2px 5px rgba(0, 0, 0, .3); font-family: var(--display); user-select: none; }
.card + .card { margin-left: calc(var(--cw) * -.5); }
.card .ix { position: absolute; left: 8%; top: 5%; display: flex; flex-direction: column; align-items: center; line-height: .92; font-weight: 600; font-size: calc(var(--cw) * .28); }
.card .ix i { font-style: normal; font-size: .78em; }
.card .ix.br { left: auto; top: auto; right: 8%; bottom: 5%; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .46); padding-top: 8%; }
.card.red { color: var(--card-red); }
.card.back { border: 3px solid var(--card);
  background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255, 255, 255, .16) 4px 5px), repeating-linear-gradient(-45deg, transparent 0 4px, rgba(255, 255, 255, .16) 4px 5px), var(--back);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), 0 0 0 1px rgba(0, 0, 0, .16), 0 2px 5px rgba(0, 0, 0, .3); }
.card.in { animation: deal .3s cubic-bezier(.2, .8, .2, 1) backwards; }
.card.flip { animation: flip .3s ease-out backwards; }
.card.d1 { animation-delay: 90ms; } .card.d2 { animation-delay: 180ms; } .card.d3 { animation-delay: 270ms; } .card.d4 { animation-delay: 360ms; }
.card.d5 { animation-delay: 450ms; } .card.d6 { animation-delay: 540ms; } .card.d7 { animation-delay: 630ms; } .card.d8 { animation-delay: 720ms; }
@keyframes deal { from { transform: translateY(-22px); } to { transform: none; } }
@keyframes flip { from { transform: rotateY(70deg); } to { transform: none; } }
.mini { --cw: 30px; display: inline-flex; vertical-align: middle; }
.mini .card { box-shadow: 0 0 0 1px var(--line-2); }
.mini .card + .card { margin-left: 3px; }
.mini .card .ix.br, .mini .card .pip { display: none; }
.mini .card .ix { left: 0; right: 0; font-size: 12px; top: 14%; }

/* Play buttons */
.actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.actions.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .actions:not(.two) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .actions:not(.two) .act { grid-column: span 2; }
  .actions:not(.two) .act.P, .actions:not(.two) .act.R { grid-column: span 3; }
}
.act { appearance: none; border: 0; border-radius: var(--r); padding: 14px 6px 11px; font: 600 16px/1 var(--body); color: var(--on-act); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px; transition: box-shadow .12s; }
.act kbd { opacity: .75; }
.act:hover:not(:disabled) { box-shadow: inset 0 0 0 100px rgba(0, 0, 0, .1); }
.act:active:not(:disabled) { box-shadow: inset 0 0 0 100px rgba(0, 0, 0, .2); }
.act.H { background: var(--hit); } .act.S { background: var(--stand); color: var(--on-stand); } .act.D { background: var(--double); } .act.P { background: var(--split); } .act.R { background: var(--surr); }
.act.I { background: var(--double); } .act.N { background: var(--surr); }
.act:disabled { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); cursor: not-allowed; }
.act:disabled kbd { opacity: .6; }
.act.want { outline: 2px solid var(--ink); outline-offset: 3px; }
.act.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Buttons */
.btn { appearance: none; border: 1px solid var(--edge); background: var(--raise); border-radius: var(--r); padding: 8px 14px; font-weight: 500; font-size: 14px; line-height: 1.3; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center; color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 70%, var(--line)); }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); }
.btn kbd { opacity: .7; }
.btn.big { padding: 12px 20px; font-size: 15px; }
.linkbtn { appearance: none; border: 0; background: none; color: var(--ink); font-weight: 500; cursor: pointer; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

/* Segmented controls: joined buttons for picking one option */
.seg { display: flex; flex-wrap: wrap; padding: 0 1px 1px 0; }
.seg button { appearance: none; flex: 1 1 auto; border: 1px solid var(--edge); background: var(--raise); border-radius: 0; margin: 0 -1px -1px 0; padding: 6px 10px;
  font-size: 13px; font-weight: 500; line-height: 1.3; cursor: pointer; color: var(--muted); position: relative; }
.seg button:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); z-index: 1; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); z-index: 2; }
.seg button:focus-visible { z-index: 3; }
.seg button:disabled { cursor: not-allowed; opacity: .5; }

/* Checkboxes */
.tog { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; font-size: 14px; }
.tog input { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--edge); border-radius: var(--r); background: var(--raise); position: relative; cursor: pointer; flex: none; }
.tog input:hover { border-color: var(--ink); }
.tog input:checked { background: var(--ink); border-color: var(--ink); }
.tog input:checked::after { content: ""; position: absolute; left: 4.5px; top: 1px; width: 4px; height: 9px; border: solid var(--paper); border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* Touch screens get bigger targets */
@media (pointer: coarse) {
  .btn, .seg button, .linkbtn { min-height: 44px; }
  .rules-chip { min-height: 36px; }
  .tog { min-height: 44px; }
  .tog input { width: 20px; height: 20px; }
  .tog input:checked::after { left: 6px; top: 2px; width: 5px; height: 11px; }
  .tab { min-height: 44px; }
}

/* Play tags and feedback */
.play-tag { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: var(--r); font: 600 13px/1.15 var(--body); color: var(--on-act); white-space: nowrap; }
.play-tag.H { background: var(--hit); } .play-tag.S { background: var(--stand); color: var(--on-stand); } .play-tag.D { background: var(--double); } .play-tag.P { background: var(--split); }
.play-tag.R { background: var(--surr); } .play-tag.I { background: var(--double); } .play-tag.N { background: var(--surr); }
.play-tag.lg { font-size: 14px; padding: 4px 9px; }
.arrow { color: var(--muted); }
.fb { background: var(--raise); border: 1px solid var(--line); border-top: 2px solid var(--line-2); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.fb.bad { border-top-color: var(--bad); }
.fb.good { border-top-color: var(--good); padding: 10px 16px; }
.fb.slim { padding: 10px 16px; }
.verdict { font: 600 20px/1.15 var(--display); }
.fb.bad .verdict { color: var(--bad); }
.fb.good .verdict, .fb.slim .verdict { font-size: 18px; }
.fb.good .verdict { color: var(--good); }
.fb-line { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.why { max-width: 68ch; }
.fb details summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.fb details[open] summary { margin-bottom: 8px; }
.cost { font-weight: 600; }
.evs { display: grid; gap: 6px; }
.evr { display: grid; grid-template-columns: 118px minmax(0, 1fr) 62px 40px; align-items: center; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.evr .play-tag { justify-self: start; }
.evbar { display: block; width: 100%; height: 14px; }
.evbar .track { fill: var(--track); }
.evbar .pos { fill: var(--good); }
.evbar .neg { fill: var(--bad); }
.evbar line { stroke: var(--muted); stroke-width: 1; }
.evv { text-align: right; font-weight: 600; }
.evtag { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.evnote { font-size: 12.5px; color: var(--muted); }
@media (max-width: 480px) { .evr { grid-template-columns: 96px minmax(0, 1fr) 56px 34px; gap: 6px; } }

/* Side panels */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.stat b { display: block; font: 600 26px/1.05 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.stat span { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.stat.wide { grid-column: 1 / -1; }
.keys { font-size: 12.5px; color: var(--muted); line-height: 1.9; }
.keys kbd { border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--raise); border-radius: var(--r); padding: 1px 5px; color: var(--ink); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; background: var(--raise); border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 14px; font-size: 14px; }
.banner b { font-weight: 600; }

/* Mistakes */
.head { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 28px; margin-bottom: 20px; }
.head h2 { font: 600 34px/1.05 var(--display); letter-spacing: -.01em; }
.head p { color: var(--muted); max-width: 60ch; }
.kpis { display: flex; gap: 36px; flex-wrap: wrap; margin-bottom: 22px; border-top: 1px solid var(--ink); padding-top: 10px; }
.kpi b { display: block; font: 600 30px/1.05 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.section-title { font: 600 20px/1.15 var(--display); margin: 34px 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-note { font: 400 13px var(--body); color: var(--muted); }
.spots { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.spot { display: grid; grid-template-columns: minmax(0, 1.6fr) 70px minmax(0, 1.3fr) 90px auto; gap: 10px; align-items: center; padding: 10px 2px; border-top: 1px solid var(--line); }
.spot:first-child { border-top: 0; }
.spot .lbl { font-weight: 600; }
.spot .miss { font: 600 20px/1 var(--display); color: var(--bad); font-variant-numeric: lining-nums; }
.spot .plays { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dots { display: flex; gap: 3px; }
.dots i { width: 9px; height: 9px; background: var(--track); border: 1px solid var(--edge); }
.dots i.on { background: var(--good); border-color: var(--good); }
.spot.done { opacity: .65; }
@media (max-width: 640px) { .spot { grid-template-columns: minmax(0, 1fr) auto; } .spot .miss { grid-row: span 2; } .spot .plays { grid-column: 1; } }
.log { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.log details { border-bottom: 1px solid var(--line); }
.log summary { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 2px; cursor: pointer; list-style: none; }
.log summary:hover { background: var(--panel); }
.log summary::-webkit-details-marker { display: none; }
.log details[open] summary { font-weight: 600; }
.log .when { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log .body { padding: 2px 2px 16px; display: flex; flex-direction: column; gap: 10px; }
.tag { font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid var(--line-2); border-radius: var(--r); padding: 1px 6px; white-space: nowrap; }
.tag.wrap { white-space: normal; }
@media (max-width: 560px) { .log summary { grid-template-columns: minmax(0, 1fr) auto; } .log .when { grid-column: 1 / -1; } }
.empty { background: var(--raise); border: 1px solid var(--line-2); border-radius: var(--r); padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: var(--r); background: color-mix(in srgb, var(--bad) 7%, var(--raise)); border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); }
.opt .confirm { width: 100%; }

/* The Book */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; list-style: none; margin: 12px 0 0; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 24px; height: 18px; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 600; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 28px; margin-top: 20px; }
.tbl { margin: 0; min-width: 0; }
.tbl figcaption { font: 600 18px/1.2 var(--display); padding-bottom: 8px; border-bottom: 1px solid var(--ink); margin-bottom: 6px; }
.tbl .note { font-size: 13px; color: var(--muted); margin-top: 6px; }
.tscroll { overflow-x: auto; }
.tbl table { border-collapse: separate; border-spacing: 1px; font-variant-numeric: tabular-nums; width: 100%; min-width: 360px; }
.tbl th { font-size: 12px; font-weight: 500; color: var(--muted); padding: 2px 4px; white-space: nowrap; }
.tbl thead th { text-align: center; }
.tbl tbody th { text-align: right; }
.tbl td { padding: 0; }
.cell { appearance: none; border: 0; width: 100%; height: 28px; border-radius: 0; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink); position: relative; padding: 0; display: block; }
.cell.H, .sw.H { background: color-mix(in srgb, var(--hit) 32%, var(--paper)); }
.cell.S, .sw.S { background: color-mix(in srgb, var(--stand) 40%, var(--paper)); }
.cell.D, .sw.D { background: color-mix(in srgb, var(--double) 34%, var(--paper)); }
.cell.P, .sw.P { background: color-mix(in srgb, var(--split) 34%, var(--paper)); }
.cell.R, .sw.R { background: color-mix(in srgb, var(--surr) 40%, var(--paper)); }
/* a pair you don't split: a paler fill in the color of the total's play */
.cell.dim.H { background: color-mix(in srgb, var(--hit) 14%, var(--paper)); }
.cell.dim.S { background: color-mix(in srgb, var(--stand) 16%, var(--paper)); }
.cell.dim.D { background: color-mix(in srgb, var(--double) 14%, var(--paper)); }
.cell.dim.R { background: color-mix(in srgb, var(--surr) 16%, var(--paper)); }
.cell:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.cell[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: -2px; }
.cell .m { position: absolute; top: -4px; right: -4px; min-width: 15px; height: 15px; border-radius: var(--r); background: var(--bad); color: var(--paper); font-size: 9.5px; line-height: 15px; padding: 0 3px; z-index: 1; }
.detail { margin-top: 22px; }
.detail .verdict { font-size: 20px; }

/* Count School */
.school { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; align-items: start; }
.lessons { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.lessons li { border-bottom: 1px solid var(--line); }
.lesson-btn { appearance: none; border: 0; background: none; border-radius: 0; padding: 10px 8px; cursor: pointer; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 2px 8px; text-align: left; width: 100%; }
.lesson-btn:hover { background: var(--panel); }
.lesson-btn[aria-current] { background: var(--raise); box-shadow: inset 3px 0 0 var(--ink); }
.lesson-btn .n { grid-row: span 2; font: 600 20px/1 var(--display); color: var(--muted); align-self: center; font-variant-numeric: lining-nums; }
.lesson-btn[aria-current] .n { color: var(--ink); }
.lesson-btn .t { font-weight: 600; }
.lesson-btn .s { font-size: 12.5px; color: var(--muted); }
@media (max-width: 820px) {
  .school { grid-template-columns: minmax(0, 1fr); }
  .lessons { flex-direction: row; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
  .lessons li { flex: none; width: 190px; border-bottom: 0; border-right: 1px solid var(--line); }
  .lesson-btn[aria-current] { box-shadow: inset 0 -3px 0 var(--ink); }
}
.lesson { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lesson h2 { font: 600 30px/1.1 var(--display); letter-spacing: -.01em; }
.learn { display: flex; flex-direction: column; gap: 10px; max-width: 70ch; }
.learn summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.groups { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 13px; }
.groups th { font: 600 30px/1 var(--display); text-align: left; padding: 8px 12px 6px 0; border-bottom: 1px solid var(--ink); }
.groups th:first-child { color: var(--good); } .groups th:last-child { color: var(--bad); }
.groups td { vertical-align: top; padding: 10px 12px 4px 0; color: var(--muted); }
.groups tr:first-child td { color: var(--ink); }
.groups th + th, .groups td + td { padding-left: 12px; border-left: 1px solid var(--line); }
@media (max-width: 560px) { .groups { font-size: 12.5px; } .groups .mini { --cw: 22px; flex-wrap: wrap; row-gap: 3px; } .groups .mini .card .ix { font-size: 10px; } }
.drill { background: var(--raise); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; min-width: 0; }
.drill.compact { padding: 14px; }
.cardview { --cw: clamp(88px, 24vw, 120px); display: flex; justify-content: center; gap: 10px; min-height: calc(var(--cw) * 1.4); }
.cardview .card + .card { margin-left: 0; }
.cardview.small-cards { --cw: 80px; }
.flipbtn { appearance: none; border: 0; background: none; cursor: pointer; padding: 0; }
.drill-wide { width: 100%; max-width: 620px; text-align: left; }
.drill-wide .ask { margin-bottom: 8px; text-align: center; }
.prog { appearance: none; display: block; width: 100%; max-width: 420px; height: 4px; border: 0; background: var(--track); color: var(--ink); }
.prog::-webkit-progress-bar { background: var(--track); }
.prog::-webkit-progress-value { background: var(--ink); }
.prog::-moz-progress-bar { background: var(--ink); }
.vals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: 100%; max-width: 420px; }
.vbtn { appearance: none; border: 1px solid var(--edge); background: var(--raise); border-radius: var(--r); padding: 12px 6px 9px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vbtn:hover { border-color: var(--ink); }
.vbtn b { font: 600 28px/1 var(--display); }
.vbtn kbd { color: var(--muted); }
.vbtn.plus b { color: var(--good); } .vbtn.minus b { color: var(--bad); }
.flash { min-height: 22px; font-weight: 600; }
.flash.ok, .score.ok { color: var(--good); }
.flash.no, .score.no { color: var(--bad); }
.score { font: 600 48px/1 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.numin { font: 600 26px var(--display); width: 120px; text-align: center; padding: 6px 8px; border-radius: var(--r); border: 1px solid var(--edge); background: var(--raise); color: var(--ink); }
.formrow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: end; }
.formrow label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.strip { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.strip .c { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-variant-numeric: tabular-nums; }
.strip .c em { font-style: normal; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 24px; width: 100%; }
.facts.narrow { max-width: 360px; }
.fact { border-top: 1px solid var(--ink); padding: 8px 0 0; text-align: left; }
.fact b { display: block; font: 600 26px/1 var(--display); font-variant-numeric: tabular-nums lining-nums; }
.fact span { font-size: 12.5px; color: var(--muted); }
.trayq { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; }
.trayfig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trayq .tray-box { width: 46px; height: 120px; border-color: var(--edge); background: var(--track); }
.trayq .tray-box .tray-card { fill: var(--muted); }
.trayq .tray-box line { stroke: var(--paper); }
.ramp, .idx { border-collapse: collapse; font-size: 14px; width: 100%; max-width: 560px; }
.ramp th, .ramp td, .idx th, .idx td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.ramp thead th, .idx thead th { border-bottom-color: var(--ink); font-size: 12.5px; color: var(--muted); font-weight: 500; }
.chips { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.mini-felt { --cw: clamp(50px, 13vw, 70px); background: var(--felt); border-radius: 3px; padding: 20px 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--felt-ink); width: 100%; max-width: 520px; position: relative; }
.cfg { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: center; font-size: 13px; }
.cfg .seg button { font-size: 12.5px; padding: 5px 9px; }
.side .cfg { justify-content: flex-start; gap: 4px 18px; }
.side .cfg .tog { width: 100%; }
.side .cfg .seg { display: inline-flex; vertical-align: middle; margin: 0 4px; }

/* Chips: a solid face, a thin inlay ring and six edge spots, like clay casino chips */
.chipbtn, .betchip { --c: #5f6b75; border-radius: 50%; color: #fff;
  background: radial-gradient(circle closest-side, var(--c) 0 66%, rgba(255, 255, 255, .6) 66% 69%, transparent 69%), repeating-conic-gradient(var(--c) 0 42deg, #efe9da 42deg 60deg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .28), 0 2px 3px rgba(0, 0, 0, .25); }
.chipbtn { appearance: none; border: 0; width: 60px; height: 60px; cursor: pointer; font: 600 19px/1 var(--display); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; transition: transform .1s; }
.chipbtn:hover:not(:disabled) { transform: translateY(-2px); }
.chipbtn kbd { font-size: 10px; opacity: .8; }
.chipbtn:disabled { opacity: .3; cursor: not-allowed; }
.u1 { --c: #5f6b75; } .u2 { --c: #a8322b; } .u4 { --c: #1f6a4a; } .u6 { --c: #2d4f8e; } .u8 { --c: #26262a; }
.c5 { --c: #a8322b; } .c25 { --c: #1f6a4a; } .c100 { --c: #26262a; } .c500 { --c: #5b3a8c; }

/* Casino */
.bankbar { display: flex; flex-wrap: wrap; gap: 12px 36px; align-items: end; border-top: 1px solid var(--ink); padding-top: 10px; }
.bankbar .eyebrow { display: block; color: var(--muted); font-weight: 500; }
.bankbar b { display: block; font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums lining-nums; margin-top: 4px; }
.bankbar b.up, .lastres.up, .simres.up b { color: var(--good); }
.bankbar b.down, .lastres.down, .simres.down b { color: var(--bad); }
.bet { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 10px; }
.betspot { width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--felt-line); display: grid; place-items: center; flex: none; }
.betspot > span:not(.betchip) { font: 500 11px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--felt-dim); }
.betchip { width: 60px; height: 60px; display: grid; place-items: center; font: 600 17px/1 var(--display); }
.betamt { font: 600 15px/1 var(--body); color: var(--felt-ink); font-variant-numeric: tabular-nums; }
.betbar { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.lastres { font-weight: 600; }
.hint { display: flex; gap: 8px; justify-content: center; align-items: center; }
.label { font: 600 13px/1.3 var(--body); margin-top: 4px; }
.chart-wrap { position: relative; }
.bank-chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.bank-chart .grid { stroke: var(--line); stroke-width: 1; }
.bank-chart .startline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.bank-chart .ax { fill: var(--muted); font-family: var(--body); font-size: 12px; font-variant-numeric: tabular-nums; }
.bank-chart .ax.start { fill: var(--ink); font-weight: 600; }
.bank-chart .line { fill: none; stroke: var(--double); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bank-chart .area { fill: var(--double); opacity: .1; }
.bank-chart .end, .bank-chart .xdot { fill: var(--double); stroke: var(--paper); stroke-width: 2; }
.bank-chart .xhair { stroke: var(--muted); stroke-width: 1; }
.bank-chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: var(--paper); border-radius: var(--r); padding: 5px 10px; font-size: 12px; pointer-events: none;
  white-space: nowrap; display: flex; flex-direction: column; align-items: center; font-variant-numeric: tabular-nums; }
.chart-tip b { font-size: 14px; }
.chart-empty { padding: 28px 10px; text-align: center; color: var(--muted); font-size: 14px; background: var(--panel); border: 1px solid var(--line); }
.sim { display: flex; flex-direction: column; gap: 8px; }
.simres { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.simres b { font: 600 26px/1 var(--display); font-variant-numeric: tabular-nums lining-nums; }

/* Dialogs, the toast and the footer */
.sheet { border: 0; padding: 0; background: none; color: var(--ink); width: min(520px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: visible; }
.sheet::backdrop { background: rgba(18, 17, 14, .5); }
.sheet-card { background: var(--panel); border: 1px solid var(--line-2); border-radius: 3px; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .5); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.sheet-card h2 { font: 600 24px/1.1 var(--display); padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.sheet-card h2 + p + .opt { border-top: 0; }
.panel .opt { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
.acct-form { display: flex; flex-direction: column; gap: 12px; }
.acct-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.acct-form input { font: 16px/1.3 var(--body); padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--edge); background: var(--raise); color: var(--ink); }
.acct-form input:focus-visible { border-color: var(--ink); outline: 2px solid var(--focus); outline-offset: 0; }
.acct-msg { font-size: 14px; font-weight: 600; }
.acct-msg.bad { color: var(--bad); }
.acct-msg.good { color: var(--good); }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r);
  font-weight: 500; font-size: 14px; z-index: 40; max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); }
.foot { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; max-width: 90ch; }

@media (prefers-reduced-motion: reduce) {
  .card.in, .card.flip, .act.shake { animation: none; }
  .chipbtn, .act { transition: none; }
}

/* Printing The Book gives a one-page strategy card: just the charts and the legend. */
@media print {
  :root { --paper: #fff; --raise: #fff; --ink: #000; --muted: #444; }
  body { background: #fff; padding: 0; font-size: 11px; }
  .top, .foot, .skip, .toast, .view:not(#view-book), #view-book .head p, #view-book .row.between .row, #cellDetail, .cell .m { display: none !important; }
  .app { max-width: none; padding: 0; }
  #view-book .head { margin-bottom: 6px; }
  #view-book .head h2 { font-size: 22px; }
  .book-grid { grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
  .tbl table { min-width: 0; }
  .cell { height: 20px; font-size: 10px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .sw { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .cell[aria-pressed="true"] { outline: 0; }
}

/* The 404 page */
.lost { flex-direction: column; align-items: flex-start; padding-top: 18vh; }
.lost .btn { text-decoration: none; }
