/* Self-hosted web fonts under the SIL Open Font License 1.1 (licence texts in app/assets/fonts), taken from the Fontsource npm
   packages @fontsource-variable/orbitron 5.3.0 and @fontsource/rajdhani 5.3.0. Served from this
   origin, so no visitor's IP address reaches a font CDN. Orbitron is variable, so weight 800 is real. */
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("/assets/orbitron-latin-wght-normal-0725597c.woff2") format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("/assets/rajdhani-latin-400-normal-9bb85716.woff2") format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("/assets/rajdhani-latin-ext-400-normal-758a0391.woff2") format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("/assets/rajdhani-latin-500-normal-48a8a78d.woff2") format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("/assets/rajdhani-latin-ext-500-normal-424264b1.woff2") format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("/assets/rajdhani-latin-600-normal-85fa0919.woff2") format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url("/assets/rajdhani-latin-ext-600-normal-01c69c95.woff2") format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("/assets/rajdhani-latin-700-normal-adb790a1.woff2") format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("/assets/rajdhani-latin-ext-700-normal-51f6658e.woff2") format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* ==========================================================================
   Base: reset, page background, scrollbar, focus ring, accessibility primitives.
   Goshboard OS rules are written :root:not([data-theme="beige"]):not([data-theme="hacker"]), so they
   also hold when no theme could be saved and the attribute is missing.
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--surface-page);
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding: 0 1rem 2rem;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) body {
  background-image: linear-gradient(to bottom, rgb(11 17 26 / .75), rgb(11 17 26 / .9)), url("/assets/circuit_board_bg-9e658c2d.png");
}

html {
  scroll-padding-top: calc(var(--bar-h) + var(--space-4));
}

button,
input,
select {
  font-family: inherit;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-page);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-raised);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-overlay);
  padding: var(--space-3) var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

main:focus {
  outline: none;
}

/* ==========================================================================
   Retro Desk, on everything: hard edges and no glow. The soft paper shadow stays on cards,
   game strips, the nameplate logo and the lobby terminal; the presence dots stay round.
   ========================================================================== */

:root[data-theme="beige"] *:not(.presence-dot, .now-playing-pulse) {
  border-radius: 0 !important;
}

:root[data-theme="beige"] * {
  text-shadow: none !important;
}

:root[data-theme="beige"] *:not(.card, .game-strip, .header-logo-title, .matrix-terminal) {
  box-shadow: none !important;
}

/* ==========================================================================
   Page layout: one content width, cards stacked or in a page grid with one gutter
   ========================================================================== */

.dashboard-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* dashboard-stacked-layout: one card per row, as wide as the header like every other page. */
.dashboard-layout,
.dashboard-stacked-layout {
  display: flex;
  flex-direction: column;
  gap: var(--layout-gutter);
  width: 100%;
}

/* Account on desktop: what is stored on the left, download and delete stacked on the right, both
   columns ending together. */
@media (min-width: 1200px) {
  .account-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "stored export"
      "stored delete";
    grid-template-rows: auto 1fr;
  }

  .account-stored-area { grid-area: stored; }
  .account-export-area { grid-area: export; }
  .account-delete-area { grid-area: delete; }

  .account-layout > section {
    display: flex;
  }
}

.wide-panel-row {
  width: 100%;
}

.wide-panel-row .card {
  width: 100%;
}

@media (max-width: 767px) {
  .dashboard-container {
    padding: 0;
  }
}

/* ==========================================================================
   Header bar: logo, main nav, search, now playing, profile menu. One sticky row of --bar-h.
   Every control in it is --ctl-h tall with --ctl-radius corners. Phones: the end of this section.
   ========================================================================== */
.dashboard-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--bar-h);
  margin-bottom: var(--space-4);
  padding-block: var(--space-2);
  --text-primary: var(--header-text);
  --text-secondary: var(--header-text-muted);
  --accent: var(--header-accent);
  --focus-ring: var(--header-accent);
}

/* The band runs edge to edge as a spread shadow: unlike a wider box, a shadow is not scrollable
   overflow, so phone layout viewports stay at the device width. One blur, here only. */
.dashboard-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface-bar);
  box-shadow: 0 0 0 100vmax var(--surface-bar);
  clip-path: inset(0 -100vmax);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
}

.header-rule {
  position: absolute;
  inset: auto 0 0;
  border-bottom: var(--header-rule);
  pointer-events: none;
}

.header-logo-title {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-height: var(--ctl-h);
  text-decoration: none;
  border-radius: var(--ctl-radius);
}

.header-logo-title .logo-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1;
  background: var(--logo-fill);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: var(--heading-glow);
}

.header-logo-title .logo-diamond {
  inline-size: 12px;
  block-size: 12px;
  margin: 0 5px;
  background: var(--diamond-fill);
  border: 3px solid var(--diamond-stroke);
  rotate: 45deg;
  box-shadow: var(--diamond-glow);
}

.logo-glow {
  position: absolute;
  inset: 50% auto auto 50%;
  inline-size: 120px;
  block-size: 28px;
  translate: -50% -50%;
  background: var(--logo-glow);
  filter: blur(28px);
  pointer-events: none;
  z-index: -1;
}

/* Main nav: inline tabs. The active tab has weight and a mark, not colour alone. */
.dashboard-nav-ribbon {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  block-size: var(--ctl-h);
  padding: 0 var(--space-3);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--ctl-radius);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--surface-chip-hover);
}

.nav-tab-icon {
  display: none;
  flex-shrink: 0;
}

.nav-tab[aria-current="page"] {
  color: var(--text-primary);
  font-weight: 800;
}

.nav-tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset: auto var(--space-3) 3px;
  block-size: 2px;
  background: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
}

.header-icon-button {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  inline-size: var(--ctl-h);
  block-size: var(--ctl-h);
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--ctl-radius);
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast);
}

.header-icon-button:hover,
.header-icon-button[aria-expanded="true"] {
  color: var(--text-primary);
  background: var(--surface-chip-hover);
}

.header-icon-button[popovertarget="theme-menu"] {
  anchor-name: --theme-menu;
}

/* A btn-primary that fits the bar. */
.header-signin {
  block-size: var(--ctl-h);
  white-space: nowrap;
}

/* Search: a combobox. Below 1100px it folds into the toggle button and opens as a sheet. */
.header-search {
  position: relative;
  flex: 0 1 17.5rem;
  min-width: 10rem;
}

.header-search-toggle,
.header-search-close {
  display: none;
}

.header-search-panel {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-search-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-secondary);
  pointer-events: none;
}

.header-search-input {
  inline-size: 100%;
  block-size: var(--ctl-h);
  padding: 0 2.25rem;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--text-sm);
  background: var(--surface-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--ctl-radius);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.header-search-input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

.header-search-input:hover,
.header-search-input:focus {
  background: var(--surface-chip-hover);
  border-color: var(--border-strong);
}

.header-search-key {
  position: absolute;
  right: var(--space-2);
  padding: 1px 6px;
  color: var(--text-secondary);
  font: var(--text-xs) / 1.4 var(--font-mono);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.header-search-input:focus ~ .header-search-key,
.header-search-input:not(:placeholder-shown) ~ .header-search-key {
  display: none;
}

/* The results sit on the overlay surface, so they take the page's colours back from the header. */
.header-search-popup {
  position: absolute;
  inset: calc(100% + var(--space-2)) 0 auto;
  min-inline-size: 18rem;
  max-block-size: min(24rem, 70dvh);
  overflow-y: auto;
  --text-primary: var(--overlay-text);
  --text-secondary: var(--text-faint);
  color: var(--overlay-text);
  background: var(--surface-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--ctl-radius);
  box-shadow: var(--shadow-pop);
}

.header-search-listbox {
  list-style: none;
}

.header-search-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.header-search-option:hover {
  background: var(--surface-row-hover);
}

.header-search-option[aria-selected="true"] {
  font-weight: 700;
  background: rgb(var(--accent-rgb) / .14);
  border-left-color: var(--page-accent);
}

.header-search-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-search-option-hours {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-family: var(--font-data);
  font-size: var(--text-xs);
}

.header-search-empty {
  padding: var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
}

/* Now playing: from the minutely Steam summary; opens the game dialog. */
.now-playing-slot {
  display: contents;
}

.now-playing {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 1 auto;
  min-width: 0;
  max-inline-size: 18rem;
  block-size: var(--ctl-h);
  padding: 0 var(--space-3);
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-decoration: none;
  background: rgb(var(--status-ingame-rgb) / .1);
  border: 1px solid rgb(var(--status-ingame-rgb) / .45);
  border-radius: var(--ctl-radius);
}

a.now-playing:hover {
  background: rgb(var(--status-ingame-rgb) / .18);
}

.now-playing-pulse {
  flex-shrink: 0;
  inline-size: 8px;
  block-size: 8px;
  background: var(--status-ingame);
  border-radius: 50%;
}

.now-playing-text {
  display: flex;
  gap: .35em;
  min-width: 0;
  white-space: nowrap;
}

.now-playing-label,
.now-playing-time {
  color: var(--text-secondary);
}

.now-playing-game {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

.now-playing-time {
  font-family: var(--font-data);
}

@keyframes now-playing-pulse {
  50% {
    box-shadow: 0 0 0 5px rgb(var(--status-ingame-rgb) / 0), 0 0 10px rgb(var(--status-ingame-rgb) / .9);
  }
}

@keyframes terminal-cursor {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .now-playing-pulse {
    animation: now-playing-pulse 1.8s ease-in-out infinite;
  }
}

/* Profile menu button: the avatar, with a Steam presence dot when a recent summary backs it. */
.header-avatar-button {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  inline-size: var(--ctl-h);
  block-size: var(--ctl-h);
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--ctl-radius);
  cursor: pointer;
  anchor-name: --profile-menu;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.header-avatar-button:hover,
.header-avatar-button[aria-expanded="true"] {
  background: var(--surface-chip-hover);
  border-color: var(--border-strong);
}

.header-avatar {
  display: block;
  inline-size: 28px;
  block-size: 28px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.presence-dot {
  position: absolute;
  right: -4px;
  bottom: -4px;
  inline-size: 12px;
  block-size: 12px;
  border: 2px solid var(--surface-page);
  border-radius: 50%;
}

.presence-dot--online { background: var(--status-online); }
.presence-dot--away { background: var(--status-away); }
.presence-dot--busy { background: var(--status-busy); }
.presence-dot--offline { background: var(--status-offline); }
.presence-dot--ingame { background: var(--status-ingame); }

/* Between tablet and desktop: search becomes a button, the chip keeps only the game. */
@media (max-width: 1099px) {
  .header-search {
    flex: 0 0 auto;
    min-width: 0;
  }

  .header-search-toggle {
    display: inline-grid;
  }

  .header-search-panel,
  .header-search-key {
    display: none;
  }

  .header-search-panel.is-open {
    position: fixed;
    inset: 0 0 auto;
    z-index: var(--z-overlay);
    display: flex;
    min-block-size: var(--bar-h);
    padding: var(--space-2) var(--space-4);
    background: var(--surface-bar);
    border-bottom: var(--header-rule);
  }

  .header-search-panel.is-open .header-search-close {
    display: inline-grid;
  }

  .header-search-icon {
    left: calc(var(--space-4) + var(--space-3));
  }

  .header-search-popup {
    inset: 100% 0 auto;
    min-inline-size: 0;
    border-radius: 0;
  }

  .now-playing {
    max-inline-size: 11rem;
  }

  /* Out of sight, still part of the link name: "Playing <game> for 12m". */
  .now-playing-label,
  .now-playing-time {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Header: theme skins */

/* Goshboard OS signature: a holographic HUD rule with a diamond node, and a diamond on the active tab. */
:root:not([data-theme="beige"]):not([data-theme="hacker"]) .header-rule {
  block-size: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, rgb(var(--accent-rgb) / .75) 20% 80%, transparent);
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .header-rule::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  inline-size: 7px;
  block-size: 7px;
  translate: -50% -50%;
  rotate: 45deg;
  background: var(--surface-page);
  border: 1px solid var(--accent);
  box-shadow: var(--diamond-glow);
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .nav-tab[aria-current="page"]::before {
  content: "";
  flex-shrink: 0;
  inline-size: 6px;
  block-size: 6px;
  rotate: 45deg;
  background: var(--accent);
  box-shadow: var(--diamond-glow);
}

/* The neon pulse: a glow ring around the chip while the dot beats. */
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-theme="beige"]):not([data-theme="hacker"]) .now-playing {
    animation: now-playing-glow 2.4s ease-in-out infinite;
  }
}

@keyframes now-playing-glow {
  50% {
    box-shadow: 0 0 14px rgb(var(--status-ingame-rgb) / .35);
  }
}

/* The bar is dark brown on the Retro Desk, so its chips and borders are paper tints. */
:root[data-theme="beige"] .dashboard-header {
  --surface-chip: rgb(244 239 226 / .1);
  --surface-chip-hover: rgb(244 239 226 / .18);
  --border-subtle: rgb(244 239 226 / .3);
}

/* Retro Desk signature: a brass desk nameplate with two rivets. Soft shadow only. */
:root[data-theme="beige"] .header-logo-title {
  padding: 0 var(--space-4);
  background:
    radial-gradient(circle at 6px 50%, var(--nameplate-rivet) 1.5px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 6px) 50%, var(--nameplate-rivet) 1.5px, transparent 2.5px),
    var(--nameplate-brass);
  border: 1px solid var(--nameplate-edge);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .4), 0 1px 2px rgb(0 0 0 / .3);
}

:root[data-theme="beige"] .header-logo-title .logo-text {
  background: none;
  color: var(--nameplate-ink);
  -webkit-text-fill-color: var(--nameplate-ink);
}

:root[data-theme="beige"] .header-logo-title .logo-diamond {
  background: var(--nameplate-diamond);
  border-color: var(--nameplate-ink);
}

/* Red half of a typewriter ribbon under the active tab. */
:root[data-theme="beige"] .nav-tab[aria-current="page"]::after {
  block-size: 4px;
  background: var(--ribbon);
}

:root[data-theme="beige"] .header-search-input {
  background-color: var(--surface-card);
  border: 2px outset var(--surface-header);
  color: var(--overlay-text);
}

:root[data-theme="beige"] .header-search-input::placeholder,
:root[data-theme="beige"] .header-search-icon,
:root[data-theme="beige"] .header-search-key {
  color: var(--text-faint);
}

/* Now playing as a paper tag with an "ON DUTY" rubber stamp. */
:root[data-theme="beige"] .now-playing {
  color: var(--overlay-text);
  background: var(--surface-card);
  border: 2px outset var(--surface-header);
  --text-secondary: var(--text-faint);
}

:root[data-theme="beige"] .now-playing-pulse {
  display: none;
}

:root[data-theme="beige"] .now-playing::before {
  content: "On duty" / "";
  flex-shrink: 0;
  padding: 0 4px;
  color: var(--danger);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  border: 2px solid currentColor;
  rotate: -4deg;
}

/* Netrunner signature: the nav as a shell prompt, an inverse-video active tab, now playing as a command. */
@media (min-width: 1280px) {
  :root[data-theme="hacker"] .dashboard-nav-ribbon::before {
    content: "root@goshboard:~/" attr(data-section) "$" / "";
    margin-right: var(--space-2);
    color: var(--header-text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    white-space: nowrap;
  }
}

:root[data-theme="hacker"] .nav-tab[aria-current="page"] {
  color: var(--surface-page);
  background: var(--header-accent);
}

:root[data-theme="hacker"] .nav-tab[aria-current="page"]::before {
  content: ">" / "";
}

:root[data-theme="hacker"] .nav-tab[aria-current="page"]::after {
  content: none;
}

:root[data-theme="hacker"] .now-playing {
  font-family: var(--font-mono);
  background: transparent;
}

:root[data-theme="hacker"] .now-playing-pulse {
  display: none;
}

/* The themed verb replaces "Playing" on screen; assistive tech still reads "Playing". */
:root[data-theme="beige"] .now-playing-label,
:root[data-theme="hacker"] .now-playing-label {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:root[data-theme="hacker"] .now-playing::before {
  content: "> exec" / "";
  flex-shrink: 0;
  color: var(--header-text-muted);
}

:root[data-theme="hacker"] .now-playing::after {
  content: "";
  flex-shrink: 0;
  inline-size: .55em;
  block-size: 1.1em;
  background: currentColor;
}

@media (prefers-reduced-motion: no-preference) {
  :root[data-theme="hacker"] .now-playing::after {
    animation: terminal-cursor 1s steps(1) infinite;
  }
}

/* Header on phones */
@media (max-width: 767px) {
  /* A 48px top bar and a 56px tab bar at the bottom: about 104px of chrome instead of ~450. */
  .dashboard-header {
    gap: var(--space-2);
    min-height: var(--bar-h-phone);
    margin-bottom: var(--space-3);
    padding-block: calc((var(--bar-h-phone) - var(--ctl-h)) / 2);
  }

  .header-logo-title .logo-text {
    font-size: var(--text-lg);
  }

  .header-logo-title .logo-diamond {
    inline-size: 10px;
    block-size: 10px;
    margin: 0 3px;
    border-width: 2px;
  }

  .dashboard-nav-ribbon {
    position: fixed;
    inset: auto 0 0;
    z-index: var(--z-header);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-bar);
    border-top: var(--header-rule);
  }

  body:has(.dashboard-nav-ribbon) {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-4));
  }

  html:has(.dashboard-nav-ribbon) {
    scroll-padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  }

  /* Toasts sit just above the tab bar, near the thumb and clear of the compact header. */
  body:has(.dashboard-nav-ribbon) .flash-region {
    top: auto;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-2));
  }

  .nav-tab {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    block-size: var(--tabbar-h);
    padding: 0 var(--space-1);
    font-family: var(--font-body);
    font-size: .6875rem;
    letter-spacing: 0;
    text-transform: none;
    border-radius: 0;
  }

  .nav-tab-icon {
    display: block;
  }

  .nav-tab-label {
    max-inline-size: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-tab[aria-current="page"]::after {
    inset: 0 25% auto;
    block-size: 3px;
  }

  :root:not([data-theme="beige"]):not([data-theme="hacker"]) .nav-tab[aria-current="page"]::before {
    position: absolute;
    top: 7px;
    right: calc(50% - 20px);
  }

  :root[data-theme="hacker"] .nav-tab[aria-current="page"]::before {
    content: none;
  }

  /* Now playing shrinks to its pulse; the game stays in the link's name. */
  .now-playing {
    justify-content: center;
    inline-size: var(--ctl-h);
    padding: 0;
  }

  .now-playing-text,
  .now-playing::before {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  :root[data-theme="beige"] .now-playing-pulse,
  :root[data-theme="hacker"] .now-playing-pulse {
    display: block;
  }

  :root[data-theme="hacker"] .now-playing::after {
    content: none;
  }

  .header-search-panel.is-open {
    min-block-size: var(--bar-h-phone);
    padding: calc((var(--bar-h-phone) - var(--ctl-h)) / 2) var(--space-4);
  }

  .btn-primary.header-signin {
    padding: 0 var(--space-3);
  }

  .header-signin-rest {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ==========================================================================
   Cards: glass panels with a titled header, a glowing rule and a diamond on it
   ========================================================================== */

.card {
  background: var(--surface-card);
  backdrop-filter: blur(calc(var(--backdrop-blur) + 4px));
  -webkit-backdrop-filter: blur(calc(var(--backdrop-blur) + 4px));
  border: var(--border-card);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: var(--card-pad);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.3s ease;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* Card Headers */
.card-header {
  margin-bottom: var(--space-6);
  text-align: center;
  position: relative;
  padding-bottom: var(--space-6);
}

/* The glowing line underneath */
.card-header::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: 2px;
  box-shadow: var(--shadow-glow);
  z-index: 1;
}

/* The diamond sitting on the line */
.card-header::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: var(--diamond-sm);
  height: var(--diamond-sm);
  background: var(--diamond-fill);
  border: var(--diamond-stroke-w) solid var(--diamond-stroke);
  box-shadow: var(--diamond-glow);
  z-index: 2;
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 4px;
  background: var(--heading-fill);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: var(--heading-glow);
  display: inline-block;
  margin: 0;
}

/* Not a duplicate of .card: Retro Desk has no --shadow-glow, which voids the .card:hover shadow list. */
:root[data-theme="beige"] .card {
  box-shadow: var(--shadow-card);
}

@media (max-width: 767px) {
  .card {
    padding: var(--space-4);
  }
}

/* ==========================================================================
   Stat tiles: a value under a diamond badge (Achievements overview, Pile of Shame)
   ========================================================================== */

.stats-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .stats-items {
    grid-template-columns: 1fr 1fr;
  }
}

.stats-items .stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 100px;
  padding: 1rem;
  padding-top: 2rem;
  text-align: center;
  margin-top: 24px;
  border-top: 3px solid var(--accent);
  background: linear-gradient(180deg, rgb(var(--accent-rgb) / .05) 0%, rgba(255, 255, 255, 0) 100%);
  overflow: visible;
  position: relative;
}

.stats-items .stat-badge {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: var(--diamond-lg);
  height: var(--diamond-lg);
  background: var(--diamond-fill);
  border: var(--diamond-stroke-w) solid var(--diamond-stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: var(--diamond-glow);
  z-index: 2;
  transition: all 0.3s ease;
}

.stats-items .stat-item:hover .stat-badge {
  box-shadow: var(--diamond-glow-strong);
  color: var(--on-accent);
  background: var(--accent);
}

/* The danger tile, the Pile of Shame: a faint red frame that warms on hover, and a red badge. */
.stats-items .stat-item.danger {
  border-color: rgb(var(--danger-rgb) / .3);
  box-shadow: var(--danger-glow);
}

.stats-items .stat-item.danger:hover {
  border-color: rgb(var(--danger-rgb) / .6);
  box-shadow: var(--danger-glow-strong);
}

.stats-items .stat-item.danger .stat-badge {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 15px rgb(var(--danger-rgb) / .4), inset 0 0 10px rgb(var(--danger-rgb) / .2);
}

.stats-items .stat-item.danger:hover .stat-badge {
  box-shadow: 0 0 25px rgb(var(--danger-rgb) / .7), inset 0 0 15px rgb(var(--danger-rgb) / .4);
  color: var(--surface-page);
  background: var(--danger);
}

.stats-items .stat-badge svg {
  transform: rotate(-45deg);
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.stats-items .stat-value {
  color: var(--text-primary);
  text-shadow: var(--glow-text);
  margin-top: auto;
  margin-bottom: auto;
  padding-top: 1rem;
}

.stats-items .stat-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-data);
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}

.stat-bottom-row {
  width: 100%;
  text-align: center;
  margin-top: 0.25rem;
}

/* The Pile of Shame tile, unlocked: the stats panel takes the lock panel's place with a glitch (a paper
   slide on the Retro Desk); instant-unlock, for a pile unlocked on load, skips that in every theme.
   The lock lives in backlog_dashboard.css, but the CSS lint counts these classes as shared. */
.unlocked .combined-locked { opacity: 0; }
.unlocked .icon-locked { display: none; }
.unlocked .icon-unlocked { display: block; }

.unlocked .combined-unlocked {
  opacity: 1;
  animation: cyber-reveal 0.4s ease-out forwards;
}

:root[data-theme="beige"] .unlocked .combined-unlocked {
  animation-name: pile-paper-in;
}

.instant-unlock .combined-unlocked {
  animation: none !important;
}

@keyframes cyber-reveal {
  0% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); filter: hue-rotate(90deg) contrast(200%); transform: scale(0.98); opacity: 0.5; }
  20% { clip-path: polygon(0 20%, 100% 0, 100% 80%, 0 100%); transform: translateX(-5px); opacity: 0.8; }
  40% { clip-path: polygon(0 0, 100% 20%, 100% 100%, 0 80%); transform: translateX(5px); opacity: 0.3; }
  60% { clip-path: polygon(0 10%, 100% 5%, 100% 90%, 0 95%); transform: translateX(-2px); filter: hue-rotate(-90deg) contrast(150%); opacity: 0.9; }
  80% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); transform: translateX(2px); opacity: 1; filter: hue-rotate(0deg); }
  100% { clip-path: none; transform: none; opacity: 1; filter: none; }
}

@keyframes pile-paper-in {
  from { opacity: 0; transform: translateY(-12px); }
}

.stat-bottom-row.backlog-label {
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  fill: var(--text-secondary);
  opacity: 0.5;
  margin-bottom: 1.5rem;
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.empty-state span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* The one-line note a card shows instead of its list. */
.empty-note {
  padding: var(--space-8) 0;
  color: var(--text-secondary);
  text-align: center;
}

.chart-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-secondary);
}

/* ==========================================================================
   Chart panels
   ========================================================================== */

.chart-wrapper {
  background: var(--surface-inset);
  padding: 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Buttons, inputs and native selects
   ========================================================================== */

.btn-primary,
.btn-cancel {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
}

.btn-primary:hover {
  background: var(--accent-2);
}

.btn-cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.btn-cancel:hover {
  background: var(--surface-chip-hover);
  color: var(--text-primary);
}

.cyber-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font: inherit;
  background: var(--surface-chip);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.native-select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 36px;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  background-color: var(--surface-chip);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-size: 5px 5px;
  background-position: right 14px center, right 9px center;
  background-repeat: no-repeat;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.native-select option {
  color: var(--overlay-text);
  background: var(--surface-raised);
}

.cyberpunk-btn {
  background: rgb(var(--accent-rgb) / .05);
  border: 1px solid var(--accent);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: var(--font-display);
  font-weight: 700;
  padding: 0.6rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 10px rgb(var(--accent-rgb) / .2), inset 0 0 5px rgb(var(--accent-rgb) / .1);
}

.cyberpunk-btn:hover {
  background: rgb(var(--accent-rgb) / .15);
  box-shadow: 0 0 15px rgb(var(--accent-rgb) / .4), inset 0 0 10px rgb(var(--accent-rgb) / .3);
  text-shadow: 0 0 8px rgb(var(--accent-rgb) / .5);
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--text-primary);
}

:root[data-theme="beige"] .cyberpunk-btn,
:root[data-theme="beige"] .btn-primary {
  background: transparent;
  border: 2px solid var(--text-primary);
  color: var(--text-primary);
}

:root[data-theme="beige"] .cyberpunk-btn:hover,
:root[data-theme="beige"] .btn-primary:hover {
  background: var(--text-primary);
  color: var(--surface-page);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

.search-icon svg {
  fill: var(--text-secondary);
}

:root[data-theme="beige"] .search-icon svg {
  fill: var(--overlay-text);
}

/* ==========================================================================
   Small shared pieces: themed flavour text, score badges, text utilities
   ========================================================================== */

.flavour {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  color: var(--text-secondary);
  text-transform: none;
}

.meta-high { background: var(--meta-high-bg); color: var(--meta-high-fg); }

.meta-mixed { background: var(--meta-mixed-bg); color: var(--meta-mixed-fg); }

.meta-low { background: var(--meta-low-bg); color: var(--meta-low-fg); }

.text-muted {
  color: var(--text-secondary);
}

.text-small {
  font-size: var(--text-sm);
}

/* ==========================================================================
   Feedback: flash and toast region
   ========================================================================== */
.flash-region {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  /* Pinned on both sides with a max width, never sized from the viewport: on phones the layout
     viewport grows to fit a fixed box, so a viewport-relative width kept itself, and the page, too wide. */
  left: var(--space-4);
  max-width: 26rem;
  margin-left: auto;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.flash {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--overlay-text);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-md);
  font-weight: 500;
}

.flash-alert {
  border-color: var(--danger);
}

.flash-message {
  flex: 1;
  min-width: 0;
}

.flash-action {
  flex-shrink: 0;
}

.flash-action button,
.flash-dismiss {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.flash-action button {
  font-weight: 700;
  text-decoration: underline;
}

.flash-dismiss {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  font-size: var(--text-lg);
  line-height: 1;
}

/* ==========================================================================
   Sync status strip, guest banner, site footer
   ========================================================================== */
.sync-strip,
.guest-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--surface-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.sync-strip-attention {
  align-items: flex-start;
  justify-content: flex-start;
  padding: var(--space-4);
  color: var(--text-primary);
  border-color: var(--danger);
}

.sync-strip-title {
  font-weight: 700;
  color: var(--text-primary);
}

.sync-strip-text {
  margin: 0;
}

.sync-strip-attention .sync-strip-text {
  flex: 1 1 100%;
}

.sync-strip-hint {
  flex: 1 1 100%;
  text-align: center;
}

.sync-strip-progress {
  width: 8rem;
  height: 6px;
  accent-color: var(--accent);
}

.sync-strip-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.site-footer {
  max-width: var(--content-max);
  margin: var(--space-8) auto 0;
  padding: var(--space-4) 1rem 0;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-align: center;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-2);
}

.site-footer-links a {
  color: var(--text-secondary);
  text-decoration: underline;
}

.site-footer-links a:hover,
.site-footer-links a:focus-visible {
  color: var(--text-primary);
}

/* ==========================================================================
   Legal pages and guest panels
   ========================================================================== */

.legal-page {
  max-width: 48rem;
  margin: var(--space-8) auto;
  padding: var(--space-8);
  line-height: 1.6;
  color: var(--text-primary);
}

.legal-page h1 {
  margin-bottom: var(--space-4);
  font-family: var(--font-display);
  font-size: var(--text-3xl);
}

.legal-page h2 {
  margin: var(--space-6) 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-label);
  color: var(--accent);
}

.legal-page p,
.legal-page ul {
  margin-bottom: var(--space-3);
}

.legal-page ul {
  padding-left: var(--space-6);
}

.legal-page a {
  color: var(--accent);
}

.legal-summary {
  padding: var(--space-4) var(--space-6);
  background: var(--surface-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.legal-address {
  margin-bottom: var(--space-3);
  font-style: normal;
}

.legal-placeholder {
  color: var(--danger);
  font-weight: 600;
}

.legal-updated {
  margin-top: var(--space-8);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

@media (max-width: 767px) {
  .legal-page {
    padding: var(--space-4);
  }
}

.guest-panel {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-4);
  text-align: center;
}

.guest-panel-title {
  margin-bottom: var(--space-4);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.guest-panel-copy {
  margin-bottom: var(--space-8);
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ==========================================================================
   Modal: every dialog from the shared dialog partial, skinned per theme by the --modal-* tokens
   ========================================================================== */
html:has(dialog.modal[open]) {
  overflow: hidden;
}

.modal {
  inline-size: min(var(--modal-w, var(--modal-w-md)), 100% - 2 * var(--space-4));
  max-inline-size: none;
  max-block-size: calc(100dvh - 2 * var(--space-8));
  margin: auto;
  padding: 0;
  flex-direction: column;
  color: var(--text-primary);
  background: var(--modal-surface);
  border: var(--modal-border);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  overflow: hidden;
  opacity: 0;
  translate: 0 .75rem;
  transition: opacity var(--modal-enter), translate var(--modal-enter),
              overlay var(--modal-enter) allow-discrete, display var(--modal-enter) allow-discrete;
}

.modal[open] {
  display: flex;
  opacity: 1;
  translate: 0 0;
}

@starting-style {
  .modal[open] {
    opacity: 0;
    translate: 0 .75rem;
  }
}

.modal--sm { --modal-w: var(--modal-w-sm); }
.modal--md { --modal-w: var(--modal-w-md); }
.modal--lg { --modal-w: var(--modal-w-lg); }

.modal::backdrop {
  background: var(--modal-scrim);
  backdrop-filter: blur(var(--modal-scrim-blur));
  -webkit-backdrop-filter: blur(var(--modal-scrim-blur));
}

/* A loaded frame holds the header and the body, like the dialog would without a frame. */
.modal__frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-block-size: 0;
}

.modal__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--modal-pad);
  background: var(--modal-header-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal__diamond {
  flex-shrink: 0;
  inline-size: .6rem;
  block-size: .6rem;
  rotate: 45deg;
  background: var(--diamond-fill);
  border: var(--diamond-stroke-w) solid var(--diamond-stroke);
  box-shadow: var(--diamond-glow);
}

.modal__title {
  flex: 1;
  min-inline-size: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--modal-title-color);
  overflow-wrap: anywhere;
}

.modal__title::before {
  content: var(--modal-title-prefix);
}

.modal__close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}

.modal__close svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.modal__close:hover,
.modal__close:focus-visible {
  color: var(--danger);
  border-color: var(--danger);
  background: rgb(var(--danger-rgb) / .08);
}

.modal__body {
  flex: 1;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--modal-pad);
}

.modal__status {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  padding-block: var(--space-12);
  color: var(--text-secondary);
  text-align: center;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--modal-pad);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.modal__hint {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.modal__error {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--danger);
}

.modal__error:empty {
  display: none;
}

/* Phones: every modal is a sheet from the bottom. */
@media (max-width: 40rem) {
  .modal {
    inline-size: 100%;
    max-block-size: 92dvh;
    margin: auto 0 0;
    border-radius: var(--modal-radius) var(--modal-radius) 0 0;
    border-bottom: 0;
    translate: 0 100%;
  }

  @starting-style {
    .modal[open] {
      translate: 0 100%;
    }
  }

  .modal__body,
  .modal__footer {
    padding-inline: var(--space-4);
  }

  .modal__footer {
    flex-direction: column-reverse;
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  }

  .modal__footer > * {
    inline-size: 100%;
  }
}

/* ==========================================================================
   Menu popovers: the profile menu and the visitors' theme menu. Anchored to their button, with the
   modal's header and skin; sheets from the bottom on phones, above the tab bar (top layer).
   ========================================================================== */
.menu-popover {
  inset: calc(var(--bar-h) + var(--space-2)) var(--space-4) auto auto;
  inline-size: min(24rem, 100vw - 2 * var(--space-4));
  max-block-size: calc(100dvh - var(--bar-h) - var(--space-8));
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  background: var(--modal-surface);
  border: var(--modal-border);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
}

@supports (anchor-name: --a) {
  .menu-popover {
    inset: anchor(bottom) anchor(right) auto auto;
    margin-top: var(--space-2);
    position-try-fallbacks: flip-inline;
  }

  .theme-menu {
    position-anchor: --theme-menu;
  }

  .profile-menu {
    position-anchor: --profile-menu;
  }
}

.menu-popover .boot-options {
  margin: 0;
  padding: 0;
  border: 0;
}

.theme-menu .boot-options {
  padding: var(--space-4);
}

.theme-menu-flavour {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

.profile-menu-section {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.profile-menu-section:last-child {
  border-bottom: 0;
}

.profile-menu-identity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.profile-menu-avatar {
  flex-shrink: 0;
  inline-size: 48px;
  block-size: 48px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.profile-menu-presence {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.profile-menu-sync,
.profile-menu-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

.profile-menu-sync {
  color: var(--text-secondary);
}

.profile-menu-field label,
.profile-menu-legend {
  color: var(--text-primary);
  font-weight: 700;
}

.profile-menu-legend {
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
}

.profile-menu-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.profile-menu-link {
  display: flex;
  align-items: center;
  inline-size: 100%;
  min-block-size: 44px;
  padding: 0 var(--space-3);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.profile-menu-link:hover {
  background: var(--surface-chip-hover);
}

.profile-menu-link[aria-current="page"] {
  border-color: var(--border-strong);
}

.profile-menu-signout {
  color: var(--danger);
}

.profile-menu-hint {
  padding-inline: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.profile-menu-unit-hint {
  flex-basis: 100%;
  padding-inline: 0;
}

@media (max-width: 40rem) {
  .menu-popover,
  .menu-popover:popover-open {
    inset: auto 0 0 0;
    inline-size: 100%;
    max-block-size: 88dvh;
    margin: 0;
    border-radius: var(--modal-radius) var(--modal-radius) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ==========================================================================
   Theme menu
   ========================================================================== */
.boot-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.boot-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  background: var(--surface-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.boot-option:hover,
.boot-option:has(:checked) {
  background: var(--surface-chip-hover);
  border-color: var(--accent);
}

.boot-option:has(:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* The radio stays focusable and in the accessibility tree; the whole label shows its state. */
.boot-radio {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.boot-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  color: var(--swatch-ink);
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.boot-icon-default { background: var(--swatch-default); }
.boot-icon-beige { background: var(--swatch-beige); }
.boot-icon-hacker { background: var(--swatch-hacker); }

.boot-name {
  display: block;
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 700;
}

/* ==========================================================================
   Pick a game: the result a roll lands on (randomizer_controller.js)
   ========================================================================== */

.randomizer-result {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  text-align: center;
}

.randomizer-result.is-shown {
  display: flex;
}

/* While the roll flicks through games, the banner reads as passing by, not as the pick. */
.is-rolling img {
  opacity: .7;
  filter: blur(1px) saturate(1.4);
}

:root[data-theme="beige"] .is-rolling img {
  filter: sepia(.8) contrast(1.1);
  transform: rotate(-1.5deg);
}

:root[data-theme="hacker"] .is-rolling img {
  filter: grayscale(1) sepia(1) hue-rotate(70deg) saturate(3);
}

/* The beat between the landed roll and the game dialog: the pick settles in with a flash of the
   theme's accent. randomizer_controller.js sets the class only when motion is allowed. */
.is-settling img {
  animation: pick-settle 600ms ease-out;
}

@keyframes pick-settle {
  from {
    transform: scale(1.06);
    box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / .9), 0 0 18px rgb(var(--accent-rgb) / .6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-settling img { animation: none; }
}

/* ==========================================================================
   Co-op lobby
   ========================================================================== */
.coop-card {
  display: flex;
  flex-direction: column;
  overflow: clip; /* not hidden: that would end the overlay terminal's sticky position */
}

.card-content-coop {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  position: relative;
}

.coop-section {
  margin-bottom: var(--space-6);
}

/* One heading style for every lobby section and results group. */
.coop-section-title,
.coop-results-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.coop-results-heading {
  font-size: var(--text-lg);
}

.coop-results-heading:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
}

.coop-party-count {
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  letter-spacing: 0;
  text-transform: none;
}

.coop-party-hint,
.coop-party-warning {
  margin-top: var(--space-2);
  color: var(--text-secondary);
}

.coop-party-warning {
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  background: var(--surface-inset);
  border-left: 3px solid var(--accent);
}

.filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface-inset);
  border-radius: var(--radius-md);
}

.coop-filter {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.filter-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.coop-inline-error {
  margin-top: var(--space-2);
  font-weight: 600;
  color: var(--danger);
}

/* Who's playing? The party as a list, in fixed-width slots. */
.roster-slots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.roster-empty-state {
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.roster-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 112px;
  min-width: 0;
  padding: var(--space-3);
  background: var(--surface-inset);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
}

.roster-slot--empty {
  display: none;
}

.roster-slot-avatar,
.friend-card-avatar {
  object-fit: cover;
  background: rgb(var(--accent-rgb) / .15);
}

.roster-slot-avatar {
  width: 48px;
  height: 48px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
}

.roster-slot-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-card-remove button {
  display: grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  color: var(--text-secondary);
  font-size: var(--text-md);
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 50%;
}

.friend-card-remove button:hover {
  color: var(--danger);
  background: var(--surface-chip-hover);
}

@media (pointer: coarse) {
  .friend-card-remove button {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Goshboard OS signature: holographic diamond squad slots, four of them; empty ones pulse with a "+". */
:root:not([data-theme="beige"]):not([data-theme="hacker"]) .roster-slot {
  overflow: hidden;
  background: linear-gradient(135deg, rgb(var(--accent-rgb) / .14), rgb(var(--accent-rgb) / .02));
  box-shadow: var(--shadow-glow);
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .roster-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgb(255 255 255 / .16) 50%, transparent 70%);
  translate: -100% 0;
  animation: coop-sheen 4s ease-in-out infinite;
  pointer-events: none;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .roster-slot-avatar {
  border: 0;
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .roster-slot--empty {
  display: grid;
  place-items: center;
  min-height: 104px;
  background: none;
  border-style: dashed;
  box-shadow: none;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .roster-slot--empty::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--accent);
  font-size: var(--text-2xl);
  background: rgb(var(--accent-rgb) / .08);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  animation: coop-pulse 2s ease-in-out infinite;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .roster-slot--empty::after {
  content: none;
}

@keyframes coop-sheen {
  50%, 100% { translate: 100% 0; }
}

@keyframes coop-pulse {
  50% { opacity: .35; }
}

@keyframes coop-cursor {
  50% { opacity: 0; }
}

/* Friend picker */
.friend-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-4);
  padding-bottom: var(--space-2);
}

.friend-selection-area:has(.friend-card:not(.add-friend-btn)) .friends-empty-hint {
  display: none;
}

.friend-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  text-align: center;
  background: var(--surface-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

/* Selected: a check badge and an inset ring, not colour alone. */
.friend-card:has(input:checked) {
  background: rgb(var(--accent-rgb) / .1);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.friend-card:has(input:checked)::after {
  content: "\2713";
  position: absolute;
  top: var(--space-1);
  left: var(--space-1);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--on-accent);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--accent);
  border-radius: 50%;
}

.friend-card:has(input:disabled) .friend-card-select {
  cursor: not-allowed;
  opacity: .55;
}

.friend-card:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.friend-card-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.friend-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.friend-card-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--text-sm);
}

.friend-card-status {
  width: 100%;
  min-width: 0;
}

.friend-card-remove {
  position: absolute;
  top: 0;
  right: 0;
}

.add-friend-btn {
  justify-content: center;
  width: 100%;
  min-height: 100%;
  color: var(--accent);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  border: 1px dashed var(--accent);
}

.add-friend-btn:disabled {
  color: var(--text-secondary);
  cursor: not-allowed;
  border-color: var(--border-subtle);
}

.add-friend-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: var(--text-2xl);
  background: rgb(var(--accent-rgb) / .1);
  border-radius: 50%;
}

.sync-chip {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.sync-chip-ready { color: var(--success); }
.sync-chip-error { color: var(--danger); }

.sync-chip-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  margin-top: 2px;
}

.sync-chip-progress progress {
  flex: 1 1 auto;
  width: 100%;
  min-width: 40px;
  height: 6px;
  appearance: none;
  border: 0;
  border-radius: 3px;
  background: var(--surface-chip-hover);
}

.sync-chip-progress progress::-webkit-progress-bar {
  background: var(--surface-chip-hover);
  border-radius: 3px;
}

.sync-chip-progress progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 3px;
}

.sync-chip-progress progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 3px;
}

/* Results: as tall as what they show, so an empty lobby ends under its hint. */
.coop-results {
  display: block;
}

.coop-match-summary {
  margin-bottom: var(--space-3);
  color: var(--text-primary);
  font-weight: 600;
}

.coop-notices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.coop-notice {
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-size: var(--text-sm);
  background: var(--surface-inset);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}

.coop-notice--alert {
  border-left-color: var(--danger);
}

.coop-notice-action {
  margin-left: var(--space-2);
  color: var(--accent);
  font-weight: 600;
}

.coop-shared {
  margin-bottom: var(--space-6);
}

/* Tonight's pick: the Pick a game roll over the shared games (randomizer_controller.js). The first roll
   swaps the button for a result card: the banner, the name that reopens the game, and Roll again. */
.party-pick {
  margin-bottom: var(--space-4);
}

/* .btn-primary sets a display, which would beat the hidden attribute the first roll sets. */
.party-pick-roll[hidden] {
  display: none;
}

.party-pick-result.is-shown {
  flex-direction: row;
  justify-content: flex-start;
  gap: var(--space-4);
  height: auto;
  padding: var(--space-3);
  text-align: left;
  background: var(--surface-chip);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glow);
}

.party-pick-banner {
  flex: 0 0 auto;
  width: 184px;
  aspect-ratio: 460 / 215;
  object-fit: cover;
  background: rgb(var(--accent-rgb) / .15);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.party-pick-meta {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
}

.party-pick-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

/* The Goshboard OS diamond. */
.party-pick-label::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  transform: rotate(45deg);
}

.party-pick-title {
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  cursor: pointer;
}

.party-pick-title:hover {
  text-decoration: underline;
}

.party-pick-title:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.party-pick-reroll {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.columns-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
  padding-bottom: var(--space-4);
}

.lobby-column {
  min-width: 0;
  max-height: 70vh;
  overflow-y: auto;
  padding: var(--space-4);
  background: var(--surface-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.lobby-column > summary {
  margin-bottom: 0;
  cursor: pointer;
}

.lobby-column[open] > summary {
  margin-bottom: var(--space-4);
}

.game-strip-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-2);
  padding: var(--space-2);
  background: var(--surface-inset);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast), transform var(--dur-fast);
}

.game-strip:hover {
  background: var(--surface-chip-hover);
  transform: translateX(2px);
}

.game-strip.match {
  background: var(--surface-chip);
  border-left: 4px solid var(--accent);
}

.game-strip-link {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.game-strip-link:focus-visible,
.game-strip-action:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.game-strip-link img {
  flex: 0 0 auto;
  width: 86px;
  height: 40px;
  object-fit: cover;
  background: rgb(var(--accent-rgb) / .15);
  border-radius: var(--radius-sm);
}

.game-strip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.game-strip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-strip-link:hover .game-strip-name {
  text-decoration: underline;
}

.game-strip-note {
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.game-strip-actions {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-2);
  margin-left: auto;
}

.game-strip-action {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--space-3);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.game-strip-action:hover {
  background: var(--surface-chip-hover);
}

.btn-gift-steam {
  color: var(--text-primary);
}

/* Co-op lobby: Retro Desk and Netrunner skins (the Goshboard OS squad slots are above) */

:root[data-theme="beige"] .friend-card-avatar,
:root[data-theme="beige"] .roster-slot-avatar {
  border: 4px solid var(--polaroid);
  border-bottom-width: 12px;
  transform: rotate(-2deg);
}

:root[data-theme="beige"] .friend-card:nth-child(even) .friend-card-avatar {
  transform: rotate(3deg);
}

/* Retro Desk signature: the party on a clipboard, lined paper with pinned polaroids. */
:root[data-theme="beige"] .roster-area {
  position: relative;
  margin-top: var(--space-6);
  padding: var(--space-8) var(--space-4) var(--space-4);
  background: repeating-linear-gradient(var(--surface-raised) 0 27px, var(--clipboard-lines) 27px 28px);
  border: 10px solid var(--clipboard-board);
}

:root[data-theme="beige"] .roster-area::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 50%;
  width: 90px;
  height: 26px;
  translate: -50% 0;
  background: var(--clipboard-clip);
  border-radius: 6px 6px 3px 3px;
  box-shadow: var(--shadow-pop);
}

:root[data-theme="beige"] .roster-slot {
  padding: var(--space-3) var(--space-2) var(--space-2);
  background: var(--polaroid);
  border: 0;
  rotate: -2deg;
}

:root[data-theme="beige"] .roster-slot:nth-child(even) {
  rotate: 2deg;
}

:root[data-theme="beige"] .roster-slot::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  translate: -50% 0;
  background: var(--clipboard-pin);
  border-radius: 50%;
  box-shadow: var(--shadow-pop);
}

:root[data-theme="beige"] .roster-slot .roster-slot-avatar {
  border: 0;
  transform: none;
}

:root[data-theme="beige"] .game-strip {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-pop);
}

/* Netrunner signature: the party as a terminal session, one "> join @name [OK]" line each. */
:root[data-theme="hacker"] .roster-area {
  padding: var(--space-4);
  background: repeating-linear-gradient(0deg, rgb(var(--accent-rgb) / .05) 0 1px, transparent 1px 3px), var(--surface-page);
  border: 1px solid var(--border-strong);
}

:root[data-theme="hacker"] .roster-slots {
  flex-direction: column;
  gap: var(--space-1);
  font-family: var(--font-mono);
}

:root[data-theme="hacker"] .roster-slots::after {
  content: "> _";
  color: var(--accent);
  animation: coop-cursor 1s steps(1) infinite;
}

:root[data-theme="hacker"] .roster-slot {
  flex-direction: row;
  width: auto;
  padding: 0 var(--space-8) 0 0;
  background: none;
  border: 0;
}

:root[data-theme="hacker"] .roster-slot-avatar {
  display: none;
}

:root[data-theme="hacker"] .roster-slot-name {
  color: var(--accent);
  font-weight: 400;
  text-shadow: var(--glow-text);
}

:root[data-theme="hacker"] .roster-slot-name::before {
  content: "> join @";
}

:root[data-theme="hacker"] .roster-slot-name::after {
  content: " [OK]";
}

/* Retro Desk: tonight's pick as a ruled index card on the desk, the banner a photo with a white border
   and the label a rubber stamp. */
:root[data-theme="beige"] .party-pick-result.is-shown {
  padding-left: var(--space-8);
  background:
    linear-gradient(var(--index-margin), var(--index-margin)) 22px 0 / 1px 100% no-repeat,
    repeating-linear-gradient(var(--surface-raised) 0 23px, var(--clipboard-lines) 23px 24px);
  border: 1px solid var(--border-subtle);
  filter: var(--paper-drop);
}

:root[data-theme="beige"] .party-pick-banner {
  border: 4px solid var(--polaroid);
  border-bottom-width: 10px;
  rotate: -2deg;
}

:root[data-theme="beige"] .party-pick-label {
  padding: 1px var(--space-2);
  color: var(--stamp-red);
  font-family: var(--font-body);
  font-weight: 700;
  border: 2px solid var(--stamp-red);
  rotate: -3deg;
}

:root[data-theme="beige"] .party-pick-label::before {
  content: none;
}

:root[data-theme="beige"] .party-pick-title {
  font-family: var(--font-body);
}

/* Netrunner: a terminal readout, the pick printed after a prompt with a blinking cursor. */
:root[data-theme="hacker"] .party-pick-result.is-shown {
  background: repeating-linear-gradient(0deg, rgb(var(--accent-rgb) / .05) 0 1px, transparent 1px 3px), var(--surface-page);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

:root[data-theme="hacker"] .party-pick-label::before {
  content: ">";
  width: auto;
  height: auto;
  background: none;
  transform: none;
}

:root[data-theme="hacker"] .party-pick-title {
  color: var(--accent);
  text-shadow: var(--glow-text);
}

:root[data-theme="hacker"] .party-pick-title::after {
  content: "_";
  animation: coop-cursor 1s steps(1) infinite;
}

/* Co-op lobby on phones */
@media (max-width: 767px) {
  .columns-container {
    grid-template-columns: 1fr;
  }

  .lobby-column {
    max-height: none;
  }

  /* Compact two-column friend rows */
  .friend-checkboxes {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }

  .friend-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0 var(--space-1);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
    text-align: left;
  }

  .friend-card-select {
    flex-direction: row;
    gap: var(--space-2);
  }

  .friend-card-avatar,
  .add-friend-icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
  }

  .friend-card-status {
    grid-column: 1;
    padding-left: 0;
  }

  .friend-card-remove {
    position: static;
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .add-friend-btn {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
  }

  .roster-slots {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .roster-slot {
    flex: 0 0 auto;
  }

  .coop-filter {
    flex: 1 1 calc(50% - var(--space-4));
  }

  .coop-filter .native-select {
    width: 100%;
  }

  .game-strip-actions {
    margin-left: 0;
  }

  .filter-actions {
    width: 100%;
    margin-left: 0;
  }

  .filter-actions .btn-primary {
    width: 100%;
  }

  .party-pick-roll {
    width: 100%;
  }

  .party-pick-result.is-shown {
    flex-direction: column;
    align-items: stretch;
  }

  .party-pick-banner {
    width: 100%;
  }
}

/* ==========================================================================
   Co-op lobby: the search overlay (matrix_controller.js)
   Every search plays a sequence of about 2.2 s (SEQUENCE_MS), and its last frame holds until the
   results come. The scene is aria-hidden and the plain "Comparing libraries…" heads it. Each theme
   shows only its own parts, and no part crosses text. The lobby behind is inert while it shows.
   ========================================================================== */
.matrix-overlay {
  position: absolute;
  inset: 0;
  z-index: var(--z-raised);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-12) var(--space-4) 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border-radius: inherit;
  cursor: pointer;
}

.matrix-overlay:not([hidden]) {
  display: flex;
}

/* Kept in view near the top, below the sticky header. */
.matrix-terminal {
  position: sticky;
  top: calc(var(--space-12) * 2);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: min(100%, 560px);
  padding: var(--space-6);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glow);
}

.matrix-header {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.matrix-status {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
}

.matrix-scene {
  display: grid;
  justify-items: center;
  align-items: center;
}

.matrix-party {
  margin: 0;
  padding: 0;
  list-style: none;
}

.matrix-node {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.matrix-avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.matrix-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-command,
.matrix-typed,
.matrix-progress,
.matrix-cabinet-label {
  display: none;
}

.matrix-count {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-2);
  animation: matrix-fade .3s ease-out .9s both;
}

.matrix-count .flavour {
  display: inline;
  font-size: var(--text-sm);
  text-transform: uppercase;
}

.matrix-count-value {
  order: -1;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.matrix-skip {
  color: var(--text-secondary);
  text-align: right;
}

@keyframes matrix-fade {
  from { opacity: 0; }
}

@keyframes matrix-type {
  from { width: 0; }
}

/* Goshboard OS: a holographic scan. The party's diamond nodes light beams in to the library core one
   after another, a ring sweeps round the core, and the counter ticks up under it. */
:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-scene > * {
  grid-area: 1 / 1;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-party {
  position: relative;
  width: 260px;
  height: 230px;
}

/* Each friend is an arm from the centre, turned to its place on the circle. */
:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-member {
  --angle: calc(var(--i) / var(--party) * 1turn - .25turn);
  position: absolute;
  top: 50%;
  left: 50%;
  width: 92px;
  rotate: var(--angle);
  transform-origin: 0 0;
}

/* The beam, drawn from the node in to the core, then pulsing. Opacity and scale only, so the
   compositor runs it without repainting under the overlay's blur. */
:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-member::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 46px;
  right: 22px;
  height: 2px;
  background: linear-gradient(90deg, rgb(var(--accent-rgb) / .35), var(--accent));
  scale: 0 1;
  transform-origin: right center;
  animation:
    matrix-beam .4s ease-out calc(.35s + var(--i) * .12s) forwards,
    matrix-beam-pulse .9s linear calc(.75s + var(--i) * .12s) infinite;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-node {
  position: absolute;
  top: -22px;
  right: -22px;
  width: 44px;
  height: 44px;
  color: var(--on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  background: var(--gradient-primary);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  rotate: calc(-1 * var(--angle));
  animation: matrix-node-in .3s ease-out calc(.15s + var(--i) * .12s) both;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-avatar {
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-name {
  display: none;
}

/* The core: a diamond that charges up, inside a ring sweeping round. */
:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-core {
  position: relative;
  width: 52px;
  height: 52px;
  background:
    radial-gradient(circle, rgb(255 255 255 / .8) 0 3px, transparent 4px),
    linear-gradient(135deg, rgb(var(--accent-rgb) / .25), rgb(var(--accent-rgb) / .6));
  border: 2px solid var(--accent);
  rotate: 45deg;
  box-shadow: var(--shadow-glow);
  animation: matrix-core-charge 2.2s ease-in both;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-core::before {
  content: "";
  position: absolute;
  inset: -22px;
  border: 2px solid rgb(var(--accent-rgb) / .15);
  border-top-color: var(--accent);
  border-right-color: rgb(var(--accent-rgb) / .5);
  border-radius: 50%;
  animation: matrix-sweep 1.1s linear infinite;
}

:root:not([data-theme="beige"]):not([data-theme="hacker"]) .matrix-count {
  grid-area: auto;
  margin-top: var(--space-2);
}

@keyframes matrix-beam {
  to { scale: 1 1; }
}

@keyframes matrix-beam-pulse {
  50% { opacity: .4; }
}

@keyframes matrix-node-in {
  from { opacity: 0; scale: .3; }
}

@keyframes matrix-sweep {
  to { rotate: 1turn; }
}

@keyframes matrix-core-charge {
  from { opacity: .4; scale: .7; }
  70% { opacity: 1; scale: 1; }
  80% { scale: 1.15; }
}

/* Retro Desk: an office search. An index card per friend comes up out of the filing cabinet, each gets
   a MATCH stamp, and "Cross-referencing files…" types out underneath. Soft paper shadows only. */
:root[data-theme="beige"] .matrix-overlay {
  background: var(--scrim-paper);
}

:root[data-theme="beige"] .matrix-terminal {
  background: var(--surface-card);
  border: 2px solid var(--surface-header);
  box-shadow: var(--shadow-card);
}

:root[data-theme="beige"] .matrix-header {
  border-bottom: 1px dashed var(--surface-header);
}

:root[data-theme="beige"] .matrix-status {
  font-family: var(--font-body);
}

:root[data-theme="beige"] .matrix-scene {
  gap: var(--space-3);
}

:root[data-theme="beige"] .matrix-party {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3) var(--space-2);
  max-width: 100%;
}

/* The cards rise from behind the drawer front, so they come out of the cabinet. */
:root[data-theme="beige"] .matrix-member {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  width: 76px;
  padding: var(--space-2) var(--space-1) var(--space-1);
  background:
    linear-gradient(var(--index-margin), var(--index-margin)) 0 6px / 100% 1px no-repeat,
    var(--surface-raised);
  border: 1px solid var(--border-subtle);
  filter: var(--paper-drop);
  rotate: -2deg;
  animation: matrix-card-up .4s cubic-bezier(.2, .8, .3, 1) calc(.2s + var(--i) * .15s) both;
}

:root[data-theme="beige"] .matrix-member:nth-child(even) {
  rotate: 2deg;
}

/* The MATCH stamp lands on the photo's corner, clear of the name. */
:root[data-theme="beige"] .matrix-member::after {
  content: "MATCH";
  position: absolute;
  top: 10px;
  right: 2px;
  padding: 0 3px;
  color: var(--stamp-red);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  background: var(--surface-raised);
  border: 2px solid var(--stamp-red);
  rotate: -14deg;
  animation: matrix-stamp .25s cubic-bezier(.2, 1.6, .4, 1) calc(1.15s + var(--i) * .1s) both;
}

:root[data-theme="beige"] .matrix-node {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 700;
  background: var(--surface-inset);
  border: 3px solid var(--polaroid);
}

:root[data-theme="beige"] .matrix-name {
  max-width: 100%;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
}

/* The drawer front, with its label holder and handle. */
:root[data-theme="beige"] .matrix-core {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: min(100%, 280px);
  margin-top: calc(-1 * var(--space-2));
  padding: var(--space-2) 0 var(--space-3);
  background: var(--cabinet-front);
  border: 3px outset;
  border-color: var(--bevel-light) var(--cabinet-edge) var(--cabinet-edge) var(--bevel-light);
  filter: var(--paper-drop);
  animation: matrix-drawer .3s ease-out both;
}

:root[data-theme="beige"] .matrix-cabinet-label {
  display: block;
  padding: 0 var(--space-3);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--surface-raised);
  border: 1px solid var(--cabinet-edge);
}

:root[data-theme="beige"] .matrix-core::after {
  content: "";
  width: 56px;
  height: 8px;
  background: var(--clipboard-clip);
  border: 1px solid var(--cabinet-edge);
}

/* 24 steps, one per character of "Cross-referencing files…" (the co-op lobby test checks it). */
:root[data-theme="beige"] .matrix-typed {
  display: block;
  width: 24ch;
  max-width: 100%;
  overflow: hidden;
  color: var(--text-primary);
  font-family: var(--font-body);
  white-space: nowrap;
  animation: matrix-type 1.2s steps(24) .4s both;
}

:root[data-theme="beige"] .matrix-count {
  color: var(--text-primary);
  font-family: var(--font-body);
  animation-delay: 1.3s;
}

:root[data-theme="beige"] .matrix-count .flavour {
  color: var(--text-primary);
  font-weight: 700;
  text-transform: none;
}

:root[data-theme="beige"] .matrix-count-value {
  order: 0;
  color: var(--stamp-red);
  font-family: var(--font-body);
}

@keyframes matrix-card-up {
  from { opacity: 0; translate: 0 48px; }
}

@keyframes matrix-stamp {
  from { opacity: 0; scale: 2.2; }
}

@keyframes matrix-drawer {
  from { translate: 0 10px; }
}

/* Netrunner: a terminal session. The diff command types out, a line per friend prints, a progress
   bar fills and MATCHES appears with a cursor, all over faint scanlines. */
:root[data-theme="hacker"] .matrix-terminal {
  background:
    repeating-linear-gradient(0deg, rgb(var(--accent-rgb) / .06) 0 1px, transparent 1px 3px),
    var(--surface-page);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-pop);
}

:root[data-theme="hacker"] .matrix-status {
  color: var(--accent);
  text-shadow: var(--glow-text);
}

:root[data-theme="hacker"] .matrix-scene {
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
  align-content: start;
  gap: var(--space-1);
  min-height: 200px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-shadow: var(--glow-text);
}

/* --chars, set with the command, gives one step per character. */
:root[data-theme="hacker"] .matrix-command {
  display: block;
  width: calc(var(--chars) * 1ch);
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  animation: matrix-type .6s steps(var(--chars)) .1s both;
}

:root[data-theme="hacker"] .matrix-party {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

:root[data-theme="hacker"] .matrix-member {
  display: flex;
  gap: 1ch;
  color: var(--text-primary);
  animation: matrix-fade .01s steps(1) calc(.75s + var(--i) * .1s) both;
}

:root[data-theme="hacker"] .matrix-member::before {
  content: "  fetch";
  white-space: pre;
}

:root[data-theme="hacker"] .matrix-name {
  flex: 1 1 auto;
}

:root[data-theme="hacker"] .matrix-member::after {
  content: "[OK]";
  color: var(--accent);
}

:root[data-theme="hacker"] .matrix-node,
:root[data-theme="hacker"] .matrix-core {
  display: none;
}

:root[data-theme="hacker"] .matrix-progress {
  display: block;
  height: 14px;
  margin-top: var(--space-2);
  padding: 2px;
  border: 1px solid var(--accent);
  animation: matrix-fade .01s steps(1) .8s both;
}

:root[data-theme="hacker"] .matrix-progress-fill {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--accent) 0 8px, transparent 8px 10px);
  animation: matrix-fill 1.1s steps(20) .8s both;
}

:root[data-theme="hacker"] .matrix-count {
  justify-content: flex-start;
  margin-top: var(--space-2);
  animation-delay: 1s;
}

:root[data-theme="hacker"] .matrix-count .flavour {
  color: var(--accent);
  font-family: var(--font-mono);
}

:root[data-theme="hacker"] .matrix-count-value {
  order: 0;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
}

:root[data-theme="hacker"] .matrix-count::after {
  content: "_";
  animation: coop-cursor 1s steps(1) infinite;
}

@keyframes matrix-fill {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0); }
}

/* The search overlay on phones */
@media (max-width: 767px) {
  .matrix-overlay {
    padding: var(--space-6) var(--space-2) 0;
  }

  .matrix-terminal {
    padding: var(--space-4);
  }

  :root[data-theme="hacker"] .matrix-scene {
    font-size: var(--text-xs);
  }
}
