/* ==========================================================================
   wwg-ui.css — Wild West Games V3 components (2026-11-14)
   Built only from wwg-tokens.css. Load order: lobby.css, wwg-tokens.css, wwg-ui.css.

   Layout rule for every game: HUD, then board/card, then controls, in normal document flow
   (.ag-game > .ag-hud + .ag-stage + .ag-controls). Nothing fixed over the play area; the only
   fixed layer is .ag-sheet (modal, with scrim).
   Touch rule: every control is >= 44px tall below 768px and on touch screens (pointer:coarse or html.wwg-phone).
   Wrap rule: control rows never wrap (.ag-seg, .ag-controls are nowrap).
   ========================================================================== */

.ag-game, .ag-game *, .ag-sheet, .ag-sheet * { box-sizing: border-box; }

/* ---- game column: HUD / stage / controls ---------------------------------------------- */
.ag-game {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--ag-s-3);
  width: 100%; max-width: 600px; margin: 0 auto;
  font-family: var(--ag-font); color: var(--ag-ink);
}
.ag-stage { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 0; }
.ag-controls {
  display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: var(--ag-s-2);
}
html.wwg-fullscreen .ag-game {
  height: 100%; max-width: none; justify-content: center;
  padding: var(--ag-s-2) var(--ag-s-3) calc(var(--ag-s-3) + env(safe-area-inset-bottom, 0px));
}
html.wwg-fullscreen .ag-stage { flex: 1 1 auto; }
/* phone landscape: HUD left, stage middle, controls right */
html.wwg-fullscreen.wwg-land .ag-game { flex-direction: row; align-items: center; }
html.wwg-fullscreen.wwg-land .ag-game > .ag-hud { width: 168px; flex: none; grid-template-columns: 1fr; }
html.wwg-fullscreen.wwg-land .ag-game > .ag-hud .ag-hud__player--end { flex-direction: row; text-align: left; }
html.wwg-fullscreen.wwg-land .ag-game > .ag-controls { flex-direction: column; flex: none; }
html.wwg-fullscreen.wwg-land .ag-game > .ag-controls .ag-seg { flex-direction: column; }

/* ---- focus (shared) -------------------------------------------------------------------- */
.ag-btn:focus-visible, .ag-icon-btn:focus-visible, .ag-seg__btn:focus-visible, .ag-tile:focus-visible,
.ag-keypad__key:focus-visible, .ag-kbd__key:focus-visible, .ag-quiz__answer:focus-visible, .ag-chip:focus-visible {
  outline: 2px solid var(--ag-focus); outline-offset: 2px;
}

/* ---- button ---------------------------------------------------------------------------- */
.ag-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ag-s-2);
  height: var(--ag-ctl-h); padding: 0 var(--ag-s-4); margin: 0;
  border: 1px solid transparent; border-radius: var(--ag-r);
  font-family: var(--ag-font); font-size: var(--ag-text-md); font-weight: 600; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .12s var(--ag-ease), border-color .12s var(--ag-ease), color .12s var(--ag-ease);
  background: var(--ag-surface); color: var(--ag-ink); border-color: var(--ag-border-strong);
}
.ag-btn svg { width: 18px; height: 18px; flex: none; }
.ag-btn--primary { background: var(--ag-accent); border-color: var(--ag-accent); color: var(--ag-on-accent); }
.ag-btn--primary:hover { background: var(--ag-accent-hover); border-color: var(--ag-accent-hover); }
.ag-btn--secondary { background: var(--ag-surface); border-color: var(--ag-border-strong); color: var(--ag-ink); }
.ag-btn--secondary:hover { background: var(--ag-surface-alt); }
.ag-btn--secondary:active { background: var(--ag-press); }
.ag-btn--ghost { background: transparent; border-color: transparent; color: var(--ag-ink-2); }
.ag-btn--ghost:hover { background: var(--ag-hover); color: var(--ag-ink); }
.ag-btn--ghost:active { background: var(--ag-press); }
.ag-btn--danger { background: var(--ag-danger); border-color: var(--ag-danger); color: var(--ag-on-accent); }
.ag-btn--lg { height: 48px; padding: 0 var(--ag-s-5); font-size: var(--ag-text-base); }
.ag-btn--block { display: flex; width: 100%; }
.ag-btn:disabled, .ag-btn[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }

.ag-icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: var(--ag-ctl-h); height: var(--ag-ctl-h); padding: 0; margin: 0;
  border: 0; border-radius: var(--ag-r); background: transparent; color: var(--ag-ink-2);
  font-size: var(--ag-text-lg); line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.ag-icon-btn svg { width: 20px; height: 20px; }
.ag-icon-btn:hover { background: var(--ag-hover); color: var(--ag-ink); }
.ag-icon-btn:active { background: var(--ag-press); }
.ag-icon-btn[aria-pressed="true"] { background: var(--ag-accent-bg); color: var(--ag-accent-ink); }
.ag-icon-btn--outline { border: 1px solid var(--ag-border-strong); background: var(--ag-surface); }

/* ---- segmented control (role=radiogroup; buttons role=radio + aria-checked) ------------- */
.ag-seg {
  display: inline-flex; flex-wrap: nowrap; flex: none; gap: 3px; padding: 3px; margin: 0;
  width: max-content; max-width: 100%;   /* never stretched by a column parent */
  border-radius: calc(var(--ag-r) + 3px); background: var(--ag-chrome); border: 1px solid var(--ag-border);
  font-family: var(--ag-font);
}
.ag-seg__btn {
  flex: none; width: var(--ag-seg-w, 76px); min-height: calc(var(--ag-ctl-h) - 8px); padding: 0 var(--ag-s-2); margin: 0;
  border: 0; border-radius: var(--ag-r); background: transparent; color: var(--ag-ink-2);
  font-family: inherit; font-size: var(--ag-text-md); font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.ag-seg__btn:hover { background: var(--ag-hover); color: var(--ag-ink); }
.ag-seg__btn[aria-checked="true"] { background: var(--ag-surface); color: var(--ag-ink); box-shadow: var(--ag-shadow-sm); }
.ag-seg--fill { display: flex; width: 100%; }
.ag-seg--fill .ag-seg__btn { flex: 1 1 0; width: auto; min-width: 0; }
.ag-seg--vertical { flex-direction: column; }

/* ---- command tile (72 x 64, icon over label) ------------------------------------------- */
.ag-tile {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--ag-s-1);
  flex: none; width: 72px; height: 64px; padding: var(--ag-s-1); margin: 0;
  border: 0; border-radius: var(--ag-r); background: transparent; color: var(--ag-ink-2);
  font-family: var(--ag-font); font-size: var(--ag-text-xs); font-weight: 500; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.ag-tile__icon { display: grid; place-items: center; width: 24px; height: 24px; font-size: 20px; line-height: 1; }
.ag-tile__icon svg { width: 22px; height: 22px; }
.ag-tile__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-tile:hover { background: var(--ag-hover); color: var(--ag-ink); }
.ag-tile:active { background: var(--ag-press); }
.ag-tile[aria-pressed="true"], .ag-tile[aria-current] { background: var(--ag-accent-bg); color: var(--ag-accent-ink); font-weight: 600; }
.ag-tile:disabled { opacity: .4; cursor: default; }

/* ---- chip + swatch ---------------------------------------------------------------------- */
.ag-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--ag-r-pill); border: 1px solid var(--ag-border); background: var(--ag-surface-alt);
  color: var(--ag-ink-2); font-family: var(--ag-font); font-size: var(--ag-text-xs); font-weight: 600; white-space: nowrap;
}
.ag-chip--accent  { background: var(--ag-accent-bg);  border-color: transparent; color: var(--ag-accent-ink); }
.ag-chip--success { background: var(--ag-success-bg); border-color: transparent; color: var(--ag-success-ink); }
.ag-chip--warning { background: var(--ag-warning-bg); border-color: transparent; color: var(--ag-warning-ink); }
.ag-chip--danger  { background: var(--ag-danger-bg);  border-color: transparent; color: var(--ag-danger-ink); }
/* category chips: neutral chip with a coloured dot (category colour never fills chrome) */
.ag-chip--learning, .ag-chip--strategy, .ag-chip--party, .ag-chip--arcade, .ag-chip--holiday { --_c: var(--ag-muted); }
.ag-chip--learning { --_c: var(--ag-cat-learning); }
.ag-chip--strategy { --_c: var(--ag-cat-strategy); }
.ag-chip--party    { --_c: var(--ag-cat-party); }
.ag-chip--arcade   { --_c: var(--ag-cat-arcade); }
.ag-chip--holiday  { --_c: var(--ag-cat-holiday); }
.ag-chip--learning::before, .ag-chip--strategy::before, .ag-chip--party::before, .ag-chip--arcade::before, .ag-chip--holiday::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--_c);
}
.ag-swatch { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ag-muted); }
.ag-swatch--p1 { background: var(--ag-p1); } .ag-swatch--p2 { background: var(--ag-p2); }
.ag-swatch--p3 { background: var(--ag-p3); } .ag-swatch--p4 { background: var(--ag-p4); }
.ag-swatch--p5 { background: var(--ag-p5); } .ag-swatch--p6 { background: var(--ag-p6); }

/* ---- card ------------------------------------------------------------------------------- */
.ag-card {
  padding: var(--ag-s-4); border-radius: var(--ag-r-lg);
  background: var(--ag-surface); border: 1px solid var(--ag-border); box-shadow: var(--ag-shadow-sm);
  color: var(--ag-ink); font-family: var(--ag-font);
}
.ag-card__title { margin: 0 0 var(--ag-s-1); font-family: var(--ag-font-display); font-size: var(--ag-text-base); font-weight: 700; }
.ag-card__text { margin: 0; color: var(--ag-muted); font-size: var(--ag-text-md); line-height: 1.45; }

/* ---- paper: the board / card sheet. Light in both themes; re-themes its children light. -- */
.ag-paper {
  --ag-ink: var(--ag-paper-ink); --ag-ink-2: var(--ag-paper-ink-2); --ag-muted: #6b7280;
  --ag-surface: #ffffff; --ag-surface-alt: #f9fafb; --ag-border: #e5e7eb; --ag-border-strong: #d1d5db;
  --ag-hover: rgba(20, 24, 33, .06); --ag-press: rgba(20, 24, 33, .10);
  --ag-accent: #2563eb; --ag-accent-hover: #1d4ed8; --ag-accent-bg: #e1eafd; --ag-accent-ink: #1d4ed8;
  --ag-success: #16a34a; --ag-success-bg: #dcfce7; --ag-success-ink: #15803d;
  --ag-warning: #d97706; --ag-warning-bg: #fef3c7; --ag-warning-ink: #b45309;
  --ag-danger: #dc2626; --ag-danger-bg: #fee2e2; --ag-danger-ink: #b91c1c; --ag-focus: #2563eb;
  color-scheme: light;
  display: block; border-radius: var(--ag-r-lg); background: var(--ag-paper); color: var(--ag-paper-ink);
  box-shadow: var(--ag-paper-shadow);
}
canvas.ag-paper { touch-action: none; cursor: pointer; }
.ag-paper--pad { padding: var(--ag-s-4) var(--ag-s-3); }
html.wwg-fullscreen canvas.ag-paper { border-radius: var(--ag-r-lg); box-shadow: var(--ag-shadow-sm); }

/* ---- HUD: player card | turn text | player card ----------------------------------------- */
.ag-hud {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--ag-s-2);
  width: 100%; font-family: var(--ag-font);
}
.ag-hud__player {
  --_c: var(--ag-muted); --_t: var(--ag-hover);
  display: flex; align-items: center; gap: var(--ag-s-2); min-width: 0;
  padding: var(--ag-s-2) var(--ag-s-3); border-radius: var(--ag-r-lg);
  background: var(--ag-surface); border: 1px solid var(--ag-border);
  transition: background-color .15s var(--ag-ease), border-color .15s var(--ag-ease);
}
.ag-hud__player--p1 { --_c: var(--ag-p1); --_t: var(--ag-p1-tint); }
.ag-hud__player--p2 { --_c: var(--ag-p2); --_t: var(--ag-p2-tint); }
.ag-hud__player--p3 { --_c: var(--ag-p3); --_t: var(--ag-p3-tint); }
.ag-hud__player--p4 { --_c: var(--ag-p4); --_t: var(--ag-p4-tint); }
.ag-hud__player--p5 { --_c: var(--ag-p5); --_t: var(--ag-p5-tint); }
.ag-hud__player--p6 { --_c: var(--ag-p6); --_t: var(--ag-p6-tint); }
.ag-hud__player--end { flex-direction: row-reverse; text-align: right; }
.ag-hud__swatch { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--_c); }
.ag-hud__name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--ag-text-sm); font-weight: 600; color: var(--ag-ink-2);
}
.ag-hud__score {
  font-family: var(--ag-font-display); font-size: 1.5rem; font-weight: 800; line-height: 1;
  color: var(--ag-ink); font-variant-numeric: tabular-nums;
}
.ag-hud__player.is-active { background: var(--_t); border-color: var(--_c); }
.ag-hud__turn {
  font-size: var(--ag-text-md); font-weight: 600; color: var(--ag-ink-2); text-align: center; white-space: nowrap;
}
.ag-hud__turn.is-win { font-size: var(--ag-text-base); font-weight: 800; color: var(--ag-ink); }
.ag-hud--stack { grid-template-columns: 1fr; }
.ag-hud--stack .ag-hud__player--end { flex-direction: row; text-align: left; }
/* a simple stat row (level / clock) for games without two sides */
.ag-hud__stat { font-family: var(--ag-font-display); font-weight: 800; font-size: var(--ag-text-lg); color: var(--ag-ink); }
.ag-hud__stat small { margin-left: 4px; font-family: var(--ag-font); font-size: var(--ag-text-sm); font-weight: 600; color: var(--ag-muted); }

/* ---- numeric keypad (3 x 4: 1-9, del, 0, go) ------------------------------------------- */
.ag-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--ag-s-2); width: 100%; }
.ag-keypad__key {
  min-height: 56px; padding: 0; margin: 0; border: 1px solid var(--ag-border); border-radius: var(--ag-r-lg);
  background: var(--ag-surface); color: var(--ag-ink); box-shadow: var(--ag-shadow-sm);
  font-family: var(--ag-font-display); font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.ag-keypad__key:hover { background: var(--ag-surface-alt); }
.ag-keypad__key:active, .ag-keypad__key.is-pressed { background: var(--ag-press); }
.ag-keypad__key--del { font-size: var(--ag-text-lg); color: var(--ag-ink-2); }
.ag-keypad__key--go { background: var(--ag-success); border-color: var(--ag-success); color: var(--ag-on-accent); }
.ag-keypad__key--go:hover { background: var(--ag-success-ink); }
.ag-keypad__key--go:active, .ag-keypad__key--go.is-pressed { background: var(--ag-success-ink); }
.ag-keypad.is-disabled .ag-keypad__key { opacity: .5; pointer-events: none; }
html.wwg-fullscreen .ag-keypad__key { min-height: 52px; }

/* ---- letter keyboard (QWERTY rows of 10 / 9 / 7 + enter + back) ------------------------- */
.ag-kbd { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 560px; margin: 0 auto; user-select: none; }
.ag-kbd__row { display: flex; flex-wrap: nowrap; gap: 5px; justify-content: center; }
.ag-kbd__row--mid { padding: 0 5%; }                 /* the 9-key row sits half a key in */
.ag-kbd__key {
  flex: 1 1 0; min-width: 0; min-height: 52px; padding: 0; margin: 0;
  border: 1px solid var(--ag-border); border-radius: var(--ag-r); background: var(--ag-surface); color: var(--ag-ink); box-shadow: var(--ag-shadow-sm);
  font-family: var(--ag-font); font-size: var(--ag-text-base); font-weight: 700; text-transform: uppercase;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color .12s var(--ag-ease), color .12s var(--ag-ease);
}
.ag-kbd__key:hover { background: var(--ag-surface-alt); }
.ag-kbd__key:active, .ag-kbd__key.is-pressed { background: var(--ag-press); }
.ag-kbd__key--wide { flex-grow: 1.5; font-size: var(--ag-text-xs); text-transform: none; }
.ag-kbd__key.is-correct { background: var(--ag-success); border-color: var(--ag-success); color: var(--ag-on-accent); }
.ag-kbd__key.is-present { background: var(--ag-warning); border-color: var(--ag-warning); color: var(--ag-on-accent); }
.ag-kbd__key.is-absent  { background: var(--ag-chrome); border-color: transparent; color: var(--ag-muted); box-shadow: none; opacity: .7; }
.ag-kbd__key:disabled { cursor: default; }
.ag-kbd.is-disabled .ag-kbd__key { pointer-events: none; opacity: .6; }
@media (min-width: 768px) { .ag-kbd__key { min-height: 56px; } }

/* ---- quiz card: progress strip, prompt, A-D answers ------------------------------------- */
.ag-quiz {
  display: flex; flex-direction: column; gap: var(--ag-s-4); width: 100%;
  padding: var(--ag-s-4); border-radius: var(--ag-r-xl);
  background: var(--ag-surface); border: 1px solid var(--ag-border); box-shadow: var(--ag-shadow-sm);
  color: var(--ag-ink); font-family: var(--ag-font);
}
.ag-quiz.ag-paper { border: 0; box-shadow: var(--ag-paper-shadow); }
.ag-quiz__top { display: flex; justify-content: space-between; align-items: center; gap: var(--ag-s-2);
  font-size: var(--ag-text-sm); font-weight: 600; color: var(--ag-muted); font-variant-numeric: tabular-nums; }
.ag-quiz__progress { display: flex; gap: 4px; }
.ag-quiz__progress > i { flex: 1 1 0; height: 6px; border-radius: 3px; background: var(--ag-border); }
.ag-quiz__progress > i.is-right   { background: var(--ag-success); }
.ag-quiz__progress > i.is-wrong   { background: var(--ag-danger); }
.ag-quiz__progress > i.is-current { background: var(--ag-accent); }
.ag-quiz__prompt {
  margin: 0; font-family: var(--ag-font-display); font-weight: 700; line-height: 1.25;
  font-size: clamp(1.25rem, 5vw, var(--ag-text-xl)); text-align: center; color: var(--ag-ink);
}
.ag-quiz__media { display: flex; justify-content: center; }
.ag-quiz__media img, .ag-quiz__media svg { max-width: 100%; max-height: 160px; border-radius: var(--ag-r); }
.ag-quiz__answers { display: grid; grid-template-columns: 1fr; gap: var(--ag-s-2); }
@media (min-width: 560px) { .ag-quiz__answers { grid-template-columns: 1fr 1fr; } }
.ag-quiz__answer {
  display: flex; align-items: center; gap: var(--ag-s-3); min-height: 56px; width: 100%;
  padding: var(--ag-s-2) var(--ag-s-3); margin: 0; text-align: left;
  border: 2px solid var(--ag-border); border-radius: var(--ag-r-lg); background: var(--ag-surface); color: var(--ag-ink);
  font-family: var(--ag-font); font-size: var(--ag-text-base); font-weight: 600; line-height: 1.25;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: border-color .12s var(--ag-ease), background-color .12s var(--ag-ease), opacity .12s;
}
.ag-quiz__answer:hover { border-color: var(--ag-border-strong); background: var(--ag-surface-alt); }
.ag-quiz__letter {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--ag-r);
  background: var(--ag-chrome); color: var(--ag-ink-2); font-size: var(--ag-text-sm); font-weight: 700;
}
.ag-quiz__answer.is-right { border-color: var(--ag-success); background: var(--ag-success-bg); color: var(--ag-ink); }
.ag-quiz__answer.is-right .ag-quiz__letter { background: var(--ag-success); color: var(--ag-on-accent); }
.ag-quiz__answer.is-wrong { border-color: var(--ag-danger); background: var(--ag-danger-bg); color: var(--ag-ink); animation: agShake .3s; }
.ag-quiz__answer.is-wrong .ag-quiz__letter { background: var(--ag-danger); color: var(--ag-on-accent); }
.ag-quiz__answer.is-dim { opacity: .5; }
.ag-quiz__answer:disabled { cursor: default; }
.ag-quiz__answer:disabled:hover { border-color: var(--ag-border); background: var(--ag-surface); }
.ag-quiz__answer.is-right:disabled:hover { border-color: var(--ag-success); background: var(--ag-success-bg); }
.ag-quiz__answer.is-wrong:disabled:hover { border-color: var(--ag-danger); background: var(--ag-danger-bg); }
.ag-quiz__feedback { min-height: 1.25em; margin: 0; text-align: center; font-size: var(--ag-text-md); font-weight: 600; color: var(--ag-muted); }
.ag-quiz__feedback.is-right { color: var(--ag-success-ink); }
.ag-quiz__feedback.is-wrong { color: var(--ag-danger-ink); }
@keyframes agShake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { .ag-quiz__answer.is-wrong { animation: none; } }

/* ---- answer display (typed number / word) ----------------------------------------------- */
.ag-answer {
  display: inline-flex; align-items: center; justify-content: center; min-width: 150px; min-height: 58px; padding: 6px 16px;
  border: 2px solid var(--ag-border-strong); border-radius: var(--ag-r-lg); background: var(--ag-surface); color: var(--ag-ink);
  font-family: var(--ag-font-display); font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.ag-answer:empty::before { content: '?'; color: var(--ag-border-strong); }
.ag-answer.is-right { border-color: var(--ag-success); color: var(--ag-success-ink); }
.ag-answer.is-wrong { border-color: var(--ag-danger); color: var(--ag-danger-ink); animation: agShake .3s; }

/* ---- sheet: bottom sheet on phones, centred 440px card from 768px ----------------------- */
.ag-sheet {
  position: fixed; inset: 0; z-index: 900; display: flex; align-items: flex-end; justify-content: center;
  visibility: hidden; pointer-events: none; font-family: var(--ag-font);
}
.ag-sheet.is-open { visibility: visible; pointer-events: auto; }
.ag-sheet__scrim { position: absolute; inset: 0; background: var(--ag-scrim); opacity: 0; transition: opacity .2s var(--ag-ease); }
.ag-sheet.is-open .ag-sheet__scrim { opacity: 1; }
.ag-sheet__panel {
  position: relative; width: 100%; max-height: 88vh; overflow: auto;
  padding: var(--ag-s-2) var(--ag-s-4) calc(var(--ag-s-4) + env(safe-area-inset-bottom, 0px));
  border-radius: var(--ag-r-xl) var(--ag-r-xl) 0 0; background: var(--ag-surface); color: var(--ag-ink);
  box-shadow: var(--ag-shadow-lg); transform: translateY(100%); transition: transform .22s var(--ag-ease);
}
.ag-sheet.is-open .ag-sheet__panel { transform: none; }
.ag-sheet__handle { display: block; width: 36px; height: 4px; margin: 0 auto var(--ag-s-3); border-radius: 2px; background: var(--ag-border-strong); }
.ag-sheet__title { margin: 0 0 var(--ag-s-1); font-family: var(--ag-font-display); font-size: var(--ag-text-lg); font-weight: 800; }
.ag-sheet__body { font-size: var(--ag-text-md); color: var(--ag-ink-2); }
.ag-sheet__actions { display: flex; flex-direction: column; gap: var(--ag-s-2); margin-top: var(--ag-s-4); }
@media (min-width: 768px) {
  .ag-sheet { align-items: center; padding: var(--ag-s-5); }
  .ag-sheet__panel { max-width: 440px; padding: var(--ag-s-5); border-radius: var(--ag-r-xl); transform: translateY(12px); opacity: 0;
    transition: transform .2s var(--ag-ease), opacity .2s var(--ag-ease); }
  .ag-sheet.is-open .ag-sheet__panel { opacity: 1; }
  .ag-sheet__handle { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ag-sheet__panel, .ag-sheet__scrim { transition: none; } }
/* documentation only: show a sheet panel in flow */
.ag-sheet--static { position: static; visibility: visible; pointer-events: auto; display: block; padding: 0; }
.ag-sheet--static .ag-sheet__panel { transform: none; opacity: 1; max-width: 440px; margin: 0 auto; border-radius: var(--ag-r-xl);
  border: 1px solid var(--ag-border); box-shadow: var(--ag-shadow-md); }

/* ---- results (lives inside a sheet panel) ----------------------------------------------- */
.ag-results { text-align: center; }
.ag-results__title { margin: 0 0 var(--ag-s-1); font-family: var(--ag-font-display); font-size: var(--ag-text-xl); font-weight: 800; color: var(--ag-ink); }
.ag-results__line { margin: 0 0 var(--ag-s-4); font-size: var(--ag-text-md); color: var(--ag-muted); }
.ag-results__list { list-style: none; margin: 0 0 var(--ag-s-4); padding: 0; text-align: left; }
.ag-results__row { display: flex; justify-content: space-between; align-items: center; gap: var(--ag-s-3);
  min-height: 40px; padding: var(--ag-s-2) var(--ag-s-3); border-radius: var(--ag-r); font-size: var(--ag-text-md); font-weight: 600; color: var(--ag-ink); }
.ag-results__row:nth-child(odd) { background: var(--ag-surface-alt); }
.ag-results__row.is-me { background: var(--ag-accent-bg); color: var(--ag-accent-ink); }
.ag-results__value { color: var(--ag-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ag-results__row.is-me .ag-results__value { color: var(--ag-accent-ink); }
.ag-results__actions { display: flex; flex-direction: column; gap: var(--ag-s-2); }

/* ---- small type helpers ----------------------------------------------------------------- */
.ag-title { margin: 0; font-family: var(--ag-font-display); font-size: var(--ag-text-xl); font-weight: 800; color: var(--ag-ink); letter-spacing: -.01em; }
.ag-label { font-size: var(--ag-text-xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ag-muted); }
.ag-muted { color: var(--ag-muted); }
.ag-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- touch: 44px minimum below 768px AND on every touch screen ---------------------------
   A phone held sideways is 844px wide, so width alone is not enough: (pointer: coarse) and the
   shell's html.wwg-phone class (set by lobby.js) get the same sizes. :where() keeps the class rule
   at the same specificity as the media rule, so a game's own sizing still wins as before. */
@media (max-width: 767.98px), (pointer: coarse) {
  .ag-btn { height: auto; min-height: var(--ag-touch); }
  .ag-btn--lg { min-height: 48px; }
  .ag-icon-btn { width: var(--ag-touch); height: var(--ag-touch); }
  .ag-seg__btn { min-height: var(--ag-touch); }
  .ag-results__row { min-height: var(--ag-touch); }
}
:where(html.wwg-phone) .ag-btn { height: auto; min-height: var(--ag-touch); }
:where(html.wwg-phone) .ag-btn--lg { min-height: 48px; }
:where(html.wwg-phone) .ag-icon-btn { width: var(--ag-touch); height: var(--ag-touch); }
:where(html.wwg-phone) .ag-seg__btn { min-height: var(--ag-touch); }
:where(html.wwg-phone) .ag-results__row { min-height: var(--ag-touch); }
