/* Phone & touch refinements — loaded last so it can adjust every page. */

/* hidden on desktop; shown in the phone action bars */
.cr-mini { display: none; }
@media (min-width: 761px) { .rl-spinbar { display: none; } }
@media (min-width: 861px) { #btn-menu { display: none; } }

/* ---------- touch targets & inputs (any coarse pointer, or narrow screens) ---------- */
@media (pointer: coarse) { .kbd { display: none; } }
@media (pointer: coarse), (max-width: 860px) {
  .btn-sm { min-height: 40px; padding: 8px 12px; }
  .seg button { min-height: 38px; padding: 8px 12px; }
  .tab { min-height: 44px; }
  .check { min-height: 40px; }
  .check input { width: 20px; height: 20px; flex-shrink: 0; }
  /* 16px stops iOS Safari zooming the page when a field is focused */
  input[type=text], input[type=number], input:not([type]), select, textarea { font-size: 16px; min-height: 42px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .seg button { min-width: 40px; }
  .bjr-cell { min-height: 38px; }
  .cr-buy { min-height: 40px; }
  .chip-btn { width: 44px; height: 44px; }
}

@media (max-width: 760px) {
  body { -webkit-text-size-adjust: 100%; }
  .bj-felt, .bac-felt, .rl-wheel-host, .cr-felt { scroll-margin-top: calc(72px + env(safe-area-inset-top, 0px)); }
  .tile-label, table.data th { font-size: 12px; }
  .page-head { margin-bottom: 12px; gap: 10px; }
  .page-head h1 { font-size: 24px; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px)); border-radius: 16px; }
  .modal-actions { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; min-height: 44px; }
  /* wide tables: show there is more to the right */
  .table-wrap { -webkit-overflow-scrolling: touch; background:
      linear-gradient(to right, var(--panel), var(--panel)) left / 16px 100% no-repeat local,
      linear-gradient(to left, var(--panel), var(--panel)) right / 16px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.45), transparent) left / 10px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.45), transparent) right / 10px 100% no-repeat scroll; }
  .toast-host { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

  /* ---------- shared: sticky action bars ---------- */
  .m-sticky, .bj-controls-host:has(.bj-actions), .bj-controls-host:has(.bj-ins), .cr-controls, .bac-controls, .rl-spinbar {
    position: sticky; bottom: 0; z-index: 30;
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.55);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ---------- blackjack ---------- */
  .bj-page .split-main > .stack:first-child { display: flex; flex-direction: column; }
  .bj-page .split-main > .stack:first-child > * { order: 3; margin-top: 0; }
  .bj-page .split-main > .stack:first-child { gap: 12px; }
  .bj-page .split-main > .stack:first-child > .bj-felt { order: 0; }
  .bj-page .split-main > .stack:first-child > .bj-advice { order: 1; }
  .bj-page .split-main > .stack:first-child > .bj-controls-host { order: 2; }
  .bj-controls-host:has(.bj-actions) > .bj-controls, .bj-controls-host:has(.bj-ins) > .bj-controls { border-radius: 14px; background: var(--panel); padding: 10px; }
  .bj-felt { min-height: 0; gap: 6px; padding: 10px 8px 8px; }
  .bj-rail-text { font-size: 10.5px; }
  .bj-hand-empty .bj-circle { width: 74px; height: 74px; }
  .bj-actions .bj-act { min-height: 48px; }
  .bj-head-tools { gap: 6px 10px; }
  /* split hands sit side by side so the dealer's card stays on screen */
  .bj-hands { flex-wrap: wrap; gap: 8px; }
  .bj-hand { padding: 6px 6px; }
  .bj-hand-info { flex-direction: column; align-items: center; gap: 3px; }
  .bj-hands:has(> .bj-hand + .bj-hand) .bj-hand { flex: 1 1 calc(50% - 8px); min-width: 0; }

  /* roulette: compact wheel comparison */
  .rl-vcards { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .rl-vcard { padding: 8px 10px; }
  .rl-vcard ul, .rl-vcard-head .badge { display: none; }
  .rl-vcard-edge { font-size: 16px; }
  .rl-variants { padding: 10px 12px; }

  /* ---------- craps ---------- */
  .cr-controls { background: var(--panel); }
  .cr-controls .row.between { gap: 8px; }
  .cr-controls .cr-roll { min-height: 50px; }
  .cr-mini { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
  .cr-mini b { color: var(--text); letter-spacing: 0.04em; }
  .cr-mini b.on { color: var(--gold-2); }
  .cr-controls .cr-hint { display: none; }

  /* advice shown inside the pinned bar */
  .bj-controls-host > .bj-advice { margin: 0 0 8px; padding: 8px 10px; font-size: 13px; background: var(--panel); border-radius: 12px; }

  /* ---------- baccarat: compact pinned bar (about 1/5 of the screen) ---------- */
  .bac-controls { background: var(--panel); padding: 8px 10px; }
  .bac-controls .bac-hint { display: none; }
  .bac-controls > .row.between { flex-wrap: nowrap; gap: 8px; align-items: center; }
  .bac-controls > .row.between > div:first-child { flex: 0 0 auto; }
  .bac-controls .tile-label { font-size: 10px; }
  .bac-controls .bac-bet-total { font-size: 18px; line-height: 1.1; }
  .bac-controls > .row.between .small.muted { display: none; }
  .bac-controls .chip-selector { flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 4px 2px; scrollbar-width: none; }
  .bac-controls .chip-selector::-webkit-scrollbar { display: none; }
  .bac-controls .chip-btn { width: 40px; height: 40px; flex: 0 0 auto; font-size: 11px; }
  .bac-controls > .row:last-child { margin-top: 6px !important; flex-wrap: nowrap; gap: 6px; }
  .bac-controls > .row:last-child .btn { min-height: 44px; padding: 6px 12px; }
  .bac-deal { min-height: 44px; flex: 1; }

  /* ---------- roulette: compact spin bar under the layout ---------- */
  .rl-spinbar { display: flex; align-items: center; gap: 12px; justify-content: space-between;
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
  .rl-spinbar-info { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .rl-spinbar-info b { font-size: 20px; font-variant-numeric: tabular-nums; }
  .rl-spinbar-btn { min-height: 48px; min-width: 120px; font-size: 16px; letter-spacing: 0.12em; }
}

/* ---------- small phones ---------- */
@media (max-width: 380px) {
  main { padding: 12px 12px; }
  .chip { width: 38px; height: 38px; font-size: 11.5px; }
  .chip-btn { width: 40px; height: 40px; }
  .chip-selector { gap: 6px; }
  .bankroll-pill .val { font-size: 15px; }
}

/* ---------- landscape phones: keep bars from eating the screen ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .m-sticky, .bj-controls-host:has(.bj-actions), .cr-controls, .bac-controls, .rl-spinbar { position: static; box-shadow: none; }
  .app-header { position: static; }
}

/* ---------- dashboard intro: compact on phones so the games show sooner ---------- */
@media (max-width: 600px) {
  .hero { padding: 16px; }
  .hero h1 { font-size: 21px; margin-bottom: 6px; }
  .hero p { font-size: 14px; margin-bottom: 0; }
  .hero .principle { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px !important; }
  .hero .principle > div { padding: 8px 10px; font-size: 12.5px; line-height: 1.35; }
  .hero .principle b { font-size: 11px; }
  .game-cards { margin-top: 12px !important; gap: 10px; }
  .game-card { min-height: 0; padding: 14px; gap: 8px; }
  .game-card .gc-icon { font-size: 26px; }
}
