/* ============================================================
   Craps table — mobile-first.
   Tokens come from /css/site.css, which loads first.
   ============================================================ */

body {
  user-select: none;
  -webkit-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

/* The game owns its own gutters — site.css's <main> padding would double up */
main {
  max-width: none;
  padding: 0;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) var(--s-6);
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.18em;
  color: var(--mint);
  margin: 0 0 var(--s-3);
  text-align: center;
}

.no-real-money {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin: calc(var(--s-3) * -1) 0 var(--s-3);
}

/* ============================================================
   Sticky status bar
   ============================================================ */

.statusbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  margin: 0 calc(var(--s-4) * -1);
  background: linear-gradient(180deg, rgba(10, 28, 18, 0.98), rgba(8, 24, 16, 0.98));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--edge-mint);
  box-shadow: var(--shadow-md);
}

.sb-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
}

.sb-k {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sb-cell b {
  font-size: 17px;
  font-weight: 600;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* "OFF (come-out)" is the longest value here — let it wrap rather than
   push the status bar wider than the viewport on small phones. */
.sb-point b {
  color: var(--mint);
  white-space: normal;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
}
#net.positive { color: var(--win); }
#net.negative { color: var(--lose); }

#notice {
  color: var(--lose);
  font-weight: 600;
  font-size: 13.5px;
  text-align: center;
  min-height: 1.2em;
  padding: var(--s-2) 0 0;
}

/* ============================================================
   Dice + history
   ============================================================ */

.die {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  background: linear-gradient(180deg, #fbf7ec, #ded5be);
  color: #10261a;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.roll-total {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}

.roll-history-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  margin-bottom: var(--s-3);
}

.roll-history {
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
  min-width: 0;
}

.roll-history::-webkit-scrollbar { display: none; }

.roll-chip {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--rail);
  background: var(--felt-well);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.roll-chip.seven {
  border-color: var(--lose);
  color: var(--lose);
}

/* ============================================================
   Bet options
   ============================================================ */

.bet-opts {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.chip-label {
  color: var(--text-dim);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-toggle,
.let-it-ride {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 13.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.mode-toggle label,
.let-it-ride {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 34px;
  cursor: pointer;
}

.mode-toggle input,
.let-it-ride input {
  width: 18px;
  height: 18px;
  accent-color: var(--mint);
}

.let-it-ride .hint { color: var(--text-dim); font-size: 12px; }

/* ============================================================
   The felt
   ============================================================ */

.table {
  position: relative;
  background-color: var(--felt);
  background-image: var(--felt-sheen);
  border: 1px solid var(--edge-mint);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  box-shadow: var(--shadow-lg), var(--inset-hi);
  overflow: hidden;
}

/* Fine grain over the felt */
.table::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.035;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.table > * { position: relative; }

.row {
  display: grid;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.row.lines { grid-template-columns: 1fr 1fr; }
.row.numbers { grid-template-columns: repeat(3, 1fr); }
.row.onetime { grid-template-columns: repeat(3, 1fr); }
.row.hardways { grid-template-columns: repeat(4, 1fr); }
.row:last-child { margin-bottom: 0; }

/* Shared surface for every clickable bet area */
.bet-strip,
.num-box,
.bet-box {
  background: linear-gradient(180deg, var(--felt-raised), rgba(20, 67, 43, 0.9));
  border: 1px solid var(--rail);
  border-radius: var(--r-sm);
  box-shadow: var(--inset-hi);
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.bet-strip { padding: var(--s-2) var(--s-3); cursor: pointer; min-width: 0; }
.bet-strip.dont { border-color: rgba(217, 140, 95, 0.45); }
.bet-strip:active,
.bet-box:active { transform: scale(0.985); border-color: var(--mint); }

.bet-strip .title {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--mint);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  min-height: 24px;
}

.bet-strip .amt-line {
  font-size: 13px;
  margin-top: var(--s-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.bet-strip .buttons { display: flex; gap: var(--s-1); }

/* ---- Number boxes ---- */

.num-box {
  padding: var(--s-2) var(--s-1) var(--s-1);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.num-box .num-head {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--bone);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  border-radius: var(--r-sm);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.num-box .num-head:hover { color: var(--mint); }
.num-box .num-head:active { background: var(--mint-faint); }

.num-box.is-point {
  border-color: var(--mint);
  box-shadow: 0 0 0 1px var(--mint-dim), 0 0 16px rgba(53, 208, 122, 0.25), var(--inset-hi);
}

.num-box.is-point .num-head {
  color: #081810;
  background: var(--mint);
}

.point-tag {
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--mint);
  font-weight: 700;
  margin-top: 2px;
}

/* Read-only bet summary — editing happens in the sheet */
.num-bets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--s-1);
}

.bet-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 3px;
  font-size: 11px;
  background: var(--felt-well);
  border-radius: 3px;
  padding: 2px 4px;
  font-variant-numeric: tabular-nums;
}

.bet-line .label { color: var(--text-muted); }
.bet-line .val { color: var(--bone); font-weight: 600; }
.bet-line.is-off { opacity: 0.5; }
.bet-line.is-off .val { text-decoration: line-through; }

.num-empty {
  font-size: 10.5px;
  color: var(--text-dim);
  text-align: center;
  padding: var(--s-1) 0;
}

.num-edit {
  margin-top: auto;
  width: 100%;
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--edge-mint);
  color: var(--mint);
  border-radius: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.num-edit:hover { background: var(--mint-faint); }

/* ---- One-roll + hardway boxes ---- */

.bet-box {
  padding: var(--s-2) var(--s-1);
  text-align: center;
  cursor: pointer;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bet-box .title {
  font-weight: 600;
  color: var(--mint);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.bet-box .payline { font-size: 10px; color: var(--text-dim); line-height: 1.3; }

/* Grid stretches every box in a row to equal height; auto-margin anchors the
   amount (and its remove button, if present) to the bottom of that box so it
   lines up with neighbors regardless of how many lines the payline needed. */
.bet-box .amt { margin-top: auto; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Small controls ---- */

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--s-2);
  border: 1px solid var(--edge-mint);
  background: var(--felt-well);
  color: var(--text);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.mini-btn:active { transform: scale(0.94); }
.mini-btn.on { background: #24693c; border-color: #38a05c; color: #dcffe6; }
.mini-btn.off { background: #5e2a2a; border-color: #8d4040; color: #ffd9d6; }

/* ============================================================
   Action bar — fixed on phones, in flow on desktop
   ============================================================ */

.actionbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-4) 0;
  padding: var(--s-2) 0;
}

.chip-strip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 1 1 auto;
  min-width: 0;
}

/* Dice + total + the one Roll button, grouped so the dice always sit
   right next to the control that produced them. */
.roll-group {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 0 0 auto;
}

.mini-dice {
  display: flex;
  gap: var(--s-1);
  flex: 0 0 auto;
}

#chipSelector {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

#chipSelector::-webkit-scrollbar { display: none; }

.chip-btn {
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px dashed rgba(244, 238, 224, 0.5);
  background: radial-gradient(circle at 50% 35%, var(--felt-raised), #16311f);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
}

.chip-btn:active { transform: scale(0.92); }

.chip-btn.selected {
  border-style: solid;
  border-color: var(--mint-bright);
  background: var(--mint);
  color: #081810;
  box-shadow: var(--shadow-md), 0 0 0 3px var(--mint-faint);
}

.btn-roll {
  flex: 0 0 auto;
  background: var(--mint);
  color: #081810;
  border: 1px solid var(--mint-deep);
  padding: 0 var(--s-5);
  min-height: 52px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--r-sm);
  cursor: pointer;
  letter-spacing: 0.12em;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.btn-roll:hover { filter: brightness(1.07); }
.btn-roll:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--edge-mint);
  color: var(--mint);
  padding: 0 var(--s-3);
  min-height: 44px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
}

.btn-outline:hover { background: var(--mint-faint); }
.btn-outline:active { transform: scale(0.97); }

.table-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--s-3);
}

.table-actions .btn-outline { flex: 1 1 auto; max-width: 190px; }

/* ============================================================
   Log + legend
   ============================================================ */

.log {
  background: var(--bg-deep);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  padding: var(--s-3);
  height: 140px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: var(--s-4);
  font-variant-numeric: tabular-nums;
}

.log .roll-header { color: var(--mint); font-weight: 600; margin-top: var(--s-2); }
.log .win { color: var(--win); }
.log .lose { color: var(--lose); }
.log .neutral { color: var(--text-muted); }

/* Shared accordion — used by both the bet reference and the how-to-play guide */
.legend,
.accordion {
  background: var(--felt);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  padding: 0 var(--s-4);
  font-size: 14px;
  margin-bottom: var(--s-2);
}

.legend summary,
.accordion summary {
  cursor: pointer;
  color: var(--mint);
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  list-style-position: outside;
}

.legend summary:hover,
.accordion summary:hover { color: var(--mint-bright); }

.legend ul { margin: 0 0 var(--s-3); padding-left: var(--s-5); line-height: 1.65; }
.legend li { margin-bottom: var(--s-2); color: var(--text-muted); }
.legend li b { color: var(--text); }

/* ============================================================
   How-to-play guide
   ============================================================ */

.learn { margin-top: var(--s-5); }

.learn-title {
  font-family: var(--font-display);
  color: var(--mint);
  font-size: 26px;
  margin: 0 0 var(--s-2);
}

.learn-intro {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0 0 var(--s-4);
}

.accordion-body {
  padding-bottom: var(--s-4);
  color: var(--text-muted);
  line-height: 1.7;
}

.accordion-body p { margin: 0 0 var(--s-3); }
.accordion-body b { color: var(--text); }
.accordion-body i { color: var(--text); font-style: italic; }
.accordion-body a { color: var(--mint); }

.accordion-body ul,
.learn-steps {
  margin: 0 0 var(--s-3);
  padding-left: var(--s-5);
}

.accordion-body li { margin-bottom: var(--s-2); }

.learn-steps li { margin-bottom: var(--s-3); }
.learn-steps li::marker { color: var(--mint); font-weight: 700; }

.learn-h3 {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mint);
  margin: var(--s-4) 0 var(--s-2);
}

.learn-note {
  background: var(--felt-well);
  border-left: 2px solid var(--mint-dim);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: var(--s-3);
  font-size: 13.5px;
  margin: 0 0 var(--s-3);
}

/* Unicode dice glyphs, matching the ones the game renders */
.pips {
  color: var(--bone);
  font-size: 1.25em;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---- Diagrams ---- */

.learn-figure {
  margin: var(--s-4) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.learn-figure figcaption {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
  margin-top: var(--s-2);
  text-align: center;
}

.figure-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Pinned to 1:1 minimum (min-width == viewBox width) so diagram labels never
   scale below their authored size. Narrower than that, the figure scrolls. */
.dgm {
  display: block;
  width: 100%;
  max-width: 330px;
  min-width: 300px;
  height: auto;
  margin: 0 auto;
}

.dgm-wide { max-width: 560px; min-width: 540px; }

.dgm text { font-family: var(--font-ui); fill: var(--text-muted); }

.dgm-phase { font-size: 12px; font-weight: 700; letter-spacing: 0.16em; fill: var(--text-dim); }
.dgm-lede { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; fill: var(--bone); }
.dgm-sub { font-size: 12px; fill: var(--text-muted); }
.dgm-num { font-size: 14px; font-weight: 600; fill: var(--bone); }
.dgm-num-sm { font-size: 13px; font-weight: 600; fill: var(--bone); }
.dgm-tag { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; fill: var(--mint); }
.dgm-win { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; fill: var(--win); }
.dgm-lose { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; fill: var(--lose); }

.dgm-box { fill: var(--felt-raised); stroke: var(--rail); stroke-width: 1; }
.dgm-box-gold { fill: var(--felt-raised); stroke: var(--mint); stroke-width: 1.5; }
.dgm-box-win { fill: rgba(111, 220, 140, 0.10); stroke: rgba(111, 220, 140, 0.45); stroke-width: 1; }
.dgm-box-lose { fill: rgba(255, 138, 128, 0.10); stroke: rgba(255, 138, 128, 0.45); stroke-width: 1; }

.dgm-line { stroke: var(--rail); stroke-width: 2; fill: none; }
.dgm-line-dash { stroke: var(--rail); stroke-width: 2; fill: none; stroke-dasharray: 4 4; }
.dgm-arrow { fill: var(--rail); }
.dgm-rule { stroke: var(--edge); stroke-width: 1; fill: none; }

/* Frequency chart. Cream bars carry no identity — length is the data and the
   single gold bar is the emphasis. Validated on the felt surface: CVD dE 20.0,
   contrast 8.70:1 and 4.80:1. */
.dgm-axis { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; fill: var(--text-dim); }
.dgm-rowlab { font-size: 14px; font-weight: 600; fill: var(--text-muted); }
.dgm-rowlab-hi { font-size: 14px; font-weight: 700; fill: var(--mint); }
.dgm-val { font-size: 13px; font-weight: 600; fill: var(--text-muted); }
.dgm-val-hi { font-size: 13px; font-weight: 700; fill: var(--mint); }
.dgm-foot { font-size: 12px; fill: var(--text-dim); }

.bar { fill: var(--text); }
.bar-hi { fill: var(--mint); }

/* Table layout map */
.map-felt { fill: var(--felt-well); stroke: var(--edge-mint); stroke-width: 1; }
.map-box { fill: var(--felt-raised); stroke: var(--rail); stroke-width: 1; }
.map-box-dont { fill: rgba(217, 140, 95, 0.14); stroke: rgba(217, 140, 95, 0.5); stroke-width: 1; }
.map-box-pass { fill: var(--mint); stroke: var(--mint-deep); stroke-width: 1; }
.map-box-prop { fill: var(--felt-raised); stroke: var(--rail); stroke-width: 1; stroke-dasharray: 3 3; }
.map-num { font-size: 17px; font-weight: 700; fill: var(--bone); }
.map-label { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; fill: var(--mint); }
.map-label-dark { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; fill: #081810; }
.map-fine { font-size: 12px; fill: var(--text-dim); }
.map-fine-warn { font-size: 12px; font-style: italic; fill: var(--lose); }

.strategy-link { text-align: center; margin-top: var(--s-4); }

.strategy-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s-3);
}

/* ============================================================
   Overlay
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  z-index: 60;
}

.overlay.hidden { display: none; }

.overlay-box {
  background: linear-gradient(180deg, var(--felt-raised), var(--felt));
  border: 1px solid var(--edge-mint);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5);
  width: min(340px, 100%);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.overlay-box h2 {
  font-family: var(--font-display);
  color: var(--mint);
  margin: 0 0 var(--s-2);
  font-size: 24px;
}

.overlay-box p { font-size: 13.5px; color: var(--text-muted); margin: 0 0 var(--s-4); }

.overlay-box input {
  width: 100%;
  padding: var(--s-3);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: var(--r-sm);
  border: 1px solid var(--edge-mint);
  background: var(--felt-well);
  color: var(--bone);
  text-align: center;
  margin-bottom: var(--s-4);
}

.overlay-buttons { display: flex; gap: var(--s-2); justify-content: center; }
.overlay-buttons .btn-roll { flex: 1 1 auto; }

/* ============================================================
   Bet sheet
   ============================================================ */

.sheet-wrap { position: fixed; inset: 0; z-index: 70; }
.sheet-wrap.hidden { display: none; }
body.sheet-open { overflow: hidden; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  animation: fade-in 0.18s ease;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--felt-raised), var(--felt));
  border-top: 1px solid var(--edge-mint);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.25);
  margin: var(--s-2) auto 0;
  flex: 0 0 auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--edge);
  flex: 0 0 auto;
}

.sheet-head h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--mint);
  font-size: 21px;
}

.sheet-close {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.sheet-close:hover { color: var(--bone); border-color: var(--edge-mint); }

.sheet-body {
  padding: var(--s-4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-bet {
  background: var(--felt-well);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
}

.sheet-bet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.sheet-bet-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--bone);
  letter-spacing: 0.03em;
}

.sheet-bet-amt {
  font-size: 17px;
  font-weight: 700;
  color: var(--mint);
  font-variant-numeric: tabular-nums;
}

.sheet-bet-meta { font-size: 12px; color: var(--text-dim); margin: -8px 0 var(--s-3); }

.sheet-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.sheet-btn {
  flex: 1 1 0;
  min-width: 72px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 var(--s-2);
  border: 1px solid var(--edge-mint);
  background: var(--felt-raised);
  color: var(--text);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.sheet-btn:active { transform: scale(0.96); }
.sheet-btn.on { background: #24693c; border-color: #38a05c; color: #dcffe6; }
.sheet-btn.off { background: #5e2a2a; border-color: #8d4040; color: #ffd9d6; }
.sheet-btn.danger { border-color: rgba(255, 138, 128, 0.5); color: var(--lose); }
.sheet-btn.danger:hover { background: rgba(255, 138, 128, 0.12); }
.sheet-btn:disabled { opacity: 0.35; cursor: default; }

.sheet-add {
  border-top: 1px solid var(--edge);
  padding-top: var(--s-4);
  margin-top: var(--s-2);
}

.sheet-add .sheet-btn { background: var(--mint); color: #081810; border-color: var(--mint-deep); }

.sheet-empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: var(--s-4) 0;
  margin: 0;
}

/* ============================================================
   Breakpoints
   ============================================================ */

/* Phones: pin the action bar to the bottom of the viewport */
@media (max-width: 700px) {
  .actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    margin: 0;
    padding: var(--s-2) var(--s-3);
    padding-bottom: calc(var(--s-2) + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(10, 28, 18, 0.97), rgba(8, 24, 16, 0.99));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--edge-mint);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.4);
  }

  .chip-strip .chip-label { display: none; }

  /* Clear the fixed bar */
  .app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* Dice shrink to make room for the chip strip in the fixed bar; the total
     text drops entirely — the dice faces plus roll history already cover it. */
  .die { width: 34px; height: 34px; font-size: 22px; }
  .roll-total { display: none; }

  .page-title { font-size: 21px; margin-bottom: var(--s-2); }
  .log { height: 116px; }
}

@media (max-width: 340px) {
  .app { padding-left: var(--s-3); padding-right: var(--s-3); }
  .statusbar { margin: 0 calc(var(--s-3) * -1); padding: var(--s-2) var(--s-3); }
  .sb-cell b { font-size: 15px; }
  .row.numbers { grid-template-columns: repeat(2, 1fr); }
  .row.hardways { grid-template-columns: repeat(2, 1fr); }
  .chip-btn { width: 44px; height: 44px; font-size: 12px; }
  .btn-roll { padding: 0 var(--s-4); font-size: 15px; }
}

/* Tablet and up */
@media (min-width: 701px) {
  .app { padding: var(--s-5) var(--s-5) var(--s-7); }
  .page-title { font-size: 32px; }
  .statusbar { margin: 0; border-radius: var(--r-md); border: 1px solid var(--edge-mint); }
  .bet-opts { flex-direction: row; align-items: center; gap: var(--s-5); }
  .table { padding: var(--s-4); }
  .row.numbers { grid-template-columns: repeat(6, 1fr); }
  .num-box { padding: var(--s-2); }
  .bet-line { font-size: 11.5px; }
  .actionbar { justify-content: center; }
  .chip-strip { flex: 0 1 auto; }
  #chipSelector { flex: 0 1 auto; }
  .log { height: 170px; }
}

/* Sheet becomes a centered modal on larger screens */
@media (min-width: 701px) {
  .sheet-wrap { display: flex; align-items: center; justify-content: center; }
  .sheet-wrap.hidden { display: none; }

  .sheet {
    position: relative;
    width: min(460px, calc(100vw - 48px));
    max-height: 80vh;
    border-radius: var(--r-lg);
    border: 1px solid var(--edge-mint);
    animation: fade-in 0.18s ease;
  }

  .sheet-grip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop { animation: none; }
}
