/* Phone layout (body.phone, .phone-portrait, .phone-landscape, set by common.js): where things go on a
   phone held upright or sideways. Shared looks are in style.css. */

body.phone .home-logo img { width: 34px; height: 34px; }
body.phone header .title img { width: 30px; height: 30px; }
body.phone-landscape header .title img { width: 24px; height: 24px; }
body.phone header .gm-long { display: none; }
body.phone header .gm-short { display: inline; }
body.phone-portrait .waiting-start { white-space: normal; max-width: 10em; text-align: center; }
body.phone .voice-wrap { gap: 0.3rem; }
body.phone .chat-mic { display: none !important; }
/* Phones held upright, and phones held sideways */
/* (was @media (max-width: 700px), (max-height: 500px) and (orientation: landscape); now a class set by table.js so a keyboard can't switch layouts) */
body.phone .phone-only { display: inline-flex !important; }
body.phone .desktop-only { display: none !important; }
/* one-row header, clear of the notch */
  body.phone header {
    flex-wrap: nowrap;
    gap: 0.3rem;
    padding: calc(0.35rem + env(safe-area-inset-top)) calc(0.5rem + env(safe-area-inset-right)) 0.35rem calc(0.5rem + env(safe-area-inset-left));
  }
body.phone header .title { font-size: 0.95em; flex: none; }
body.phone header .header-info { min-width: 0; font-size: 0.85em; }
body.phone header .header-sub, body.phone #game-mode { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.phone header .gear-btn { width: 2.75rem; height: 2.75rem; flex: none; padding: 0; }
body.phone .sound-pop { position: fixed; top: calc(var(--header-h, 52px) + 0.4rem); left: 0.5rem; right: 0.5rem; justify-content: space-between; }
body.phone .sound-pop input[type=range] { flex: 1; width: auto; }
/* Pause / Leave / Away live in the ☰ menu */
  body.phone .top-bar { display: none !important; }
body.phone .menu-wrap { position: relative; }
body.phone .menu-sheet {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 80;
    width: min(18rem, calc(100vw - 1rem));
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.4rem;
    background: rgba(26, 33, 41, 0.97);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
body.phone .menu-sheet[hidden] { display: none !important; }
body.phone .menu-sheet .icon-btn {
    box-sizing: border-box;
    text-decoration: none;
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    min-height: 48px;
    padding: 0.55rem 0.8rem;
    background: transparent;
    border: 0;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
  }
body.phone .menu-sheet .icon-btn svg { width: 1.45em; height: 1.45em; flex: none; }
body.phone .menu-sheet .icon-btn:active { background: rgba(255, 255, 255, 0.08); }
body.phone .menu-sheet > span { padding: 0.4rem 0.8rem; color: var(--muted); font-size: 0.9em; }
/* bottom area: action buttons (and Start game); the chat slides up from the bottom */
  body.phone .bottom-row { grid-template-columns: 1fr; gap: 0.4rem; padding: 0 0.5rem calc(0.4rem + env(safe-area-inset-bottom)); }
body.phone .bottom-row .action-bar { grid-row: auto; grid-column: 1; }
body.phone .start-slot { grid-column: 1; justify-content: center; }
body.phone .bottom-row .chat {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    grid-row: auto;
    border-radius: 14px 14px 0 0;
    padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
    background: rgba(26, 33, 41, 0.98);
    transform: translateY(110%);
    transition: transform 0.2s ease;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  }
body.phone.chat-open .bottom-row .chat { transform: none; }
body.phone .chat-head { display: flex !important; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
body.phone .chat-messages { height: 35vh; }
body.phone .chat-form button { min-height: 44px; }
body.phone .chat-form .emoji-btn { min-width: 44px; }
body.phone .chat-head .dialog-x { width: 44px; height: 44px; margin: -0.4rem -0.4rem -0.4rem 0; }
/* action buttons: compact 3-column grid with finger-sized buttons */
  body.phone .action-bar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem; padding: 0.3rem 0; }
body.phone .action-bar:not(:has(.raise)) { grid-template-columns: 1fr 1fr; }
body.phone .action-bar .raise { display: contents; }
body.phone .action-bar .presets { grid-column: 1 / -1; display: flex; gap: 0.3rem; }
body.phone .action-bar .presets button { flex: 1; min-height: 40px; padding: 0; font-size: 0.85em; }
body.phone #raise-slide { grid-column: 1 / 3; width: 100%; min-height: 40px; }
body.phone #raise-input { grid-column: 3; width: 100%; min-height: 40px; padding: 0.3em 0.5em; }
body.phone .action-bar:has(.raise) > [data-act] { grid-row: 3; }
body.phone #raise-btn { grid-row: 3; grid-column: 3; }
body.phone .action-bar > button, body.phone #raise-btn { min-width: 0; min-height: 48px; padding: 0.3em 0.4em; font-size: 1rem; }
body.phone .show-panel { width: 100%; }
body.phone .show-panel button { min-height: 44px; }
/* table and panels */
  body.phone .seat { width: 8.6em; }
/* hand log: a sheet from the bottom over the betting buttons, like the chat */
  body.phone .log-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    z-index: 70;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(26, 33, 41, 0.98);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  }
body.phone .log-panel #log { height: 35vh; flex: none; }
/* phones: a compact strip at the top, under the header (clear of the table and buttons) */
  body.phone .outs-panel {
    position: fixed;
    top: calc(var(--header-h, 52px) + 0.35rem);
    bottom: auto;
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    z-index: 30;
    gap: 0.3rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }
body.phone .outs-title { margin-bottom: 0.2rem; }
body.phone .outs-note { display: none; }
/* one row: title on the left, cards scroll sideways when there are many */
  body.phone .outs-block { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
body.phone .outs-title { margin: 0; flex: none; max-width: 40%; font-size: 0.75rem; line-height: 1.2; }
body.phone .outs-cards { flex-wrap: nowrap; overflow-x: auto; gap: 0.12rem; min-width: 0; scrollbar-width: none; }
body.phone .outs-cards .card.mini { flex: none; font-size: 0.55rem; width: 1.45rem; height: 2rem; border-radius: 0.18rem; }
body.phone-landscape .outs-panel { left: auto; width: min(16rem, 40vw); }
body.phone .start-slot .start-btn { min-height: 48px; }
/* Phones held sideways: table on the left, action buttons in a column on the right */
/* (was @media (max-height: 500px) and (orientation: landscape); now a class set by table.js so a keyboard can't switch layouts) */
body.phone-landscape .main { flex-direction: row; }
body.phone-landscape .bottom-row { width: min(17rem, 38vw); align-content: center; padding-right: calc(0.5rem + env(safe-area-inset-right)); }
body.phone-landscape .table-area { padding-left: env(safe-area-inset-left); }
body.phone-landscape .board { --card-scale: 1.65; }
/* Phones: page height is locked (keyboards open over it); the panel you type in lifts above the keyboard. */
/* (was @media (max-width: 700px), (max-height: 500px) and (orientation: landscape); now a class set by table.js so a keyboard can't switch layouts) */
body.phone.table-page { height: var(--app-h, 100dvh); }
body.phone .bottom-row .action-bar {
    position: relative;
    z-index: 60;
    transform: translateY(calc(-1 * var(--kb, 0px)));
    transition: transform 0.15s ease;
  }
body.phone.kb-open .bottom-row .action-bar:focus-within {
    background: var(--panel);
    border-radius: 6px;
    /* a frame drawn with shadows: the bar keeps its exact size, so nothing behind it moves */
    box-shadow: 0 0 0 0.45rem var(--panel), 0 -6px 24px 0.45rem rgba(0, 0, 0, 0.5);
  }
body.phone.chat-open .bottom-row .chat { transform: translateY(calc(-1 * var(--kb, 0px))); }
/* Phones: Host controls are opened from the ☰ menu instead of a gear in the header */
body.phone .gear-wrap { display: none !important; }
body.phone .menu-sheet .badge { margin-left: auto; }
/* Phones: Host controls (like the chat sheet) are almost solid and sit above the betting buttons */
body.phone .drawer { z-index: 75; background: rgba(26, 33, 41, 0.98); }
body.phone .below-board .show-panel button { min-height: 40px; }
body.phone .seat .cards.four .card:not(:first-child) { margin-left: -1.45em; }
body.phone .action-bar .show-panel { grid-column: 1 / -1; width: 100%; }
body.phone #actions:not(.raise-open) > button { grid-row: 1; }
/* Phones: the raise options open on top of the table's bottom edge, so the table never moves */
body.phone .bottom-row .action-bar { position: relative; }
body.phone #actions.raise-open::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  right: -0.5rem;
  bottom: calc(100% - 0.3rem);
  height: calc(40px + 40px + 1.6rem);
  background: rgba(15, 20, 25, 0.96);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.45);
}
body.phone #actions.raise-open .presets { position: absolute; left: 0; right: 0; bottom: calc(100% + 40px + 0.8rem); z-index: 1; }
body.phone #actions.raise-open #raise-slide { position: absolute; left: 0; width: calc(66% - 0.3rem); bottom: calc(100% + 0.35rem); z-index: 1; }
body.phone #actions.raise-open #raise-input { position: absolute; right: 0; width: 33%; bottom: calc(100% + 0.35rem); z-index: 1; }
body.phone #actions.raise-open > button,
body.phone #actions.raise-open #raise-btn { grid-row: 1; }
body.phone #actions.raise-open #raise-slide,
body.phone #actions.raise-open #raise-input,
body.phone #actions.raise-open .presets { grid-column: 1 / -1; grid-row: 1; }
body.phone #actions.raise-open #raise-input { width: 32%; }
/* ======= Phones held sideways v2: table fills the screen (Poker Now style) ======= */
/* header floats over the top edge instead of taking a row */
body.phone-landscape header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 45;
  background: transparent;
  border: 0;
  padding: calc(0.15rem + env(safe-area-inset-top)) calc(0.4rem + env(safe-area-inset-right)) 0 calc(0.5rem + env(safe-area-inset-left));
  pointer-events: none;
}
body.phone-landscape header > * { pointer-events: auto; }
body.phone-landscape header .gear-btn { width: 2rem; height: 2rem; }
body.phone-landscape header .header-info { font-size: 0.68em; }
body.phone-landscape header .title { font-size: 0.8em; }
body.phone-landscape .menu-sheet, body.phone-landscape .sound-pop { z-index: 90; }
/* the table gets the whole screen except a narrow column on the right for the buttons */
body.phone-landscape .main { position: relative; flex-direction: column; }
body.phone-landscape .table-area { padding: 0 calc(92px + env(safe-area-inset-right)) 0 env(safe-area-inset-left); }
body.phone-landscape #table {
  width: min(100cqw - 0.5rem, (100cqh - 2.6em) * 2.3);
  aspect-ratio: 2.3 / 1;
  margin: 1.8em 0 0.8em;
  font-size: clamp(7px, min(100cqw / 62, 100cqh / 25), 13px);
}
body.phone-landscape .board { --card-scale: 1.3; }
body.phone-landscape .seat { width: 6.6em; }
body.phone-landscape .plate { padding: 0.15em 0.3em 0.45em; border-radius: 0.5em; }
body.phone-landscape .name { font-size: 0.82em; }
body.phone-landscape .card.small { font-size: 0.95em; }
body.phone-landscape .seat .cards { height: calc(3.5em * 0.95); margin-bottom: -0.8em; }
/* buttons: small, stacked in the bottom-right corner */
body.phone-landscape .bottom-row {
  position: absolute;
  right: calc(0.4rem + env(safe-area-inset-right));
  bottom: calc(0.4rem + env(safe-area-inset-bottom));
  width: 84px;
  padding: 0;
  display: block;
}
body.phone-landscape #actions:not(:has(.show-panel)) { grid-template-columns: 84px; gap: 0.3rem; align-content: end; position: relative; }
/* raise options pop up to the left of the buttons */
body.phone-landscape #actions.raise-open::before {
  display: block;
  content: '';
  position: absolute;
  right: calc(100% + 0.3rem);
  bottom: 0;
  left: auto;
  width: 262px;
  height: 84px;
  background: rgba(15, 20, 25, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
body.phone-landscape #actions.raise-open .presets { position: absolute; right: calc(100% + 0.55rem); bottom: 44px; width: 250px; display: flex; gap: 0.2rem; z-index: 1; }
body.phone-landscape #actions.raise-open :is(.presets, #raise-slide, #raise-input) { left: auto; }
body.phone-landscape #actions.raise-open .presets button { flex: 1; min-height: 32px; font-size: 11px; padding: 0; }
body.phone-landscape #actions.raise-open #raise-slide { position: absolute; right: calc(100% + 5.6rem); bottom: 10px; width: 160px; z-index: 1; }
body.phone-landscape #actions.raise-open #raise-input { position: absolute; right: calc(100% + 0.55rem); bottom: 6px; width: 76px; min-height: 30px; z-index: 1; }
/* upright phones stack the Start button under the bar: there the Start button takes the room instead */
body.phone-portrait .bottom-row:has(.start-btn) #actions.idle-hidden { display: none; }
/* phones held upright: one row of up to 4 columns, Check/Fold above Fold */
body.phone #actions#actions > *, body.phone #actions#actions .raise > * { grid-row: auto; grid-column: auto; }
body.phone-portrait #actions#actions { --bw: 84px; --bh: 46px; --gap: 0.35rem; --slot: calc(var(--bh) + var(--gap)); }
body.phone-portrait #actions#actions:not(:has(.show-panel)) {
  grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: var(--bw); justify-content: center; align-items: end; gap: var(--gap);
}
body.phone-portrait #actions#actions > button, body.phone-portrait #actions#actions .fold-col > button, body.phone-portrait #actions#actions #raise-btn { font-size: 14px; }
/* the raise options start right above the buttons (the empty Check/Fold slot is covered) */
body.phone-portrait #actions.raise-open::before { bottom: calc(100% - var(--slot) - 0.3rem); }
body.phone-portrait #actions.raise-open .presets { bottom: calc(100% - var(--slot) + 40px + 0.8rem); }
body.phone-portrait #actions.raise-open #raise-slide,
body.phone-portrait #actions.raise-open #raise-input { bottom: calc(100% - var(--slot) + 0.35rem); }
/* phones held sideways: one column at the bottom right */
body.phone-landscape #actions#actions { --bw: 84px; --bh: 34px; --gap: 0.25rem; }
body.phone-landscape #actions#actions:not(:has(.show-panel)) { grid-template-columns: var(--bw); grid-auto-flow: row; gap: var(--gap); }
body.phone-landscape #actions .fold-col { display: contents; }
body.phone-landscape #actions .cf-slot { display: none; }
body.phone-landscape #actions [data-pre="checkfold"] { order: -1; }
body.phone-landscape #actions#actions > button, body.phone-landscape #actions#actions .fold-col > button, body.phone-landscape #actions#actions #raise-btn { font-size: 13px; }
body.phone .felt { --armrest: 1.05em; --track: 0.55em; }
body.phone-landscape .seat { --cards-overlap: 0.8em; }
body.phone-landscape .action-bar .show-panel { width: 84px; gap: 0.25rem; }
/* one button column wide */
body.phone-landscape .action-bar .show-panel button { min-height: 34px; padding: 0; font-size: 13px; }
body.phone-landscape .action-bar .show-panel .show-one { font-size: 15px; }
body.phone-landscape .action-bar .show-panel.four { grid-template-columns: 1fr 1fr; }
/* Omaha: 2 x 2 cards */
body.phone-landscape .action-bar .show-panel.four .show-one { font-size: 13px; }
/* phones held upright (chat hidden): the show-card buttons stay on the right, two buttons wide */
body.phone-portrait #actions:has(.show-panel) { display: flex; justify-content: flex-end; }
body.phone-portrait .action-bar .show-panel { width: calc(2 * 84px + 0.35rem); gap: 0.35rem; }
body.phone-portrait .action-bar .show-panel button { min-height: 46px; }
body.phone #actions button[data-key]::after, body.phone .rabbit-btn[data-key]::after { display: none; }
body.phone .plate .rebuy-badge { font-size: 0.62em; right: 0.6em; }
body.phone .plate:has(.hand-name) .rebuy-badge { bottom: -1.25em; }
body.phone .join-row input { font-size: 16px; }
/* Raise options cover only Bet/Raise, Check and Call (table.js sets --rp-left / --rp-width / --rp-right),
   so the Time Bank or Check/Fold button above Fold stays free. Presets: Min, ½ Pot, Pot, All-in. */
body.phone-portrait #actions.raise-open::before { left: calc(var(--rp-left) - 0.35rem); right: auto; width: calc(var(--rp-width) + 0.7rem); border-radius: 14px; }
body.phone-portrait #actions.raise-open .presets { left: var(--rp-left); right: auto; width: var(--rp-width); display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; }
body.phone-portrait #actions.raise-open .presets button { min-width: 0; padding: 0; font-size: 12px; white-space: nowrap; }
body.phone-portrait #actions.raise-open #raise-slide { left: var(--rp-left); width: calc(var(--rp-width) * 0.72 - 0.3rem); }
body.phone-portrait #actions.raise-open #raise-input { left: calc(var(--rp-left) + var(--rp-width) * 0.72); right: auto; width: calc(var(--rp-width) * 0.28); }
/* Phones held sideways: hole cards that sit higher on the name box, so rank and suit both show */
body.phone-landscape .seat { --cards-overlap: 0.35em; }
/* sideways phones have a very short table: a little smaller there so the bets still fit */
body.phone-landscape .card.small { font-size: 1.1em; }
body.phone-landscape .seat .cards { height: calc(3.5em * 1.1); }
/* phones held sideways: a small line at the top of the button column */
body.phone-landscape #actions .your-turn { position: static; order: -2; width: auto; height: 18px; font-size: 11px; letter-spacing: 0.08em; }
/* ======= Phones held upright: the table =======
   This is the one place that sizes the upright-phone table. The table box fills the space between the
   header and the buttons; the felt fills the box, leaving room above for the top seat's cards and below for
   your own seat's labels. The ends are rounded but not half circles, so the table uses the whole screen.
   Seats sit in fixed rows (table.js portraitSeat): you at the bottom, one seat at the top, four on each
   side; the board sits between the side seats and gets as big as fits there (table.js fitTableContents). */
body.phone-portrait #table#table {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  margin: 0;
  font-size: clamp(10px, min(3.4vw, var(--app-h, 100vh) * 0.0158), 17px); /* from the width, and smaller on short phones */
}
/* (no smaller seats for 8+ players: the same sizes, so the seats never shift when someone sits down) */
body.phone-portrait .felt {
  inset: 5.2em 0.3em 3.4em;
  --armrest: 0.9em;
  --track: 0.45em;
  --felt-r: 34cqw; /* about a third of the table's width: rounded ends, not half circles */
  border-radius: var(--felt-r);
}
body.phone-portrait .felt::before { border-radius: max(0px, calc(var(--felt-r) - var(--armrest) - var(--track))); }
body.phone-portrait .rail-stitch { border-radius: max(0px, calc(var(--felt-r) - var(--armrest))); }
body.phone-portrait .felt-line { inset: calc(var(--track) + 1em); border-radius: max(0px, calc(var(--felt-r) - var(--armrest) - var(--track) - 1em)); }
/* seats: narrow name boxes, so the board has room between the side seats */
body.phone-portrait .seat { width: 5.8em; --cards-overlap: 0.35em; }
body.phone-portrait .plate { padding: 0.15em 0.3em 0.45em; border-radius: 0.5em; }
body.phone-portrait .name { font-size: 0.82em; }
body.phone-portrait .stack { font-size: 0.9em; }
body.phone-portrait .card.small { font-size: 1.15em; }
body.phone-portrait .seat .cards { height: calc(3.5em * 1.15); }
/* the board starts big; table.js makes it as big as fits between the side seats */
body.phone-portrait .board { --card-scale: 1.6; }
/* the start page's made-up game doesn't resize its board like a game does: a fixed size that fits */
body.home-table.phone-portrait .board { --card-scale: 1.1; }
/* voice badge: on phones the hole cards cover the name box's top corners, so it sits on the bottom-left one */
body.phone .plate .voice-badge { top: auto; bottom: -0.55em; }

/* ======= Phones held upright: the table never changes size =======
   The buttons are a strip laid over the bottom of the page instead of a row under the table: the table
   area always reaches from under the header to the top of a one-button-row strip, whatever the buttons
   do. Anything taller than one row (Check/Fold or Time Bank above Fold, the raise options, the show-card
   buttons, Start game) grows upward over the table. Seats (fixed rows), the board (fixed spot, table.js
   portraitBoard) and every card spot therefore stay put. */
body.phone-portrait { --strip: calc(46px + 1rem + 22px + env(safe-area-inset-bottom)); } /* one button row + the "Your turn" line */
body.phone-portrait .main { position: relative; }
body.phone-portrait:not(.home-table) .table-area { padding-bottom: var(--strip); } /* (the start page has no buttons) */
body.phone-portrait .bottom-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  pointer-events: none; /* the empty parts let taps through to the table */
}
body.phone-portrait .bottom-row :is(button, input, a, .raise, .show-panel, .chat) { pointer-events: auto; }
body.phone-portrait .bottom-row .action-bar { pointer-events: none; }
/* the text under the board stays between the side seats (table.js sets --corridor) */
body.phone-portrait .below-board { max-width: var(--corridor, 100%); }
body.phone-portrait .below-board .results { white-space: normal; }

/* Phones: smaller chips (every size in a pile is in em) */
body.phone .chips { font-size: 0.8em; }
/* "Your turn" on its own line at the top of the strip, so it never touches your name box */
body.phone-portrait #actions .your-turn { top: auto; bottom: calc(var(--bh) + 0.2rem); height: 20px; font-size: 13px; }
/* after a hand: the show-card buttons in one row (Show all, then each card), the height of the betting
   buttons, so they never cover the table */
body.phone-portrait #actions:has(.show-panel) { display: block; }
body.phone-portrait .action-bar .show-panel { display: flex; width: 100%; gap: 0.35rem; }
body.phone-portrait .action-bar .show-panel button { flex: 1; min-width: 0; min-height: 46px; padding: 0; }
body.phone-portrait .action-bar .show-panel .show-both { flex: 1.7; }
body.phone-portrait .action-bar .show-panel .show-one { font-size: 16px; }
