/* Mobile / phone overrides — loaded last so they beat the per-game styles */
html { -webkit-text-size-adjust: 100%; }
html, body { overscroll-behavior: none; }
button, .nav-item, .bet-spot, .tray-chip { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; font-size: 16px; } /* 16px stops iOS focus-zoom */

/* phone-only pieces (js/mobile.js adds them to every game) stay hidden on bigger screens */
.m-opt, .m-ap, .m-drawer, .m-rotate, .lbl-s, .vp-pt-short { display: none; }
.op-floor { flex: none; margin-top: -6px; pointer-events: none; }

/* full-screen hint: a small note at the top of the screen, away from the chips and the Deal button */
.m-fs-hint { position: fixed; z-index: 3000; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(92vw, 520px);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 12px; background: rgba(16, 23, 34, .96); border: 1px solid var(--gold);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .65); color: #e8edf5; font-size: 13px; line-height: 1.4; animation: bannerIn .25s; pointer-events: none; }
.m-fs-hint b { color: var(--gold); }
.m-fs-hint small { display: block; font-size: 11.5px; color: var(--muted); }
.m-fs-hint-x { pointer-events: auto; flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border2); background: var(--panel3); color: var(--text); font-size: 13px; }
.m-drawer-sys:empty { display: none; }

/* =====================================================================
   Phones (portrait ≤700px wide, or any touch screen ≤500px tall)
   The table + controls fill exactly one screen; the odds sit below it (scroll down for them).
   ===================================================================== */
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  :root { --top-h: calc(46px + env(safe-area-inset-top)); --nav-h: calc(54px + env(safe-area-inset-bottom)); --avail: calc(100vh - var(--top-h) - var(--nav-h)); }
  @supports (height: 100dvh) { :root { --avail: calc(100dvh - var(--top-h) - var(--nav-h)); } }
  #app, body.nav-mini #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top-h) minmax(0, 1fr) var(--nav-h); grid-template-areas: "top" "main" "nav"; height: 100vh; height: 100dvh; }
  .nav-toggle { display: none; }
  body.nav-mini .nav-lbl { display: block !important; }
  body.nav-mini .nav-item { flex-direction: column; padding: 4px 10px; }
  .topbar { grid-area: top; grid-column: auto; gap: 8px; padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left)); }
  .brand { width: auto; } .brand > div:last-child { display: none; }
  .brand-logo { width: 28px; height: 28px; font-size: 15px; border-radius: 8px; }
  .hist-strip, .wb-item.alltime { display: none; }
  .topbar .spacer { display: none; }
  .wallet-box { flex: 1; min-width: 0; justify-content: space-between; padding: 3px 4px 3px 10px; gap: 2px; border-radius: 10px; }
  .wallet-box .wb-item { padding-right: 8px; margin-right: 4px; }
  .wb-label { font-size: 8.5px; letter-spacing: .8px; }
  .wb-value { font-size: 14px; }
  .wallet-box .btn.sm { padding: 6px 9px; min-height: 0; }
  .wb-item:nth-child(3) { display: none; }

  .sidebar { grid-area: nav; display: flex; flex-direction: row; gap: 2px; padding: 4px 6px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; background: var(--bg2); }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav-group, .nav-he { display: none !important; }
  .nav-item { flex: 0 0 auto; flex-direction: column; justify-content: center; gap: 1px; padding: 4px 10px; min-width: 62px; border-radius: 10px; box-shadow: none !important; font-size: 10px; text-align: center; }
  .nav-item span:not(.nav-ico):not(.nav-he) { display: block !important; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-ico { font-size: 19px; line-height: 1; }
  .nav-item.active { background: rgba(244, 194, 91, .14); }
  #main { grid-area: main; }
  ::-webkit-scrollbar { width: 0; height: 0; }

  /* ---- game screen ---- */
  .view { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  .game { display: block; height: auto; }
  .game-main { position: relative; height: var(--avail); padding: 6px; gap: 6px; overflow: hidden; }
  .game-head { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 2px; scrollbar-width: none; flex: none; align-items: center; }
  .game-head > * { flex: none; }
  .game-head .spacer, .rule-chips { display: none; }
  .game-title { font-size: 16px; } .game-title small { display: none; }
  .m-game > .game-head { display: none; }          /* its buttons live in the ⚙ drawer */
  .felt { flex: 1 1 auto; min-height: 0; border-radius: 16px; padding: 8px; --cw: clamp(38px, min(15cqw, calc((100cqh - 100px) / 4.4)), 80px);
    box-shadow: inset 0 0 0 4px #2e1a0c, inset 0 0 0 5px #8a5a2c, inset 0 0 40px rgba(0, 0, 0, .55); -webkit-overflow-scrolling: touch; }
  .felt::before { inset: 8px; }
  .table-msg { pointer-events: none; bottom: 8px; max-width: 94%; white-space: normal; text-align: center; font-size: 12.5px; padding: 6px 12px; }
  .result-banner { padding: 10px 18px; font-size: 19px; max-width: 92%; }
  .result-banner small { font-size: 12px; }
  .lbl-l { display: none; } .lbl-s { display: inline; }
  kbd, .kbd { display: none; }

  /* ---- controls: chips on one row, then [⚙][↶][✕][⟳][×2][ main action ] on one row ---- */
  .controls { flex: none; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 0; border-radius: 12px; justify-content: flex-start; align-items: center; }
  .controls > * { margin: 0; }
  .controls .spacer { display: none; }
  .chip-tray { order: -1; flex: 1 1 100%; justify-content: center; overflow-x: auto; max-width: 100%; gap: 6px; padding: 2px 2px 4px; scrollbar-width: none; }
  .chip-tray .chip { --cs: 40px; }
  .chip-tray .tray-chip.sel { transform: scale(1.1); }
  /* the controls are the table's chip rack: a wooden rail joined to the felt */
  .m-game { gap: 0; }
  .m-game > .felt { border-radius: 16px 16px 0 0; }
  .m-game > .controls { border: 0; border-radius: 0 0 14px 14px; background: linear-gradient(180deg, #1a0e05, #3b2413 14%, #2e1a0c 55%, #24140a);
    box-shadow: inset 0 0 0 1px #8a5a2c, inset 0 0 0 4px #2e1a0c, inset 0 0 0 5px rgba(255, 210, 140, .18), inset 0 0 16px rgba(0, 0, 0, .65); }
  .m-game > .controls > .chip-tray { border-radius: 10px; background: rgba(0, 0, 0, .38); box-shadow: inset 0 2px 7px rgba(0, 0, 0, .75); padding: 4px; }
  .controls .btn { min-height: 44px; padding: 0 12px; font-size: 14px; border-radius: 11px; }
  .controls .btn.ctl { min-width: 42px; justify-content: center; font-size: 17px; padding: 0 6px; }
  .bet-controls { gap: 6px; flex: none; }
  .bet-controls .bl { display: none; }
  .action-row { display: flex; flex: 1 1 0; min-width: 0; gap: 5px; flex-wrap: nowrap; justify-content: flex-end; }
  .action-row > .btn { flex: 1 1 0; min-width: 0; padding: 0 4px; white-space: nowrap; }
  .controls > .btn.xl, .controls > .btn.primary { flex: 1 1 auto; }
  .btn.xl { min-width: 0; padding: 0 10px; font-size: 14.5px; }
  /* decision time (two or more action buttons showing): chips and bet tools (but not ⚙) step aside so the actions get one row */
  .controls:has(.action-row > .btn:not([hidden]) ~ .btn:not([hidden])):not(:has(.vp-betbtn)) > .chip-tray,
  .controls:has(.action-row > .btn:not([hidden]) ~ .btn:not([hidden])):not(:has(.vp-betbtn)) > .bet-controls > :not(.m-opt) { display: none; }
  .action-row:has(> .btn:not([hidden]) ~ .btn:not([hidden]) ~ .btn:not([hidden]) ~ .btn:not([hidden])) > .btn { font-size: 13px; }
  .btn.recommended::after { top: -9px; right: -2px; font-size: 9px; padding: 1px 5px; }
  .m-opt { display: inline-flex; position: relative; }
  .m-opt.on { background: rgba(244, 194, 91, .2) !important; border-color: var(--gold) !important; color: var(--gold); }
  .m-opt.armed::after { content: ''; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 6px var(--teal); }
  .m-ap-on .m-ap { display: inline-flex; background: linear-gradient(180deg, #ff7d88, #d8404f) !important; color: #2b0006; border-color: #b02f3c !important; font-size: 13px !important; font-weight: 800; }

  /* ---- ⚙ drawer over the table ---- */
  .m-open > .m-drawer { display: flex; }
  .m-drawer { position: absolute; z-index: 60; left: 6px; right: 6px; top: 6px; max-height: calc(100% - 12px); overflow-y: auto; flex-direction: column; gap: 10px; padding: 10px; border-radius: 14px;
    background: rgba(12, 17, 25, .97); border: 1px solid rgba(244, 194, 91, .55); box-shadow: 0 16px 40px rgba(0, 0, 0, .7); animation: bannerIn .18s; }
  .m-drawer-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; }
  .m-drawer-h .btn { min-height: 38px; padding: 0 16px; }
  .m-drawer-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .m-drawer-body > * { flex: 1 1 auto; }
  .m-drawer-body > select { flex: 1 1 calc(50% - 4px); min-width: 0; min-height: 42px; font-size: 14px; }
  .m-drawer-body > .btn { min-height: 42px; font-size: 13.5px; }
  .m-drawer-body > .ap { flex: 1 1 100%; justify-content: space-between; padding: 4px; }
  .m-drawer-body > .ap .ap-btn { min-height: 36px; padding: 0 14px; }
  .m-drawer-body > .ap select { min-height: 36px; font-size: 14px; }
  .m-drawer-body > .switch { flex: 1 1 calc(50% - 4px); min-height: 40px; }
  .m-drawer-body > .roll-hist { flex: 1 1 100%; max-width: none; }
  .m-drawer-sys { border-top: 1px solid var(--border); padding-top: 10px; }
  .m-drawer-sys > .btn.on { border-color: var(--gold); color: var(--gold); }

  /* ---- odds below the table ---- */
  .odds-panel { border-left: 0; border-top: 2px solid var(--gold); min-height: 60vh; overflow: visible; }
  .op-content { overflow: visible; }
  .op-resize, .op-wide { display: none; }
  .odds-panel > .roads { margin: 8px 8px 0; flex-wrap: wrap; }
  .rules-form { grid-template-columns: 1fr; }
  .btn { min-height: 34px; }
  .modal { max-width: 96vw; }
  .page { padding: 12px 12px 24px; }
  .page-head, .pl-head, .ws-head { flex-wrap: wrap; }
  .page h2 { font-size: 20px; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 14px; border-radius: 16px; }
  .hero h1 { font-size: 26px; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .hs { padding: 10px 12px; } .hs-v { font-size: 20px; }
  .tile-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }

  /* ---- bet-spot rows must fit a 390px felt ---- */
  .tcp-spots, .uth-spots { gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; max-width: 100%; }
  .tcp-col { gap: 8px; }
  .tcp-spots .bet-spot, .uth-spots .bet-spot, .bet-spot.tcp-spot, .bet-spot.tcp-spot.play { width: 74px; height: 74px; min-width: 0; min-height: 0; }
  .bs-label { font-size: 11px !important; line-height: 1.1; } .bs-sub { font-size: 9px !important; }
  .bj-spots { gap: 8px; margin-bottom: 22px; }
  .bj-main { width: 84px !important; height: 84px !important; } .bet-spot.bj-side { width: 56px !important; height: 56px !important; }
  .bj-hands { gap: 8px; } .bj-hand { padding: 4px 4px; }
  .tcp-print, .bj-print { display: none; }

  /* ---- baccarat ---- */
  .bac-felt { padding-top: 14px; gap: 8px; --cw: clamp(38px, min(14cqw, calc((100cqh - 300px) / 1.6)), 72px); }
  .bac-hands { grid-template-columns: 1fr 1fr; max-width: 100%; min-height: 0; gap: 6px; }
  .bac-hl { font-size: 12px; letter-spacing: 2px; }
  .bac-total { width: 38px; height: 38px; font-size: 19px; }
  .bac-cards { gap: 4px; }
  .bac-live { grid-column: 1 / -1; grid-row: 2; }
  .bac-spots-top, .bac-spots-main { gap: 6px; max-width: 100%; }
  .bet-spot.bac-side { min-width: 0; width: 30%; height: 48px; min-height: 0; }
  .bac-spots-main { margin-bottom: 18px; }
  .bac-spots-main .bet-spot { min-width: 0; }
  .bet-spot.bac-main, .bet-spot.bac-main.t { min-width: 0; width: 25%; height: 78px; min-height: 0; }
  .bet-spot.bac-dragon { min-width: 0; width: 15%; height: 78px; min-height: 0; }
  .bac-main .bs-label { font-size: 12px !important; letter-spacing: 1px; }
  .road.bead { width: 100%; max-width: 100%; }
  .bac-felt .shoe-ind { display: none; }
  .bac-felt .table-msg { bottom: auto; top: 40%; }

  /* ---- video poker: compact pay strip, the hand always on screen, tap a card to hold ---- */
  .vp-felt { padding: 6px; align-items: stretch; overflow: hidden; }
  .vp-screen, .vp-screen.multi { position: relative; height: 100%; min-height: 0; padding: 6px; border-width: 2px; gap: 5px; justify-content: space-between; }
  .vp-paytable { flex: none; grid-template-columns: repeat(3, minmax(0, 1fr)); cursor: pointer; }
  .vp-pt-row { display: flex; justify-content: space-between; align-items: baseline; min-width: 0; }
  .vp-pt-row span, .vp-screen.multi .vp-paytable .vp-pt-row span { padding: 1px 5px; font-size: 10.5px; line-height: 1.35; }
  .vp-pt-name, .vp-pt-v:not(.cur) { display: none; }
  .vp-pt-short { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
  .vp-pt-v.cur { background: none; color: #fff; }
  .vp-pt-row.hit .vp-pt-v.cur { color: #0c1c64; }
  .vp-paytable.full { position: absolute; z-index: 30; left: 6px; right: 6px; top: 6px; grid-template-columns: 1fr; box-shadow: 0 12px 30px rgba(0, 0, 0, .7); }
  .vp-paytable.full .vp-pt-row { display: grid; grid-template-columns: 1.7fr repeat(5, 1fr); }
  .vp-paytable.full .vp-pt-name, .vp-paytable.full .vp-pt-v { display: block; }
  .vp-paytable.full .vp-pt-short { display: none; }
  .vp-paytable.full .vp-pt-v.cur { background: #b81d2d; }
  .vp-paytable.full .vp-pt-row span { font-size: 11px; padding: 3px 5px; }
  .vp-status { font-size: 12.5px; min-height: 16px; letter-spacing: 1px; flex: none; }
  .vp-multi { flex: 1 1 auto; min-height: 0; max-height: none; align-content: start; }
  .vp-screen.multi .vp-multi { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .vp-screen[data-hands="3"] .mc, .vp-screen[data-hands="5"] .mc { min-width: 30px; height: 38px; font-size: 13px; }
  .vp-cards, .vp-screen.multi .vp-cards { flex: none; gap: 4px; --cw: min(calc((100cqw - 48px) / 5), calc((100cqh - 150px) / 1.42)); }
  .vp-screen.multi .vp-cards { --cw: min(calc((100cqw - 48px) / 5), 15cqh); }
  .vp-slot { padding: 2px 1px 6px; gap: 2px; }
  .vp-slot:hover { transform: none; }
  .vp-held { font-size: 11px; letter-spacing: 1px; line-height: 14px; }
  .vp-ev, .vp-hold-btn { display: none !important; }
  .vp-meter { flex: none; font-size: 11.5px; gap: 4px; }
  .vp-credit { display: none; }
  .vp-tally { padding: 5px 8px; gap: 4px; flex: none; }
  .m-game .vp-betbtn:disabled { display: none; }
  .vp-felt .table-msg { bottom: auto; top: 12px; }

  /* ---- craps & roulette: landscape only (portrait shows a rotate prompt over the table) ---- */
  .m-rotate { position: absolute; inset: 6px; z-index: 50; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; border-radius: 16px;
    background: radial-gradient(ellipse at center, #17784a, #0a432a); box-shadow: inset 0 0 0 4px #2e1a0c, inset 0 0 0 5px #8a5a2c; color: #fff; }
  .m-rotate b { font-size: 20px; }
  .m-rotate span { font-size: 13.5px; line-height: 1.5; color: rgba(255, 255, 255, .8); max-width: 300px; }
  .m-rotate-ico { font-size: 54px; animation: mRot 2.4s ease-in-out infinite; }
  @keyframes mRot { 0%, 25% { transform: rotate(0); } 50%, 75% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
}
@media (max-width: 700px) and (orientation: portrait) {
  .m-rotate { display: flex; }
}

/* =====================================================================
   Phones in landscape: navigation becomes a left icon rail. At a table the header bar goes away and the
   controls become a wooden chip rack built onto the right edge of the table (balance, chips, bet tools and the
   Deal button, all on screen at once), so the table gets the full height of the screen.
   The page itself scrolls (not an inner box), so on iPhone — whose browsers have no full-screen mode — a swipe up
   on the table hides the browser bars; the table stays pinned and the odds slide up over it like a sheet.
   ===================================================================== */
@media (max-height: 500px) and (pointer: coarse) {
  :root { --top-h: calc(34px + env(safe-area-inset-top)); --rail-w: calc(58px + env(safe-area-inset-left)); --rack-w: 122px; --avail: calc(100vh - var(--top-h)); }
  @supports (height: 100dvh) { :root { --avail: calc(100dvh - var(--top-h)); } }
  body.m-ingame { --top-h: 0px; --avail: 100vh; }
  @supports (height: 100dvh) { body.m-ingame { --avail: 100dvh; } }
  html, body { height: auto; min-height: 100%; }
  body { overflow: visible; }
  #app, body.nav-mini #app { display: block; height: auto; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: var(--rail-w); flex-direction: column; gap: 2px; padding: calc(4px + env(safe-area-inset-top)) 4px calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left)); border-top: 0; border-right: 1px solid var(--border); overflow-x: hidden; overflow-y: auto; }
  .nav-item span:not(.nav-ico):not(.nav-he) { display: none !important; }
  .nav-item, body.nav-mini .nav-item { flex: none; flex-direction: row; min-width: 0; width: 100%; min-height: 42px; padding: 0; justify-content: center; }
  .topbar { position: fixed; z-index: 35; top: 0; left: var(--rail-w); right: 0; height: var(--top-h); padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 8px; }
  body.m-ingame .topbar { display: none; }
  .brand { display: none; }
  .wallet-box { flex: 0 1 auto; margin-left: auto; padding: 2px 4px 2px 10px; }
  .wb-value { font-size: 13px; }
  main#main { margin-left: var(--rail-w); padding-top: var(--top-h); overflow: visible; min-height: 100vh; }
  .view, .view.scroll, .game { position: relative; inset: auto; overflow: visible; }
  .page { padding-right: calc(12px + env(safe-area-inset-right)); }

  /* the table (felt + rack) is pinned; the odds panel comes after a gap that only the browser bars scroll into */
  .game-main { position: sticky; top: var(--top-h); z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) var(--rack-w); grid-template-rows: minmax(0, 1fr);
    padding: 4px calc(4px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom) / 3) 4px; gap: 0; }
  .game-main > .felt { grid-column: 1; grid-row: 1; min-height: 0; }
  .game-main > .game-head:not(:empty) { display: none; }
  .felt { --cw: clamp(30px, min(9cqw, calc((100cqh - 60px) / 4.4)), 70px); }
  .m-game > .felt { border-radius: 14px 0 0 14px; }
  .odds-panel { position: relative; z-index: 20; margin-top: 96px; min-height: 100vh; border-radius: 16px 16px 0 0; box-shadow: 0 -14px 34px rgba(0, 0, 0, .7); }

  /* ---- the chip rack: wood rail, balance on top, chips in a recessed tray, tools, then Deal at the bottom ---- */
  .controls { grid-column: 2; grid-row: 1; width: auto; min-height: 0; flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start; gap: 5px; padding: 6px 6px 6px 5px;
    overflow-x: hidden; overflow-y: auto; scrollbar-width: none; }
  .m-game > .controls { border-radius: 0 14px 14px 0; background: linear-gradient(90deg, #1a0e05, #3b2413 14%, #2e1a0c 55%, #24140a); }
  .controls > .wallet-box { order: -3; flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 4px; margin: 0; padding: 3px 3px 3px 7px;
    border-radius: 9px; background: #0b0f14; border: 1px solid #5a3a1c; box-shadow: inset 0 1px 5px rgba(0, 0, 0, .9); }
  .controls > .wallet-box .wb-item { grid-column: 1; min-width: 0; padding: 0; margin: 0; border: 0; line-height: 1.15; }
  .controls > .wallet-box .wb-label, .controls > .wallet-box .wb-item:nth-child(3) { display: none; }
  .controls > .wallet-box .wb-value { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .controls > .wallet-box .wb-item:nth-child(2) .wb-value { font-size: 10.5px; }
  .controls > .wallet-box #wb-add { grid-column: 2; grid-row: 1 / span 2; width: 26px; min-width: 0; height: 30px; min-height: 0; padding: 0; border-radius: 7px; font-size: 0; }
  .controls > .wallet-box #wb-add::before { content: '+'; font-size: 19px; line-height: 1; }
  .controls > .m-ap { order: -2; }
  .chip-tray { order: -1 !important; flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); justify-items: center; gap: 3px 2px; overflow: visible; }
  .m-game > .controls > .chip-tray { padding: 4px 2px; }
  .chip-tray .chip { --cs: 32px; }
  .controls .btn { min-height: 40px; }
  .controls .btn.ctl { min-width: 0; }
  .bet-controls { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .bet-controls > .btn.ctl, .controls > .btn.ctl { height: 34px; min-height: 34px; padding: 0; font-size: 16px; border-radius: 9px; }
  .action-row { flex: none; flex-direction: column; flex-wrap: nowrap; align-items: stretch; margin-top: auto !important; }
  .controls > .btn.xl, .controls > .btn.primary { flex: none; margin-top: auto !important; min-height: 46px; }
  .btn.xl { font-size: 14px; padding: 0 8px; }
  .action-row > .btn, .hm-actions .btn.xl { flex: none; white-space: normal; line-height: 1.15; font-size: 13px; padding: 3px 4px; }
  .action-row > .btn.primary:only-child, .action-row > .btn.primary:not([hidden]):last-child { min-height: 46px; }
  .m-drawer { right: calc(var(--rack-w) + 8px + env(safe-area-inset-right)); left: 6px; }
  .m-drawer-body > select { flex-basis: calc(33% - 6px); }
  .m-rotate { display: none !important; }

  /* ---- blackjack: dealer across the top; side bets flank your hands and the main bet ---- */
  .bj-felt { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "dealer dealer dealer" "sideL hands sideR" "sideL main sideR";
    justify-items: center; align-items: center; gap: 0 10px; padding: 8px 10px 24px; --cwb: clamp(34px, min(12cqw, calc((100cqh - 92px) / 4.1)), 84px); }
  .bj-dealer { grid-area: dealer; flex-direction: row; gap: 10px; min-height: 0; }
  .bj-dealer > .zone-label { flex-direction: column; margin: 0; gap: 4px; font-size: 11px; }
  .bj-cards { min-height: var(--ch); }
  .bj-hands { grid-area: hands; min-height: 0; align-self: end; gap: 8px; flex-wrap: nowrap; }
  .bj-hands[data-n="2"] { --cw: calc(var(--cwb) * .85); }
  .bj-hand { padding: 3px 4px; gap: 3px; }
  .bj-spots { display: contents; }
  .bj-spots > :first-child { grid-area: sideL; justify-self: end; }
  .bj-spots > :last-child { grid-area: sideR; justify-self: start; }
  .bet-spot.bj-main { grid-area: main; width: calc(var(--cw) * 1.25) !important; height: calc(var(--cw) * 1.25) !important; min-width: 52px; min-height: 52px; }
  .bj-sidegrp, .bj-sidegrp[data-n="3"], .bj-sidegrp[data-n="4"] { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(2, auto); gap: 18px 8px; }
  .bj-sidegrp[data-n="1"] { grid-template-columns: auto; }
  .bj-sidegrp[data-n="5"] { gap: 8px 6px; }
  .bj-sidegrp[data-n="5"] .bet-spot.bj-side { width: 46px !important; height: 46px !important; }
  .bet-spot.bj-side { width: 54px !important; height: 54px !important; }
  .bj-felt .shoe-ind { top: 8px; right: 12px; transform: scale(.8); transform-origin: top right; }

  /* ---- three card poker: dealer and you side by side, the bets in one row below ---- */
  .tcp-felt { display: grid; grid-template-columns: auto auto; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "d p" "s s"; justify-content: center; align-content: space-evenly; justify-items: center;
    gap: 6px clamp(24px, 6cqw, 60px); padding: 8px 10px 24px; --cw: clamp(34px, min(calc((100cqw - 110px) / 6.6), calc((100cqh - 140px) / 1.75)), 84px); }
  .tcp-felt > .tcp-zone:has(> .zone-label:first-child) { grid-area: d; }
  .tcp-felt > .tcp-zone:has(> .zone-label:last-child) { grid-area: p; flex-direction: column-reverse; }
  .tcp-felt .zone-label { margin-bottom: 0; }
  .tcp-felt .cards-row { min-height: var(--ch); gap: 6px; }
  .tcp-spots { grid-area: s; margin: 0; flex-wrap: nowrap; gap: 10px; }
  .tcp-spots .bet-spot, .bet-spot.tcp-spot, .bet-spot.tcp-spot.play { width: 64px; height: 64px; }
  .tcp-spots .bet-spot.tcp-spot.side { width: 54px; height: 54px; font-size: 9px; }

  /* ---- ultimate texas hold'em: dealer beside the board, your cards beside the bets ---- */
  .uth-felt { display: grid; grid-template-columns: auto auto; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "d b" "p s"; justify-content: center; align-content: space-evenly; justify-items: center; align-items: center;
    gap: 4px clamp(18px, 4cqw, 40px); padding: 8px 10px 22px; --cw: clamp(30px, min(calc((100cqw - 130px) / 7.5), calc((100cqh - 84px) / 2.95)), 76px); }
  .uth-felt > .uth-zone:has(> .zone-label:first-child) { grid-area: d; }
  .uth-felt > .uth-zone:has(> .uth-board) { grid-area: b; justify-content: flex-end; }
  .uth-felt > .uth-zone:has(> .zone-label:last-child) { grid-area: p; flex-direction: column-reverse; }
  .uth-felt .zone-label { margin-bottom: 0; }
  .uth-felt .cards-row, .uth-board { gap: 5px; }
  .uth-print { display: none; }
  .uth-spots { grid-area: s; margin: 0; flex-wrap: nowrap; gap: 8px; }
  .uth-spots .bet-spot { width: 62px; height: 62px; }
  /* the three bonus bets stack in a column beside the ante so the row still fits half the table */
  .uth-sides { flex-direction: column; gap: 3px; margin-right: 2px; }
  .uth-spots .bet-spot.uth-spot.side { width: 44px; height: 40px; min-width: 0; min-height: 0; font-size: 8.5px; border-radius: 12px; }
  .uth-spots .bet-spot.uth-spot.side .bs-sub { display: none; }
  .bet-spot.uth-spot.play { width: 70px; height: 54px; }
  .uth-eq { margin: 0 -4px; }

  /* craps: the full layout in one landscape screen. The felt is one grid: last roll and the dice across the top left,
     the layout below them, and the proposition column running the full height on the right. The game status is a
     compact block inside the right end of the dice stage (the dice land to its left), so no column is spent on it. */
  .cr-felt { display: grid; grid-template-columns: 17% minmax(0, 1fr) 23%; grid-template-rows: 20% minmax(0, 1fr); padding: 6px 8px; gap: 5px 6px; }
  .cr-felt .felt-decor { display: none; }
  .cr-top, .cr-layout { display: contents; }
  .cr-last { grid-area: 1 / 1; padding: 2px 4px; border-radius: 11px; }
  .cr-stage { grid-area: 1 / 2; border-radius: 11px; }
  .cr-stage-wall { width: 10px; }
  .cr-statuswrap { grid-area: 1 / 2; z-index: 2; justify-self: end; align-self: stretch; width: min(48%, 156px); margin: 2px 2px 2px 0; padding: 2px 6px; gap: 2px; justify-content: center;
    border-left: 1px dashed rgba(255, 255, 255, .22); pointer-events: none; }
  .cr-main { grid-area: 2 / 1 / 3 / 3; }
  .cr-props { grid-area: 1 / 3 / 3 / 4; }
  .cr-pucks { gap: 6px; }
  .cr-statuswrap .puck { width: 24px; height: 24px; font-size: 7.5px; border-width: 2px; }
  .cr-last { overflow: hidden; }
  .cr-last-n { font-size: min(8.5cqh, 34px); }
  .cr-last-t { font-size: 7.5px; letter-spacing: 1px; line-height: 1.1; }
  .cr-last-call { font-size: 9.5px; letter-spacing: .4px; line-height: 1.15; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .cr-last-dice { display: none; }
  .die3d { --ds: min(13cqh, 44px); }
  .cr-status { font-size: 10px; line-height: 1.25; min-width: 0; } .cr-status b { font-size: 11.5px; }
  .cr-diceinfo { display: none; }
  .puck { width: 30px; height: 30px; font-size: 9px; }
  .cr-main { grid-template-rows: minmax(0, 1.4fr) minmax(0, .55fr) minmax(0, .6fr) minmax(0, 1fr); gap: 4px; }
  .cr-box { padding: 2px; gap: 2px; }
  .cr-num span { font-size: 13px; padding: 0 4px; border-width: 1px; }
  .cr-puck-slot { top: 18px; } .cr-puck-slot .puck { width: 24px; height: 24px; font-size: 8px; }
  .bet-spot.cr.place { min-height: 0; }
  .bet-spot.cr.come .bs-label { font-size: 18px; letter-spacing: 5px; }
  .cr-field-word { font-size: 16px; letter-spacing: 3px; margin-left: 4px; }
  .cr-field-nums { font-size: 11px; gap: 3px; }
  .bet-spot.cr.field { gap: 6px; }
  .bet-spot.cr.big .bs-label { font-size: 16px; }
  .bet-spot.cr.pass .bs-label { font-size: 16px; letter-spacing: 4px; }
  .bet-spot.cr.dp .bs-label { font-size: 10px; letter-spacing: 2px; }
  .cr-props { padding: 4px; gap: 3px; }
  .bet-spot.cr.prop, .bet-spot.cr.side { min-height: 0; }
  .bet-spot.cr.prop .bs-label { font-size: 9.5px !important; } .bet-spot.cr.prop .bs-sub { font-size: 8px !important; }
  .bet-spot.cr.prop.seven .bs-label { font-size: 12px !important; letter-spacing: 3px; }
  /* one-line SEVEN / ANY CRAPS / FIRE BET and no captions, so the nine prop rows fit the short screen */
  .cr-props-t { display: none; }
  /* the full-height column has room for the hop bets in a 2×2 block like the hardways, so each spot is wide enough to read */
  .cr-props .cr-grid4 { grid-template-columns: 1fr 1fr; }
  .cr-props > .cr-grid4, .cr-props > .cr-grid2.hw { flex: 2; }
  .bet-spot.cr.prop.seven, .bet-spot.cr.prop.anyc, .bet-spot.cr.fire { flex-direction: row; gap: 6px; }
  .bet-spot.cr.fire .bs-sub { display: none; }
  .cr-felt .table-msg { display: none; }   /* it repeats the call the Last Roll box already shows, and would cover the status */
  /* bj / 3-card / UTH: the table message sits in the free bottom-left corner, not over the bets */
  :is(.bj-felt, .tcp-felt, .uth-felt) .table-msg { left: 10px; bottom: 8px; transform: none; max-width: min(25%, 170px); text-align: left; font-size: 12px; }
  .mdie { width: 12px; height: 12px; }

  /* baccarat: the four side bets on one row */
  .bac-felt { padding-top: 6px; gap: 4px; --cw: clamp(36px, min(9cqw, calc((100cqh - 220px) / 1.45)), 64px); }
  .bac-spots-top { flex-wrap: nowrap; width: 100%; }
  .bet-spot.bac-side { width: 23%; height: 44px; }
  .bac-spots-top.many { gap: 3px; }
  .bac-spots-top.many .bet-spot.bac-side { flex: 1 1 0; width: auto; min-width: 0; height: 42px; font-size: 8.5px; }
  .bac-spots-top.many .bet-spot.bac-side .bs-sub { display: none; }
  .bet-spot.bac-main, .bet-spot.bac-main.t, .bet-spot.bac-dragon { height: 66px; }
  .bac-spots-main { margin-bottom: 16px; width: 80%; justify-content: center; }
  .bac-felt .table-msg { top: 6px; }
  .cr-main { grid-template-rows: minmax(0, 1.3fr) minmax(0, .5fr) minmax(0, .58fr) minmax(0, .95fr); }

  /* roulette: small wheel beside the board */
  .rl-felt { flex-direction: row; align-items: stretch; gap: 8px; padding: 6px 8px; }
  .rl-felt .felt-decor { display: none; }
  /* only the right part of a big wheel shows; the camera turns with the ball (js), so the ball stays at the right edge */
  .rl-top { --rld: calc(100cqh - 12px); position: relative; flex-direction: column; align-items: flex-start; gap: 0; width: calc(var(--rld) * .5); flex: none; align-self: stretch; }
  .rl-wheel-wrap { width: calc(var(--rld) * .5); height: var(--rld); aspect-ratio: auto; overflow: hidden; border-radius: 0 50% 50% 0 / 0 50% 50% 0; }
  .rl-wheel-wrap .rl-wheel { position: absolute; top: 0; left: calc(var(--rld) * -.5); width: var(--rld); height: var(--rld); box-shadow: none; }
  .rl-wheel-wrap .rl-pointer { top: 50%; left: auto; right: -2px; margin: -9px 0 0; border: 9px solid transparent; border-right: 16px solid var(--gold); border-left: 0; }
  .rl-wheel-wrap .rl-result { left: 8%; right: auto; width: 52px; height: 52px; font-size: 21px; }
  .rl-side { position: absolute; left: 2px; bottom: 2px; width: calc(var(--rld) * .3); gap: 4px; z-index: 2; }
  .rl-side > .zone-label, .rl-wheelinfo, .rl-zoomchk, .rl-calls, .rl-top > :not(.rl-wheel-wrap):not(.rl-side) { display: none; }
  .rl-hist { min-height: 0; gap: 2px; justify-content: center; }
  .rl-board { --rlh: calc((100cqh - 20px) / 4.6); align-self: center; flex: 1; min-width: 0; margin: 0; }
  .rl-cols .bet-spot { font-size: 9px; }
}
/* landscape tablets/phones that only the width query caught keep the portrait grid; the landscape rail needs the
   touch query above, so a short desktop window is unaffected */

/* ---------- Texas Hold'em on phones ---------- */
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .hm-felt { --cw: clamp(20px, min(6.5cqw, 8cqh), 40px); }
  .hm-seat.you { --cw: clamp(30px, min(10cqw, 12cqh), 54px); }
  .hm-board { --cw: clamp(26px, min(10cqw, 12cqh), 54px); gap: 3px; }
  .hm-plate { padding: 2px 6px; min-width: 0; gap: 4px; border-radius: 9px; }
  .hm-ava, .hm-id small, .hm-pos { display: none; }
  .hm-id b { font-size: 10.5px; }
  .hm-stack { font-size: 10.5px; }
  .hm-act { font-size: 9.5px; padding: 1px 5px; bottom: -15px; }
  .hm-bet { font-size: 10.5px; padding: 1px 6px 1px 1px; }
  .hm-bet .chip { --cs: 16px; }
  .hm-info, .hm-sizer { display: none !important; }
  .hm-actions { justify-content: center; }
  .hm-actions .btn.xl { min-width: 0; padding: 0 12px; min-height: 44px; font-size: 14px; }
  .hm-size { min-height: 44px; padding: 2px 9px; }
  .hm-size kbd { display: none; }
  .hm-lu-row { grid-template-columns: 34px minmax(0, 1fr); }
  .hm-lu-row.head { display: none; }
}

/* =====================================================================
   Phone fixes (layout audit, 2026-12-01)
   ===================================================================== */
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  /* bottom navigation: the labels were squeezed to 9px and lost their lower half */
  .sidebar .nav-item { padding-top: 2px; padding-bottom: 2px; }
  .sidebar .nav-item .nav-lbl { line-height: 13px; min-height: 13px; }
  /* Poker Odds Lab: one column that never grows wider than the screen; header controls wrap instead of running off */
  .pl { grid-template-columns: minmax(0, 1fr); }
  .pl-left { padding: 10px 10px 24px; }
  .pl-left > .game-head { flex-wrap: wrap; overflow: visible; row-gap: 6px; }
  .pl-left > .game-head > .game-title { flex: 1 1 100%; }
  .pl-left > .game-head .head-sel { max-width: 100%; min-width: 0; }
  .pl-sel { flex: 1 1 calc(50% - 6px); min-width: 0; font-size: 10.5px; } .pl-sel select { flex: 1; min-width: 0; }
  .pl-players { grid-template-columns: minmax(0, 1fr); }
  .pl-board { gap: 14px 24px; }
  .pl-felt { padding: 12px 12px; }
  .pl-slot, .pl-slot .card { --cw: 48px; }
  /* Workshop: the tab bar wraps instead of hiding its last tab off the right edge */
  .ws-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
  .ws-tab { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11.5px; line-height: 1.15; text-align: center; justify-content: center; }
}
@media (max-width: 700px) and (orientation: portrait) {
  /* baccarat: many side bets sit in a 4-across grid, so Player / Tie / Banker stay on screen on short phones */
  .bac-spots-top.many { max-width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; width: 100%; }
  .bac-spots-top.many .bet-spot.bac-side { width: auto; min-width: 0; height: clamp(38px, 7cqh, 50px); min-height: 0; font-size: 8.5px; padding: 2px; }
  .bac-spots-top.many .bet-spot.bac-side .bs-label { font-size: 9.5px !important; letter-spacing: .5px; }
  .bac-spots-top.many .bet-spot.bac-side .bs-sub { font-size: 8px !important; }
  /* UTH: three rows of cards plus two rows of bets must fit a short screen */
  .uth-felt { --cw: clamp(34px, min(15cqw, calc((100cqh - 250px) / 4.3)), 80px); gap: 4px; }
  .uth-spots .uth-eq { display: none; }
  .uth-spots .bet-spot, .tcp-spots .bet-spot, .bet-spot.tcp-spot, .bet-spot.tcp-spot.play { width: clamp(56px, 12cqh, 74px); height: clamp(56px, 12cqh, 74px); }
}
@media (max-height: 500px) and (pointer: coarse) {
  /* sideways phone: all twelve destinations fit the rail's height (they were 42px each and the last ones hid below the fold) */
  .sidebar .nav-item, body.nav-mini .sidebar .nav-item { flex: 1 1 0; min-height: 26px; max-height: 44px; padding: 0; }
  .sidebar .nav-ico { font-size: clamp(14px, 4.6vh, 19px); }
}
@media (max-width: 700px) {
  /* stats: two tiles across instead of six full-width ones filling the first screen */
  .stats-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .big-tile { padding: 10px 12px; border-radius: 12px; }
  .bt-v { font-size: 20px; }
  .bt-s { font-size: 11px; }
  .stats-page .card-panel { overflow-x: auto; }
}
@media (max-width: 700px) and (orientation: portrait) {
  /* the table leaves room for the odds panel's header to peek above the navigation bar: the live odds are one swipe
     (or one tap on that header) away, instead of hidden below the fold with nothing to say they are there */
  .m-game { height: calc(var(--avail) - 34px); }
  .m-game ~ .odds-panel > .op-header { cursor: pointer; }
  .m-game ~ .odds-panel > .op-header .op-h-title::after { content: ' ▴'; opacity: .7; }
}
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  /* finger-sized hit areas for the small header and panel buttons */
  .wb-reset { position: relative; }
  .wb-reset::after { content: ''; position: absolute; inset: -10px -8px; }
  .op-exp { min-width: 34px; min-height: 30px; }
  .pl-x { width: 26px; height: 26px; top: -10px; right: -10px; font-size: 12px; }
  .hm-tip-hide { min-height: 28px; padding: 4px 10px; }
  /* odds-panel stat labels wrap instead of being cut off */
  .stat-l { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.2; }
}
@media (max-width: 700px) {
  /* Workshop on a phone: every editor fits the screen width (the rank buttons, face remove buttons and the last
     suits / pockets used to be cut off on the right) */
  .ws-rank-row { grid-template-columns: 22px repeat(3, minmax(0, 1fr)); gap: 2px 8px; padding: 6px; font-size: 12px; }
  .ws-rank-row > :nth-child(1) { grid-row: 1 / span 2; }
  .ws-rank-row > :nth-child(2) { grid-column: 2 / 4; grid-row: 1; }
  .ws-rank-row > :nth-child(6) { grid-column: 4; grid-row: 1; }
  .ws-rank-row > :nth-child(3) { grid-column: 2; grid-row: 2; }
  .ws-rank-row > :nth-child(4) { grid-column: 3; grid-row: 2; }
  .ws-rank-row > :nth-child(5) { grid-column: 4; grid-row: 2; }
  .ws-rank-row.head { font-size: 9.5px; }
  .ws-rank-btns { flex-wrap: wrap; }
  .ws-face { flex-wrap: wrap; gap: 6px 10px; }
  .ws-face input { width: 62px; }
  .deck-mx { border-spacing: 2px; }
  .deck-mx td { width: 30px; height: 28px; font-size: 12px; }
  .deck-mx th { padding: 2px 3px; }
  .deck-mx th.sh { min-width: 30px; font-size: 16px; }
  .wp-nums { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; }
  .wp-zeros { min-width: 28px; }
  .wp { font-size: 11px; min-height: 34px; min-width: 0; padding: 0; border-radius: 4px; }
  .wp small { font-size: 8px; }
}
@media (max-width: 700px) {
  /* 🎛 Set cards: all thirteen ranks of a suit on screen (the row scrolled sideways with no visible scrollbar) */
  .rig-grid { overflow-x: visible; }
  .rig-row { gap: 2px; }
  .rig-card { flex: 1 1 0; width: auto; min-width: 0; height: 44px; font-size: 11.5px; padding: 0; }
  .rig-card sup { font-size: 7.5px; right: 1px; }
  .rig-slot { width: 54px; height: 64px; }
  .rig-slots { gap: 8px 14px; }
  /* dialog buttons wrap instead of running off the right edge */
  .rf-actions { flex-wrap: wrap; }
  .rf-actions > .btn { flex: 1 1 auto; }
}
@media (max-width: 700px) {
  /* the bottom bar scrolls sideways: fade the edge that has more destinations behind it */
  .sidebar.more-r { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
  .sidebar.more-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%); mask-image: linear-gradient(90deg, transparent, #000 18%); }
  .sidebar.more-l.more-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); }
}
@media (max-width: 700px) {
  /* Poker Odds Lab pre-flop table: the player-count buttons share the width instead of pushing "6 Players" off it */
  .pf-seg { display: flex; max-width: 100%; }
  .pf-seg-btn { flex: 1 1 0; min-width: 0; padding: 6px 2px; font-size: 11px; white-space: nowrap; }
}
