@layer components {
  .live-line p {
    margin: 0;
  }
  .glance-boards:has(.stats-table-card) {
    grid-template-columns: minmax(0, 1fr);
  }
  .stats-table {
    overflow-x: auto;
  }
  .stats-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
  }
  .stats-table th, .stats-table td {
    padding: var(--s2) var(--s1);
    border-bottom: var(--stroke) solid var(--line);
    text-align: right;
  }
  .stats-table th:first-child {
    text-align: left;
  }
  .stats-table th {
    letter-spacing: normal;
    text-transform: none;
  }
  .stats-table thead {
    color: var(--muted);
  }
  @media (min-width: 48rem) {
    .glance-boards:has(.stats-table-card) {
      grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    }
  }
  dialog.site-dialog {
    max-width: var(--dialog-max);
    width: calc(100% - var(--s9));
    max-height: calc(100dvh - var(--s9));
    margin: auto;
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: var(--stroke) solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--modal-shadow);
    overflow: hidden;
    animation: site-arrive var(--duration) var(--ease);
  }
  dialog.site-dialog[open] {
    display: flex;
    flex-direction: column;
  }
  dialog.site-dialog .dialog-panel {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    padding: var(--s9) var(--s8);
    overflow-y: auto;
  }
  dialog.site-dialog::backdrop {
    background: var(--backdrop);
    backdrop-filter: blur(var(--s2));
  }
  /* A phone would blur the whole page again on every frame the dialog is open, so it lays the tint over the page's own
     colour instead. */
  @media (hover: none) {
    dialog.site-dialog::backdrop {
      background: linear-gradient(var(--backdrop), var(--backdrop)) var(--bg);
      backdrop-filter: none;
    }
  }
  dialog.site-dialog .close-form {
    position: absolute;
    top: var(--s4);
    right: var(--s4);
    margin: var(--s0);
  }
  dialog.site-dialog .close {
    background: var(--clear);
    border: none;
  }
  dialog.site-dialog .dialog-panel > .eyebrow {
    padding-right: var(--s8);
    margin-bottom: var(--s7);
  }
  dialog.site-dialog h2 {
    margin-bottom: var(--s6);
  }
  dialog.site-dialog p {
    margin-bottom: var(--s6);
    font-size: var(--text-sm);
  }
  dialog.site-dialog fieldset {
    padding: var(--s0);
    margin: var(--s0) var(--s0) var(--s7);
    border: none;
  }
  dialog.site-dialog legend {
    padding: var(--s0);
    margin-bottom: var(--s5);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
  }
  @keyframes site-arrive {
    from {
      opacity: 0;
      transform: translateY(var(--s5));
    }
    to {
      opacity: 1;
      transform: translateY(var(--s0));
    }
  }
}
@layer components {
  :is(.daily-game, .site-dialog) .legend {
    display: flex;
    align-items: center;
    gap: var(--s4);
    font-size: var(--text-xs);
    margin: var(--s6) var(--s0);
  }
  :is(.daily-game, .site-dialog) .legend-tile {
    display: inline-grid;
    place-items: center;
    width: var(--s9);
    height: var(--s9);
    border-radius: var(--radius-tile);
  }
  :is(.daily-game, .site-dialog) .correct {
    background: var(--correct);
    color: var(--on-correct);
    border-color: var(--correct);
  }
  :is(.daily-game, .site-dialog) .present {
    background: var(--present);
    color: var(--on-present);
    border-color: var(--present);
  }
  :is(.daily-game, .site-dialog) .absent {
    background: var(--absent);
    color: var(--on-absent);
    border-color: var(--absent);
  }
}
@layer components {
  /* The frame holds no game content. Each game's placeholder class gives it the play area's size. */
  .pause-frame {
    min-height: calc(var(--s12) * 5);
    border: var(--stroke) solid var(--line);
    border-radius: var(--radius-card);
    background:
      linear-gradient(135deg, var(--accent-soft), var(--surface-2) 45%, var(--progress-soft));
    filter: blur(var(--s1));
    opacity: 0.85;
    transition: filter var(--duration) var(--ease), opacity var(--duration) var(--ease);
  }
  .pause-control {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s1);
  }
  .pause-button {
    min-width: var(--tap);
    min-height: var(--tap);
  }
  .pause-reason, .pause-notice, .pause-hold {
    font-size: var(--text-xs);
    color: var(--muted);
  }
  dialog.pause-dialog .pause-body {
    display: flex;
    flex-direction: column;
    gap: var(--s5);
  }
  dialog.pause-dialog .pause-body p {
    margin: var(--s0);
  }
  dialog.pause-dialog .pause-resume {
    width: 100%;
    min-height: var(--s11);
    font-size: var(--text-md);
  }
  dialog.pause-dialog .pause-countdown {
    min-height: var(--s11);
    margin: var(--s0);
    text-align: center;
    font-size: var(--text-title);
    font-weight: var(--weight-heavy);
    line-height: var(--line-solid);
    color: var(--ink);
  }
  dialog.pause-dialog .pause-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s4);
  }
  @media (forced-colors: active) {
    .pause-frame {
      background: Canvas;
      border-color: CanvasText;
      filter: none;
      opacity: 1;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .pause-frame, dialog.pause-dialog, dialog.pause-dialog * {
      transition: none;
      animation: none;
    }
  }
}
/* Play with friends (owner decision 2026-11-05). Team up is always green and Challenge always orange. Each chip and
   card also names its mode in words, so the colour is never the only signal. */
@layer components {
  [data-mode="team"] {
    --mode: var(--done);
    --mode-soft: var(--done-soft);
  }
  [data-mode="challenge"] {
    --mode: var(--progress);
    --mode-soft: var(--progress-soft);
  }
  .mode-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s3);
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .mode-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s3);
    justify-self: start;
    align-self: flex-start;
    padding: var(--s1) var(--s4);
    border: var(--stroke) solid var(--mode, var(--line));
    border-radius: var(--radius-pill);
    background: var(--mode-soft, var(--surface-2));
    color: var(--ink);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    line-height: var(--line-body);
  }
  /* Plain text beside the chips, so it does not read as one more mode. */
  .mode-players {
    align-self: center;
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
  }
  .mode-chip[data-mode="team"]::before, .mode-chip[data-mode="challenge"]::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mode);
  }
  .friends {
    display: grid;
    gap: var(--s5);
    margin: var(--s4) 0 var(--s8);
  }
  .friends > h2 {
    margin: 0;
  }
  .friend-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: var(--s5);
  }
  .friend-card {
    display: grid;
    align-content: start;
    gap: var(--s5);
    min-width: 0;
    padding: var(--s6);
    border: var(--stroke) solid var(--line);
    border-top: 4px solid var(--mode);
    border-radius: var(--radius-card);
    background: var(--surface);
  }
  .friend-card h3 {
    margin: 0;
    font-size: var(--text-md);
  }
  .friend-card-line {
    margin: 0;
    color: var(--muted);
    font-size: var(--text-sm);
  }
  .friend-card .button {
    justify-self: start;
  }
  .friend-card .primary {
    --control-bg: var(--mode);
    border-color: var(--mode);
  }
  .friend-card-notice, .friend-join-notice {
    margin: 0;
    font-size: var(--text-sm);
  }
  /* An empty live region leaves the grid so it adds no gap, but it stays in the accessibility tree: a screen reader
     announces only text that appears in a region it already knows. */
  .friend-card-notice:empty, .friend-join-notice:empty {
    position: absolute;
  }
  .choice-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s4);
    margin: 0;
  }
  .choice-chips legend {
    margin-bottom: var(--s4);
    font-size: var(--text-sm);
  }
  .choice-chip {
    position: relative;
    display: inline-grid;
    align-content: center;
    min-height: var(--tap);
    padding: var(--s3) var(--s5);
    border: var(--stroke) solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: var(--line-tight);
    cursor: pointer;
  }
  .choice-chip small {
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-normal);
  }
  /* The radio stays in the page for keyboards and screen readers. The chip around it shows its state. */
  .choice-chip input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }
  .choice-chip:has(input:checked) {
    border: var(--stroke-heavy) solid var(--mode, var(--accent));
    background: var(--mode-soft, var(--accent-soft));
  }
  .choice-chip:has(input:checked) .choice-label::before {
    content: "✓ " / "";
  }
  .choice-chip:has(input:focus-visible) {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: 2px;
  }
  .choice-chips:disabled .choice-chip {
    opacity: 0.5;
    cursor: not-allowed;
  }
  .friend-join {
    display: grid;
    gap: var(--s4);
    justify-items: start;
  }
  .friend-join label {
    font-weight: var(--weight-medium);
  }
  .friend-join-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s4);
  }
  .friend-join input {
    width: 12ch;
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .friend-lobby-head {
    display: grid;
    gap: var(--s4);
  }
  .friend-lobby-head h1 {
    margin: 0;
  }
  @media (forced-colors: active) {
    .choice-chip:has(input:checked) {
      border-color: Highlight;
    }
  }
}
