/* GRID0+ dashboard.
 *
 * The look borrows Splatoon's: flat blocks of vivid ink on near-black, chunky
 * type, hard edges. That is not decoration for its own sake -- this is the one
 * surface in GRID0+ a person looks at, and the operator should be able to
 * tell at a glance who is online and whether a fest is running.
 *
 * Two colours carry meaning and are used for nothing else:
 *   --ink-a (pink)  a player who is IN GAME
 *   --ink-b (green) a player who is ONLINE
 * Everything decorative stays grey, so a splash of colour always means someone
 * is actually there.
 */

:root {
  --bg:        #0e0e12;
  --bg-raised: #17171d;
  --bg-sunk:   #101014;
  --line:      #26262f;

  --fg:        #f2f2f5;
  --fg-dim:    #9a9aa8;
  --fg-faint:  #5e5e6d;

  --ink-a:     #f5407e;  /* in game */
  --ink-b:     #57e64b;  /* online  */
  --ink-c:     #38b6ff;  /* accent  */
  --warn:      #ffb340;

  --radius: 14px;
  --pad: clamp(16px, 3vw, 28px);

  color-scheme: dark;
}

/* The dashboard is dark by design rather than by preference -- it sits on a
 * screen in a room, often next to the console it is reporting on. A light
 * variant is still honoured for anyone who needs it, either by the OS
 * preference below or by the explicit toggle in the header, which stamps
 * data-theme="light"/"dark" on the root and wins over the OS either way. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:        #f6f6f9;
    --bg-raised: #ffffff;
    --bg-sunk:   #eeeef3;
    --line:      #dcdce5;
    --fg:        #16161c;
    --fg-dim:    #55555f;
    --fg-faint:  #8a8a97;
    color-scheme: light;
  }
  /* The ink wash is built for a dark ground. At the same opacity on a light
   * one it reads as a smudge rather than atmosphere, so it is pulled right
   * back -- the colour still has to MEAN something in the stats and badges,
   * and a tinted background steals from that. */
  :root:not([data-theme="dark"]) .blob { opacity: .07; }
}

/* The explicit toggle. Same values as the media query above, just reachable
 * regardless of what the OS says -- an operator whose OS is dark but who
 * wants this one page light (or the reverse) is not a hypothetical, it is
 * the whole reason the button exists rather than deferring to the media
 * query alone. */
:root[data-theme="light"] {
  --bg:        #f6f6f9;
  --bg-raised: #ffffff;
  --bg-sunk:   #eeeef3;
  --line:      #dcdce5;
  --fg:        #16161c;
  --fg-dim:    #55555f;
  --fg-faint:  #8a8a97;
  color-scheme: light;
}
:root[data-theme="light"] .blob { opacity: .07; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---- ink background ---------------------------------------------------- */

.ink-field {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.blob {
  position: absolute;
  border-radius: 45% 55% 62% 38% / 52% 44% 56% 48%;
  filter: blur(70px);
  opacity: .16;
  animation: drift 26s ease-in-out infinite;
}
.b1 { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: var(--ink-a); }
.b2 { width: 38vmax; height: 38vmax; right: -10vmax; top: 18vmax; background: var(--ink-c); animation-delay: -9s; }
.b3 { width: 30vmax; height: 30vmax; left: 34vmax; bottom: -14vmax; background: var(--ink-b); animation-delay: -17s; }

@keyframes drift {
  0%, 100% { transform: translate3d(0,0,0) rotate(0deg) scale(1); }
  50%      { transform: translate3d(3vmax,-2vmax,0) rotate(140deg) scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  * { transition: none !important; }
}

header, nav, main { position: relative; z-index: 1; }

/* ---- login --------------------------------------------------------------
 * The one page that is not part of the tabbed dashboard -- a centred card
 * rather than the header/tabs/main shell, since there is nothing to show
 * until the token is accepted. */

.login-body { display: flex; min-height: 100vh; }
.login-main {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: var(--pad);
}
.login-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 6px;
  padding: 32px 28px;
}
.login-mark { width: 44px; height: 44px; margin-bottom: 6px; }
.login-card h1 { font-size: 24px; }
.login-error {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 9px;
  background: color-mix(in srgb, var(--ink-a) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink-a) 34%, transparent);
  color: var(--ink-a); font-size: 13px; font-weight: 600;
}
.login-field {
  width: 100%; display: flex; flex-direction: column; gap: 6px;
  text-align: left; margin-top: 18px; font-size: 13px; font-weight: 600;
}
.login-field input {
  width: 100%; padding: 10px 12px; font-size: 15px;
  background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: 9px; color: var(--fg); font: inherit;
}
.login-field input:focus-visible { outline: 2px solid var(--ink-c); outline-offset: 1px; }
.login-submit { width: 100%; margin-top: 16px; }
.login-note { margin: 18px 0 0; color: var(--fg-faint); font-size: 12px; line-height: 1.5; }

.logout-form { display: contents; }

/* ---- header ------------------------------------------------------------ */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: var(--pad) var(--pad) 0;
  max-width: 1180px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  filter: drop-shadow(0 2px 10px color-mix(in srgb, var(--ink-a) 35%, transparent));
}
.brand-eye { fill: var(--bg); }
h1 {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 30px);
  letter-spacing: -0.02em;
  font-weight: 800;
}
.sub { margin: 2px 0 0; color: var(--fg-dim); font-size: 13px; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--fg-dim);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--fg); border-color: color-mix(in srgb, var(--ink-c) 40%, var(--line)); }
.theme-toggle:focus-visible { outline: 2px solid var(--ink-c); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.theme-toggle .icon-sun circle { fill: currentColor; stroke: none; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
/* Both icons live in the button; only one shows, and it shows what the page
 * currently IS rather than what clicking would switch to -- a moon while
 * dark, a sun while light. Dark is the default, so the sun stays hidden
 * until something actually makes the page light. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: inline; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 13px;
  color: var(--fg-dim);
  white-space: nowrap;
}
.live .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg-faint);
}
.live[data-state="live"]  { color: var(--ink-b); border-color: color-mix(in srgb, var(--ink-b) 40%, var(--line)); }
.live[data-state="live"]  .dot { background: var(--ink-b); animation: pulse 2s ease-in-out infinite; }
.live[data-state="down"]  { color: var(--warn); }
.live[data-state="down"]  .dot { background: var(--warn); }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ink-b) 60%, transparent); }
  70%     { box-shadow: 0 0 0 7px transparent; }
}

/* ---- tabs -------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 18px var(--pad) 0;
  max-width: 1180px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--ink-a);
}
.tabs button:focus-visible { outline: 2px solid var(--ink-c); outline-offset: 2px; }
/* A phone gets a row that scrolls sideways, not tab labels broken over two
 * lines. */
.tabs { overflow-x: auto; scrollbar-width: thin; }
.tabs button { white-space: nowrap; flex: none; padding: 10px 11px; }
.tabs button[hidden] { display: none; }
/* Pushes the tabs every game shares (Players, Health, Debug) to the right,
 * so which tabs change with the game is visible at a glance. */
.tabs-gap { flex: 1 0 12px; }

/* ---- game switch ------------------------------------------------------- */

.game-bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px var(--pad) 0;
}
.game-switch {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-sunk);
}
.game-switch button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 7px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--fg-dim);
  background: transparent;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.game-switch button:hover { color: var(--fg); }
/* Not pink or green: those mean "in game" and "online" and nothing else. */
.game-switch button[aria-checked="true"] {
  color: var(--bg);
  background: var(--fg);
}
.game-switch button:focus-visible { outline: 2px solid var(--ink-c); outline-offset: 2px; }

/* A Splatoon 2 view with the NEX server not connected shows the one
 * explanation above it instead of its own empty lists. */
.view.is-active.is-gated { display: none; }

.s2-vote-bar {
  height: 8px;
  border-radius: 999px;
  margin: 10px 0;
  background: var(--fg-faint);
  overflow: hidden;
}
.s2-vote-bar span { display: block; height: 100%; background: var(--ink-c); }
tr.is-hidden td { color: var(--fg-faint); }

/* ---- layout ------------------------------------------------------------ */

main { max-width: 1180px; margin: 0 auto; padding: var(--pad); }
.view { display: none; }
.view.is-active { display: block; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--fg-dim);
  font-weight: 700;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin-bottom: 0; }
.panel-note p { color: var(--fg-dim); font-size: 14px; margin: 0 0 10px; }
.panel-note p:last-child { margin-bottom: 0; }

/* ---- stats ------------------------------------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color .15s, transform .15s;
}
.stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--fg) 18%, var(--line)); }
/* A thin top accent per metric, so the row reads by colour before the eye
 * gets to the number -- the same "colour means something" rule the badges
 * and pips follow, just stretched into a stripe. */
.stat::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--line);
}
.stat-online::before  { background: var(--ink-b); }
.stat-playing::before { background: var(--ink-a); }
.stat-accounts::before { background: var(--ink-c); }
.stat-icon {
  width: 18px; height: 18px;
  margin-bottom: 8px;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  color: var(--fg-faint);
}
.stat-online .stat-icon  { color: var(--ink-b); fill: currentColor; stroke: none; }
.stat-playing .stat-icon { color: var(--ink-a); fill: currentColor; }
.stat-accounts .stat-icon { color: var(--ink-c); }
.stat-value {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
#stat-online  { color: var(--ink-b); }
#stat-playing { color: var(--ink-a); }
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-dim);
  font-weight: 600;
}
.stat-queue .stat-value { color: var(--fg-faint); }
.stat-note { font-size: 11px; color: var(--fg-faint); margin-top: 2px; }

/* ---- avatars -------------------------------------------------------------
 *
 * A deterministic colour per user id (hashed in dashboard.js, not chosen) so
 * the same player is always the same colour across a session -- a small
 * thing, but it is what turns "a row of names" into "a room full of people"
 * at a glance. Pink and green stay reserved for state, so avatar hues avoid
 * that band -- see hueForID in dashboard.js. */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 11px; font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.avatar-sm { width: 20px; height: 20px; font-size: 9.5px; }

.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.avatar-status {
  position: absolute; right: -1px; bottom: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-sunk);
}
.avatar-status.playing { background: var(--ink-a); }
.avatar-status.online  { background: var(--ink-b); }
.avatar-status.offline { background: var(--fg-faint); }
/* The table's avatars sit on --bg-raised, not --bg-sunk -- the ring has to
 * match whatever is actually behind it or it reads as a grey halo. */
.grid .avatar-status { border-color: var(--bg-raised); }

/* ---- player strip ------------------------------------------------------ */

.player-strip { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.player-strip li {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  font-size: 14px;
  transition: border-color .15s, transform .15s;
}
.player-strip li:hover { border-color: color-mix(in srgb, var(--fg) 22%, var(--line)); transform: translateY(-1px); }
.player-strip .pip { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pip.playing { background: var(--ink-a); }
.pip.online  { background: var(--ink-b); }
.pip.offline { background: var(--fg-faint); }
.player-strip .what { color: var(--fg-dim); font-size: 12px; }

/* ---- table ------------------------------------------------------------- */

.player-cell { display: inline-flex; align-items: center; gap: 9px; }

.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-faint);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.grid td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { transition: background .12s; }
.grid tbody tr:hover { background: var(--bg-sunk); }
.grid tr.just-changed { animation: flash 1.1s ease-out; }
@keyframes flash {
  from { background: color-mix(in srgb, var(--ink-c) 22%, transparent); }
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid transparent;
}
.badge.playing { color: var(--ink-a); background: color-mix(in srgb, var(--ink-a) 14%, transparent); border-color: color-mix(in srgb, var(--ink-a) 34%, transparent); }
.badge.online  { color: var(--ink-b); background: color-mix(in srgb, var(--ink-b) 14%, transparent); border-color: color-mix(in srgb, var(--ink-b) 34%, transparent); }
.badge.offline { color: var(--fg-faint); background: var(--bg-sunk); border-color: var(--line); }

input[type="search"], input[type="text"], input[type="datetime-local"],
.fest-form input[type="number"], .fest-form select {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--fg);
  font: inherit;
  padding: 8px 12px;
  min-width: 0;
}
input:focus-visible { outline: 2px solid var(--ink-c); outline-offset: 1px; }

/* ---- fests ------------------------------------------------------------- */

.fest-banner {
  border-radius: 12px;
  padding: 18px 20px;
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--ink-a) 20%, var(--bg-sunk)),
    color-mix(in srgb, var(--ink-c) 20%, var(--bg-sunk)));
  border: 1px solid var(--line);
}
.fest-banner.is-empty { background: var(--bg-sunk); }
.fest-banner .fid { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.fest-banner .meta { color: var(--fg-dim); font-size: 13px; margin-top: 4px; }

.phase-track { display: flex; gap: 4px; margin-top: 14px; }
.phase-track span {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
}
.phase-track span.done { background: color-mix(in srgb, var(--ink-a) 55%, transparent); }
.phase-track span.now  { background: var(--ink-a); }
.phase-names { display: flex; gap: 4px; margin-top: 6px; }
.phase-names span { flex: 1; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); }
.phase-names span.now { color: var(--ink-a); font-weight: 700; }

.fest-form { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.fest-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.fest-form label > span em { color: var(--fg-faint); font-style: normal; font-weight: 400; }
.fest-form small { font-weight: 400; color: var(--fg-faint); font-size: 12px; line-height: 1.45; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
#s2-methods { margin: 10px 0 14px; }
.chips label {
  flex-direction: row; align-items: center; gap: 6px;
  background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
}
.inline { flex-direction: row !important; align-items: center; gap: 8px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-sunk);
  color: var(--fg); font: inherit; font-weight: 700;
  padding: 9px 18px; border-radius: 10px; cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink-a); border-color: var(--ink-a); color: #fff; }
.btn-ghost { padding: 6px 12px; font-size: 13px; font-weight: 600; }
.btn-danger:hover { color: var(--ink-a); border-color: var(--ink-a); }
.btn:focus-visible { outline: 2px solid var(--ink-c); outline-offset: 2px; }

.form-error {
  grid-column: 1 / -1;
  margin: 0; padding: 10px 14px;
  background: color-mix(in srgb, var(--ink-a) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink-a) 40%, transparent);
  border-radius: 9px;
  color: var(--fg);
  font-size: 13px;
}

.fest-list { display: flex; flex-direction: column; gap: 10px; }
.coop-weapon-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.fest-card {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color .15s, background .15s;
}
.fest-card:hover { border-color: color-mix(in srgb, var(--fg) 22%, var(--line)); background: color-mix(in srgb, var(--bg-raised) 55%, var(--bg-sunk)); }
.fest-card.live { border-color: color-mix(in srgb, var(--ink-a) 50%, var(--line)); }
.fest-card .fid { font-weight: 800; letter-spacing: -0.01em; }
.fest-card .cols { flex: 1; min-width: 200px; }
.fest-card .meta { color: var(--fg-dim); font-size: 12px; margin-top: 3px; word-break: break-all; }
.fest-card .actions { display: flex; gap: 8px; margin-left: auto; }
.pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--fg-dim);
}
.pill.on { color: var(--ink-b); border-color: color-mix(in srgb, var(--ink-b) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

.empty { color: var(--fg-faint); font-size: 14px; margin: 6px 0 0; }

@media (max-width: 620px) {
  .grid thead { display: none; }
  .grid td { display: block; padding: 4px 10px; border: 0; }
  .grid tbody tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .top { flex-direction: column; align-items: flex-start; }
}

/* ---- matchmaking ---------------------------------------------------------
 *
 * Reuses the fest-card shape: same sunk panel, same pill vocabulary, so the two
 * control surfaces read as one page rather than as two features bolted together.
 *
 * The one colour decision worth naming: a mode that is SHORT of a full match
 * gets --warn, not --ink-a or --ink-b. Pink and green mean a player is in game
 * or online and are used for nothing else on this page; a queue that will not
 * fill is neither of those, it is a thing needing the operator's attention. */
.mm-mode, .mm-session {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color .15s, background .15s;
}
.mm-mode:hover, .mm-session:hover { border-color: color-mix(in srgb, var(--fg) 22%, var(--line)); background: color-mix(in srgb, var(--bg-raised) 55%, var(--bg-sunk)); }
.mm-mode > .cols, .mm-session > .cols { display: inline-block; vertical-align: top; }
.mm-mode { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.mm-mode .cols { flex: 1; min-width: 200px; }
.mm-mode .fid, .mm-session .fid {
  font-weight: 800; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mm-mode .meta, .mm-session .meta {
  color: var(--fg-dim); font-size: 12px; margin-top: 3px;
}
.mm-mode .actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }

.mm-size { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-dim); }
.mm-size input {
  width: 62px; text-align: center;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px;
  color: var(--fg); padding: 6px 8px; font: inherit; font-size: 13px;
}

/* The waiting tickets sit under their mode rather than in a table of their own:
 * a ticket only means anything next to the queue it is in. */
.mm-tickets { list-style: none; margin: 12px 0 0; padding: 12px 0 0; width: 100%;
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.mm-tickets li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.mm-tickets .what { color: var(--fg-dim); font-size: 12px; }
.mm-tickets .btn { margin-left: auto; }

.btn-tiny { padding: 4px 10px; font-size: 12px; }

.note { color: var(--fg-dim); font-size: 13px; margin: 10px 0 0; }
.note code {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 12px;
}

/* ---- service health ------------------------------------------------------
 *
 * Same card as the matchmaking panel. The left border is the whole signal, so
 * a column of services reads at a glance without any text being parsed: green
 * up, amber degraded, pink down, plain grey for "not probed" — which is a
 * deliberate absence of colour, because it is not a state anyone should act on. */
.svc {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: border-color .15s, background .15s;
}
.svc:hover { background: color-mix(in srgb, var(--bg-raised) 55%, var(--bg-sunk)); }
.svc .fid {
  font-weight: 800; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.svc .meta { color: var(--fg-dim); font-size: 12px; margin-top: 3px; }
.svc-detail { color: var(--warn); word-break: break-word; }

.svc-ok       { border-left-color: var(--ink-b); }
.svc-degraded { border-left-color: var(--warn); }
.svc-down     { border-left-color: var(--ink-a); }
.svc-unknown  { border-left-color: var(--line); }

/* ---- player detail --------------------------------------------------------
 *
 * Every row in the Players table opens this: friends, device accounts and
 * recent matches assembled from stores that already exist rather than a new
 * history log -- see internal/dashboard/server.go's handlePlayerDetail. */

#players-table tbody tr { cursor: pointer; }

.player-detail {
  width: min(640px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  padding: 22px 24px;
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.player-detail::backdrop { background: rgba(0, 0, 0, .55); }
/* The dialog only ever animates open -- <dialog> has no closing transition
 * without extra JS to delay the close() call, and that complexity buys
 * nothing an operator would notice on a control panel. */
.player-detail[open] { animation: rise .18s ease-out; }

.dialog-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  appearance: none; border: 1px solid var(--line); background: var(--bg-sunk);
  color: var(--fg-dim); border-radius: 50%; font-size: 18px; line-height: 1;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.dialog-close:hover { color: var(--fg); border-color: color-mix(in srgb, var(--fg) 22%, var(--line)); }

.player-detail-head {
  display: flex; align-items: center; gap: 14px;
  padding-right: 30px; /* clears the close button */
  margin-bottom: 18px;
}
.player-detail-head .avatar { width: 44px; height: 44px; font-size: 16px; }
.player-detail-head h3 { margin: 0 0 4px; font-size: 18px; }
.player-detail-head .meta { color: var(--fg-dim); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.player-detail-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.player-detail-cols h4 {
  margin: 0 0 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--fg-faint);
  display: flex; align-items: center; gap: 6px;
}
.player-detail-cols h4 .meta { font-weight: 600; text-transform: none; letter-spacing: normal; }

.player-detail-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 220px; overflow-y: auto;
}
.player-detail-list li {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.player-detail-list li .meta { color: var(--fg-dim); font-size: 12px; margin-left: auto; }
.player-detail-list li code {
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 12px;
}
.player-detail-list .empty { margin: 0; }

@media (max-width: 480px) {
  .player-detail-cols { grid-template-columns: 1fr; }
}
.svc-unknown .svc-detail { color: var(--fg-dim); }

/* ---- debug -----------------------------------------------------------
 *
 * Deliberately plainer than the rest of the page: no gradient banner, no
 * avatar colours. This tab edits rows directly, and looking like every
 * other panel is how a destructive control ends up clicked as casually as
 * the Hold button on a fest. */

.debug-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.debug-stat {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.debug-stat-value {
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.debug-stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--fg-dim); font-weight: 600;
}

.debug-lookup { display: flex; gap: 8px; margin-bottom: 4px; }
.debug-lookup input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; }

.debug-account-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.debug-account-head h3 { margin: 0 0 4px; font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.debug-account-head h3 code {
  font-size: 12px; font-weight: 600; color: var(--fg-dim);
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}

.debug-presence-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.debug-device-list li { flex-wrap: wrap; }
.debug-device-list li .meta { margin-left: 0; }
.debug-device-list li .actions { display: flex; gap: 6px; margin-left: auto; }

@media (max-width: 480px) {
  .debug-presence-cols { grid-template-columns: 1fr; }
}

/* ---- live table browser -------------------------------------------------- */

.debug-tables-controls { display: flex; align-items: center; gap: 10px; }
.debug-tables-controls select {
  background: var(--bg-sunk); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; font-size: 13px; font-family: inherit;
}
.debug-live-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--fg-dim); user-select: none; cursor: pointer;
}
.debug-live-toggle input { accent-color: var(--ink-a); }

.debug-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 10px;
}
.debug-table-grid { font-size: 13px; white-space: nowrap; }
.debug-table-grid th, .debug-table-grid td { border-right: 1px solid var(--line); }
.debug-table-grid th:last-child, .debug-table-grid td:last-child { border-right: 0; }
.debug-table-grid td { padding: 0; }

.debug-cell {
  display: block;
  width: 100%;
  min-width: 90px;
  max-width: 320px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg);
  font: inherit;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  border-radius: 0;
  resize: none;
}
.debug-cell:hover { border-color: var(--line); }
.debug-cell:focus {
  outline: none;
  border-color: var(--ink-a);
  background: var(--bg-sunk);
  box-shadow: inset 0 0 0 1px var(--ink-a);
}
.debug-cell.readonly {
  color: var(--fg-faint);
  cursor: default;
  background: var(--bg-sunk);
}
.debug-cell.dirty { border-color: var(--warn); }
.debug-cell.save-error { border-color: var(--ink-a); }
.debug-cell-bool { padding: 8px 10px; display: flex; justify-content: center; }
.debug-cell-bool input { accent-color: var(--ink-a); }

.debug-table-grid tbody tr.just-changed td { animation: flash 1.1s ease-out; }

/* The delivery cache's revision, which is 40 hex characters and unreadable in
   the body face. */
.meta.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--fg-faint);
  word-break: break-all;
}

.grid.compact td, .grid.compact th { padding: 6px 10px; }

/* A service on an older build: amber, because it is working now and will stop
 * the next time the config moves on without it. */
.banner-warn {
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-size: 13px;
}
