/* Phone landscape UI (approved mobile mockup, 2026-11-15).
   game/phone-ui.js adds html.phone-ui when the viewport is a landscape phone (height up to 510 px).
   Everything here is scoped to that class, so desktop layouts are untouched. Sizes are CSS px:
   the layout targets 874 x 402 pt (iPhone 6.3") and keeps clear of the Dynamic Island and home bar. */
html.phone-ui {
  --pu-ink:#0c1424; --pu-navy:#111e30; --pu-navy-2:#1b2d42; --pu-navy-3:#27415a;
  --pu-line:#5d83927a; --pu-paper:#fbf0df; --pu-muted:#a9bcc6; --pu-dim:#7890a0;
  --pu-orange:#ff985d; --pu-orange-soft:#ffd4a8; --pu-teal:#00cfcd; --pu-ready:#a6eee0; --pu-gold:#f7c354; --pu-red:#ff7a6b;
  --pu-surface:linear-gradient(180deg,#233d4ef2,#111e30f7);
  --pu-lift:inset 0 1px 0 #e0f0ff20,0 3px 0 #080e19,0 8px 20px #03081055;
  --pu-sl:max(16px,env(safe-area-inset-left,0px)); --pu-sr:max(16px,env(safe-area-inset-right,0px));
  --pu-sb:max(10px,env(safe-area-inset-bottom,0px)); --pu-st:max(8px,env(safe-area-inset-top,0px));
  --pu-bs:1;
}

/* ---------- Full-screen pages: every dialog fills the screen with Back / X in the header ---------- */
html.phone-ui #modal[open] {
  width:auto; height:var(--pu-h,auto); max-width:none; max-height:none; margin:0; inset:0; border:0; border-radius:0;
  padding:0 var(--pu-sr) 0 var(--pu-sl); display:grid; grid-template-rows:auto auto minmax(0,1fr); overflow:hidden;
  background:radial-gradient(70% 90% at 80% 0%,#1d3550 0%,transparent 60%),var(--pu-ink); color:var(--pu-paper);
}
html.phone-ui #modal[open]::backdrop { background:var(--pu-ink); }
html.phone-ui #modal[open] .sheet-head {
  display:flex; align-items:center; gap:12px; min-height:56px; margin:0; padding:var(--pu-st) 0 4px; background:none; border:0; color:var(--pu-paper);
}
html.phone-ui #modal[open] .sheet-head h2 {
  margin:0; min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  font:800 24px/1 var(--font-display); letter-spacing:.03em; text-transform:uppercase; color:inherit;
}
html.phone-ui #modal[open] .sheet-head :is(#back,#close) {
  min-width:44px; min-height:40px; padding:0 12px; border-radius:10px; border:1px solid var(--pu-line);
  background:var(--pu-surface); box-shadow:var(--pu-lift); color:var(--pu-paper); font:700 14px/1 var(--font-body); letter-spacing:.06em; text-transform:uppercase;
}
html.phone-ui #modal[open] .sheet-head #close { order:3; width:44px; padding:0; font-size:22px; }
html.phone-ui #modal[open] #sheet {
  width:100%; max-width:none; min-height:0; margin:0; padding:0 0 var(--pu-sb); overflow:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
}
html.phone-ui #modal[open] #sheet :is(button,select,input:not([type=checkbox]):not([type=radio]):not([type=range])) { min-height:40px; }
html.phone-ui #modal[open] .queue-page-bar { margin:0 0 6px; }
/* Light-themed pages (account, lab hub) now match the dark pages. */
html.phone-ui #modal.page-mode:has(.account-panel), html.phone-ui #modal:has(.lab-hub) { background:var(--pu-ink); color:var(--pu-paper); --muted:var(--pu-muted); }
html.phone-ui #modal.page-mode:has(.account-panel) .sheet-head, html.phone-ui #modal:has(.lab-hub) .sheet-head { background:none; color:var(--pu-paper); padding-inline:0; }
html.phone-ui #modal.page-mode:has(.account-panel) .sheet-head button, html.phone-ui #modal:has(.lab-hub) #close { background:var(--pu-surface); color:var(--pu-paper); border:1px solid var(--pu-line); }
html.phone-ui #modal.page-mode:has(.account-panel) #sheet :is(p,h3,label) { color:var(--pu-paper); }
html.phone-ui #modal.page-mode:has(.account-panel) #sheet :is(.account-note,.account-or) { color:var(--pu-muted); }
html.phone-ui #modal.page-mode:has(.account-panel) #sheet input:not([type=checkbox]) { background:#0a1220; color:var(--pu-paper); border:1px solid var(--pu-line); border-radius:10px; }
html.phone-ui #modal.page-mode:has(.account-panel) #sheet button:not(.google-login):not(.account-text) { background:var(--pu-surface); color:var(--pu-paper); border:1px solid var(--pu-line); border-radius:10px; box-shadow:var(--pu-lift); }
html.phone-ui #modal.page-mode:has(.account-panel) #sheet button:is(.account-primary,.account-create):not(.google-login):not(.account-text) { background:linear-gradient(180deg,#ffb582,var(--pu-orange) 55%,#f07d45); color:#2a1206; border-color:#ffc49c; }
html.phone-ui #modal.page-mode:has(.account-panel) #sheet .account-text { color:var(--pu-muted); }

/* Other menu dialogs (Clubs, Leaderboards, News, Friends) fill the screen the same way. */
html.phone-ui :is(#clubs-dialog,#leaderboards-dialog,#news-dialog,#account-dialog,dialog.friend-list)[open] {
  inset:0; width:auto; height:var(--pu-h,auto); max-width:none; max-height:none; margin:0; border:0; border-radius:0; box-shadow:none;
  padding:0 var(--pu-sr) 0 var(--pu-sl); background:radial-gradient(70% 90% at 80% 0%,#1d3550 0%,transparent 60%),var(--pu-ink);
}
html.phone-ui :is(#clubs-dialog,#leaderboards-dialog,#news-dialog,#account-dialog,dialog.friend-list)::backdrop { background:var(--pu-ink); }
html.phone-ui #news-dialog .news-shell { max-height:none; height:100%; }
html.phone-ui #news-dialog .news-header { padding:var(--pu-st) 0 4px; min-height:56px; border:0; }
html.phone-ui #news-dialog .news-tabs { padding:0 0 8px; }
html.phone-ui #news-dialog .news-scroll { padding:0 0 var(--pu-sb); }
html.phone-ui #news-dialog .news-banner { max-height:180px; object-fit:cover; }
/* Clubs: header on top, section tabs as a rail down the left, content on the right. */
html.phone-ui #clubs-dialog .clubs-hub { display:grid; grid-template-columns:132px minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); gap:6px 14px; height:100%; padding:var(--pu-st) 0 var(--pu-sb); }
html.phone-ui #clubs-dialog .clubs-header { grid-column:1 / -1; min-height:48px; }
html.phone-ui #clubs-dialog .clubs-header h2 { font-size:26px; }
html.phone-ui #clubs-dialog .clubs-tabs { grid-column:1; display:flex; flex-direction:column; gap:4px; margin:0; padding:2px 0 0; overflow:auto; border:0; background:none; }
html.phone-ui #clubs-dialog .clubs-tabs:empty { display:none; }
html.phone-ui #clubs-dialog .clubs-tabs:empty + .clubs-body { grid-column:1 / -1; }
html.phone-ui #clubs-dialog .clubs-tabs button { justify-content:flex-start; width:100%; min-height:42px; padding:0 12px; border:0; border-radius:9px; background:none; box-shadow:none; color:var(--pu-muted); font:700 15px/1 var(--font-display); letter-spacing:.06em; text-transform:uppercase; text-align:left; }
html.phone-ui #clubs-dialog .clubs-tabs button:is([aria-pressed=true],[aria-selected=true],[aria-current=page]) { background:var(--pu-navy-2); color:var(--pu-paper); box-shadow:inset 3px 0 0 var(--pu-orange); }
html.phone-ui #clubs-dialog .clubs-body { grid-column:2; min-height:0; }

/* ---------- Lobby ---------- */
html.phone-ui #modal:has(.hero-lobby) { padding:0; background:linear-gradient(90deg,#0c1424d9 0%,#0c142440 26%,transparent 50%,#0c142440 70%,#0c1424cc 100%),linear-gradient(0deg,#0c1424b3 0%,transparent 40%),url("art/crown-arena-avenue-menu.webp") center 53% / cover no-repeat #0c1424; }
html.phone-ui #modal:has(.hero-lobby) .sheet-head { display:none; }
html.phone-ui #modal:has(.hero-lobby) #sheet {
  display:grid; height:auto; align-self:stretch; overflow:hidden; position:relative;
  grid-template-columns:168px minmax(0,1fr) 184px; grid-template-rows:48px minmax(0,1fr) auto;
  grid-template-areas:"logo queue tools" "tabs stage news" "tabs stage play";
  gap:8px 12px; align-items:end;
  padding:var(--pu-st) var(--pu-sr) var(--pu-sb) var(--pu-sl);
}
html.phone-ui .hero-lobby .title-logo { grid-area:logo; width:120px; align-self:center; }
html.phone-ui .hero-lobby .lobby-tools { grid-area:tools; align-self:center; justify-self:end; display:flex; gap:6px; position:relative; z-index:3; }
html.phone-ui .hero-lobby .lobby-queue { grid-area:queue; align-self:center; }
html.phone-ui #sheet .hero-lobby .lobby-tools button { min-height:40px; height:40px; padding:0 12px; font:600 14px/1 var(--font-body); white-space:nowrap; }
html.phone-ui #sheet .hero-lobby .lobby-tools :is(.title-settings,.title-account,.news-info) { width:40px; padding:0; }
html.phone-ui .hero-lobby nav { display:contents; }
/* All four destinations fit in two rows without a swipe. Reserve the separate Lab hitbox. */
html.phone-ui .hero-lobby .lobby-tabs {
  grid-area:tabs; align-self:stretch; min-height:0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-auto-rows:56px; align-content:start; gap:6px;
  margin:8px 0 54px; max-width:none; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin;
}
html.phone-ui #sheet .hero-lobby .lobby-tab {
  display:flex; flex-direction:column; justify-content:center; align-items:center; min-width:0; min-height:44px; height:100%; padding:2px; gap:4px; border-radius:10px; background:#111e30c7;
  font:700 12px/1.12 var(--font-body); letter-spacing:0; text-transform:none; white-space:nowrap;
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
}
html.phone-ui #sheet .hero-lobby .lobby-tab span { min-width:0; overflow:hidden; text-overflow:ellipsis; }
html.phone-ui #sheet .hero-lobby .lobby-tab svg { width:20px; height:20px; flex:none; }
/* Tutorial and sign-in offers become one slim bar under the top row; the Lab shortcut lives in Select mode. */
html.phone-ui .hero-lobby .lobby-side {
  position:absolute; z-index:4; top:calc(var(--pu-st) + 4px); left:calc(var(--pu-sl) + 130px); right:calc(var(--pu-sr) + 286px); height:40px; align-items:center;
  display:flex; justify-content:center; gap:8px; pointer-events:none;
}
html.phone-ui .hero-lobby .lobby-side > * { pointer-events:auto; }
/* Lab: the desktop shortcut card becomes the last button at the bottom of the left rail. */
html.phone-ui #sheet .hero-lobby .lobby-side .lobby-shortcut {
  position:fixed; z-index:4; left:var(--pu-sl); bottom:var(--pu-sb); width:168px; min-height:46px; height:46px;
  display:flex; align-items:center; gap:10px; padding:0 12px; border-radius:10px; border-color:#00cfcd66; background:#111e30c7;
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
}
html.phone-ui #sheet .hero-lobby .lobby-shortcut::before {
  content:""; width:20px; height:20px; flex:none; background:var(--pu-teal);
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3h8m-6 0v6l-6 10a1 1 0 0 0 1 2h14a1 1 0 0 0 1-2L14 9V3m-7 12h10'/%3E%3C/svg%3E") center / contain no-repeat;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3h8m-6 0v6l-6 10a1 1 0 0 0 1 2h14a1 1 0 0 0 1-2L14 9V3m-7 12h10'/%3E%3C/svg%3E") center / contain no-repeat;
}
html.phone-ui #sheet .hero-lobby .lobby-shortcut > span { display:block; min-width:0; }
html.phone-ui #sheet .hero-lobby .lobby-shortcut small { display:block; color:var(--pu-paper); font:700 15px/1 var(--font-display); letter-spacing:.02em; text-transform:uppercase; }
html.phone-ui #sheet .hero-lobby .lobby-shortcut :is(b,span > span,i) { display:none; }
html.phone-ui #sheet .hero-lobby .tutorial-offer {
  display:flex; align-items:center; flex-wrap:nowrap; gap:8px; max-width:100%; padding:4px; border-radius:12px; border-left-width:1px; background:#111e30eb;
}
html.phone-ui #sheet .hero-lobby .tutorial-offer { border-color:#ff985d80; }
html.phone-ui #sheet .hero-lobby .tutorial-offer p { display:none; }
html.phone-ui #sheet .hero-lobby .tutorial-offer small { display:none; white-space:nowrap; color:var(--pu-paper); font:700 14px/1 var(--font-display); letter-spacing:.05em; }
html.phone-ui #sheet .hero-lobby .tutorial-offer > div { flex-wrap:nowrap; gap:6px; }
html.phone-ui #sheet .hero-lobby .tutorial-offer button { min-height:36px; height:36px; padding:0 10px; font:700 13px/1 var(--font-body); white-space:nowrap; }
/* Right column: news, mode, Play under the right thumb. */
html.phone-ui .hero-lobby .lobby-play { grid-area:play; display:flex; flex-direction:column; gap:8px; width:100%; max-width:none; justify-self:stretch; }
html.phone-ui #sheet .hero-lobby .lobby-announcement {
  grid-area:news; align-self:end; width:100%; min-height:0; height:50px; display:grid; grid-template-columns:46px minmax(0,1fr); align-items:center; gap:8px; padding:5px; text-align:left;
}
html.phone-ui #sheet .hero-lobby .lobby-announcement img { grid-column:1; grid-row:1; position:static; width:46px; height:38px; object-fit:cover; border-radius:6px; inset:auto; }
html.phone-ui #sheet .hero-lobby .lobby-announcement .lobby-announcement-copy { grid-column:2; grid-row:1; position:static; padding:0; gap:3px; background:none; }
html.phone-ui #sheet .hero-lobby .lobby-announcement :is(.lobby-announcement-arrow,small) { display:none; }
html.phone-ui #sheet .hero-lobby .lobby-announcement strong { font:700 14px/1.05 var(--font-display); text-transform:uppercase; letter-spacing:.02em; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
html.phone-ui #sheet .hero-lobby .lobby-announcement .lobby-announcement-kind { display:none; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card { grid-template-columns:minmax(0,1fr) auto; padding:7px 8px 7px 10px; gap:3px 8px; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card small { grid-column:1; grid-row:1; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card b { grid-column:1; grid-row:2; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card .lobby-format { grid-column:1; grid-row:3; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card b { font:700 17px/1.05 var(--font-display); text-transform:uppercase; letter-spacing:.03em; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card .lobby-format { font-size:12px; }
html.phone-ui #sheet .hero-lobby .lobby-mode-card i { grid-column:2; grid-row:1 / span 3; padding:5px 6px; font-size:12px; white-space:nowrap; }
html.phone-ui #sheet .hero-lobby [data-duo="pickup"] { min-height:54px; height:54px; border-radius:12px; }
html.phone-ui #sheet .hero-lobby [data-duo="pickup"] #pickup-label { display:none; }
html.phone-ui #sheet .hero-lobby .lobby-play-word { font:italic 800 30px/1 var(--font-display); letter-spacing:.05em; text-transform:uppercase; }
html.phone-ui #sheet .hero-lobby .duo-status:not(:empty) { font-size:12px; padding:4px 8px; border-radius:6px; background:#0c1424cc; }
/* Centre stage: your athlete plus the teammate slot. */
html.phone-ui #modal:has(.hero-lobby) .duo-stage { grid-area:stage; grid-column:2; grid-row:2 / span 2; align-self:end; justify-self:center; width:100%; height:100%; margin:0; display:flex; flex-direction:column; justify-content:flex-end; }
html.phone-ui #modal:has(.hero-lobby) .duo-athletes { display:flex; align-items:flex-end; justify-content:center; gap:4px; height:100%; }
html.phone-ui #modal:has(.hero-lobby) .duo-slot { width:auto; flex:0 1 auto; }
html.phone-ui #modal:has(.hero-lobby) .duo-stage[data-duo="false"] .duo-slot:first-child { width:auto; }
html.phone-ui #modal:has(.hero-lobby) .duo-model { height:min(54dvh,214px); }
html.phone-ui #modal:has(.hero-lobby) .duo-model canvas { height:100%; width:auto; max-width:100%; }
html.phone-ui #modal:has(.hero-lobby) .duo-stage[data-duo="false"] .duo-slot-empty { position:static; width:128px; align-self:flex-end; }
html.phone-ui #modal:has(.hero-lobby) .duo-slot-empty .duo-empty { display:flex; flex-direction:column; align-items:stretch; gap:6px; padding-bottom:8px; }
html.phone-ui #modal:has(.hero-lobby) .duo-stage .duo-platform-invite { display:flex; flex-direction:column; align-items:center; gap:8px; min-height:132px; padding:12px 8px; border:2px dashed #a9bcc680; background:#0c142466; box-shadow:none; font:700 15px/1.05 var(--font-display); letter-spacing:.05em; text-transform:uppercase; }
html.phone-ui #modal:has(.hero-lobby) .duo-stage .duo-platform-invite b { width:44px; height:44px; display:grid; place-items:center; border-radius:12px; background:var(--pu-ready); color:var(--pu-ink); font:700 28px/1 var(--font-body); }
html.phone-ui #modal:has(.hero-lobby) .duo-squad-actions { display:flex; gap:4px; }
html.phone-ui #modal:has(.hero-lobby) .duo-squad-actions button { flex:1; min-height:36px; padding:0 4px; font:600 12px/1.05 var(--font-body); white-space:normal; }
html.phone-ui #modal:has(.hero-lobby) .duo-member { margin-top:-4px; }
html.phone-ui #modal:has(.hero-lobby) .duo-member strong { font:700 15px/1 var(--font-display); text-transform:uppercase; }
html.phone-ui #modal:has(.hero-lobby) .duo-member :is(span,small) { font-size:12px; }
html.phone-ui #modal:has(.hero-lobby) .duo-controls { display:flex; justify-content:center; gap:6px; flex-wrap:wrap; }

/* Select mode: all six choices remain reachable without a swipe. */
html.phone-ui .hero-lobby .mode-select:not([hidden]) {
  position:fixed; inset:0; z-index:20; display:grid; padding:0 var(--pu-sr) var(--pu-sb) var(--pu-sl);
  background:radial-gradient(70% 90% at 80% 0%,#1d3550 0%,transparent 60%),var(--pu-ink);
}
html.phone-ui .hero-lobby .mode-select-panel { display:grid; grid-template-rows:auto minmax(0,1fr); width:100%; height:100%; max-width:none; max-height:none; margin:0; padding:0; border:0; border-radius:0; background:none; box-shadow:none; }
html.phone-ui .hero-lobby .mode-select-head { display:flex; align-items:center; gap:12px; min-height:56px; padding:var(--pu-st) 0 4px; border:0; }
html.phone-ui .hero-lobby .mode-select-head h2 { flex:1; margin:0; font:800 24px/1 var(--font-display); text-transform:uppercase; letter-spacing:.03em; }
html.phone-ui #sheet .hero-lobby .mode-select-head button { height:44px; min-height:44px; min-width:44px; padding:0 12px; }
html.phone-ui #sheet .hero-lobby .mode-select-close { order:3; }
html.phone-ui .hero-lobby .mode-select-body {
  display:grid; grid-template-rows:auto minmax(72px,1fr) auto minmax(72px,1fr);
  gap:6px; min-height:0; padding:2px 4px 4px; overflow:auto; overscroll-behavior:contain;
}
html.phone-ui .hero-lobby .mode-select-body .mode-group {
  margin:0; color:var(--pu-orange-soft); line-height:1; font-size:12px; letter-spacing:.1em;
}
html.phone-ui .hero-lobby .mode-select-body .mode-grid {
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; min-height:0;
}
html.phone-ui #sheet .hero-lobby .mode-tile {
  display:grid; grid-template-columns:32px minmax(0,1fr); grid-template-rows:auto auto 1fr;
  align-items:start; align-content:start; min-width:0; min-height:44px; height:auto;
  gap:2px 6px; padding:6px; border-radius:10px;
}
html.phone-ui #sheet .hero-lobby .mode-tile svg { grid-area:1 / 1 / 3 / 2; padding:5px; border-radius:7px; background:#0c142499; }
html.phone-ui #sheet .hero-lobby .mode-tile span {
  grid-area:1 / 2; font:800 16px/1.05 var(--font-display); text-transform:uppercase; overflow-wrap:anywhere;
}
html.phone-ui #sheet .hero-lobby .mode-tile small {
  grid-area:2 / 2; color:var(--pu-orange-soft); font:700 10px/1.1 var(--font-display); text-transform:uppercase;
}
html.phone-ui #sheet .hero-lobby .mode-tile em {
  grid-area:3 / 1 / 4 / 3; color:#c4d1da; font:400 11px/1.2 var(--font-body);
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
html.phone-ui #sheet .hero-lobby .mode-tile[aria-pressed="true"] { border-color:var(--pu-orange); box-shadow:0 0 0 1px var(--pu-orange); }
html.phone-ui #sheet .hero-lobby .mode-tile[aria-pressed="true"]::after { content:none; }

/* ---------- Match HUD ---------- */
html.phone-ui .gym > header { position:absolute; inset:0 0 auto; height:0; padding:0; background:none; pointer-events:none; z-index:6; }
html.phone-ui .gym > header .brand { display:none; }
html.phone-ui .gym > header .screen-controls { position:absolute; top:var(--pu-st); left:var(--pu-sl); right:auto; display:flex; gap:8px; pointer-events:auto; }
html.phone-ui .gym #fullscreen { order:2; width:44px; min-width:44px; min-height:44px; padding:0; border-radius:12px; background:#0c1424a6; border:1px solid #ffffff2e; font-size:0; color:var(--pu-paper); }
html.phone-ui .gym #fullscreen::before { content:'\2922'; font:700 20px/1 var(--font-body); }
html.phone-ui .gym .match-menu summary { width:44px; height:44px; }
html.phone-ui .gym .match-menu-icon { width:44px; height:44px; padding:10px; border-radius:12px; background:#0c1424a6; border:1px solid #ffffff2e; }
/* In-match menu: a side sheet over the left edge, the match keeps running. */
html.phone-ui .gym .match-menu[open] .tools {
  position:fixed; z-index:30; left:0; top:0; bottom:0; width:calc(var(--pu-sl) + 280px); max-height:none; margin:0;
  padding:calc(var(--pu-st) + 56px) 14px var(--pu-sb) calc(var(--pu-sl) + 4px);
  display:flex; flex-direction:column; gap:8px; overflow:auto; border:0; border-right:1px solid var(--pu-line); border-radius:0;
  background:#0c1424f2; box-shadow:20px 0 40px #0008;
}
html.phone-ui .gym .match-menu[open] .tools :is(button,#guide,#pause) { width:100%; min-height:46px; justify-content:flex-start; padding:0 12px; border-radius:10px; background:var(--pu-surface); border:1px solid var(--pu-line); text-align:left; font:700 15px/1 var(--font-display); letter-spacing:.06em; text-transform:uppercase; }
html.phone-ui .live-banner:not([hidden]) { left:var(--pu-sl); top:calc(var(--pu-st) + 56px); transform:none; z-index:31; width:276px; }

/* Score: one bar, top centre. */
html.phone-ui .gym .scoreboard {
  top:var(--pu-st); left:50%; right:auto; transform:translateX(-50%); display:flex; flex-direction:row; align-items:stretch; gap:0;
  height:44px; padding:0; border-radius:12px; overflow:hidden; background:#0c1424d9; border:1px solid #ffffff26; box-shadow:0 6px 18px #0006;
}
html.phone-ui .gym .score-row { display:flex; align-items:center; gap:6px; padding:0 4px 0 10px; margin:0; background:none; border:0; border-radius:0; box-shadow:inset 4px 0 0 #33c3d6; }
html.phone-ui .gym .score-row.yard { flex-direction:row-reverse; padding:0 10px 0 4px; box-shadow:inset -4px 0 0 #f07a5c; }
html.phone-ui .gym .score-row .team-score { display:flex; flex-direction:row; align-items:center; gap:6px; width:auto; }
html.phone-ui .gym .score-row.yard .team-score { flex-direction:row-reverse; }
html.phone-ui .gym .score-row .team-score span { font:700 13px/1 var(--font-display); letter-spacing:.1em; text-transform:uppercase; color:var(--pu-muted); max-width:64px; }
html.phone-ui .gym .score-row .team-score b { display:grid; place-items:center; min-width:40px; height:44px; font:800 30px/1 var(--font-display); font-variant-numeric:tabular-nums; background:#ffffff0d; }
html.phone-ui .gym .score-athletes { gap:0; }
html.phone-ui .gym .score-athlete { width:auto; }
html.phone-ui .gym .score-athlete + .score-athlete { margin-left:-7px; }
html.phone-ui .gym .score-athlete canvas { width:24px; height:24px; border-radius:50%; border:2px solid #0c1424; }
html.phone-ui .gym .score-athlete span { display:none; }
html.phone-ui .gym .scoreboard .match-info { display:none; }
html.phone-ui .gym .live-stats { position:absolute; top:var(--pu-st); left:calc(var(--pu-sl) + 104px); z-index:6; }
html.phone-ui .gym .live-stats summary { display:grid; place-items:center; min-width:44px; height:44px; padding:0 10px; border-radius:12px; background:#0c1424a6; border:1px solid #ffffff2e; font:700 13px/1 var(--font-display); letter-spacing:.08em; text-transform:uppercase; }
html.phone-ui .gym .live-stats[open] > div { position:absolute; top:52px; left:0; width:300px; max-height:calc(100dvh - 120px); overflow:auto; padding:10px; border-radius:12px; background:#0c1424eb; border:1px solid var(--pu-line); }
html.phone-ui .gym .live-stats > small { display:none; }
html.phone-ui .gym .court-tag { display:none; }

/* Instruction and timing: one compact line under the score instead of a bar over the court. */
html.phone-ui .gym .deck .readout {
  position:absolute; top:calc(var(--pu-st) + 52px); bottom:auto; left:50%; transform:translateX(-50%);
  width:auto; max-width:min(420px,calc(100% - 2*var(--pu-sl) - 300px)); min-width:200px; padding:6px 12px; border-radius:9px; background:#0c1424b3;
}
html.phone-ui .gym .deck .readout .phase { display:flex; align-items:center; gap:8px; }
html.phone-ui .gym .deck .readout .phase strong { font:700 12px/1 var(--font-display); letter-spacing:.12em; text-transform:uppercase; color:var(--pu-gold); white-space:nowrap; }
html.phone-ui .gym .deck #hint { font:600 13px/1.25 var(--font-body); color:var(--pu-paper); }
html.phone-ui .gym .deck .timing { height:8px; margin:5px 0 0; }
html.phone-ui .gym .deck .set-options { bottom:calc(var(--pu-sb) + 8px); width:min(360px,calc(100% - 2*var(--pu-sl) - 340px)); }

/* Thumbs: joystick left, contact button with Dive / Roll / Ult in an arc on the right. */
html.phone-ui .gym .deck .stick-unit { left:calc(var(--pu-sl) + 12px); bottom:calc(var(--pu-sb) + 10px); }
html.phone-ui .gym #stick { width:calc(128px*var(--pu-bs)); height:calc(128px*var(--pu-bs)); }
html.phone-ui .gym #stick-label { display:none; }
html.phone-ui .gym .deck .actions {
  --contact-size:calc(86px*var(--pu-bs)); --secondary-size:calc(58px*var(--pu-bs));
  right:calc(var(--pu-sr) + 14px); bottom:calc(var(--pu-sb) + 10px);
}
html.phone-ui .gym .actions #strike { width:var(--contact-size); height:var(--contact-size); border-radius:50%; border:2px solid #ffd8bb; background:radial-gradient(circle at 50% 35%,#ffbf91,var(--pu-orange) 70%); color:#2a1206; font-size:14px; letter-spacing:.02em; padding:0 4px; overflow-wrap:normal; word-break:normal; box-shadow:0 6px 18px #ff985d55; }
html.phone-ui .gym .actions :is(#defend,#roll,#push,#tool) { width:var(--secondary-size); height:var(--secondary-size); border-radius:50%; border:2px solid #ffffff4d; background:#0c1424a6; -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px); font-size:12px; }
html.phone-ui .gym .actions #roll { right:calc(var(--contact-size) - 4px); bottom:calc(var(--contact-size) - 6px); }
/* Ult joins the arc above the contact button, with its charge as a ring. */
html.phone-ui .gym .signature-panel {
  top:auto; left:auto; right:calc(var(--pu-sr) + 14px + 12px*var(--pu-bs)); bottom:calc(var(--pu-sb) + 10px + 100px*var(--pu-bs));
  width:auto; padding:0; background:none; border:0; z-index:6;
}
html.phone-ui .gym #mobile-ult-meter { display:none; }
html.phone-ui .gym #signature-use {
  width:calc(62px*var(--pu-bs)); height:calc(62px*var(--pu-bs)); border-radius:50%; border:0;
  background:radial-gradient(circle,#0c1424d9 62%,transparent 63%),conic-gradient(var(--pu-gold) calc(var(--pu-ult,0)*1%),#ffffff2e 0);
  color:var(--pu-paper); font:700 12px/1 var(--font-display); letter-spacing:.1em;
}
html.phone-ui .gym #signature-use.touch-ready:enabled { color:var(--pu-gold); filter:none; animation:pu-ult 1.2s infinite; }
@keyframes pu-ult { 0% { box-shadow:0 0 0 0 #f7c354aa; } 100% { box-shadow:0 0 0 14px #f7c35400; } }
/* Left-handed: swap the thumbs. */
html.phone-ui.pu-lefty .gym .deck .stick-unit { left:auto; right:calc(var(--pu-sr) + 12px); }
html.phone-ui.pu-lefty .gym .deck .actions { right:auto; left:calc(var(--pu-sl) + 14px); transform:scaleX(-1); }
html.phone-ui.pu-lefty .gym .deck .actions > * { transform:scaleX(-1); }
html.phone-ui.pu-lefty .gym .signature-panel { right:auto; left:calc(var(--pu-sl) + 14px + 12px*var(--pu-bs)); }


/* ---------- Lab: control pages instead of a continuous on-court scroll ---------- */
html.phone-ui .gym #training-panel:not([hidden]) {
  position:absolute; z-index:14; inset:0 auto 0 0; width:min(72vw,calc(var(--pu-sl) + 322px));
  max-height:none; margin:0; padding:var(--pu-st) 12px var(--pu-sb) calc(var(--pu-sl) + 4px);
  gap:3px; overflow:auto; border:0; border-right:1px solid #00cfcd55; border-radius:0;
  background:#0b1422f2; box-shadow:20px 0 40px #0008; transform:none;
}
html.phone-ui .gym #training-panel :is(.training-head,.training-pager) { position:sticky; z-index:1; background:#0e1929; }
html.phone-ui .gym #training-panel .training-head { top:0; }
html.phone-ui .gym #training-panel .training-head strong { font:800 18px/1 var(--font-display); text-transform:uppercase; color:var(--pu-teal); letter-spacing:.05em; }
html.phone-ui .gym #training-panel .training-pager { top:44px; display:flex; gap:4px; }
html.phone-ui .gym #training-panel .training-pager button { flex:1; min-width:0; padding:0 4px; font-size:12px; }
/* The cut-in preference shares the title row on phones: it remains a
   44px label, while the six activity choices clear the bottom safe inset. */
html.phone-ui .gym #training-panel .drill-cutin-option {
  position:absolute;z-index:2;top:var(--pu-st);left:calc(var(--pu-sl) + 97px);right:76px;
  align-items:center;gap:4px;min-height:44px;margin:0;font-size:12px;line-height:1.1;
}
html.phone-ui .gym #training-panel [hidden] { display:none; }
html.phone-ui .gym #training-panel :is(button,select) { min-height:44px; min-width:0; border-radius:8px; font-size:13px; }
html.phone-ui .gym #training-panel .training-drills:not([hidden]),
html.phone-ui .gym #training-panel #lab-controls:not([hidden]),
html.phone-ui .gym #training-panel #receive-options:not([hidden]) {
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; align-content:start; min-width:0;
}
html.phone-ui .gym #training-panel #training-tools { display:block; min-width:0; }
html.phone-ui .gym #training-panel:not([data-training-page=activity]) :is(.training-drills,.drill-cutin-option),
html.phone-ui .gym #training-panel:not([data-training-page=court]):not([data-training-page=serves]) #receive-options,
html.phone-ui .gym #training-panel:not([data-training-page=court]) #receive-roles,
html.phone-ui .gym #training-panel:not([data-training-page=lines]) #lab-lines-controls,
html.phone-ui .gym #training-panel:not([data-training-page=defense]) #defense-tools,
html.phone-ui .gym #training-panel[data-training-page=lines] #lab-controls,
html.phone-ui .gym #training-panel[data-training-page=activity] #training-tools,
html.phone-ui .gym #training-panel[data-training-page=serves] #training-tools { display:none; }
html.phone-ui .gym #training-panel[data-training-page=court] #lab-controls > :not(:is(label[for=lab-bots],#lab-bots,#lab-feed,#lab-swap,#lab-set-feed-label,#lab-set-feed,#lab-opposition-label,#lab-opposition,#lab-physical-build)),
html.phone-ui .gym #training-panel[data-training-page=ultimate] #lab-controls > :not(:is(label[for=lab-ultimate],#lab-ultimate,#lab-fill,#lab-auto-fill,#lab-overload-note,#lab-status)),
html.phone-ui .gym #training-panel[data-training-page=demo] #lab-controls > :not(#lab-ultimate-clip),
html.phone-ui .gym #training-panel[data-training-page=room] #lab-controls > :not(:is(p:first-child,#lab-invite,#lab-play)),
html.phone-ui .gym #training-panel[data-training-page=court] #receive-options > label:has([data-serve-option]),
html.phone-ui .gym #training-panel[data-training-page=court] #receive-options > small:not(#receive-side-label),
html.phone-ui .gym #training-panel[data-training-page=serves] #receive-options > :is(label:has(#receive-coverage),#receive-switch-side,#receive-side-label) { display:none; }
html.phone-ui .gym #training-panel #receive-options { padding:0; border:0; }
html.phone-ui .gym #training-panel[data-training-page=serves] #receive-options:not([hidden]) {
  grid-template-columns:repeat(3,minmax(0,1fr));
}
html.phone-ui .gym #training-panel #receive-options > small,
html.phone-ui .gym #training-panel #lab-controls > p,
html.phone-ui .gym #training-panel #lab-controls > video,
html.phone-ui .gym #training-panel label:has(#receive-coverage) { grid-column:1 / -1; }
html.phone-ui .gym #training-panel #receive-options label { gap:4px; min-height:44px; line-height:1.12; }
html.phone-ui .gym #training-panel #lab-controls > label { align-self:center; }
html.phone-ui .gym #training-panel #lab-controls > video { width:100%; max-height:min(160px,42dvh); object-fit:contain; }
html.phone-ui .gym #training-panel #lab-status:empty { display:none; }
html.phone-ui .gym .training-show:not([hidden]) { top:calc(var(--pu-st) + 56px); left:var(--pu-sl); min-height:44px; padding:0 12px; border-radius:12px; background:#0c1424cc; border:1px solid #00cfcd88; color:var(--pu-teal); font:700 14px/1 var(--font-display); letter-spacing:.1em; text-transform:uppercase; }
html.phone-ui .gym .practice-drills:not([hidden]) { top:var(--pu-st); left:calc(var(--pu-sl) + 60px); width:auto; padding:0; background:none; border:0; }
html.phone-ui .gym .drill-coach:not([hidden]) { top:calc(var(--pu-st) + 52px); }

/* ---------- Portrait prompt ---------- */
#phone-orientation { background:radial-gradient(80% 50% at 50% 40%,#1d3550,#0c1424); }
#phone-orientation::backdrop { background:#0c1424; }
#phone-orientation h2 { font-family:var(--font-display); font-weight:800; text-transform:uppercase; letter-spacing:.02em; }
#phone-orientation svg { color:#ffd4a8; }

/* Layout editor dialog */
html.phone-ui .pu-layout-editor[open] { position:fixed; inset:0; width:auto; height:var(--pu-h,auto); max-width:none; max-height:none; margin:0; padding:0; border:0; background:#0c1424e0; }
html.phone-ui .pu-layout-editor::backdrop { background:transparent; }
html.phone-ui .pu-layout-editor .pu-editbar { position:fixed; z-index:2; top:var(--pu-st); left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:8px; padding:5px 5px 5px 14px; border-radius:12px; background:#0c1424f0; border:1px solid var(--pu-orange); color:var(--pu-paper); white-space:nowrap; font:400 13px/1 var(--font-body); }
html.phone-ui .pu-ghost { position:fixed; display:grid; place-items:center; border-radius:50%; border:2px dashed var(--pu-orange); background:#ff985d33; color:var(--pu-paper); font:700 12px/1 var(--font-body); text-transform:uppercase; letter-spacing:.06em; touch-action:none; cursor:grab; }
html.phone-ui #sheet .court-touch-settings { display:grid; gap:6px; }
html.phone-ui #sheet .court-touch-settings .touch-check { display:flex; align-items:center; gap:10px; min-height:44px; }
html.phone-ui .pu-editbar button { min-height:36px; padding:0 12px; border-radius:9px; border:1px solid var(--pu-line); background:var(--pu-surface); color:var(--pu-paper); font:700 13px/1 var(--font-body); }
html.phone-ui .pu-editbar button.primary { background:var(--pu-orange); color:#2a1206; border-color:#ffc49c; }
html.phone-ui #account-dialog[open] { overflow:auto; padding-top:var(--pu-st); padding-bottom:var(--pu-sb); }
/* First-launch welcome page: pitch left, choice card right, clear of the Dynamic Island and home bar. */
html.phone-ui #welcome-dialog { height:var(--pu-h,100dvh); }
html.phone-ui #welcome-dialog .welcome-page { grid-template-columns:minmax(0,1fr) 300px; gap:24px; width:100%; padding:var(--pu-st) var(--pu-sr) var(--pu-sb) var(--pu-sl); }
html.phone-ui #welcome-dialog .welcome-pitch img { height:60px; }
html.phone-ui #welcome-dialog .welcome-pitch p { margin-top:10px; font-size:20px; }
html.phone-ui #welcome-dialog .welcome-pitch ul { margin-top:12px; gap:6px; font-size:13px; }
html.phone-ui #welcome-dialog .welcome-card { gap:8px; padding:14px; border-color:var(--pu-line); }
html.phone-ui #welcome-dialog .welcome-card h2 { font-size:22px; }
html.phone-ui #welcome-dialog .welcome-card p { font-size:13px; line-height:1.4; }
html.phone-ui #welcome-dialog .welcome-card button { min-height:44px; font-size:15px; }
html.phone-ui #welcome-dialog .welcome-card .welcome-link { min-height:40px; font-size:14px; }
html.phone-ui #sheet .court-touch-settings { padding:10px 12px; border:1px solid var(--pu-line); border-radius:12px; background:var(--pu-surface); }
html.phone-ui #sheet .court-touch-settings legend { padding:0 6px; font:700 15px/1 var(--font-display); letter-spacing:.08em; text-transform:uppercase; }
html.phone-ui #sheet .court-touch-settings #touch-layout-edit { background:linear-gradient(180deg,#ffb582,var(--pu-orange) 55%,#f07d45); color:#2a1206; border:1px solid #ffc49c; border-radius:10px; font-weight:700; }
html.phone-ui #sheet .court-touch-settings input[type=range] { width:100%; accent-color:var(--pu-orange); }
html.phone-ui #sheet .court-touch-settings .touch-check { justify-content:flex-start; text-align:left; }
html.phone-ui #sheet .court-touch-settings .touch-check input { width:22px; height:22px; margin:0; flex:none; accent-color:var(--pu-orange); }
html.phone-ui #sheet .court-touch-settings small { color:var(--pu-muted); font-size:12px; }
html.phone-ui #sheet .binding-reset { position:static; }
/* Lab activities: two compact rows and a persistent exit/resume row. */
html.phone-ui #modal:has(.lab-hub) #close { height:44px; min-height:44px; }
html.phone-ui #modal:has(.lab-hub) #sheet { padding:0 0 var(--pu-sb); }
html.phone-ui #sheet .lab-hub {
  min-height:100%; display:grid; grid-template-rows:auto minmax(124px,1fr) auto; gap:6px;
}
html.phone-ui #sheet .lab-hub :is(h3,h2,p,small) { color:var(--pu-paper); }
html.phone-ui #sheet .lab-hub .lab-intro { display:flex; align-items:center; flex-wrap:wrap; gap:3px 12px; margin:0; }
html.phone-ui #sheet .lab-hub .lab-intro p { margin:0; font:800 17px/1.1 var(--font-display); }
html.phone-ui #sheet .lab-hub .lab-intro > span { color:var(--pu-muted); font:400 12px/1.15 var(--font-body); }
html.phone-ui #sheet .lab-hub .lab-sessions {
  grid-template-columns:repeat(3,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(0,1fr)); gap:6px;
}
html.phone-ui #sheet .lab-hub .lab-sessions button, html.phone-ui #sheet .lab-hub button {
  background:var(--pu-surface); color:var(--pu-paper); border:1px solid var(--pu-line); border-radius:10px; box-shadow:var(--pu-lift);
}
html.phone-ui #sheet .lab-hub .lab-sessions button {
  display:grid; grid-template-columns:24px minmax(0,1fr); align-content:start; align-items:start;
  min-height:44px; min-width:0; gap:6px; padding:6px;
}
html.phone-ui #sheet .lab-hub .lab-sessions svg { width:24px; height:24px; }
html.phone-ui #sheet .lab-hub .lab-sessions strong { margin:0 0 4px; font:800 16px/1.05 var(--font-display); }
html.phone-ui #sheet .lab-hub .lab-sessions small {
  color:var(--pu-muted); font:400 11px/1.2 var(--font-body);
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
html.phone-ui #sheet .lab-hub .lab-card-action { display:none; }
html.phone-ui #sheet .lab-hub .lab-sessions button[aria-pressed=true] {
  border-color:var(--pu-orange); box-shadow:0 0 0 1px var(--pu-orange); background:var(--pu-navy-2);
}
/* Keep Lab activities reachable even with the phone's left-side tools drawer open. */
html.phone-ui .gym > header #lab-browse:not([hidden]) { position:fixed; top:var(--pu-st); right:var(--pu-sr); }
html.phone-ui #sheet .hero-lobby .lobby-play { width:100%; max-width:none; justify-self:stretch; }
html.phone-ui #sheet .lab-hub .lab-footer { position:static; background:none; border:0; padding:0; margin:0; }
html.phone-ui #sheet .lab-hub .lab-footer button { height:44px; min-height:44px; padding:4px 12px; }
html.phone-ui #sheet .hero-lobby .lobby-tab [id="character-points-notice"] { position:absolute; }

/* ---------- Menus over the court: the open menu sits above every other HUD button ---------- */
html.phone-ui .gym > header:has(.match-menu[open]) { z-index:30; }
html.phone-ui .gym .match-menu[open] summary { position:relative; z-index:31; }

/* ---------- Kits: the same page frame as Character (Back, title, X) inside the safe area ---------- */
html.phone-ui #modal[open]:has(#kit-form.kit-studio) {
  display:grid; grid-template-rows:auto auto minmax(0,1fr); overflow:hidden; padding:0 var(--pu-sr) 0 var(--pu-sl);
  background:radial-gradient(70% 90% at 80% 0%,#1d3550 0%,transparent 60%),var(--pu-ink); color:var(--pu-paper);
}
html.phone-ui #modal[open]:has(#kit-form.kit-studio) .sheet-head { display:flex; }
html.phone-ui #modal[open]:has(#kit-form.kit-studio) #sheet { padding:0 0 var(--pu-sb); overflow:hidden; }
html.phone-ui #modal[open] #kit-form.kit-studio { display:grid; grid-template-rows:minmax(0,1fr) auto; height:100%; min-height:0; gap:8px; }
html.phone-ui #modal[open] .kit-studio :is(.kit-studio-top,.kit-studio-kicker,.kit-studio-main > h2) { display:none; }
html.phone-ui #modal[open] .kit-studio :is(.kit-studio-main,.kit-studio-footer) { width:100%; margin:0; }
html.phone-ui #modal[open] .kit-studio .kit-studio-main { align-self:stretch; min-height:0; padding:0; overflow:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }
html.phone-ui #modal[open] .kit-studio .kit-studio-work { grid-template-columns:230px minmax(0,1fr); gap:12px; align-items:start; }
html.phone-ui #modal[open] .kit-studio .kit-preview { position:sticky; top:0; display:grid; grid-template-columns:1fr; grid-template-rows:auto 1fr auto; min-height:0; border-radius:12px; }
html.phone-ui #modal[open] .kit-studio .kit-preview canvas { grid-column:1; grid-row:2; width:100%; height:150px; }
html.phone-ui #modal[open] .kit-studio .kit-fields { padding:10px 12px; border-radius:12px; border-top-width:1px; background:var(--pu-surface); }
html.phone-ui #modal[open] #sheet .kit-studio h3 { margin:0 0 8px; font:800 20px/1 var(--font-display); font-style:normal; letter-spacing:.03em; }
html.phone-ui #modal[open] .kit-studio .kit-studio-footer { padding:0; border:0; }
html.phone-ui #modal[open] #sheet .kit-studio-footer button { min-height:40px; border-radius:10px; }
html.phone-ui #modal[open] .kit-studio .kit-fields { border-top-color:var(--pu-line); }
html.phone-ui #modal[open] #sheet .kit-studio-footer button.primary { background:linear-gradient(180deg,#ffb582,var(--pu-orange) 55%,#f07d45); color:#2a1206; border:1px solid #ffc49c; }

/* Kits keep one shared draft. On short phones, page the controls, not the preview. */
html.phone-ui #modal[open] .kit-studio .kit-studio-work{grid-template-columns:minmax(86px,1fr) minmax(0,3.1fr);gap:6px}
html.phone-ui #modal[open] .kit-studio .kit-preview{position:static}
html.phone-ui #modal[open] .kit-studio .kit-preview canvas{height:clamp(64px,29dvh,140px)}
html.phone-ui #modal[open] .kit-studio .kit-preview-tag{font-size:12px;letter-spacing:.02em;margin:5px 5px 0}
html.phone-ui #modal[open] .kit-studio .kit-preview-label{display:block;padding:4px 5px;line-height:1.12}
html.phone-ui #modal[open] .kit-studio .kit-preview-label small{display:block;font-size:12px}
html.phone-ui #modal[open] .kit-studio .kit-fields{
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;align-items:end;
  padding:5px 6px;gap:4px 5px;
}
html.phone-ui #modal[open] .kit-studio .kit-fields h3{display:none}
html.phone-ui #modal[open] .kit-studio .kit-section-nav{display:flex;gap:4px;grid-row:1;grid-column:1/3}
html.phone-ui #modal[open] #sheet #kit-form.kit-studio .kit-section-nav button{
  flex:1 1 0;min-width:44px;min-height:44px;padding-inline:5px;
  border:1px solid var(--pu-line);border-radius:8px;background:var(--pu-surface);color:var(--pu-paper);
}
html.phone-ui #modal[open] #sheet #kit-form.kit-studio .kit-section-nav [aria-pressed=true]{background:var(--pu-orange);color:#2a1206}
html.phone-ui #modal[open] .kit-studio .kit-team-field{grid-row:1;grid-column:3}
html.phone-ui #modal[open] .kit-studio .kit-pattern-field{grid-row:2;grid-column:1}
html.phone-ui #modal[open] .kit-studio .kit-field{margin:0;min-width:0}
html.phone-ui #modal[open] #sheet #kit-form.kit-studio label{font-size:12px;margin:0 0 3px}
html.phone-ui #modal[open] #sheet #kit-form.kit-studio select{min-height:44px;padding-inline:4px;font-size:12px}
html.phone-ui #modal[open] .kit-studio .kit-colours{grid-row:2;grid-column:2/4;gap:5px}
html.phone-ui #modal[open] .kit-studio .kit-colour-chip{padding:0 2px;gap:2px;flex-wrap:nowrap;min-height:44px}
html.phone-ui #modal[open] #sheet #kit-form.kit-studio .kit-colour-chip input{width:44px;height:44px}
html.phone-ui #modal[open] .kit-studio .kit-colour-chip span{font-size:12px;letter-spacing:0;overflow-wrap:anywhere}
html.phone-ui #modal[open] .kit-studio[data-kit-active=jersey] [data-kit-piece=shorts],
html.phone-ui #modal[open] .kit-studio[data-kit-active=shorts] [data-kit-piece=jersey]{display:none}
html.phone-ui #modal[open] .kit-studio #kit-message{grid-column:1/-1;margin:0}
html.phone-ui #modal[open] #sheet #kit-form.kit-studio .kit-studio-footer button{min-height:44px}

/* iOS home-screen app: phone-ui.js sets --pu-h to the real screen height, because iOS reports a short viewport there. */
html.phone-ui.pu-fill, html.phone-ui.pu-fill body { height:var(--pu-h); min-height:var(--pu-h); }
html.phone-ui.pu-fill .gym { height:var(--pu-h); }
html.phone-ui.pu-fill .hero-lobby .mode-select:not([hidden]) { bottom:auto; height:var(--pu-h); }
html.phone-ui.pu-fill .gym .match-menu[open] .tools { bottom:auto; height:var(--pu-h); }
html.phone-ui #modal[open] #sheet .pu-screen-info { display:block; margin-top:8px; color:var(--pu-dim); font:400 12px/1.3 var(--font-body); }

/* ---------- Character (Locker Room popout): full screen inside the safe area, like the other pages ---------- */
html.phone-ui #character-dialog[open]:has(#athlete-form) {
  inset:0; width:auto; height:var(--pu-h,auto); max-width:none; max-height:none; margin:0; border:0; border-radius:0; box-shadow:none;
  padding:var(--pu-st) var(--pu-sr) var(--pu-sb) var(--pu-sl);
}
html.phone-ui #character-dialog::backdrop { background:var(--pu-ink); }
html.phone-ui #character-dialog .character-dialog-head { padding-inline:0; }
html.phone-ui #character-dialog #athlete-form { padding-inline:0; }

/* Page rows are placed by name. With the header hidden (lobby), Safari would otherwise auto-place the
   content in the first, content-sized row and leave the stretching row empty: a blank band at the bottom. */
html.phone-ui #modal[open] > .sheet-head { grid-row:1; }
html.phone-ui #modal[open] > .queue-page-bar { grid-row:2; }
html.phone-ui #modal[open] > #sheet { grid-row:3; grid-column:1; min-height:0; }
html.phone-ui #modal[open] { grid-template-columns:minmax(0,1fr); }
html.phone-ui #character-dialog #athlete-form .athlete-preview { position:relative; }
html.phone-ui #character-dialog .roster-turn { inset:auto auto 104px 6px; }

/* Court choices: a compact card row and labelled page buttons, no gesture required. */
html.phone-ui #modal.page-mode #sheet .venue-list {
  grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin:4px 0 8px;
}
html.phone-ui #modal.page-mode #sheet .venue-list .venue-option {
  min-width:0; min-height:78px; display:grid; grid-template-columns:minmax(0,1fr);
  align-content:start; gap:4px; white-space:normal; padding:4px; text-align:center; position:relative;
}
html.phone-ui #modal.page-mode #sheet .venue-list .venue-option[data-venue-other-page] { display:none; }
html.phone-ui #modal.page-mode #sheet .venue-list .venue-option :is(img,.venue-beach-preview) {
  width:100%; height:42px; object-fit:cover; border-radius:3px;
}
html.phone-ui #modal.page-mode #sheet .venue-option[aria-pressed="true"]::after { position:absolute; top:11px; right:12px; }
html.phone-ui #modal #sheet .venue-pager { display:flex; gap:10px; align-items:center; justify-content:center; }
html.phone-ui #modal #sheet .venue-pager button { min-height:44px; min-width:92px; touch-action:manipulation; }
html.phone-ui #modal #sheet #venue-message:empty { display:none; }


/* Explicit touch drawer pages: all primary actions reachable without dragging. */
html.phone-ui .gym .match-menu[open] .tools[data-match-drawer-page] {
 width:min(calc(100vw - var(--pu-sr)),calc(var(--pu-sl) + 315px));
 padding:calc(var(--pu-st) + 4px) 10px calc(var(--pu-sb) + 4px) calc(var(--pu-sl) + 54px);
 display:grid; grid-template-columns:repeat(2,minmax(0,1fr));
 grid-auto-rows:max-content; align-content:start; gap:6px;
}
html.phone-ui .gym .match-menu[open] .tools[data-match-drawer-page] :is(button,#guide,#pause) {
 min-height:44px; padding:0 5px; text-align:center; font-size:14px; letter-spacing:0;
}
html.phone-ui .gym .match-menu[open] .match-drawer-pages {
 display:grid; grid-column:1/-1; grid-template-columns:1fr 1fr; gap:6px;
}
html.phone-ui .match-drawer-pages button[aria-pressed=true] {
 border-color:var(--pu-teal); box-shadow:inset 0 -2px var(--pu-teal);
}
html.phone-ui .gym .match-menu .tools[data-match-drawer-page=quick] > [data-match-drawer-action=setup],
html.phone-ui .gym .match-menu .tools[data-match-drawer-page=setup] > [data-match-drawer-action=quick] { display:none; }
html.phone-ui .gym .match-menu[open] .tools > [data-match-drawer-resume] { display:block; grid-column:1/-1; }
html.phone-ui .gym .match-menu .tools [data-match-drawer-label] { font-size:0!important; }
html.phone-ui .gym .match-menu .tools [data-match-drawer-label]::before {
 content:attr(data-match-drawer-label); font-size:14px;
}
/* Settings: native controls stay mounted; only landscape phones get task tabs and
   bounded pages. The sheet still scrolls at zoom, with a keyboard, or at tiny heights. */
html.phone-ui #sheet:has(.settings-paged) { overflow:auto; padding-bottom:var(--pu-sb); }
html.phone-ui #sheet .settings-paged { --settings-gap:5px; display:flex; flex-direction:column; gap:var(--settings-gap); }
html.phone-ui #sheet .settings-paged [data-settings-hidden] { display:none !important; }
html.phone-ui #sheet .settings-paged .settings-tabs { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; }
html.phone-ui #sheet .settings-paged fieldset { margin:0; padding:0; border:0; min-inline-size:0; background:none; }
html.phone-ui #sheet .settings-paged label { margin:0; }
html.phone-ui #sheet .settings-paged legend,html.phone-ui #sheet .settings-paged .binding-columns { display:none; }
html.phone-ui #sheet .settings-paged :is(label,button,select) { font-size:14px; }
html.phone-ui #sheet .settings-paged :is(small,.binding-status) { font-size:12px; line-height:1.2; color:var(--pu-muted); }
html.phone-ui #sheet .settings-paged .timing-settings { grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:6px 12px; }
html.phone-ui #sheet .settings-paged .timing-options { grid-template-columns:repeat(2,minmax(0,1fr)); gap:2px 8px; grid-auto-flow:column; grid-template-rows:auto auto auto auto; }
html.phone-ui #sheet .settings-paged .timing-options select { min-height:40px; padding:3px 6px; }
html.phone-ui #sheet .settings-paged .timing-preview { min-height:106px; }
html.phone-ui #sheet .settings-paged .timing-reset-actions { gap:4px; }
html.phone-ui #sheet .settings-paged .timing-reset-actions button { min-height:40px; padding:4px 8px; }
html.phone-ui #sheet .settings-paged .court-touch-settings { grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 16px; }
html.phone-ui #sheet .settings-paged .settings-touch-field { display:grid; align-content:start; gap:3px; min-width:0; }
html.phone-ui #sheet .settings-paged .settings-touch-field > :is(button,select,input) { margin:0; min-height:40px; align-self:start; }
html.phone-ui #sheet .settings-paged .settings-touch-field .touch-check { align-self:start; min-height:40px; }
html.phone-ui #sheet .settings-paged .pu-screen-info { grid-column:1/-1; margin-top:0; }
html.phone-ui #sheet .settings-paged .court-graphics-settings { display:block; }
html.phone-ui #sheet .settings-paged .settings-graphics.settings-page { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
html.phone-ui #sheet .settings-paged .settings-graphic-field { display:grid; align-content:start; gap:4px; padding:4px 6px; border:1px solid var(--pu-line); border-radius:8px; }
html.phone-ui #sheet .settings-paged .settings-graphic-field select { min-width:0; min-height:40px; }
html.phone-ui #sheet .settings-paged .settings-graphic-field small { grid-column:auto; }
html.phone-ui #sheet .settings-paged .settings-keyboard { position:relative; display:block; }
html.phone-ui #sheet .settings-paged .binding-status { min-height:15px; margin:0 0 3px; line-height:1.15; }
html.phone-ui #sheet .settings-paged .binding-list { padding:0; margin:0; overflow:visible; }
html.phone-ui #sheet .settings-paged .binding-list h3 { display:none; }
html.phone-ui #sheet .settings-paged .binding-row { grid-template-columns:minmax(0,1.23fr) minmax(0,1fr); gap:6px; min-height:0; padding:1px 0; }
html.phone-ui #sheet .settings-paged .binding-copy { gap:1px; line-height:1.05; font-size:14px; }
html.phone-ui #sheet .settings-paged .binding-copy small { font-size:12px; }
html.phone-ui #sheet .settings-paged .binding-slot { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:end; gap:0 3px; }
html.phone-ui #sheet .settings-paged .binding-slot small { grid-column:1/-1; }
html.phone-ui #sheet .settings-paged .binding-slot button { min-height:40px; padding:3px 5px; line-height:1.05; }
html.phone-ui #sheet .settings-paged .binding-slot .binding-clear:not([hidden]) { min-width:36px; font-size:0; }
html.phone-ui #sheet .settings-paged .binding-clear:not([hidden])::after { content:'×'; font-size:20px; }
html.phone-ui #sheet .settings-paged .settings-pager { display:flex; align-items:center; justify-content:flex-start; gap:8px; margin-top:6px; }
html.phone-ui #sheet .settings-paged .settings-pager :is(button,span) { display:inline-flex; align-items:center; justify-content:center; }
html.phone-ui #sheet .settings-paged .settings-pager button { padding:4px 12px; }
html.phone-ui #sheet .settings-paged .settings-pager button:disabled { opacity:.55; }
html.phone-ui #sheet .settings-paged .settings-count { font-size:12px; min-width:38px; }
html.phone-ui #sheet .settings-paged .settings-pager .binding-reset { margin:0 0 0 auto; }
html.phone-ui #sheet .settings-paged .binding-confirm:not([hidden]) { position:absolute; z-index:2; inset:0 0 auto; min-height:86px; margin:0; background:var(--pu-navy); }

html.phone-ui #sheet .settings-paged .timing-settings { display:block; }
html.phone-ui #sheet .settings-paged .settings-timing-options { display:grid; align-items:start; gap:5px; }
html.phone-ui #sheet .settings-paged .settings-timing-options .timing-options { grid-template-columns:repeat(4,minmax(0,1fr)); grid-template-rows:auto auto; }
html.phone-ui #sheet .settings-paged .settings-timing-preview { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:3px 10px; align-items:start; }
html.phone-ui #sheet .settings-paged .settings-timing-preview .timing-preview { grid-row:1 / span 2; min-height:103px; }
html.phone-ui #sheet .settings-paged .settings-timing-preview .timing-reset-actions { grid-column:2; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
html.phone-ui #sheet .settings-paged .settings-timing-preview .timing-reset-actions button { padding:3px 4px; line-height:1.1; }
html.phone-ui #sheet .settings-paged .settings-timing-preview .timing-reset-status { grid-column:1; grid-row:3; }
html.phone-ui #sheet .settings-paged .settings-timing-preview small:last-child { grid-column:2; grid-row:2; }
html.phone-ui #sheet .settings-paged .binding-list .binding-columns { display:flex; margin:0!important; line-height:1.1; }
html.phone-ui #sheet .settings-paged .binding-slot small { display:none; }

/* A guide topic is a page, with sound and help controls kept in reach. */
html.phone-ui #sheet .guide-content { max-width:700px; display:grid; gap:6px; align-content:start; margin:0 auto; }
html.phone-ui #sheet .guide-content .guide-intro { margin:0; font-size:13px; }
html.phone-ui #sheet .guide-topics { min-height:64px; margin:0; padding:8px; list-style:none; border:1px solid var(--pu-line); border-radius:8px; }
html.phone-ui #sheet .guide-topics li { margin:0; line-height:1.38; }
html.phone-ui #sheet .guide-topics [data-guide-other-page] { display:none; }
html.phone-ui #sheet .guide-pager { display:flex; align-items:center; gap:10px; }
html.phone-ui #modal[open] #sheet .guide-content :is(#guide-prev,#guide-next,#mute,#guide-hitboxes,.guide-actions a) { min-height:44px; touch-action:manipulation; }
html.phone-ui #sheet .guide-actions { gap:8px; flex-wrap:wrap; }
html.phone-ui #sheet .guide-actions a { display:inline-flex; align-items:center; padding:0 4px; }

/* Phone-only private room navigation; the full desktop lobby and ranked queues stay intact. */
html.phone-ui #modal[open]:has([data-room-navigation]) { display:block; width:auto; height:var(--pu-h,100dvh); overflow:hidden; padding:0; }
html.phone-ui #modal[open]:has([data-room-navigation]) .sheet-head { display:none; }
html.phone-ui #modal[open]:has([data-room-navigation]) #sheet { margin:0; padding:0; min-height:0; height:100%; overflow:hidden; }
html.phone-ui #sheet [data-room-navigation] {
  display:grid; grid-template-rows:auto auto minmax(0,1fr) auto;
  height:100%; min-height:0; padding:0 var(--pu-sr) 0 var(--pu-sl);
}
html.phone-ui #sheet [data-room-navigation] :is(.room-lobby-top,.room-lobby-body,.room-lobby-footer-inner) { width:100%; margin:0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-top { height:calc(42px + var(--pu-st)); min-height:0; padding:var(--pu-st) 0 1px; gap:6px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-top img { width:94px; }
html.phone-ui #sheet [data-room-navigation] #lobby-close { min-width:44px; min-height:40px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-nav { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:1px 0; }
html.phone-ui #sheet [data-room-navigation] :is(.room-lobby-tabs,.room-lobby-team-pager) { display:flex; align-items:center; gap:5px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-nav button { min-height:40px; min-width:48px; padding:0 8px; font:700 14px/1.1 var(--font-body); }
html.phone-ui #sheet [data-room-navigation] [aria-selected=true] { background:var(--pu-orange); color:#251303; border-color:#ffc49c; }
html.phone-ui #sheet [data-room-navigation] #room-lobby-team-count { min-width:28px; text-align:center; font:600 12px/1 var(--font-body); }
html.phone-ui #sheet [data-room-navigation]:not([data-room-lobby-tab=teams]) .room-lobby-team-pager,
html.phone-ui #sheet [data-room-navigation]:not([data-room-lobby-tab=invite]) .room-lobby-hero,
html.phone-ui #sheet [data-room-navigation]:not([data-room-lobby-tab=teams]) .lobby-teams,
html.phone-ui #sheet [data-room-navigation]:not([data-room-lobby-tab=setup]) .room-lobby-settings,
html.phone-ui #sheet [data-room-navigation][data-room-lobby-team="0"] [data-room-lobby-team-card="1"],
html.phone-ui #sheet [data-room-navigation][data-room-lobby-team="1"] [data-room-lobby-team-card="0"],
html.phone-ui #sheet [data-room-navigation] .room-lobby-court-picker { display:none; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-body { padding:0; min-height:0; overflow:auto; overscroll-behavior:contain; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-hero { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:8px; margin:0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-hero h2 { font-size:26px; margin:2px 0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-hero p { font-size:13px; margin:2px 0 0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-invite { display:flex; flex-wrap:wrap; gap:4px 6px; padding:3px 6px; max-width:340px; margin:0; }
html.phone-ui #sheet [data-room-navigation] #lobby-code { font-size:16px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-invite small { font-size:12px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-invite button { min-height:40px; padding:0 6px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-manual-invite { flex-basis:100%; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-manual-invite label { margin:0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-manual-invite input { width:100%; min-height:40px; }
html.phone-ui #sheet [data-room-navigation] .lobby-teams { display:block; margin:0; }
html.phone-ui #sheet [data-room-navigation] .lobby-teams .room-lobby-team { padding:1px 6px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-team-head { display:flex; align-items:center; justify-content:space-between; padding:0; gap:5px; min-height:40px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-team-head h3 { display:inline; margin:0; font-size:20px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-team-head small { display:inline; margin-right:4px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-team-head .lobby-kit { display:inline; margin:0 0 0 4px; padding:2px 4px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-team-actions { justify-content:flex-end; flex-wrap:nowrap; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-team-actions .edit-team { margin:0; }
html.phone-ui #sheet [data-room-navigation] :is(.room-lobby-team-actions,.room-lobby-player) :is(button,select) { padding:0 5px; min-height:40px; font:700 12px/1.1 var(--font-body); }
html.phone-ui #sheet [data-room-navigation] .room-lobby-players { gap:0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-player { display:flex; flex-direction:row; align-items:center; gap:4px; min-height:42px; padding:1px 3px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-player > :nth-child(2) { flex:1 1 72px; min-width:0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-player strong { white-space:nowrap; font-size:13px; }
html.phone-ui #sheet [data-room-navigation] :is(.room-lobby-portrait,.room-lobby-empty-icon) { flex:0 0 30px; width:30px; height:30px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-player select { max-width:141px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-settings { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:6px; margin:0; padding:6px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-setting label { margin:0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-setting select { min-width:0; min-height:40px; padding:0 6px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-setting .room-lobby-court-art { width:52px; height:35px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-settings p { grid-column:1/-1; margin:0; }
html.phone-ui #sheet [data-room-navigation] :is(#lobby-reminder,#room-message) { font-size:12px; line-height:1.15; margin:2px 0; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-footer { position:relative; align-self:end; padding:3px 0 var(--pu-sb); }
html.phone-ui #sheet [data-room-navigation] :is(.room-lobby-footer-inner,.room-lobby-footer-actions) { flex-wrap:nowrap; gap:6px; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-footer :is(button,#lobby-leave) { min-height:40px; font-size:13px; padding:0 7px; white-space:nowrap; }
html.phone-ui #sheet [data-room-navigation] .room-lobby-footer-actions .primary { min-width:0; }

/* Pause stays a compact match card inside the full-height phone dialog. */
html.phone-ui #modal[open]:has(#pause-result){
  width:auto;max-width:660px;height:fit-content;max-height:calc(100% - var(--pu-st) - var(--pu-sb));
  margin:auto;inset:var(--pu-st) var(--pu-sr) var(--pu-sb) var(--pu-sl);
  padding:8px 12px 12px;border:0;border-radius:0;
  display:block;background:transparent;box-shadow:none
}
html.phone-ui #modal[open]:has(#pause-result)::backdrop{background:rgb(10 14 20 / 23%)}
html.phone-ui #modal[open]:has(#pause-result) .sheet-head{min-height:44px;margin:0 0 6px;padding:0}
html.phone-ui #modal[open]:has(#pause-result) #close{min-height:44px;box-shadow:none}
html.phone-ui #modal[open]:has(#pause-result) #sheet{padding:0;overflow:visible}
html.phone-ui #modal[open]:has(#pause-result) #sheet .pause-actions button{min-height:44px}
/* Network readout and details: no menu button up here on phones, so sit just below the scoreboard.
   The details panel ignores taps, so the Ult and Roll buttons under it still work. */
html.phone-ui .net-debug { top: 60px; right: max(14px, env(safe-area-inset-right)); }
html.phone-ui .net-details { top: 96px; right: max(14px, env(safe-area-inset-right)); }
