:root { color-scheme: dark; --ink: #eef2e9; --muted: #a3bdb2; --line: #ffffff20; --accent: #e2c58a; --card-width: 94px; --card-height: 136px; --step: 27px; --down-step: 15px; }
* { box-sizing: border-box; }
/* A stable scrollbar gutter and no scroll anchoring keep the felt in place. */
html { overflow-y: scroll; scrollbar-gutter: stable; overflow-anchor: none; }
body { margin: 0; color: var(--ink); background: #102e2a; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: radial-gradient(ellipse at 50% 20%, #235045 0%, #102e2a 75%); }
button, select { font: inherit; }
button { color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 8px 14px; font-size: 13px; cursor: pointer; background: #ffffff08; }
button:hover:enabled { background: #ffffff17; }
button:disabled { cursor: default; opacity: .38; }
button.primary { background: var(--accent); color: #1b3029; font-weight: 650; border-color: var(--accent); }
button.primary:hover { background: #efd7a8; }
button:focus-visible, summary:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.topbar { padding: 23px max(24px, calc((100vw - 1320px) / 2)); display: flex; justify-content: space-between; gap: 20px; align-items: center; background: #0c2522bb; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 15px; }
.brand-mark { color: var(--accent); font-size: 44px; line-height: 1; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .18em; color: var(--accent); }
h1 { font-size: 24px; font-weight: 600; line-height: 1.25; margin: 3px 0 0; letter-spacing: -.03em; }
h1 span { color: var(--muted); font-weight: 400; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.local-badge { color: var(--muted); font-size: 12px; margin-right: 12px; }
main { max-width: 1368px; padding: 28px 24px; margin: auto; }
.table-header { display: flex; gap: 24px; align-items: center; justify-content: space-between; min-height: 90px; }
.hand-info { min-width: 150px; }
.hand-info p { color: var(--muted); margin: 6px 0; font-size: 13px; }
.hand-info strong { color: var(--ink); font-weight: 550; }
.dot { margin: 0 8px; opacity: .5; }
.foundations { display: flex; gap: 7px; }
.foundation-area { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.deal-actions { display: flex; gap: 8px; }
.deal-actions button { min-height: 36px; padding: 7px 18px; }
.foundation-area #redeal { padding: 7px 18px; box-shadow: inset 0 1px #fff6, 0 3px 0 #8d774c, 0 4px 8px #0003; }
.foundation { width: 40px; height: 56px; border: 1px solid #ffffff24; border-radius: 5px; display: grid; place-items: center; color: #ffffff21; font-size: 23px; }
.foundation.complete { background: #f7f3e8; color: #172321; box-shadow: 0 2px 4px #0003; }
.foundation.complete.red { color: #ab2934; }
.stock { display: flex; align-items: center; font-size: 12px; }
.stock-fan { display: block; position: relative; width: 76px; height: 38px; flex: 0 0 76px; }
.stock-fan span { position: absolute; width: 22px; height: 31px; background: repeating-linear-gradient(45deg, #385c69 0 2px, #2a4958 2px 5px); border: 2px solid #e6e2d8; border-radius: 3px; top: 3px; box-shadow: 0 1px 2px #0006; transform-origin: center bottom; }
.stock-fan:empty::after { content: ""; position: absolute; width: 22px; height: 31px; top: 3px; left: 27px; border: 1px dashed #c4d0bd80; border-radius: 3px; }
#status { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
#status.error, #status.win, #status.notice { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; margin: 0 0 10px; padding: 10px 14px; font-size: 16px; color: #e9e0ff; background: #071e1980; border-radius: 7px; }
#status.error { color: #ffd7a2; } #status.win { color: var(--accent); }
.board-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px; margin: 0 -4px; }
#board { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 14px; min-width: 0; }
.column { position: relative; min-height: 370px; padding-top: 28px; }
.column-number { position: absolute; top: 0; left: 0; width: 100%; font-size: 10px; color: #adc5b3bb; display: block; text-align: center; line-height: 20px; }
.column::after { content: ""; position: absolute; left: 0; top: 28px; width: 100%; height: var(--card-height); border: 1px solid #ffffff21; border-radius: 6px; z-index: 0; background: #061e191c; pointer-events: none; }
.column.legal::after { border: 2px solid #ead79e; box-shadow: 0 0 18px #ead79e30; }
.column.over { background: #e2c58a12; border-radius: 6px; }
.card { position: absolute; left: 0; width: 100%; height: var(--card-height); border: 0; border-radius: 6px; padding: 0; background: #f6f3eb; box-shadow: 0 1px 3px #0005; overflow: hidden; user-select: none; -webkit-user-select: none; }
.card img { width: 100%; height: 100%; display: block; pointer-events: none; }
.card.dimmed::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .25); pointer-events: none; }
.card:disabled { opacity: 1; }
.card[aria-disabled=true] { opacity: 1; cursor: default; }
.card.movable { touch-action: none; cursor: grab; }
.card.movable:hover { filter: brightness(1.08); }
.card:focus-visible { outline-offset: 1px; outline: 3px solid var(--accent); z-index: 200 !important; }
.card.dragged { opacity: .15; }
.card.hinted { outline: 3px solid #b99aef; outline-offset: -3px; box-shadow: 0 0 0 2px #a47bd9, 0 0 16px #bc94ef80; }
.column.hint-source .column-number { color: #d2b8ff; font-weight: 800; }
.stock.stock-hinted { outline: 3px solid #c7a7ff; outline-offset: 3px; background: linear-gradient(#635079, #403252); box-shadow: 0 0 18px #c7a7ff70, inset 0 1px #ffffff35, 0 3px 0 #071f19; }
.drag-ghost { position: fixed; pointer-events: none; z-index: 1000; filter: drop-shadow(0 12px 13px #0007); }
.drag-ghost .card { width: 100%; }
footer { border-top: 1px solid var(--line); color: var(--muted); margin-top: 24px; padding-top: 15px; font-size: 12px; display: flex; flex-wrap: wrap; align-items: start; gap: 12px 28px; }
footer > p { margin: 0; margin-right: auto; } details { max-width: 560px; } summary { cursor: pointer; } details p { line-height: 1.7; } .history ol { max-height: 240px; overflow: auto; padding-left: 24px; } .history li { padding: 3px 0; }
dialog { border: 1px solid #526358; background: #142e29; color: var(--ink); border-radius: 14px; padding: 30px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 20px 80px #0009; }
dialog::backdrop { background: #041510bb; backdrop-filter: blur(3px); } h2 { margin: 10px 0; font-size: 25px; } dialog p { color: var(--muted); font-size: 13px; } dialog label { display: block; margin-top: 20px; font-size: 13px; } select { display: block; width: 100%; padding: 10px; margin-top: 7px; border-radius: 6px; border: 1px solid var(--line); background: #0e231e; color: var(--ink); } .check { display: flex; gap: 10px; align-items: center; } input[type=checkbox] { accent-color: var(--accent); } .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
@media (max-width: 850px) { .topbar { padding: 16px; }.local-badge { display: none; }main { padding: 18px 14px; }#board { gap: 7px; }.foundations { gap: 4px; }.foundation { width: 26px; height: 38px; font-size: 17px; }.table-header { gap: 12px; }.stock { flex-direction: column; gap: 5px; }.stock-fan { transform: scale(.8); height: 48px; }.hand-info { min-width: 125px; } }
@media (max-width: 550px) { .topbar { gap: 8px; }.brand { gap: 8px; }.brand-mark { font-size: 30px; }h1 { font-size: 18px; }h1 span { display: block; }.toolbar { gap: 5px; }button { padding: 8px 10px; }.foundations { flex-wrap: wrap; max-width: 120px; }.foundation { width: 24px; height: 31px; }.hand-info { min-width: 105px; }.hand-info p { font-size: 11px; }.dot { margin: 0 3px; }#status { min-height: 63px; }.stock { font-size: 10px; }footer { display: block; }footer > * { margin-bottom: 12px; } }
/* Setup is the entry screen; actions stay outside the tab panels. */
[hidden] { display: none !important; }
.gear { font-size: 23px; padding: 3px 12px; }
.settings-label, #table-menu, #compact-progress, #play-footer, #footer-deals { display: none; }
.table-tools { display: flex; flex-wrap: wrap; gap: 12px 50px; align-items: center; position: sticky; top: 0; z-index: 300; background: #12372ff2; border-radius: 8px; margin: 6px 0 10px; padding: 6px 10px; }
.table-actions { display: flex; gap: 8px; align-items: center; min-height: 54px; }
.auto-play-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
#auto-play-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.auto-play-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.auto-play-actions .table-button { min-height: 36px; padding: 7px 10px; font-size: 13px; white-space: nowrap; }
.table-button { min-height: 49px; background: linear-gradient(#436257, #2b4b40); border: 1px solid #80978a; box-shadow: inset 0 1px #ffffff24, 0 3px 0 #071f19, 0 4px 8px #0003; font-weight: 600; }
.table-button:hover:enabled { background: linear-gradient(#547768, #375d4f); }
.auto-play-actions .table-button[aria-pressed=true] { color: #132c23; background: linear-gradient(#f5dfab, #d8b974); border-color: #f3d891; box-shadow: 0 0 12px #e6c77f50, inset 0 1px #fff5, 0 3px 0 #071f19; }
.table-button:active:enabled, .foundation-area #redeal:active { transform: translateY(2px); box-shadow: inset 0 1px 3px #0004; }
.table-button:disabled { opacity: .55; }
.table-tools .stock { flex-direction: row; gap: 6px; }
.table-tools .stock-fan { transform: none; height: 38px; }
#deal-kind { color: var(--muted); font-size: 11px; }
#closed-screen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
#closed-screen p { color: var(--muted); max-width: 420px; }
#setup-dialog { padding: 0; width: min(960px, calc(100% - 32px)); max-width: 960px; max-height: calc(100dvh - 32px); overflow: hidden; }
#setup-dialog[open] { display: flex; flex-direction: column; }
.setup-layout { display: grid; grid-template-columns: 29% minmax(0, 1fr); min-height: 0; }
.setup-art { padding: 32px 24px 20px; background: linear-gradient(160deg, #234f40, #102b25); display: flex; flex-direction: column; align-items: flex-start; overflow: hidden; }
.setup-art h2 { font: 500 37px/1.1 Georgia, serif; letter-spacing: -.03em; margin: 17px 0 0; }
.setup-art h2 span { color: #c3cfb6; }
.setup-art p { font-size: 12px; margin: 15px 0 0; }
.setup-art svg { width: 100%; max-height: 310px; margin: 20px 0 8px; flex: 1; }
.art-caption { font-size: 10px; color: #baceb2; letter-spacing: .05em; align-self: center; margin-top: auto; text-align: center; }
.setup-content { min-width: 0; display: flex; flex-direction: column; }
.tabs { display: flex; padding: 16px 20px 0; border-bottom: 1px solid var(--line); flex-shrink: 0; overflow-x: auto; }
.tabs button { flex: 1; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 11px 8px; font-size: 12px; color: var(--muted); }
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.setup-panels { height: 490px; max-height: calc(100dvh - 205px); overflow-y: auto; padding: 30px; }
.setup-panels h3 { font-size: 25px; line-height: 1.2; letter-spacing: -.03em; font-weight: 550; margin: 10px 0 12px; }
.setup-panels h4 { font-size: 13px; color: var(--ink); margin: 24px 0 4px; }
.setup-panels p { line-height: 1.65; }
.setup-panels select { max-width: 330px; }
.setup-panels .check { margin: 22px 0 12px; font-size: 14px; }
.setup-panels input[type=checkbox] { width: 17px; height: 17px; flex-shrink: 0; }
.setting-group { margin: 20px 0; padding: 14px; border: 1px solid #a3bdb245; border-radius: 8px; background: #ffffff04; }
.setup-panels .setting-group .check { margin: 0; }
.setting-group p { margin: 10px 0 0; }
.animation-control { max-width: 330px; padding: 0 2px; }
.animation-control label { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }
.animation-control output { color: var(--accent); }
.animation-control input { width: 100%; margin: 12px 0 0; accent-color: #baa0dc; }
.animation-control input:disabled { opacity: .4; }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.stats-layout { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; margin-top: 22px; }
.stats-tabs { display: flex; flex-direction: column; gap: 5px; border-right: 1px solid var(--line); padding-right: 9px; }
.stats-tabs button { text-align: left; padding: 10px 8px; font-size: 12px; border: 0; white-space: nowrap; }
.stats-tabs button[aria-selected=true] { color: var(--accent); background: #e2c58a15; box-shadow: inset 3px 0 var(--accent); }
#stats-content { min-width: 0; }
#stats-content h4 { margin: 0 0 15px; font-size: 17px; }
.stats-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 20px; }
.stats-summary > div { padding: 14px; background: #0b241e; border: 1px solid var(--line); border-radius: 7px; }
.stats-summary dt { font-size: 11px; color: var(--muted); }
.stats-summary dd { margin: 5px 0 0; font-size: 26px; color: var(--ink); font-variant-numeric: tabular-nums; }
.stats-breakdown { overflow-x: auto; scrollbar-width: thin; margin-bottom: 20px; }
.stats-grid { width: 100%; min-width: 330px; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; margin-bottom: 20px; }
.stats-grid:last-child { margin-bottom: 0; }
.stats-grid caption { text-align: left; color: var(--accent); font-weight: 600; font-size: 13px; padding: 0 0 7px; }
.stats-grid th, .stats-grid td { padding: 8px 5px; border-bottom: 1px solid var(--line); text-align: right; }
.stats-grid th { font-weight: 500; }
.stats-grid thead { color: var(--muted); background: #ffffff05; }
.stats-grid th:first-child { text-align: left; }
.stats-grid tbody th { white-space: nowrap; }
.stats-rules { display: block; white-space: normal; font-size: 10px; color: var(--muted); }
.stats-clear-confirm { border: 1px solid #d4b48b66; border-radius: 7px; padding: 10px; margin-top: 10px; }
.stats-clear-confirm p { margin: 0 0 10px; }
#stats-message:empty { display: none; }
.setting-note { font-size: 12px !important; color: #a3b8ac; margin-top: 24px; }
.setting-note.rule-note { margin-top: 12px; }
.setup-actions { border-top: 1px solid var(--line); padding: 16px 24px; display: flex; align-items: center; gap: 16px; background: #102921; flex-shrink: 0; }
.setup-actions p { font-size: 12px; margin: 0; flex: 1; }
.setup-feedback { flex: 1; min-width: 0; }
.setup-feedback #exit-note { margin-top: 5px; }
.action-buttons { display: flex; gap: 8px; }
.action-buttons #play { min-width: 90px; }
#deal-filters { padding: 0; margin: 16px 0 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#deal-filters:disabled { opacity: .4; }
.filter-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.filter-grid th, .filter-grid td { text-align: left; padding: 7px 15px; border-bottom: 1px solid #ffffff0c; }
.filter-grid thead { background: #ffffff06; color: var(--muted); }
.filter-grid th { font-weight: 500; }
.filter-grid label { margin: 0; }
.filter-grid select { padding: 5px 8px; margin: 0; min-width: 100px; }
.filter-grid tr:last-child > * { border-bottom: 0; }
.promo-mark { font: 44px Georgia, serif; color: var(--accent); letter-spacing: 12px; padding: 25px 0; }
.promo-mark span { color: #b5826d; }
#debug-info { white-space: pre-wrap; overflow-wrap: anywhere; color: #b8cabb; font-size: 11px; padding: 12px; background: #0d241f; border: 1px solid var(--line); border-radius: 5px; user-select: text; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
#celebration-dialog { width: min(760px, calc(100% - 20px)); max-width: 760px; max-height: calc(100dvh - 20px); padding: 14px; overflow: hidden; }
#celebration-dialog[open] { display: flex; flex-direction: column; }
#celebration-dialog > h2 { font-size: 16px; font-weight: 500; margin: 0 4px 12px; flex-shrink: 0; }
.celebration-scroll { overflow-y: auto; min-height: 0; }
#celebration-status { padding: 35px 20px; text-align: center; }
.celebration-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 12px; flex-shrink: 0; }
.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 18px; align-items: start; }
.table-layout.without-tape { grid-template-columns: minmax(0, 1fr); }
.move-tape { color: #463e30; background: #e9dec4; border-radius: 8px 8px 3px 3px; box-shadow: 0 6px 16px #0004; border: 1px solid #c2b392; overflow: hidden; }
.tape-heading { padding: 11px 13px 8px; background: #d9cdad; border-bottom: 2px solid #ad9b76; box-shadow: inset 0 1px #fff8; }
.tape-heading h2 { font: 600 12px/1.4 system-ui,sans-serif; text-transform: uppercase; letter-spacing: .13em; margin: 0 0 9px; }
.tape-modes { display: flex; justify-content: space-between; gap: 10px; padding: 0; margin: 0; border: 0; font-size: 12px; }
.tape-modes label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.tape-modes input { accent-color: #34594c; margin: 0; color-scheme: light; }
#tape-summary { font: 11px/1.4 system-ui,sans-serif; margin: 7px 0 0; }
#tape-scroll { height: 480px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #aa9c7c #e0d5ba; scrollbar-width: thin; }
#tape-scroll:focus-visible { outline: 2px solid #456b58; outline-offset: -2px; }
#tape-paper { position: relative; min-height: 480px; background: repeating-linear-gradient(transparent 0 23px, #98866425 23px 24px); }
#tape-paper::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 5px; background: radial-gradient(circle, #12372f80 2px, transparent 2.5px) center 0 / 5px 24px; }
#tape-rows { position: absolute; top: 0; left: 0; width: 100%; list-style: none; padding: 0 4px 0 14px; margin: 0; font: 11.5px/24px ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; white-space: pre; }
#tape-rows li { height: 24px; }
#tape-rows li:last-child[data-latest] { color: #203e30; font-weight: bold; }
#tape-empty { padding: 27px 18px; margin: 0; color: #81745c; font: italic 13px/1.8 Georgia,serif; }
.tape-key { margin: 0; border-top: 1px dashed #a99b7a; padding: 9px 12px; font-size: 10px; line-height: 1.7; background: #e1d5b8; }
@media (max-width: 1000px) { .table-layout { grid-template-columns: minmax(0, 1fr); }.move-tape { width: min(100%, 180px); justify-self: end; }.table-layout { gap: 18px; } }
@media (max-width: 650px) {
    .auto-play-actions .table-button { min-height: 40px; font-size: 12px; padding: 7px 9px; }
    .table-actions { justify-content: space-between; }
    #setup-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
    .setup-layout { display: flex; flex-direction: column; }
    .setup-art { position: relative; padding: 18px 22px; min-height: 119px; flex-shrink: 0; }
    .setup-art h2 { font-size: 29px; margin: 6px 0 0; }.setup-art h2 br { display: none; }.setup-art h2 span { margin-left: 6px; }
    .setup-art p { margin: 7px 0 0; }.setup-art svg { position: absolute; right: 4px; top: -30px; width: 100px; height: 160px; margin: 0; opacity: .75; }.art-caption { display: none; }
    .tabs { padding: 0 8px; }.tabs button { font-size: 12px; padding: 11px 5px; }
    .setup-content { min-height: 0; }.setup-panels { padding: 21px; height: 420px; max-height: calc(100dvh - 299px); }
    .setup-panels h3 { font-size: 23px; }.setup-panels .eyebrow { font-size: 9px; }
    .setup-actions { padding: 12px; flex-direction: column; align-items: stretch; gap: 10px; }.setup-actions p { font-size: 11px; }
    .action-buttons { display: grid; grid-template-columns: .7fr .9fr 1.5fr 1.2fr; gap: 5px; }.action-buttons button { padding: 9px 5px; font-size: 12px; }.action-buttons #play { min-width: 0; }
    .stats-layout { grid-template-columns: 57px minmax(0, 1fr); gap: 9px; }.stats-tabs { padding-right: 4px; }.stats-tabs button { padding: 10px 5px; }
    .stats-summary > div { padding: 10px; }.stats-summary dd { font-size: 23px; }
}
#status { min-height: 0; }
@media (max-width: 550px) {
    .deal-actions #redeal, .deal-actions #same-deal { padding: 7px 10px; font-size: 12px; }
    .stats-breakdown { overflow-x: visible; }
    .stats-grid { display: block; min-width: 0; }
    .stats-grid caption, .stats-grid tbody { display: block; }
    .stats-grid thead { display: none; }
    .stats-grid tbody tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 5px; margin: 0 0 8px; background: #0b241e; }
    .stats-grid tbody th { grid-column: 1 / -1; white-space: normal; padding: 7px; }
    .stats-grid td { min-width: 0; padding: 6px; font-size: 12px; border: 0; text-align: left; }
    .stats-grid td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 9px; margin-bottom: 3px; }
}

/* The table and its controls keep the same order at every viewport size.
   Only the optional tape moves between the sidebar and a footer popup. */
html { overflow: hidden; scrollbar-gutter: auto; }
#game-shell { height: 100dvh; overflow: hidden; }
main { width: 100%; height: 100%; max-width: 1368px; padding: max(4px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); display: flex; flex-direction: column; }
.table-layout { flex: 1; min-height: 0; align-items: stretch; overflow: hidden; }
.board-scroll { height: 100%; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #64897c #102e2a; }
.board-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table-layout > .move-tape { min-height: 0; display: flex; flex-direction: column; }
.table-layout > .move-tape #tape-scroll { flex: 1; min-height: 0; height: auto; }
#play-footer { display: block; flex: 0 0 auto; position: relative; z-index: 300; min-width: 0; margin: 0; padding: 4px 0 calc(5px + env(safe-area-inset-bottom)); background: #102e2a; border-top: 1px solid var(--line); }
#play-footer > * { margin: 0; }
.table-tools { position: static; width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 7px; min-height: 28px; margin: 0; padding: 0; border-radius: 0; background: transparent; }
.table-tools > * { flex: 0 0 auto; }
.table-actions { min-height: 28px; gap: 4px; }
.table-tools .table-button, .table-tools .primary { min-height: 28px; padding: 3px 7px; font-size: 11px; white-space: nowrap; }
.table-tools .stock { gap: 0; padding-left: 3px; }
.table-tools .stock-fan { width: 46px; flex-basis: 46px; height: 20px; transform: scale(.6); transform-origin: left center; }
#stock-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
#footer-deals { display: flex; }
#footer-deals .deal-actions { gap: 5px; }
#compact-progress { display: flex; flex-direction: column; min-width: 58px; font-size: 10px; line-height: 1.5; font-variant-numeric: tabular-nums; color: var(--muted); }
#compact-series { color: var(--accent); }
#table-menu { display: block; }
#table-menu.auto-running { color: #132c23; background: var(--accent); }
#play-footer .auto-play-actions { flex-wrap: nowrap; gap: 6px; }
#play-footer #auto-play-label { font-size: 11px; }
#play-footer .auto-play-buttons { flex-wrap: nowrap; gap: 4px; }
#play-footer .auto-play-buttons button { min-height: 28px; padding: 3px 6px; font-size: 10px; }
#play-footer .foundations { gap: 2px; flex-wrap: nowrap; max-width: none; }
#play-footer .foundation { width: 13px; height: 21px; font-size: 12px; }
#play-footer .hand-info { min-width: 0; white-space: nowrap; line-height: 1.4; }
#play-footer .hand-info .eyebrow { font-size: 8px; letter-spacing: .08em; }
#play-footer .hand-info p { display: none; }
#play-footer #deal-kind { display: block; font-size: 9px; }
#footer-tape { display: none; }
#play-footer .footer-panel { margin: 0; }
#play-footer .footer-panel > summary { min-height: 28px; padding: 5px 3px; color: var(--muted); font-size: 10px; white-space: nowrap; }
#play-footer .footer-panel > summary:hover, #play-footer .footer-panel[open] > summary { color: var(--accent); }
#play-footer .footer-panel-content { position: fixed; z-index: 360; right: max(12px, env(safe-area-inset-right)); bottom: calc(var(--play-footer-height, 82px) + 8px); width: min(250px, calc(100vw - 24px)); max-height: calc(100dvh - var(--play-footer-height, 82px) - 28px); overflow-y: auto; overscroll-behavior: contain; border-radius: 8px; box-shadow: 0 6px 24px #0008; background: #e9dec4; color: #463e30; white-space: normal; }
#play-footer .move-tape { width: 100%; }
#play-footer .tape-modes { justify-content: flex-start; gap: 22px; }
#play-footer .tape-modes label { margin-top: 0; }
#play-footer #tape-summary, #play-footer .tape-key { color: #463e30; }
#play-footer #tape-scroll { height: min(240px, 35dvh); }
#status.error, #status.win, #status.notice { position: fixed; z-index: 350; left: 50%; bottom: calc(var(--play-footer-height, 82px) + 8px); transform: translateX(-50%); width: max-content; max-width: min(540px, 90vw); max-height: 25dvh; overflow-y: auto; margin: 0; padding: 8px 14px; font-size: 12px; background: #071e19ed; box-shadow: 0 4px 16px #0005; pointer-events: none; }
.help-link { border: 0; background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; padding: 6px 0; font-size: 12px; }
#help-dialog { width: min(680px, calc(100% - 24px)); max-width: 680px; max-height: calc(100dvh - 24px); padding: 20px; }
#help-dialog[open] { display: flex; flex-direction: column; }
#help-dialog h2 { flex-shrink: 0; margin: 0 0 12px; font-size: 21px; }
#help-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 12px; font-size: 13px; line-height: 1.65; }
#help-content p { line-height: 1.65; }
#help-content h3 { margin: 28px 0 12px; color: var(--accent); font-size: 17px; }
#help-content h4 { margin: 20px 0 8px; font-size: 14px; }
.help-rules { list-style: none; margin: 12px 0; padding-left: 1.8em; }
.help-rules > li { position: relative; margin-bottom: 12px; }
.help-rules .rule-marker { position: absolute; right: calc(100% + .5em); white-space: nowrap; }
.help-actions { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.help-actions p { margin: 0; font-size: 11px; }
.help-actions button { white-space: nowrap; }

/* Compact spacing covers portrait phones as well as shallow landscape windows. */
@media (max-width: 1000px), (orientation: landscape) and (max-height: 600px) {
    .table-layout { display: block; }
    #board { gap: 6px; }
    .column { min-height: 0; padding-top: 16px; }
    .column::after { top: 16px; }
    .column-number { line-height: 12px; font-size: 9px; }
    #footer-tape { display: block; }
}
@media (max-width: 650px) {
    .setup-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); }
    .action-buttons { grid-column: 1 / -1; }
}
@media (max-width: 550px) {
    .table-tools { gap: 5px; }
    #play-footer .table-button, #play-footer .primary { font-size: 10px; padding: 3px 5px; }
    #play-footer .stock-fan { width: 46px; flex-basis: 46px; transform: scale(.6); }
    #play-footer .foundation { width: 11px; }
    #play-footer #auto-play-label { font-size: 10px; }
    #play-footer .auto-play-buttons button { padding: 3px 6px; font-size: 10px; }
    .tabs button, .action-buttons button { font-size: 11px; }
}

/* Compact labels keep a single control row on shallow screens. Full names
   remain in tooltips and accessible labels. Narrow portrait screens may wrap. */
.short-label { display: none; }
@media (max-width: 1050px) {
    .table-tools .wide-label { display: none; }
    .table-tools .short-label { display: inline; }
    #footer-overview { display: none; }
    #play-footer .auto-play-actions { gap: 4px; }
    #play-footer .auto-play-buttons { gap: 3px; }
    #play-footer .auto-play-buttons button { min-width: 28px; }
    #play-footer .foundation { width: 10px; height: 19px; font-size: 11px; }
}
@media (max-width: 700px) {
    main { padding-right: max(6px, env(safe-area-inset-right)); padding-left: max(6px, env(safe-area-inset-left)); }
    #board { gap: 3px; }
    #compact-progress { min-width: 0; flex-direction: row; gap: 6px; }
    #compact-progress span { font-size: 0; }
    #compact-progress span::after { content: attr(data-short); font-size: 10px; }
    #play-footer .table-button, #play-footer .primary { min-width: 28px; }
    .table-tools { gap: 4px 3px; }
    #play-footer .stock-fan { width: 40px; flex-basis: 40px; }
    #play-footer #auto-play-label { font-size: 10px; }
    #play-footer .foundation { width: 8px; font-size: 10px; }
}
@media (max-width: 550px) {
    #footer-foundations { order: 1; }
    #auto-play-actions, #compact-progress, #table-win-loss, #footer-tape, #table-menu { order: 2; }
}
@media (max-width: 600px) {
    .table-tools { column-gap: 2px; }
    #play-footer .table-button, #play-footer .primary, #play-footer .auto-play-buttons button { min-width: 24px; min-height: 26px; font-size: 9px; padding: 3px 4px; }
    #play-footer .stock-fan { width: 34px; flex-basis: 34px; transform: scale(.5); }
    #play-footer #auto-play-label { font-size: 9px; }
    #play-footer .auto-play-buttons, #footer-deals .deal-actions { gap: 2px; }
    #play-footer .foundations { gap: 1px; }
    #play-footer .foundation { width: 7px; font-size: 9px; }
    #compact-progress { gap: 4px; }
    #compact-progress span::after { font-size: 9px; }
    #table-win-loss { font-size: 9px; padding: 3px 4px; }
    #play-footer .footer-panel > summary { font-size: 9px; padding-left: 2px; padding-right: 2px; }
}
@media (max-width: 450px) {
    #board { gap: 2px; }
    .board-scroll { scrollbar-gutter: auto; }
    .card, .column::after { border-radius: 3px; }
}

/* Hidden controls overlay the table when revealed: no column reflow or jump. */
#play-footer.auto-hide-chrome, #play-header.auto-hide-chrome {
    position: fixed; left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right));
    z-index: 300; box-shadow: 0 0 14px #0008; transition: transform .14s ease, opacity .14s ease;
}
#play-footer.auto-hide-chrome { bottom: 0; padding-left: 6px; padding-right: 6px; }
#play-header.auto-hide-chrome { top: 0; }
.auto-hide-chrome.chrome-hidden { transform: translateY(110%); visibility: hidden; opacity: 0; pointer-events: none; }
#play-header.chrome-hidden { transform: translateY(-110%); }
.edge-reveal { position: fixed; z-index: 290; left: 0; right: 0; bottom: 0; width: 100%; height: calc(50px + env(safe-area-inset-bottom)); padding: 0; border: 0; border-radius: 0; background: transparent; touch-action: manipulation; }
.edge-reveal:hover:enabled { background: transparent; }
.edge-reveal span { position: absolute; bottom: max(3px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); padding: 1px 12px; border-radius: 8px 8px 0 0; background: #09241be6; color: var(--muted); font-size: 10px; }
.edge-reveal.expanded { height: calc(var(--play-footer-height, 0px) + 50px); }
.edge-reveal.expanded span { display: none; }
.edge-reveal.top-edge { top: 0; bottom: auto; height: 50px; }
.edge-reveal.top-edge span { top: 0; bottom: auto; }
#table-win-loss { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: #09241bf0; color: var(--ink); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#play-footer.auto-hide-chrome.chrome-hidden { transform: none; visibility: visible; opacity: 1; padding: 0; border: 0; background: transparent; box-shadow: none; }
#play-footer.chrome-hidden .table-tools > :not(#table-win-loss) { display: none !important; }
#play-footer.chrome-hidden .table-tools { min-height: 0; justify-content: flex-end; }
.sound-control { display: flex; align-items: center; gap: 15px; margin-top: 12px; }
.sound-control label { flex: 1; min-width: 0; margin: 0; max-width: 290px; }
.sound-control output { float: right; color: var(--accent); }
.sound-control input { display: block; width: 100%; margin: 10px 0 0; accent-color: #baa0dc; }
.sound-control button { white-space: nowrap; }
.setup-panels .setting-group .check + .check { margin-top: 12px; }
.sound-options h4 { margin: 0 0 14px; }
@media (prefers-reduced-motion: reduce) { .auto-hide-chrome { transition: none !important; } }
@media (orientation: landscape) and (max-height: 600px) {
    #setup-dialog { width: min(960px, calc(100% - 24px)); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
    .setup-layout { flex: 1; display: block; min-height: 0; }
    .setup-art { display: none; }
    .setup-content { height: 100%; min-height: 0; }
    .tabs { padding: 0 12px; }
    .tabs button { min-height: 36px; padding: 7px 8px; }
    .setup-panels { flex: 1; height: auto; max-height: none; min-height: 0; padding: 16px 24px; }
    .setup-actions { display: flex; padding: 7px 12px; gap: 10px; flex-direction: row; align-items: center; }
    .setup-actions p { font-size: 11px; }
    .action-buttons { display: flex; gap: 6px; flex-shrink: 0; }
    .action-buttons button { min-height: 36px; padding: 6px 9px; font-size: 11px; }
}
