/* Phones first: 44px tap targets, notch padding, no background scroll behind the sheet. */
:root {
  color-scheme: light dark;
  --bg: #eef0f2; --panel: #fff; --text: #14171a; --dim: #565d64; --line: #e4e7ea; --chip: #eef0f2;
  --maize: #ffcb05; --blue: #00274c; --link: #00274c; --btn: #00274c; --btn-ink: #ffcb05; --live: #b00f1f; --me: #fff3bf; --hero: #00274c;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f11; --panel: #1a1d20; --text: #f1f3f5; --dim: #a7afb7; --line: #2d3237; --chip: #262a2f;
    --link: #ffcb05; --live: #ff6b75; --me: #3b3214; --hero: #001a33; --btn: #ffcb05; --btn-ink: #00274c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
input { min-height: 44px; font-size: 16px; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; }

.top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--blue); color: var(--maize); border-bottom: 4px solid var(--maize); min-height: 60px;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.top h1 { font-family: var(--display); font-style: italic; font-weight: 800; font-size: 1.5rem; text-transform: uppercase; }
.invite { min-height: 44px; padding: 0 16px; border: 1px solid var(--maize); border-radius: 22px; font-size: 0.8rem; font-weight: 800; }

#status, main { max-width: 640px; margin: 0 auto; }
#status { color: var(--dim); font-size: 0.7rem; text-align: right; padding: 4px 16px; }
.panel { background: var(--panel); }
.pad { padding: 16px; }
.center { text-align: center; }
.line { display: flex; gap: 8px; margin: 12px 0; }
.line input { flex: 1; min-width: 0; }
.primary { min-height: 48px; padding: 0 22px; border-radius: 24px; background: var(--btn); color: var(--btn-ink); font-weight: 800; font-size: 0.95rem; }
.wide { width: 100%; }
.note { color: var(--dim); font-size: 0.75rem; padding: 10px 16px 0; }
.pad .note { padding: 8px 0; }
.link { min-width: 44px; min-height: 44px; color: var(--link); font-weight: 800; font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }

.hero { display: flex; align-items: center; gap: 12px; background: var(--hero); color: #fff; padding: 14px 16px; }
.hero h2 { font-size: 1.1rem; font-weight: 800; overflow-wrap: anywhere; }
#rank { font-size: 0.75rem; color: #c5d3e3; }
#rename { min-height: 44px; margin-bottom: -8px; color: var(--maize); font-size: 0.75rem; font-weight: 800; padding-right: 16px; }
.badge { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 50%; background: var(--maize); color: var(--blue); font: 700 1.4rem var(--display); }
.total { text-align: right; }
.total strong { color: var(--maize); display: block; font: 700 2.75rem/1 var(--display); font-variant-numeric: tabular-nums; }
.total small { font-size: 0.6rem; letter-spacing: 0.08em; color: #c5d3e3; }
.label { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px 6px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; color: var(--dim); }

.row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 62px; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.slot { width: 38px; flex: none; padding: 5px 0; border-radius: 4px; background: var(--chip); text-align: center; font-size: 0.62rem; font-weight: 800; color: var(--dim); }
.face { position: relative; display: grid; place-items: center; width: 44px; height: 44px; flex: none; overflow: hidden; border-radius: 50%; background: var(--team, var(--chip)); color: var(--ink, var(--dim)); font-weight: 800; font-size: 0.75rem; box-shadow: inset 0 0 0 1px #8884; }
.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.face.photo span { visibility: hidden; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.who b { font-size: 0.875rem; font-weight: 800; }
.who small { font-size: 0.72rem; color: var(--dim); }
.who small.live { color: var(--live); font-weight: 600; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 4px; background: var(--team, var(--chip)); color: var(--ink, var(--dim)); font-size: 0.65rem; font-weight: 800; white-space: nowrap; }
.pts { font: 700 1.4rem var(--display); font-variant-numeric: tabular-nums; }
.add { color: var(--link); font: 800 0.8rem Inter, system-ui, sans-serif; }
.plus { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--btn); color: var(--btn-ink); font-size: 1.6rem; line-height: 1; }

#games { padding: 4px 12px; }
.game { background: var(--panel); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.when { font-size: 0.68rem; font-weight: 800; color: var(--dim); margin-bottom: 4px; }
.when.live { color: var(--live); }
.side { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-weight: 800; font-size: 0.9rem; }
.side .face { width: 28px; height: 28px; font-size: 0.5rem; }
.side .face.logo { background: #fff; }
.side .face img { object-fit: contain; padding: 2px; }
.side > span:nth-child(2) { flex: 1; min-width: 0; }
.side strong { font: 700 1.4rem var(--display); }

summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; border-bottom: 1px solid var(--line); }
summary::-webkit-details-marker { display: none; }
summary i { width: 20px; font: 700 1.4rem var(--display); }
summary .badge { width: 40px; height: 40px; font: 800 0.85rem Inter, system-ui, sans-serif; }
summary .who b { font-size: 0.95rem; }
details.me summary { background: var(--me); }
details .row { background: var(--bg); }

nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 2; display: flex; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav button { flex: 1; height: 64px; font-size: 0.8rem; font-weight: 800; color: var(--dim); border-top: 3px solid transparent; }
nav button[aria-current="page"] { color: var(--text); border-top-color: var(--maize); }

body:has(dialog[open]) { overflow: hidden; }
dialog { width: 100%; max-width: min(640px, 100%); height: 92dvh; max-height: 92dvh; margin: auto auto 0; padding: 0 0 env(safe-area-inset-bottom); border: 0; border-radius: 18px 18px 0 0; background: var(--panel); color: var(--text); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #000a; }
.sheetTop { display: flex; align-items: center; gap: 16px; padding: 8px 16px; }
.sheetTop h2 { flex: 1; font: 700 1.6rem var(--display); text-transform: uppercase; }
#search { flex: none; margin: 0 16px 10px; }
#chips { display: flex; gap: 8px; padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
#chips button { min-width: 64px; height: 44px; border-radius: 22px; border: 1px solid var(--line); font-size: 0.8rem; font-weight: 800; }
#chips button[aria-pressed="true"] { background: var(--text); color: var(--panel); border-color: var(--text); }
#choices { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.group { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--bg); font-size: 0.7rem; font-weight: 800; color: var(--dim); }
.group span { flex: 1; }
.group button { min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--team, var(--chip)); color: var(--ink, var(--text)); font-size: 0.7rem; font-weight: 800; box-shadow: inset 0 0 0 1px #8886; }
.empty { padding: 16px; color: var(--dim); font-size: 0.85rem; }

button.row:not(:disabled):active, nav button:active { background: var(--chip); }
.primary:active, .invite:active, .group button:active { filter: brightness(0.85); }
@media (hover: hover) { button.row:not(:disabled):hover { background: var(--chip); } }
@media (max-width: 360px) {
  .row { gap: 8px; padding-left: 8px; padding-right: 8px; }
  .row .face { width: 36px; height: 36px; }
  .slot { width: 32px; }
  .top h1 { font-size: 1.25rem; }
}
/* Tablets and desktops: centred sheet and tab bar. */
@media (min-width: 700px) {
  dialog { margin: auto; height: 80dvh; border-radius: 16px; }
  nav { left: 50%; right: auto; width: 640px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; overflow: hidden; }
  .hero { border-radius: 12px 12px 0 0; }
}
