/*
  Easy Craps · 练习台 — a printed baize layout on a walnut rail.
  Two layouts share the rail: Easy Craps and the standard Las Vegas table.
  Tokens: baize, rail, bone, brass, paper/ink, oxblood (dice and losses).
  Mobile portrait is the base; the pit opens up at 1024px.
*/
:root {
  --baize: #1f4a37;
  --baize-deep: #173a2b;
  --rail: #211a15;
  --rail-raised: #2e251d;
  --rail-edge: #45362a;
  --bone: #efe6d2;
  --brass: #b8934a;
  --paper: #eae0c8;
  --ink: #1d1915;
  --oxblood: #a3271f;

  --line: rgba(239, 230, 210, 0.5);
  --dim: rgba(239, 230, 210, 0.66);
  --pos: #dcbf74;
  --neg: #e58a78;
  --edge-g: #7dbb8a;
  --edge-y: #dcb24a;
  --edge-r: #e2725c;

  --display: "Big Shoulders Display", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ui: "Hanken Grotesk", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bar-h: 70px;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 70px; scroll-padding-bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); }
html, body { margin: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--bone);
  background: var(--rail);
  padding-bottom: calc(var(--bar-h) + 28px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p, dl, dd { margin: 0; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
}
.brand h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.brand p { font-size: 12px; color: var(--dim); margin-top: 3px; }
.lang {
  grid-row: 1; grid-column: 2;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: none; border: 1px solid var(--rail-edge); border-radius: 3px; font-size: 14px; font-weight: 500;
}
.modes {
  grid-column: 1 / -1; justify-self: start; display: inline-flex; margin-top: 8px;
  border: 1.5px solid var(--rail-edge); border-radius: 4px; padding: 2px; gap: 2px;
}
.modes button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 2px; background: none;
  font-family: var(--display); font-weight: 800; font-size: 17px; letter-spacing: 0.02em; color: var(--dim);
}
.modes button.active { background: var(--bone); color: var(--ink); }
@media (hover: hover) { .modes button:hover:not(.active) { color: var(--bone); } }
.menu { grid-column: 1 / -1; display: flex; justify-content: space-between; margin: 0 -8px; }
.menu button {
  flex: 1 1 auto; min-height: 44px; padding: 0 6px; background: none; border: 0;
  font-size: 14px; color: var(--dim); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.menu button:hover { color: var(--bone); }
.menu button[aria-pressed="true"] { color: var(--bone); font-weight: 700; border-bottom-color: var(--brass); }

/* ---------- page frame ---------- */
.pit {
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px max(10px, env(safe-area-inset-right)) 16px max(10px, env(safe-area-inset-left));
}
.side { display: contents; }
.status { order: 1; }
.tray { order: 2; }
.slip { order: 3; }
.felt-col { order: 4; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.disclaimer { order: 9; font-size: 12px; color: var(--dim); max-width: 60ch; }

/* ---------- status ---------- */
.status {
  position: sticky; top: 0; z-index: 20; background: var(--rail);
  display: flex; align-items: flex-end; justify-content: space-between; gap: 4px 10px;
  padding: 7px 4px 8px; border-top: 1px solid var(--rail-edge); border-bottom: 1px solid var(--rail-edge);
}
.stat.last { align-items: flex-end; }
.stat { display: flex; flex-direction: column; }
.stat > span { font-size: 11.5px; color: var(--dim); line-height: 1.3; white-space: nowrap; }
.stat b {
  font-family: var(--display); font-weight: 800; font-size: 27px; line-height: 1.05;
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.phase-row { display: flex; align-items: center; gap: 6px; height: 28px; }
.puck {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  font: 800 10px/1 var(--ui); font-style: normal; letter-spacing: 0.02em;
  background: var(--ink); color: var(--bone); border: 2px solid var(--bone);
}
.phase.on .puck, .puck.on { background: var(--bone); color: var(--ink); border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--bone); }
.bank-actions { display: flex; justify-content: flex-end; gap: 8px; }
.bank-actions button {
  min-height: 44px; padding: 0 6px; background: none; border: 0; font-size: 13px; color: var(--dim);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rail-edge);
}
.bank-actions button:hover { color: var(--bone); }

/* ---------- dice tray ---------- */
.tray {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 8px 12px;
  grid-template-areas: "dome total history" "label label label" "strip strip strip";
}
.tray-info { display: contents; }
.dome {
  grid-area: dome; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 124px; height: 68px; border-radius: 5px;
  background: var(--baize-deep) var(--grain);
  border: 3px solid var(--rail-edge);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
}
.die {
  width: 42px; height: 42px; padding: 6px; border-radius: 6px;
  background: var(--oxblood);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px;
  box-shadow: 0 2px 0 #6a1612, inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transform: rotate(-5deg);
}
.die + .die { transform: rotate(7deg); }
.die i { border-radius: 50%; }
.die i.on { background: var(--bone); }
.dome.shaking .die { animation: tumble-a 0.24s linear infinite; }
.dome.shaking .die + .die { animation: tumble-b 0.2s linear infinite; }
@keyframes tumble-a {
  0% { transform: translate(-6px, -8px) rotate(-40deg); } 25% { transform: translate(6px, 7px) rotate(70deg); }
  50% { transform: translate(-3px, 9px) rotate(170deg); } 75% { transform: translate(7px, -6px) rotate(250deg); }
  100% { transform: translate(-6px, -8px) rotate(320deg); }
}
@keyframes tumble-b {
  0% { transform: translate(6px, 8px) rotate(30deg); } 25% { transform: translate(-7px, -6px) rotate(-70deg); }
  50% { transform: translate(4px, -9px) rotate(-170deg); } 75% { transform: translate(-5px, 7px) rotate(-260deg); }
  100% { transform: translate(6px, 8px) rotate(-330deg); }
}
.total {
  grid-area: total; min-width: 46px; text-align: center;
  font-family: var(--display); font-weight: 800; font-size: 58px; line-height: 1; font-variant-numeric: tabular-nums;
}
.total:empty::before { content: "–"; color: var(--rail-edge); }
#lbl-next { grid-area: label; font-size: 12px; color: var(--dim); margin-bottom: -4px; }
.next-strip { grid-area: strip; display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px; }
.next-strip span {
  text-align: center; padding: 3px 0; border-radius: 2px;
  font-family: var(--display); font-weight: 600; font-size: 17px; line-height: 1.2; color: rgba(239, 230, 210, 0.4);
  background: var(--rail-raised);
}
.next-strip span.hot { background: var(--brass); color: var(--ink); font-weight: 800; }
.history {
  grid-area: history; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 2px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 80%, transparent); mask-image: linear-gradient(90deg, #000 80%, transparent);
}
.history::-webkit-scrollbar { display: none; }
.h {
  flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 3px 5px; border-radius: 2px;
  background: var(--paper); color: var(--ink);
}
.h b { font-family: var(--display); font-weight: 800; font-size: 17px; line-height: 1; margin-left: 3px; min-width: 1ch; text-align: center; }
.h.seven { background: var(--oxblood); color: var(--bone); }
.h.made { background: var(--brass); }
.h.set { box-shadow: inset 0 0 0 2px var(--brass); }
.h:first-child { padding: 5px 7px; }

/* mini dice (history, slip, hardways, hops) */
.md {
  display: inline-grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 1px;
  width: 15px; height: 15px; padding: 2px; border-radius: 2.5px; background: var(--oxblood); vertical-align: middle; flex: none;
}
.md i { border-radius: 50%; }
.md i.on { background: var(--bone); }
.h.seven .md { background: var(--bone); }
.h.seven .md i.on { background: var(--oxblood); }
.faces { display: inline-flex; gap: 3px; margin-bottom: 2px; }
.zone .md { width: 17px; height: 17px; }

/* ---------- result slip (paper) ---------- */
.slip, .odds-bar, .info, .toast, dialog {
  --pos: #2b6941; --neg: #a3271f; --dim: rgba(29, 25, 21, 0.64);
  --edge-g: #2b6941; --edge-y: #8a6410; --edge-r: #a3271f;
  background: var(--paper); color: var(--ink);
}
.slip { border-radius: 2px; padding: 8px 10px; font-size: 13.5px; }
.slip:empty { display: none; }
.r-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }
.r-dice { display: inline-flex; align-items: center; gap: 3px; }
.r-dice b { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1; margin-left: 4px; }
.r-dice small { font-size: 11px; font-weight: 500; margin-left: 4px; color: var(--dim); }
.slip ul { list-style: none; margin: 6px 0 0; padding: 0; height: 74px; overflow-y: auto; border-top: 1px dashed rgba(29, 25, 21, 0.35); }
.slip li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed rgba(29, 25, 21, 0.18); }
.slip li b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.slip li em { font-style: normal; font-weight: 400; color: var(--dim); }
.slip li.w b { color: var(--pos); }
.slip li.l b { color: var(--neg); }
.slip li.p b { color: var(--dim); font-weight: 400; }
.slip .muted { margin-top: 6px; height: 74px; }
.r-net { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; font-weight: 700; }
.r-net b { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.muted { color: var(--dim); font-size: 13px; }

/* ---------- felt ---------- */
.felt {
  padding: 10px 10px 6px;
  background: var(--baize) var(--grain);
  border: 5px solid var(--rail-edge);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 6px 14px rgba(0, 0, 0, 0.28);
}
.felt h2, .hops summary { font-size: 12.5px; font-weight: 500; color: rgba(239, 230, 210, 0.78); margin: 12px 0 4px; }
.felt h2:first-child { margin-top: 0; }
.hops summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; margin: 4px 0 0; list-style: none; }
.hops summary::-webkit-details-marker { display: none; }
.hops summary::before { content: "+"; display: inline-block; width: 1em; font-size: 16px; font-weight: 700; }
.hops[open] summary::before { content: "−"; }
.hops .row { margin-bottom: 6px; }

.row { display: grid; padding: 0 1.5px 1.5px 0; }
.row-place { grid-template-columns: repeat(5, 1fr); }
.row-hard { grid-template-columns: repeat(4, 1fr); }
.row-field { grid-template-columns: 1fr 1.45fr 1fr; }
.row-line { grid-template-columns: 1.9fr 1fr; }
.row-prop { grid-template-columns: repeat(4, 1fr); }
.row-hop { grid-template-columns: repeat(5, 1fr); }
.row-line2 { grid-template-columns: 1fr 1fr; }
.row-nums { grid-template-columns: repeat(6, 1fr); }
#felt-std .odds-bar + .odds-bar { margin-top: 4px; }

/* Zones are printed boxes sharing their lines, like a real layout. */
.zone {
  position: relative; min-width: 0; min-height: 76px; margin: 0 -1.5px -1.5px 0; padding: 6px 3px 5px;
  border: 1.5px solid var(--line); border-radius: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  text-align: center; line-height: 1.2;
  transition: background-color 0.15s;
}
.zone:disabled { opacity: 1; }
@media (hover: hover) { .zone:hover:not(:disabled) { background: rgba(239, 230, 210, 0.07); } }
.zone:active:not(:disabled) { background: rgba(239, 230, 210, 0.14); }
.zone .big { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 0.95; }
.zone .zh { font-size: 13.5px; font-weight: 700; }
.zone .en { font-size: 11.5px; color: rgba(239, 230, 210, 0.78); }
.zone .en.solo { font-size: 13px; font-weight: 700; color: var(--bone); }
.zone .pay { font-size: 12px; color: rgba(239, 230, 210, 0.72); font-variant-numeric: tabular-nums; }
.zone .pay b { font-weight: 500; color: var(--bone); display: block; }
.zone .nums { font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1.05; letter-spacing: 0.06em; }
.zone .nums b { box-shadow: inset 0 -2px 0 var(--bone); }
.zone.num { min-height: 84px; }
.zone.pass { min-height: 72px; }
.zone.pass .en { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1; text-transform: uppercase; color: var(--bone); letter-spacing: 0.03em; }
.zone.odds { border-style: dashed; }
.zone.dont .en, .zone.dont .en.solo { color: var(--bone); }
.zone.dont { background: rgba(0, 0, 0, 0.12); }
.zone.pass.come .en { font-size: 19px; }
.zone .bigword { font-family: var(--display); font-weight: 800; font-size: 14px; line-height: 1; text-transform: uppercase; letter-spacing: 0.08em; color: var(--oxblood); background: var(--bone); padding: 2px 5px 1px; border-radius: 2px; }
.zone.big .big { color: var(--bone); }

/* standard numbers row: one printed box per number, every bet on it listed as a tag */
.nums-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; margin: 12px 0 6px; }
.nums-head h2 { margin: 0; }
.nummode { display: grid; grid-template-columns: repeat(4, auto); gap: 0; border: 1.5px solid var(--line); border-radius: 3px; overflow: hidden; }
.nummode button {
  min-height: 38px; padding: 0 9px; border: 0; border-left: 1.5px solid var(--line); background: transparent;
  font-size: 12.5px; font-weight: 700; color: rgba(239, 230, 210, 0.82); white-space: nowrap;
}
.nummode button:first-child { border-left: 0; }
.nummode button.active { background: var(--bone); color: var(--ink); }
.nummode button.dim:not(.active) { color: rgba(239, 230, 210, 0.42); }
.zone.numx { min-height: 100px; justify-content: flex-start; padding-top: 24px; }
.tags { display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%; margin-top: 4px; }
.tag {
  display: flex; align-items: center; justify-content: center; gap: 2px; flex-wrap: wrap; padding: 1px 2px; border-radius: 3px;
  font-size: 11px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums;
  background: var(--bone); color: var(--ink); animation: set-down 0.16s ease-out;
}
.tag i { font-style: normal; font-size: 9.5px; letter-spacing: 0.04em; color: var(--oxblood); }
.tag em { font-style: normal; font-weight: 500; }
.tag em.off { opacity: 0.6; }
.tag.idle { background: transparent; color: var(--bone); box-shadow: inset 0 0 0 1px var(--line); }
.tag.idle i { color: var(--brass); }
.tag .lock { width: 7px; height: 9px; }
.nums-legend { font-size: 11.5px; color: rgba(239, 230, 210, 0.66); margin: 4px 0 0; }
.zone.dim > :not(.edge) { opacity: 0.45; }
.zone.hop { min-height: 62px; }
.zone.live { box-shadow: inset 0 0 0 2.5px var(--brass); z-index: 1; }
.zone.glow { background: rgba(184, 147, 74, 0.22); }
.zone.won { animation: won 0.5s ease-out 2; }
.zone.lost { animation: lost 0.5s ease-out 1; }
@keyframes won { 0%, 100% { background-color: transparent; } 40% { background-color: var(--brass); } }
@keyframes lost { 0%, 100% { background-color: transparent; } 40% { background-color: rgba(163, 39, 31, 0.75); } }

/* a bet: a flat check sitting in the box */
.stake {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 3px; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  font-size: 12.5px; font-weight: 700; line-height: 1.35; font-variant-numeric: tabular-nums;
  background: var(--bone); color: var(--ink); border: 1.5px dashed rgba(29, 25, 21, 0.5);
  animation: set-down 0.16s ease-out;
}
.stake.idle { background: transparent; color: var(--bone); border-color: var(--line); }
@keyframes set-down { from { transform: translateY(-5px); opacity: 0.4; } }
.lock { width: 9px; height: 11px; }
.offtag {
  position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font-size: 7px; letter-spacing: 0.02em; font-weight: 800; background: var(--ink); color: var(--bone); border: 1.5px solid var(--bone);
}
.zone .puck { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; font-size: 8px; border-width: 1.5px; }
.edge { display: block; margin-top: 2px; line-height: 1; }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; font-style: normal; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.g { color: var(--edge-g); }
.badge.y { color: var(--edge-y); }
.badge.r { color: var(--edge-r); }
body.removing .zone.has { background: rgba(163, 39, 31, 0.35); }

/* odds ticket, tucked under the line */
.odds-bar {
  margin-top: 6px; padding: 8px 10px; border-radius: 2px;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px;
}
.odds-bar[hidden] { display: none; }
.ob-title { font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.ob-btns { display: flex; flex-wrap: wrap; gap: 5px; }
.odds-bar button {
  min-width: 44px; min-height: 40px; padding: 0 8px; border-radius: 3px; background: transparent;
  border: 1.5px solid rgba(29, 25, 21, 0.4); font-weight: 700; font-variant-numeric: tabular-nums;
}
.odds-bar button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.odds-bar button:disabled { opacity: 0.4; }
.ob-note { color: var(--dim); }

/* ---------- table actions ---------- */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.actions button {
  min-height: 46px; padding: 4px; border-radius: 3px; border: 0; background: var(--rail-raised);
  font-size: 13px; font-weight: 500; line-height: 1.2;
}
.actions button:disabled { color: rgba(239, 230, 210, 0.32); }
@media (hover: hover) { .actions button:hover:not(:disabled) { background: var(--rail-edge); } }
.actions button:active:not(:disabled) { transform: translateY(1px); }
.actions .toggle.active { background: var(--bone); color: var(--ink); font-weight: 700; }
.actions #btn-remove.active { background: var(--oxblood); color: var(--bone); }

/* ---------- play bar: chips + roll, always under the thumb ---------- */
.playbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 9px max(10px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: var(--rail); border-top: 1px solid var(--rail-edge);
}
.chips { display: flex; gap: 5px; flex: none; }
.chip {
  width: 46px; height: 46px; padding: 0; border-radius: 50%; flex: none;
  font-size: 12.5px; font-weight: 700; color: var(--bone); font-variant-numeric: tabular-nums;
  border: 3px dashed rgba(239, 230, 210, 0.85);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease-out;
}
.chip.c1 { background: var(--bone); color: var(--ink); border-color: #51718a; }
.chip.c5 { background: #a3271f; }
.chip.c25 { background: #27693f; }
.chip.c100 { background: #15120f; }
.chip.c500 { background: #4f2a63; }
.chip.sel { transform: translateY(-7px); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.28), 0 0 0 2px var(--rail), 0 0 0 4px var(--brass); }
.roll {
  flex: 1; min-width: 0; height: 52px; padding: 0 4px; border: 0; border-radius: 4px;
  background: var(--brass); color: var(--ink);
  font-family: var(--display); font-weight: 800; font-size: 23px; line-height: 1; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 3px 0 #7c6230;
  transition: transform 0.08s, box-shadow 0.08s;
}
.roll:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 #7c6230; }
.roll:disabled { background: #6f5d3a; color: rgba(29, 25, 21, 0.7); transform: translateY(3px); box-shadow: none; }

/* ---------- learn card ---------- */
.info {
  position: fixed; z-index: 25; left: 8px; right: 8px; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 8px);
  max-height: 40vh; overflow-y: auto; padding: 12px 14px; border-radius: 2px;
  font-size: 14px; line-height: 1.55; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.info[hidden], .info.empty { display: none; }
.info h3 { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.1; margin: 0 40px 4px 0; text-transform: uppercase; }
.info p { max-width: 68ch; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin-top: 8px; font-size: 13px; }
.info dt { color: var(--dim); }
.info .w { color: var(--pos); }
.info .l { color: var(--neg); }
.info-close {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px; background: none; border: 0; font-size: 24px; line-height: 1;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 10px);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 24px); padding: 9px 14px; border-radius: 2px; font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- sheets (bottom sheet on a phone, card on desktop) ---------- */
dialog {
  width: 100%; max-width: 100%; max-height: 90vh; max-height: 90dvh; margin: auto 0 0; padding: 0; border: 0;
  border-radius: 10px 10px 0 0; overflow: hidden;
}
dialog[open] { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
dialog::backdrop { background: rgba(12, 9, 7, 0.66); }
.modal-body {
  max-height: 90vh; max-height: 90dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); font-size: 15px; line-height: 1.6;
}
.modal-body h2 { font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.1; text-transform: uppercase; margin-bottom: 8px; }
.modal-body h3 { font-size: 15px; font-weight: 700; margin: 20px 0 8px; padding-top: 12px; border-top: 1px solid rgba(29, 25, 21, 0.25); }
.modal-body .prose, .modal-body > .muted { max-width: 66ch; }
.modal-body button {
  min-height: 44px; padding: 8px 14px; border-radius: 3px; background: transparent; border: 1.5px solid rgba(29, 25, 21, 0.4); font-weight: 500;
}
.modal-body button:disabled { opacity: 0.4; }
.modal-body button.primary, .modal-body button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.modal-foot, .modal-nav { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-nav { justify-content: space-between; }
.modal-nav + .modal-foot { display: none; }
.dots { display: flex; gap: 5px; margin-bottom: 12px; }
.dots i { flex: 1; max-width: 44px; height: 3px; background: rgba(29, 25, 21, 0.2); }
.dots i.on { background: var(--ink); }
.cards { display: grid; grid-template-columns: 1fr; gap: 6px; }
.modal-body .card { text-align: left; display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.card span { font-size: 13px; font-weight: 400; color: var(--dim); }
.quiz .q { font-size: 16px; font-weight: 700; margin-bottom: 10px; max-width: 60ch; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.opts button { font-variant-numeric: tabular-nums; font-weight: 700; }
.modal-body .opts .right { background: var(--pos); border-color: var(--pos); color: var(--paper); opacity: 1; }
.modal-body .opts .wrongpick { background: var(--neg); border-color: var(--neg); color: var(--paper); opacity: 1; }
.quiz .pos, .quiz .neg { font-weight: 700; margin-bottom: 8px; }
.settings { display: grid; grid-template-columns: 1fr; gap: 6px; }
.settings label { font-weight: 700; margin-top: 10px; }
.settings + .muted { margin-top: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
table th, table td { padding: 6px 8px 6px 0; border-bottom: 1px solid rgba(29, 25, 21, 0.18); text-align: left; vertical-align: top; font-weight: 400; }
table.grid tr:first-child th { font-weight: 700; font-size: 13px; }
table.grid td { font-variant-numeric: tabular-nums; }
tr.grp th { font-weight: 700; padding-top: 14px; border-bottom-color: var(--ink); }
table.cmp td.me { font-weight: 700; }
table.kv td { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.histo { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; height: 170px; align-items: end; margin: 6px 0; }
.bar { display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar .col { position: relative; flex: 1; width: 100%; display: flex; align-items: flex-end; border-bottom: 1.5px solid var(--ink); }
.bar .fill { width: 100%; background: var(--baize); min-height: 1px; }
.bar .fill.seven { background: var(--oxblood); }
.bar .mark { position: absolute; left: -2px; right: -2px; height: 0; border-top: 2.5px solid var(--brass); }
.bar .n { font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.3; }
.bar .c { font-size: 11.5px; color: var(--dim); }
.legend { font-size: 13px; color: var(--dim); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.lg { display: inline-block; width: 14px; height: 10px; }
.lg.fill { background: var(--baize); }
.lg.mark { height: 0; border-top: 2.5px solid var(--brass); margin-left: 10px; }

/* ---------- small phones ---------- */
@media (max-width: 374px) {
  .chip { width: 42px; height: 42px; font-size: 11.5px; }
  .chips { gap: 4px; }
  .roll { font-size: 20px; }
  .zone .big { font-size: 30px; }
  .stat b { font-size: 23px; }
}

/* ---------- roomy phones / tablets ---------- */
@media (min-width: 600px) {
  .row-place { grid-template-columns: repeat(10, 1fr); }
  .row-prop { grid-template-columns: repeat(8, 1fr); }
  .row-hop { grid-template-columns: repeat(9, 1fr); }
  .cards { grid-template-columns: 1fr 1fr; }
  .settings { grid-template-columns: auto 1fr; gap: 12px 18px; align-items: center; }
  .settings label { margin-top: 0; }
  .playbar { justify-content: center; }
  .chips { gap: 10px; }
  .roll { flex: 0 1 280px; }
}
@media (min-width: 700px) {
  dialog { width: min(720px, 92vw); margin: auto; border-radius: 3px; max-height: 86vh; }
  .modal-body { padding: 26px 30px; max-height: 86vh; }
}

/* ---------- desktop: the pit opens up ---------- */
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .top { grid-template-columns: auto auto 1fr auto; gap: 28px; padding: 18px 28px 8px; max-width: 1240px; margin: 0 auto; }
  .brand h1 { font-size: 40px; }
  .menu { grid-column: auto; justify-content: flex-end; gap: 6px; margin: 0; }
  .menu button { flex: none; padding: 0 12px; font-size: 15px; }
  .modes { grid-column: auto; margin-top: 0; }
  .zone.numx { min-height: 132px; }
  .tag { font-size: 12.5px; }
  .pit {
    display: grid; grid-template-columns: minmax(0, 1fr) 348px; gap: 16px 24px; align-items: start;
    max-width: 1240px; margin: 0 auto; padding: 4px 28px 48px;
  }
  .status, .tray, .slip, .felt-col, .disclaimer { order: 0; }
  .status { position: static; grid-column: 1 / -1; justify-content: flex-start; gap: 4px 44px; padding: 10px 2px 12px; }
  .stat.last { display: none; }
  .lang { grid-row: auto; grid-column: auto; }
  .stat b { font-size: 34px; }
  .phase-row { height: 36px; }
  .disclaimer { grid-column: 1 / -1; }
  .side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 14px; }
  .felt-col { gap: 14px; }
  .felt { padding: 18px 18px 10px; border-width: 8px; border-radius: 10px; }
  .zone { min-height: 88px; }
  .zone.num { min-height: 108px; }
  .zone .big { font-size: 44px; }
  .zone.pass .en { font-size: 28px; }
  .zone .nums { font-size: 26px; }
  .zone.hop { min-height: 70px; }
  .tray { grid-template-columns: 1fr auto; grid-template-areas: "dome total" "history history" "label label" "strip strip"; }
  .dome { width: 100%; height: 132px; gap: 18px; }
  .die { width: 62px; height: 62px; padding: 9px; border-radius: 9px; gap: 3px; }
  .total { font-size: 96px; min-width: 96px; }
  .playbar { position: static; flex-direction: column; align-items: stretch; gap: 14px; padding: 6px 0 0; border: 0; background: none; }
  .chips { justify-content: space-between; gap: 6px; padding-top: 8px; }
  .chip { width: 56px; height: 56px; font-size: 14px; }
  .roll { flex: none; height: 64px; font-size: 32px; }
  .slip ul, .slip .muted { height: auto; max-height: 260px; }
  .info { position: static; max-height: none; box-shadow: none; }
  .info.empty { display: block; }
  .toast { bottom: 28px; }
}

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

/* ---------- chip glyph back to the Casino Tutor hub ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .home { display: block; width: 30px; height: 30px; flex: none; padding: 7px; margin: -7px; box-sizing: content-box; }
.brand .home svg { display: block; width: 100%; height: 100%; }
.brand .home:hover svg { transform: rotate(30deg); transition: transform 0.2s; }
