/* Session-selected, viewport-fitting layouts. These rules only affect the game. */
body[data-layout] { height:100vh; height:100dvh; min-height:0; overflow:hidden; }
body[data-layout] .app-shell {
  height:100vh; height:100dvh; min-height:0; padding:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
  display:grid; grid-template-rows:auto minmax(0,1fr); gap:8px;
}
body[data-layout] header { max-width:none; width:100%; margin:0; gap:8px; }
body[data-layout] h1 { font-size:clamp(1.15rem,2.8vw,2.5rem); }
body[data-layout] .brand-mark { width:40px; height:40px; font-size:26px; }
body[data-layout] .header-actions { gap:6px; }
body[data-layout] .status-pill { padding:8px 12px; font-size:clamp(.72rem,1.4vw,1.05rem); }
body[data-layout] .game {
  width:100%; max-width:none; height:100%; min-height:0; display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:auto minmax(0,1fr) auto; gap:8px;
}
body[data-layout] .top-strip { grid-column:1/-1; }
body[data-layout] .top-controls { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; width:100%; gap:8px; }
body[data-layout] .mode-bar { grid-column:2; grid-row:1; padding:10px 22px; flex:none; }
.format-picker { grid-column:1; grid-row:1; display:flex; gap:4px; align-items:center; }
.format-picker button { width:46px; min-height:44px; padding:4px; color:var(--cream); background:#ffffff14; border:1px solid #ffffff28; border-radius:10px; display:grid; place-items:center; gap:2px; font:800 .65rem/1.15 system-ui; }
.format-picker button[aria-pressed="true"] { color:var(--forest-2); background:var(--honey); border-color:var(--honey); }
.format-picker svg { width:22px; height:22px; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.format-picker [data-format="auto"] > span:first-child { font-size:22px; line-height:22px; }
.format-label { font-size:10px; }
body[data-layout] .caller { min-width:0; min-height:0; padding:clamp(12px,2vh,28px); display:grid; grid-template-rows:auto minmax(0,1fr) auto; gap:8px; border-radius:22px; }
body[data-layout] .number-stage { min-height:0; container-type:size; grid-row:2; }
body[data-layout] .eyebrow { grid-row:1; }
body[data-layout] .callout { grid-row:3; }
body[data-layout] .current-wrap { left:2%; top:50%; transform:translateY(-50%); }
body[data-layout] .current-ball { min-width:0; width:min(76cqw,85cqh); }
body[data-layout] #currentNumber { font-size:min(50cqw,57cqh); }
body[data-layout] .bear { width:min(108cqw,124cqh); right:-8%; bottom:-3%; max-height:112%; object-fit:contain; object-position:right bottom; }
body[data-layout] .eyebrow { font-size:clamp(.62rem,1.4vh,.85rem); }
body[data-layout] .call-label { font-size:clamp(1rem,2.6vh,2rem); white-space:normal; line-height:1.1; font-weight:900; }
body[data-layout] .board-card { min-width:0; min-height:0; padding:clamp(10px,1.7vh,24px); display:flex; flex-direction:column; container-type:size; border-radius:22px; }
body[data-layout] .board-head { margin-bottom:8px; flex:none; }
body[data-layout] .board-head h2 { font-size:clamp(1.15rem,2.4vw,2.3rem); }
body[data-layout] .board-title-group { gap:8px; }
body[data-layout] .board-note { display:none; }
body[data-layout] .board { min-height:0; grid-template-columns:repeat(10,minmax(0,1fr)); grid-template-rows:repeat(8,minmax(0,1fr)); gap:4px; padding:4px; border-radius:12px; }
body[data-layout] .board-number { min-height:0; min-width:0; border-radius:5px; line-height:1; font-size:clamp(14px,min(3.2vw,6cqh),56px); }
body[data-layout] .board-number:nth-child(71) { grid-column:3; }
body[data-layout] .board-number.called { transform:none; }
body[data-layout] .board-number.latest { transform:none; box-shadow:inset 0 0 0 2px var(--amber); }
body[data-layout] .recent-card { grid-column:1/-1; min-width:0; min-height:0; height:clamp(72px,12vh,116px); padding:10px 14px; display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:10px; border-radius:20px; text-align:start; }
body[data-layout] .recent-title { font-size:clamp(.8rem,1.8vw,1.3rem); }
body[data-layout] .recent-list { height:100%; min-width:0; display:flex; gap:clamp(5px,1vw,18px); align-items:center; justify-content:space-evenly; }
body[data-layout] .recent-ball { flex-shrink:0; width:min(5vw,8vh,82px); font-size:clamp(1rem,2.5vw,2.5rem); }
body[data-layout] .recent-ball:first-child { transform:none; }
body[data-layout] .recent-empty { font-size:.9rem; text-align:center; }
body[data-layout] .controls { flex-wrap:nowrap; gap:8px; }
body[data-layout] .controls > .btn { min-height:46px; padding:0 12px; font-size:clamp(.85rem,1.3vw,1.1rem); white-space:nowrap; }
.btn-next { background:var(--honey); color:var(--forest-2); box-shadow:inset 0 -3px 0 #0002; }
.mobile-views { display:none; }
body[data-layout] #settingsBtn { width:44px; padding:0; }
body[data-layout] .pattern-panel { inset:0 0 0 45%; min-height:0; padding:10px; }
body[data-layout] .pattern-grid { min-height:0; grid-template-rows:20px repeat(5,minmax(0,1fr)); }
body[data-layout] .pattern-cell { min-height:0; }
body[data-layout].pattern-mode .current-wrap { left:0; top:50%; }
body[data-layout].pattern-mode .current-ball { width:min(41cqw,80cqh); }
body[data-layout].pattern-mode #currentNumber { font-size:min(29cqw,54cqh); }

/* Portrait monitor / portrait tablet: fill the height with a stacked board. */
body[data-layout="portrait"] .game,
body[data-layout="tablet"][data-orientation="portrait"] .game { grid-template-columns:1fr; grid-template-rows:auto minmax(0,.8fr) minmax(0,1.45fr) auto; }
body[data-layout="portrait"].pattern-mode .game,
body[data-layout="tablet"][data-orientation="portrait"].pattern-mode .game { grid-template-rows:auto minmax(0,1.05fr) minmax(0,1.2fr) auto; }
body[data-layout="portrait"] .pattern-panel p,
body[data-layout="tablet"][data-orientation="portrait"] .pattern-panel p { display:none; }
body[data-layout="portrait"] .board,
body[data-layout="tablet"] .board { grid-template-columns:repeat(5,minmax(0,1fr)); grid-template-rows:repeat(15,minmax(0,1fr)); }
body[data-layout="portrait"] .board-number:nth-child(71),
body[data-layout="tablet"] .board-number:nth-child(71) { grid-column:auto; }
body[data-layout="portrait"] .board-number,
body[data-layout="tablet"] .board-number { font-size:clamp(14px,min(3.5vw,4.5cqh),36px); }
body[data-layout="portrait"] .recent-card,
body[data-layout="tablet"][data-orientation="portrait"] .recent-card { grid-template-columns:auto minmax(0,1fr); height:112px; }
body[data-layout="portrait"] .controls,
body[data-layout="tablet"][data-orientation="portrait"] .controls { grid-column:1/-1; justify-content:center; }
body[data-layout="portrait"] .recent-list,
body[data-layout="tablet"][data-orientation="portrait"] .recent-list { height:44px; }
body[data-layout="portrait"] .recent-ball,
body[data-layout="tablet"][data-orientation="portrait"] .recent-ball { width:42px; font-size:1.4rem; }
body[data-layout="portrait"]:not(.pattern-mode) .current-wrap,
body[data-layout="tablet"][data-orientation="portrait"]:not(.pattern-mode) .current-wrap { left:calc(50% - min(40cqw,90cqh)); }
body[data-layout="portrait"]:not(.pattern-mode) .current-ball,
body[data-layout="tablet"][data-orientation="portrait"]:not(.pattern-mode) .current-ball { width:min(48cqw,92cqh); }
body[data-layout="portrait"]:not(.pattern-mode) #currentNumber,
body[data-layout="tablet"][data-orientation="portrait"]:not(.pattern-mode) #currentNumber { font-size:min(32cqw,62cqh); }
body[data-layout="portrait"] .bear,
body[data-layout="tablet"][data-orientation="portrait"] .bear { left:calc(50% - min(15cqw,30cqh)); right:auto; width:min(65cqw,130cqh); }
body[data-layout="tablet"] .key { display:none; }
body[data-layout="tablet"] .btn { min-height:48px; }

/* Phone: switch views instead of squeezing 75 cells next to the ball. */
body[data-layout="mobile"] .game { grid-template-columns:1fr; grid-template-rows:auto minmax(0,1fr) auto; }
body[data-layout="mobile"] .top-controls { grid-template-columns:1fr auto; }
body[data-layout="mobile"] .mode-bar { grid-column:2; padding:10px 12px; }
body[data-layout="mobile"] .mode-value { min-width:70px; font-size:1rem; }
body[data-layout="mobile"] .format-picker { gap:3px; }
body[data-layout="mobile"] .format-picker button { width:36px; min-height:44px; }
body[data-layout="mobile"] .format-label { display:none; }
body[data-layout="mobile"] .brand-mark { display:none; }
body[data-layout="mobile"] .version { display:none; }
body[data-layout="mobile"] .key { display:none; }
body[data-layout="mobile"] .status-pill { padding:7px 9px; }
body[data-layout="mobile"] .status-dot { display:none; }
body[data-layout="mobile"] .header-fullscreen { width:36px; min-height:40px; }
body[data-layout="mobile"] #settingsBtn { width:36px; min-height:40px; color:var(--cream); background:#ffffff20; }
body[data-layout="mobile"][data-game-view="caller"] .board-card,
body[data-layout="mobile"][data-game-view="pattern"] .board-card { display:none; }
body[data-layout="mobile"][data-game-view="board"] .caller { display:none; }
body[data-layout="mobile"] .caller,body[data-layout="mobile"] .board-card { grid-row:2; grid-column:1; }
body[data-layout="mobile"] .current-wrap { left:50%; top:55%; transform:translate(-50%,-50%); }
body[data-layout="mobile"] .current-ball { width:min(86cqw,77cqh); }
body[data-layout="mobile"] #currentNumber { font-size:min(60cqw,52cqh); }
body[data-layout="mobile"] .bear { right:-4%; width:100%; max-height:100%; bottom:14%; }
body[data-layout="mobile"] .callout { justify-content:center; }
body[data-layout="mobile"] .call-label { text-align:center; }
body[data-layout="mobile"] .recent-card { height:162px; grid-template-columns:auto minmax(0,1fr); grid-template-rows:44px 44px 48px; gap:4px 8px; padding:9px; grid-row:3; }
body[data-layout="mobile"] .recent-title { grid-row:1; grid-column:1; font-size:.75rem; white-space:normal; }
body[data-layout="mobile"] .recent-list { grid-row:1; grid-column:2; height:44px; gap:4px; }
body[data-layout="mobile"] .recent-ball { width:min(10vw,42px); font-size:1.2rem; }
body[data-layout="mobile"] .mobile-views { grid-row:2; grid-column:1/-1; display:grid; grid-template-columns:1fr 1fr; gap:4px; }
.mobile-views button { border:1px solid #c6b78f; border-radius:8px; color:var(--forest); background:#fffdf6; font:800 .85rem system-ui; }
.mobile-views button[aria-pressed="true"] { background:var(--forest); color:white; border-color:var(--forest); }
body[data-layout="mobile"] .controls { display:grid!important; grid-row:3; grid-column:1/-1; grid-template-columns:1fr 1fr 1fr; gap:5px; width:100%; }
body[data-layout="mobile"] .controls #normalSettingsSlot { display:none; }
body[data-layout="mobile"] .controls .btn { min-height:48px; font-size:.8rem; gap:4px; padding:0 6px; }
body[data-layout="mobile"] .board { grid-template-columns:repeat(5,minmax(0,1fr)); grid-template-rows:repeat(15,minmax(0,1fr)); gap:3px; }
body[data-layout="mobile"] .board-number:nth-child(71) { grid-column:auto; }
body[data-layout="mobile"] .board-number { font-size:clamp(14px,4.5cqh,26px); }
body[data-layout="mobile"].pattern-mode .current-wrap { left:0; top:50%; transform:translateY(-50%); }
body[data-layout="mobile"].pattern-mode .current-ball { width:min(41cqw,75cqh); }
body[data-layout="mobile"].pattern-mode #currentNumber { font-size:min(28cqw,50cqh); }
body[data-layout="mobile"] .pattern-panel { inset:0 0 0 45%; padding:8px; }
body[data-layout="mobile"][data-game-view="caller"].pattern-mode .pattern-panel { display:none; }
body[data-layout="mobile"][data-game-view="caller"].pattern-mode .current-wrap { left:50%; top:55%; transform:translate(-50%,-50%); }
body[data-layout="mobile"][data-game-view="caller"].pattern-mode .current-ball { width:min(86cqw,77cqh); }
body[data-layout="mobile"][data-game-view="caller"].pattern-mode #currentNumber { font-size:min(60cqw,52cqh); }
body[data-layout="mobile"][data-game-view="pattern"] .current-wrap,
body[data-layout="mobile"][data-game-view="pattern"] .eyebrow,
body[data-layout="mobile"][data-game-view="pattern"] .callout { display:none; }
body[data-layout="mobile"][data-game-view="pattern"] .pattern-panel { inset:0; padding:12px; }
body[data-layout="mobile"][data-game-view="pattern"] .pattern-panel p { display:none; }
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"] .recent-card { height:114px; grid-template-rows:44px 48px; }
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"] .recent-title,
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"] .recent-list { display:none; }
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"] .mobile-views { grid-row:1; }
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"] .controls { grid-row:2; }
body[data-layout="mobile"].pattern-mode .mobile-views { grid-template-columns:1fr 1fr 1fr; }
body[data-layout="mobile"].pattern-mode .mobile-views button { font-size:.7rem; }

/* Landscape phone: a low screen needs controls on the side, not below. */
body[data-layout="mobile"][data-orientation="landscape"] .game { grid-template-columns:minmax(0,1fr) minmax(220px,.62fr); grid-template-rows:auto minmax(0,1fr); }
body[data-layout="mobile"][data-orientation="landscape"] .top-controls { grid-template-columns:1fr auto 1fr; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-card { grid-row:2; grid-column:2; height:auto; grid-template-columns:1fr; grid-template-rows:auto auto 44px minmax(0,1fr); padding:8px; gap:5px; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-title { grid-row:1; grid-column:1; text-align:center; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-list { grid-row:2; grid-column:1; height:32px; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-ball { width:30px; font-size:1rem; }
body[data-layout="mobile"][data-orientation="landscape"] .mobile-views { grid-row:3; grid-column:1; }
body[data-layout="mobile"][data-orientation="landscape"] .controls { grid-row:4; grid-column:1; grid-template-columns:1fr; grid-template-rows:repeat(3,minmax(0,1fr)); gap:5px; align-self:stretch; align-items:stretch; height:100%; }
body[data-layout="mobile"][data-orientation="landscape"] .controls .btn { min-height:36px; font-size:.9rem; }
body[data-layout="mobile"][data-orientation="landscape"] .current-wrap { left:2%; top:50%; transform:translateY(-50%); }
body[data-layout="mobile"][data-orientation="landscape"] .current-ball { width:min(72cqw,90cqh); }
body[data-layout="mobile"][data-orientation="landscape"] #currentNumber { font-size:min(48cqw,60cqh); }
body[data-layout="mobile"][data-orientation="landscape"] .bear { width:100%; bottom:0; max-height:110%; }
body[data-layout="mobile"][data-orientation="landscape"] .board { grid-template-columns:repeat(10,minmax(0,1fr)); grid-template-rows:repeat(8,minmax(0,1fr)); }
body[data-layout="mobile"][data-orientation="landscape"] .board-number:nth-child(71) { grid-column:3; }
body[data-layout="mobile"][data-orientation="landscape"] .board-number { font-size:clamp(12px,7cqh,24px); }

/* TV audience mode. The first interaction opens a paused action chooser. */
body[data-layout="tv"] .controls { display:none!important; }
body[data-layout="tv"] .recent-card { grid-template-columns:auto minmax(0,1fr); }
body[data-layout="tv"] .recent-list { justify-content:space-evenly; }
body[data-layout="tv"] .recent-ball { width:min(8vw,9vh,96px); font-size:clamp(1.4rem,3.5vw,3.2rem); }
body[data-layout="tv"] .board-number { font-size:clamp(18px,min(3.4vw,6cqh),128px); }
body[data-layout="tv"] .key { display:none; }
.tv-controller-launch { position:fixed; right:max(14px,env(safe-area-inset-right)); bottom:max(16px,env(safe-area-inset-bottom)); z-index:4; border:1px solid #fff6; border-radius:12px; background:var(--forest); color:var(--cream); display:flex; gap:8px; align-items:center; padding:12px 16px; min-height:48px; font:800 1rem system-ui; box-shadow:0 3px 10px #0005; }
/* Give the launcher its own space in the toolbar; never cover the last numbers. */
body[data-layout="tv"] .tv-controller-launch { position:static; grid-column:3; grid-row:1; justify-self:end; }
body[data-layout="tv"] .top-controls { grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); }
#tvControllerDialog { width:min(620px,calc(100% - 24px)); max-height:calc(100dvh - 24px); }
.tv-controller-panel { padding:24px; }
.tv-controller-panel p { color:var(--muted); line-height:1.4; }
.tv-controller-actions { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.tv-controller-actions .btn { min-height:60px; white-space:normal; }
.tv-controller-actions .btn:last-child { grid-column:1/-1; background:#eadcb7; color:var(--forest); }
.tv-controller-actions .btn:focus-visible { outline:4px solid var(--amber); outline-offset:3px; }
.controls>.btn:disabled,.tv-controller-actions>.btn:disabled { opacity:.5;cursor:not-allowed;transform:none;box-shadow:none; }
body[data-layout="tv"] #tvControllerDialog { width:min(900px,calc(100% - 32px)); }
body[data-layout="tv"] .tv-controller-panel h2 { font-size:clamp(1.5rem,2.8vw,3rem); }
body[data-layout="tv"] .tv-controller-panel p { font-size:clamp(1rem,1.2vw,1.4rem); }
body[data-layout="tv"] .tv-controller-actions .btn { min-height:clamp(52px,7.5vh,86px); font-size:clamp(1rem,1.5vw,1.8rem); }

@media(max-width:1100px) { body[data-layout] .key { display:none; } body[data-layout] .format-label { display:none; } body[data-layout="tv"] .tv-controller-launch { position:static; grid-column:3; } }
@media(max-width:620px) {
  body[data-layout] .format-picker button { width:34px; min-height:44px; }
  body[data-layout] .format-picker { gap:2px; }
  body[data-layout] .mode-bar { padding:10px; }
  body[data-layout] .mode-value { min-width:70px; font-size:.95rem; }
  body[data-layout] .status-pill { max-width:150px; }
  body[data-layout] .header-actions { gap:4px; }
  .tv-controller-panel { padding:18px; }
}
@media(max-width:360px) {
  body[data-layout="mobile"] .format-picker button { width:30px; padding:2px; }
  body[data-layout="mobile"] h1 { font-size:1rem; }
  body[data-layout="mobile"] .status-pill { max-width:96px; min-width:0; }
  body[data-layout="mobile"] #statusText { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  body[data-layout="mobile"] .mode-value { width:70px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}
@media(max-height:500px) {
  body[data-layout] .app-shell { padding-top:5px; padding-bottom:5px; gap:4px; }
  body[data-layout] .game { gap:4px; }
  body[data-layout] .brand-mark { display:none; }
  body[data-layout] h1 { font-size:1.1rem; }
  body[data-layout] .header-actions .btn { min-height:32px; }
  body[data-layout] .status-pill { padding:5px 9px; font-size:.7rem; }
  body[data-layout] .format-picker button { min-height:36px; }
  body[data-layout] .mode-bar { padding:7px 16px; }
  body[data-layout] .caller { padding:8px; gap:4px; }
  body[data-layout] .eyebrow { display:none; }
  body[data-layout] .board-card { padding:6px; }
  body[data-layout] .board-head { margin-bottom:4px; }
  body[data-layout] .board-head h2 { font-size:1rem; }
  body[data-layout] .counter { font-size:.7rem; min-height:24px; padding:0 7px; }
  body[data-layout] .recent-card { height:60px; padding:5px 8px; }
  body[data-layout="mobile"][data-orientation="landscape"] .recent-card { height:auto; }
  body[data-layout] .pattern-panel p { display:none; }
  body[data-layout] .pattern-panel h3 { font-size:.85rem; margin-bottom:4px; }
  body[data-layout] .pattern-panel .btn { min-height:28px; font-size:.7rem; }
  .tv-controller-panel { padding:14px; }
  .tv-controller-panel p { margin:6px 0 10px; font-size:.85rem; }
  .tv-controller-actions { gap:8px; }
  .tv-controller-actions .btn { min-height:44px; }
}
@media print { body[data-layout] .tv-controller-launch { display:none!important; } }
/* Legacy fullscreen used viewport limits. Match its specificity so these new
   format-specific bounds remain authoritative in fullscreen as well. */
body[data-layout].is-fullscreen .game { grid-template-rows:auto minmax(0,1fr) auto; }
body[data-layout].is-fullscreen .caller { min-height:0; }
body[data-layout].is-fullscreen .current-ball { width:min(76cqw,85cqh); }
body[data-layout].is-fullscreen #currentNumber { font-size:min(50cqw,57cqh); }
body[data-layout].is-fullscreen.hide-fullscreen-controls .recent-ball { width:min(5vw,8vh,82px); font-size:clamp(1rem,2.5vw,2.5rem); }
body[data-layout="portrait"].is-fullscreen .game,
body[data-layout="tablet"][data-orientation="portrait"].is-fullscreen .game { grid-template-columns:1fr; grid-template-rows:auto minmax(0,.8fr) minmax(0,1.45fr) auto; }
body[data-layout="mobile"].is-fullscreen .game { grid-template-columns:1fr; grid-template-rows:auto minmax(0,1fr) auto; }
body[data-layout="mobile"].is-fullscreen .recent-card { height:162px; grid-template-columns:auto minmax(0,1fr); grid-template-rows:44px 44px 48px; }
body[data-layout="mobile"].is-fullscreen .current-ball { width:min(86cqw,77cqh); }
body[data-layout="mobile"].is-fullscreen #currentNumber { font-size:min(60cqw,52cqh); }
body[data-layout="mobile"].is-fullscreen .recent-list { height:44px; }
body[data-layout="mobile"].is-fullscreen.hide-fullscreen-controls .recent-ball { width:min(10vw,42px); font-size:1.2rem; }
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen .game { grid-template-columns:minmax(0,1fr) minmax(220px,.62fr); grid-template-rows:auto minmax(0,1fr); }
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen .recent-card { height:auto; grid-template-columns:1fr; grid-template-rows:auto auto 44px minmax(0,1fr); }
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen .recent-list { height:32px; }
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen .current-ball { width:min(72cqw,90cqh); }
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen #currentNumber { font-size:min(48cqw,60cqh); }
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen.hide-fullscreen-controls .recent-ball { width:30px; font-size:1rem; }
body[data-layout="tv"].is-fullscreen.hide-fullscreen-controls .recent-ball { width:min(8vw,9vh,96px); font-size:clamp(1.4rem,3.5vw,3.2rem); }
body[data-layout].pattern-mode.is-fullscreen .current-ball { width:min(41cqw,80cqh); }

/* Device choices belong only to settings, including in fullscreen. */
.settings-device { margin:0 0 16px; }
body[data-layout] .settings-device .format-picker { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:5px; margin-top:10px; }
body[data-layout] .settings-device .format-picker button { width:100%; min-height:60px; color:var(--forest); background:#f6edd7; border-color:#c6b78f; }
body[data-layout] .settings-device .format-picker button[aria-pressed="true"] { background:var(--honey); border-color:var(--forest); }
body[data-layout] .settings-device .format-label { display:block; font-size:10px; }
.settings-fullscreen { margin:0 0 16px; }
.settings-fullscreen .settings-actions { margin-top:0; }

/* Explicit controls, not an unlabeled gear-shaped click target. */
/* Mouse/touch clicks do not leave a yellow keyboard ring on the game. Actual
   Tab navigation and every TV layout retain the existing focus indicators. */
body[data-layout]:not([data-layout="tv"])[data-input-mode="pointer"] .app-shell button:focus { outline:none!important; }
body[data-layout] #settingsBtn {
  width:auto;min-width:44px;min-height:46px;padding:0 14px;display:inline-flex;align-items:center;justify-content:center;gap:8px;
  border:2px solid #dcc78e;border-radius:12px;background:var(--cream);color:var(--forest-2);font:850 1rem/1.2 system-ui;white-space:nowrap;
  box-shadow:0 3px 0 #071b1740;transition:background-color .12s,box-shadow .12s;
}
.settings-button-icon { font-size:1.45em;line-height:1;flex:none; }
.settings-button-label { display:inline; }
body[data-layout] #settingsBtn:hover { background:#fffbe9;box-shadow:0 3px 0 #071b1740,0 0 0 2px #fff5; }
body[data-layout] #settingsBtn:active { box-shadow:inset 0 2px 0 #071b1730; }
body[data-layout] #settingsBtn:focus-visible,body[data-layout] .tv-controller-launch:focus-visible { outline:4px solid var(--honey);outline-offset:4px; }
body[data-layout] .header-actions { min-width:0;max-width:100%;flex-wrap:wrap;justify-content:flex-end; }
body[data-layout] #fullscreenSettingsSlot { display:inline-flex;max-width:100%;flex:none; }
/* experience.css has an older, more specific 44px mobile icon rule. */
body[data-layout] .header-actions #fullscreenSettingsSlot #settingsBtn { width:auto; }
body[data-layout="tv"] #settingsBtn {
  min-height:clamp(56px,5.5vh,84px);padding:10px clamp(14px,1.4vw,28px);border-color:var(--honey);background:var(--honey);color:var(--forest-2);
  font-size:clamp(1.1rem,1.7vw,2rem);gap:12px;
}
body[data-layout="tv"] #settingsBtn:hover { background:#ffda87; }
body[data-layout="tv"] #settingsBtn:focus-visible { outline-color:var(--cream); }
body[data-layout="tv"] .tv-controller-launch {
  max-width:100%;min-height:clamp(56px,5.5vh,84px);padding:10px clamp(14px,1.4vw,28px);gap:12px;border:2px solid #f7d891;border-radius:14px;
  font-size:clamp(1.05rem,1.6vw,1.9rem);line-height:1.2;background:var(--forest);color:var(--cream);text-align:start;
}
body[data-layout="tv"] .tv-controller-launch>span:first-child { flex:none;font-size:1.15em; }
body[data-layout="tv"] #tvControllerDialog { width:min(1040px,calc(100% - 32px)); }
body[data-layout="tv"] .tv-controller-panel { padding:clamp(20px,2.4vw,40px); }
body[data-layout="tv"] .tv-controller-panel h2 { font-size:clamp(1.7rem,2.4vw,3rem);line-height:1.12; }
body[data-layout="tv"] .tv-controller-panel p { font-size:clamp(1.05rem,1.5vw,1.7rem);line-height:1.4; }
body[data-layout="tv"] .tv-controller-actions { gap:clamp(12px,1.4vw,22px); }
body[data-layout="tv"] .tv-controller-actions .btn { min-height:clamp(64px,8vh,102px);font-size:clamp(1.15rem,1.9vw,2.2rem);padding:14px 18px;line-height:1.2; }
@media(max-width:1100px) {
  body[data-layout] header { flex-wrap:wrap; }
  body[data-layout] .header-actions { margin-inline-start:auto; }
}
/* The dense 601–900px laptop toolbar keeps its accessible name and a clear
   button surface; fullscreen/TV/mobile headers retain the visible text. */
@media(max-width:900px) {
  body[data-layout="laptop"]:not(.is-fullscreen) #settingsBtn { width:46px;padding:0; }
  body[data-layout="laptop"]:not(.is-fullscreen) .settings-button-label { display:none; }
}
@media(max-height:500px) {
  body[data-layout="tv"] .tv-controller-panel { padding:16px; }
  body[data-layout="tv"] .tv-controller-panel h2 { font-size:1.5rem; }
  body[data-layout="tv"] .tv-controller-panel p { font-size:1rem; }
  body[data-layout="tv"] .tv-controller-actions .btn { min-height:52px;font-size:1.1rem;padding:10px; }
}
.device-hint { position:fixed; z-index:35; top:max(12px,env(safe-area-inset-top)); left:50%; transform:translateX(-50%); max-width:calc(100% - 24px); width:max-content; padding:12px 18px; border:1px solid #d9c59a; border-radius:14px; background:#fff8e5; color:var(--forest); box-shadow:var(--shadow); font:700 clamp(.85rem,1.4vw,1.2rem)/1.4 system-ui; text-align:center; pointer-events:none; }

/* Keep the last five together; do not spread them across the whole screen. */
body[data-layout] .recent-list { justify-content:center; gap:clamp(4px,.6vw,10px); }
body[data-layout="portrait"] .recent-ball,
body[data-layout="tablet"][data-orientation="portrait"] .recent-ball,
body[data-layout="portrait"].is-fullscreen.hide-fullscreen-controls .recent-ball,
body[data-layout="tablet"][data-orientation="portrait"].is-fullscreen.hide-fullscreen-controls .recent-ball { width:48px; font-size:1.6rem; }
body[data-layout="portrait"] .recent-list,
body[data-layout="tablet"][data-orientation="portrait"] .recent-list { height:50px; }
body[data-layout="portrait"] .recent-card,
body[data-layout="tablet"][data-orientation="portrait"] .recent-card { height:120px; }
body[data-layout="mobile"] .recent-card,
body[data-layout="mobile"].is-fullscreen .recent-card { height:172px; grid-template-rows:54px 44px 48px; }
body[data-layout="mobile"] .recent-title { max-width:55px; }
body[data-layout="mobile"] .recent-list,
body[data-layout="mobile"].is-fullscreen .recent-list { height:54px; gap:4px; }
body[data-layout="mobile"] .recent-ball,
body[data-layout="mobile"].is-fullscreen.hide-fullscreen-controls .recent-ball { width:min(13vw,52px); font-size:1.5rem; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-card,
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen .recent-card { height:auto; grid-template-rows:auto auto 44px minmax(0,1fr); }
body[data-layout="mobile"][data-orientation="landscape"] .recent-title { max-width:none; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-list,
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen .recent-list { height:42px; }
body[data-layout="mobile"][data-orientation="landscape"] .recent-ball,
body[data-layout="mobile"][data-orientation="landscape"].is-fullscreen.hide-fullscreen-controls .recent-ball { width:min(5vw,40px); font-size:1.3rem; }
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"] .recent-card,
body[data-layout="mobile"][data-game-view="pattern"][data-orientation="portrait"].is-fullscreen .recent-card { height:114px; grid-template-rows:44px 48px; }
@media print { .device-hint { display:none!important; } }
/* Phone-only refinements: do not change TV, desktop or tablet controls. */
body[data-layout="mobile"] .top-controls { grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); }
body[data-layout="mobile"] .mode-bar { grid-column:2;justify-self:center; }
body[data-layout="mobile"] #settingsDialog select,
body[data-layout="mobile"] #settingsDialog input:not([type="checkbox"]):not([type="range"]),
body[data-layout="mobile"] #settingsDialog textarea { font-size:16px;line-height:1.35; }
body[data-layout="mobile"] #settingsDialog select { min-height:48px; }
body[data-layout="mobile"] #settingsDialog .settings-device .format-picker { grid-template-columns:repeat(3,minmax(0,1fr));gap:8px; }
body[data-layout="mobile"] #settingsDialog .settings-device .format-picker button { min-height:60px; }
body[data-layout="mobile"] #settingsDialog .settings-device .format-label { font-size:.75rem;line-height:1.25; }
body[data-layout="mobile"][data-orientation="portrait"] .controls { gap:8px; }
/* Retain 44px targets on landscape phones when vertical room permits it. Very
   short/zoomed screens keep their existing compact layout pending device QA. */
@media(min-height:380px) {
  body[data-layout="mobile"][data-orientation="landscape"] .controls .btn { min-height:44px; }
}
body[data-layout].pattern-mode.is-fullscreen #currentNumber { font-size:min(29cqw,54cqh); }
body[data-layout="mobile"][data-game-view="caller"].pattern-mode.is-fullscreen .current-ball { width:min(86cqw,77cqh); }
body[data-layout="mobile"][data-game-view="caller"].pattern-mode.is-fullscreen #currentNumber { font-size:min(60cqw,52cqh); }
body[data-layout="portrait"].pattern-mode.is-fullscreen .game,
body[data-layout="tablet"][data-orientation="portrait"].pattern-mode.is-fullscreen .game { grid-template-rows:auto minmax(0,1.05fr) minmax(0,1.2fr) auto; }
body[data-layout="portrait"].is-fullscreen.hide-fullscreen-controls .recent-card,
body[data-layout="tablet"][data-orientation="portrait"].is-fullscreen.hide-fullscreen-controls .recent-card { height:76px; }
