/* Couch-distance ("10-foot") sizes for the Kostos Game Night TV app. Only applies with html.tv-app,
   which tv.html / table.html set when the page is opened by the TV app (user agent KostosGameNightTV),
   or in any browser with ?big=1 (a laptop plugged into a TV). Computer and phone browsers keep the normal look.

   Numbers follow Microsoft's Xbox/TV guidance, on the 1920x1080 page the app lays out
   (Xbox apps run at 200%, so 1 Xbox "effective pixel" = 2 px here):
   - main text 15 epx minimum = 30px+, small/supporting text 12 epx = 24px+
   - anything you can select at least 32 epx tall = 64px+
   - keep text and buttons out of the outer 5%: 48 epx sides (96px) and 27 epx top/bottom (54px)
   - show about as much as a phone screen would, not a desktop's worth
   https://learn.microsoft.com/en-us/windows/apps/design/devices/designing-for-tv */

/* ---- The game picker (/tv) ---- */
html.tv-app .tv-picker { max-width: none; height: 100vh; box-sizing: border-box; padding: 34px 96px 54px; display: flex; flex-direction: column; }
html.tv-app .tv-picker .brand.big { font-size: 88px; margin: 0 0 18px; line-height: 1.1; }
html.tv-app .tv-join { justify-content: center; align-items: center; gap: 28px; padding: 20px 32px; margin: 0 0 8px; }
html.tv-app .tv-join .lbl { font-size: 32px; margin: 0; }
html.tv-app .tv-join .code-in { font-size: 52px; max-width: 300px; padding: 8px 18px; }
html.tv-app .tv-join .btn { font-size: 36px; min-height: 76px; padding: 12px 40px; }
html.tv-app .tv-picker .tv-shelf,
html.tv-app .tv-shelf .shelf-tier1,
html.tv-app .tv-shelf .shelf-tier2 { flex: 1; display: flex; flex-direction: column; }
html.tv-app .tv-shelf .shelf-h { font-size: 42px; margin: 22px 0 16px; }
html.tv-app .tv-shelf .shelf { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px; }
html.tv-app .tv-shelf .cat-row { flex: 1; min-height: 0; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: 1fr; }
html.tv-app .tv-shelf .tile { padding: 32px 36px; border-radius: 24px; }
html.tv-app .tv-shelf .tile b { font-size: 40px; }
html.tv-app .tv-shelf .tile small { font-size: 30px; line-height: 1.3; }
html.tv-app .tv-shelf .tile-icon { font-size: 88px; }
html.tv-app .tv-shelf .tile.cat { min-height: 0; align-content: center; justify-items: center; text-align: center; }
html.tv-app .tv-shelf .tile.cat .tile-icon { font-size: 130px; line-height: 1.1; }
html.tv-app .tv-shelf .tile.cat b { font-size: 46px; white-space: nowrap; }
html.tv-app .tv-shelf .recent-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Recently played: short tiles, icon beside the name, so the categories still fit below */
html.tv-app .tv-shelf .recent-row .tile { grid-template-columns: auto 1fr; align-items: center; column-gap: 24px; padding: 18px 80px 18px 28px; position: relative; }
html.tv-app .tv-shelf .recent-row .tile-icon { font-size: 64px; grid-row: span 2; }
html.tv-app .tv-shelf .shelf-back { font-size: 34px; min-height: 72px; padding: 12px 32px; }
html.tv-app .tv-picker .ht-q { width: 56px; height: 56px; font-size: 30px; }

/* The same shelf inside a room ("Change game", table.js): fills the space under the top bar. */
html.tv-app .tv-pick { height: calc(100vh - 108px - 86px); display: flex; flex-direction: column; }
html.tv-app .tv-pick .shelf-tier1 > .shelf-h:first-child,
html.tv-app .tv-pick .shelf-tier2 .shelf-bar { margin-top: 0; }

/* The TV's table-theme picker (table.js themeOpen): 13 scenes as big tiles, 5 across, names at TV size. */
html.tv-app .tv-themes { height: calc(100vh - 108px - 86px); display: flex; flex-direction: column; }
html.tv-app .tv-themes .shelf-h { font-size: 42px; margin: 0 0 20px; }
html.tv-app .tv-themes .theme-grid.tv { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px 28px; margin: 0; }
html.tv-app .tv-themes .theme-opt { padding: 10px; border-radius: 18px; gap: 8px; background: rgb(var(--panel-rgb) / .88); }
html.tv-app .tv-themes .theme-opt.on { background: rgb(var(--panel-rgb) / .96); }
html.tv-app .tv-themes .theme-opt .sw { border-radius: 12px; }
html.tv-app .tv-themes .theme-opt b { font-size: 30px; min-height: 0; }
html.tv-app .tv-themes .theme-opt.on { box-shadow: 0 0 0 5px var(--gold); }

/* ---- Shared bits on the room lobby (/table before a game). Only the lobby: game screens keep their own
   sizes and are scaled up as a whole (see "Game screens" below). ---- */
html.tv-app .tv-lobby { font-size: 30px; }
html.tv-app .tv-lobby .fine { font-size: 26px; }
html.tv-app .tv-lobby .lbl { font-size: 26px; margin-bottom: 12px; }
html.tv-app .tv-lobby .btn, html.tv-app .over-box .btn { font-size: 32px; min-height: 72px; padding: 12px 36px; border-radius: 18px; }
html.tv-app .tv-lobby .chip { font-size: 26px; min-height: 64px; padding: 8px 22px; }
html.tv-app .tv-lobby .panel { padding: 24px 30px; margin: 0 0 24px; border-radius: 24px; }
html.tv-app .toast { font-size: 32px; padding: 20px 32px; bottom: 54px; }
html.tv-app .icon-btn.ht-q { width: 64px; height: 64px; font-size: 34px; }

/* Top bar */
html.tv-app .tv-top { gap: 32px; padding: 24px 96px 20px; }
html.tv-app .tv-top .brand { font-size: 40px; }
html.tv-app .tv-top .top-game { font-size: 38px; }
html.tv-app .join-mini { font-size: 30px; }

/* Room lobby: join info (with a big QR) on the left, who's playing and what's next on the right */
html.tv-app .tv-main { max-width: none; padding: 32px 96px 48px; }
html.tv-app .tv-lobby { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 48px; align-items: start; }
html.tv-app .join-side { padding: 28px 30px 34px; margin: 0; }
html.tv-app .join-side .hand { font-size: 34px; }
html.tv-app .join-url { font-size: 56px; margin: 4px 0 14px; }
html.tv-app .join-side .room-code { font-size: 128px; line-height: 1.05; margin-bottom: 6px; }
/* The QR is drawn 220px; showing it at exactly 2x with hard pixels keeps every square crisp for phone cameras. */
html.tv-app .qr { padding: 20px; border-radius: 20px; margin-top: 8px; }
html.tv-app .qr canvas, html.tv-app .qr img { width: 440px !important; height: 440px !important; image-rendering: pixelated; }
html.tv-app .game-now.big { font-size: 60px; margin: 4px 0 12px; }
html.tv-app .game-now .tile-q, html.tv-app .game-now a { font-size: 30px; }
html.tv-app .setup-sum { font-size: 30px; padding: 14px 20px; border-radius: 14px; }
html.tv-app .rules-tag { font-size: 26px; margin-top: 18px; display: inline-block; vertical-align: middle; }
html.tv-app .change-game { margin: 18px 0 0 14px; vertical-align: middle; min-height: 64px; padding: 8px 18px; font-size: 26px !important; white-space: nowrap; }
html.tv-app .roster.big { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 28px; margin: 0; }
html.tv-app .roster.big .who { font-size: 34px; gap: 16px; min-width: 0; }
html.tv-app .roster.big .who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.tv-app .roster.big .face > svg, html.tv-app .roster.big .face > .face-fb { width: 64px !important; height: 64px !important; }
html.tv-app .roster.big .face > .face-fb { font-size: 34px !important; }
/* Under the panels: robot speed (label over chips) on the left, + Robot and Start beside it. */
html.tv-app .lobby-side { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 36px; align-content: start; }
html.tv-app .lobby-side > .panel { grid-column: 1 / -1; }
html.tv-app .lobby-side > .lbl { grid-column: 1; grid-row: 3; margin-bottom: 8px; }
html.tv-app .lobby-side > .seg { grid-column: 1; grid-row: 4; }
html.tv-app .lobby-side > .row { grid-column: 2; grid-row: 3 / span 2; align-self: end; }
html.tv-app .lobby-side:not(:has(> .seg)) > .row,
html.tv-app .lobby-side > .fine { grid-column: 1 / -1; grid-row: auto; }
html.tv-app .lobby-side > .row { gap: 24px; flex-wrap: nowrap; align-items: stretch; }
html.tv-app .lobby-side > .row .btn { margin: 0; }
html.tv-app .lobby-side > .row #startBtn { flex: 1; width: auto; font-size: 38px; }
html.tv-app .lobby-side .seg .chip { font-size: 26px; }

/* ---- Game screens (table.js fitTable) ----
   Each game's table is laid out at whichever width (960-2304px) lets it fill the space under the top bar best,
   then scaled to fit: short tables grow up to 1.8x, tall ones shrink just enough that nothing scrolls. Pop-ups,
   banners and spotlights live on <body>, outside the scaled box, so they are unaffected. */
html.tv-app .tv-main.playing { padding-bottom: 0; }
html.tv-app .tv-fit { position: relative; overflow: hidden; }
html.tv-app .tv-fit-in { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
html.tv-app .tv-fit-in > .table-view { margin-top: 0; }
/* Views that size themselves to the screen (100vh rules in werewolf.js, celebrity.js, dominoes.js) get the scaled box's
   own "screen" height instead, so they can be scaled up like the rest. */
html.tv-app .tv-fit-in .ww-tv, html.tv-app .tv-fit-in .cel-tv { min-height: var(--fit-h, 0px); }
html.tv-app .tv-fit-in .dm-tv { height: var(--fit-h, 600px); }
/* Own TV arrangements for the four games the generic fit couldn't make big (they're listed in table.js OWN_TV). */
/* Farkle: roller, dice and scoring rules on the left; the score sheet down the right. */
html.tv-app .tv-fit-in .f-table { grid-template-columns: minmax(min-content, 1.2fr) minmax(520px, 1fr); grid-template-areas: "roll pad" "tray pad" "rules pad"; column-gap: 28px; align-items: start; }
html.tv-app .tv-fit-in .f-table > .y-roller { grid-area: roll; }
html.tv-app .tv-fit-in .f-table > .f-tray { grid-area: tray; margin: 4px 0; }
html.tv-app .tv-fit-in .f-table > .f-pad-panel { grid-area: pad; margin: 0; }
html.tv-app .tv-fit-in .f-table > .f-rules { grid-area: rules; margin: 8px 0 0; max-width: none; }
html.tv-app .tv-fit-in .f-table > :not(.y-roller):not(.f-tray):not(.f-pad-panel):not(.f-rules) { grid-column: 1 / -1; }
html.tv-app .tv-fit-in .f-pad.tv .f-pad-scroll { height: 400px; }
/* Spite & Malice and Ten Phases: player boards flow across as many columns as fit (the fit search picks the width),
   and the end-of-hand results sit beside the piles instead of under everything. */
html.tv-app .tv-fit-in .sm-table.tv .sm-boards { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); }
html.tv-app .tv-fit-in .tp-table.tv .tp-boards { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); }
html.tv-app .tv-fit-in :is(.sm-table, .tp-table).tv:has(> .hand-over) { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
html.tv-app .tv-fit-in :is(.sm-table, .tp-table).tv:has(> .hand-over) > * { grid-column: 1 / -1; }
html.tv-app .tv-fit-in :is(.sm-table, .tp-table).tv:has(> .hand-over) > :first-child { grid-column: 1; grid-row: 1; }
html.tv-app .tv-fit-in :is(.sm-table, .tp-table).tv > .hand-over { grid-column: 2; grid-row: 1; margin: 0; }
/* Wordslinger sized its board from the real screen (vh/vw), so scaling couldn't help: size it from the box instead.
   The board is a square as tall as the space under the seats row; the word list takes the rest of the width. */
html.tv-app .tv-fit-in .ws-tv { width: 100%; }
html.tv-app .tv-fit-in .ws-tvmain { --bd: calc(var(--fit-h, 700px) - 96px); }

/* "side" arrangement: the game's first block (its table) on the left, everything else in a column on the right. */
html.tv-app .tv-side { display: grid !important; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); column-gap: 24px; align-items: start; }
html.tv-app .tv-side > :first-child { grid-column: 1; grid-row: 1 / span 40; }
html.tv-app .tv-side > :not(:first-child) { grid-column: 2; margin-top: 0; }

/* Table themes (theme.js): with a scene picture behind the table, words that sit straight on the scene (names, pile
   labels, "leads", round lines) lose contrast from the couch. In the TV app give them a soft dark shadow, so the
   picture stays visible. Light surfaces (scorecards, cards, dice, paper pads, name tags) keep their own crisp ink;
   that list came from scanning all 21 TV games under the busiest theme (Monte Carlo), 2026-10-30. */
html.tv-app[data-theme] .tv-fit-in { text-shadow: 0 1px 2px rgb(0 0 0 / .9), 0 0 12px rgb(0 0 0 / .7); }
html.tv-app[data-theme] .tv-fit-in :is(.card, .ycard-wrap, .y-card, .f-pad, .sp-pad, .sb-paper, .bg-die, .die, .d3, .lrc-die,
  .lrc-seat, .badge, .sp-broken, .ce-seat .nm, .tt-seat .nm, .ce-suit, .wch, .cel-tvt, .cel-pill, .cel-chip, .handwritten, .rt-t, .ws-t, .nc, svg),
html.tv-app[data-theme] .tv-fit-in :is(.card, .ycard-wrap, .y-card, .f-pad, .sp-pad, .sb-paper, .bg-die, .die, .d3, .lrc-die,
  .lrc-seat, .badge, .sp-broken, .ce-suit, .wch, .cel-tvt, .cel-pill, .cel-chip, .handwritten, .rt-t, .ws-t, .nc) * { text-shadow: none; }

/* End of a game (inside the scaled box) */
html.tv-app .over-box { font-size: 30px; padding: 24px; margin-top: 16px; }
html.tv-app .over-box .fine { font-size: 20px; margin: 8px 0 14px; }
