/* Turbo Hockey admin. Dark blue with a little gold. One theme, colours as tokens.
   No outside font, script or image: the page's CSP allows none. */
:root {
  color-scheme: dark;
  --page: #081226;
  --surface: #0f1d3a;
  --surface-2: #162a50;
  --surface-3: #1d3563;
  --line: rgba(151, 180, 255, 0.16);
  --line-2: rgba(151, 180, 255, 0.36);
  --ink: #eef3fc;
  --ink-2: #b9c6de;
  --muted: #8b9cbd;
  --gold: #e6b84d;
  --gold-2: #f2cc6f;
  --gold-ink: #1b1403;
  /* The server's states. Each also has its own word and its own dot shape. */
  --good: #46d39a;
  --moving: #6cb6ff;
  --off: #93a4c6;
  --bad: #ff8f85;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 18px; font-weight: 650; letter-spacing: 0.01em; }
h3 { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }

/* ---------------------------------------------------------------- controls */
button {
  min-height: 40px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--surface-3); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
button.primary:hover:not(:disabled) { background: var(--gold-2); }
button.danger { border-color: var(--bad); }
button.link {
  min-height: 0;
  padding: 2px 4px;
  font-weight: 400;
  color: var(--gold);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.link:hover:not(:disabled) { background: none; color: var(--gold-2); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button.primary:focus-visible { outline-color: var(--ink); }

/* Keep awake: pressed or not. The word On or Off says it too, not the colour alone. */
.toggle { display: inline-flex; align-items: center; gap: 10px; }
.toggle-word {
  min-width: 40px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.toggle[aria-pressed="true"] { border-color: var(--gold); }
.toggle[aria-pressed="true"] .toggle-word { color: var(--gold-ink); background: var(--gold); border-color: transparent; }

input[type="number"] {
  width: 5.5em;
  min-height: 40px;
  padding: 6px 8px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--line-2);
  border-radius: 8px;
}
input[data-edited] { border-color: var(--gold); }
.unsaved { font-size: 13px; color: var(--gold); }

/* ------------------------------------------------------------------ header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* A gold puck, drawn. */
.mark { flex: none; width: 22px; height: 11px; margin-bottom: 3px; border-radius: 50%; background: var(--gold); box-shadow: 0 3px 0 #a67c1d; }
.badge {
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.badge.preview { color: var(--gold); border-color: var(--gold); }
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--ink-2); }
.who { overflow-wrap: anywhere; }

/* The line that says the API can't be reached. It stays in the page while empty, so a
   screen reader hears it when it fills. */
.status { padding: 0 24px; font-size: 14px; color: #ffe2a1; }
.status:not(:empty) { padding: 9px 24px; background: #33260a; border-bottom: 1px solid var(--gold); }

/* -------------------------------------------------------------------- page */
main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 40px; }

.gate { max-width: 460px; margin: 12vh auto 0; text-align: center; }
.gate h2 { font-size: 22px; font-weight: 650; }
.gate h2:focus { outline: none; }
.gate p { margin: 8px 0 18px; color: var(--ink-2); overflow-wrap: anywhere; }

.board { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.card {
  min-width: 0;
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.card.log { grid-column: 1 / -1; }
.card > h2 {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.about { margin-bottom: 8px; font-size: 13px; color: var(--muted); }

/* What a button press did, or a refusal. It keeps its line while empty, so nothing jumps. */
.note { min-height: 1.5em; margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.note[data-kind="error"]:not(:empty) { padding-left: 10px; color: var(--bad); border-left: 3px solid var(--bad); }
.card.log .note { min-height: 0; margin: 0; }
.card.log .note:not(:empty) { margin-bottom: 8px; color: #ffe2a1; }

/* ------------------------------------------------------------ match server */
.state {
  --state: var(--off);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 38px;
  font-weight: 750;
  line-height: 1.1;
}
/* The dot: full when running, a ring when stopped, a beating ring while it changes, a
   dashed ring when no machine is found. */
.dot {
  flex: none;
  width: 18px;
  height: 18px;
  border: 3px solid var(--state);
  border-radius: 50%;
  background: transparent;
}
.state[data-server-state="running"] { --state: var(--good); }
.state[data-server-state="running"] .dot { background: var(--state); }
.state[data-server-state="starting"],
.state[data-server-state="stopping"] { --state: var(--moving); }
.state[data-server-state="starting"] .dot,
.state[data-server-state="stopping"] .dot { animation: beat 1.2s ease-in-out infinite; }
.state[data-server-state="missing"] { --state: var(--bad); }
.state[data-server-state="missing"] .dot { border-style: dashed; }
@keyframes beat {
  50% { transform: scale(0.6); opacity: 0.5; }
}
@media (prefers-reduced-motion: reduce) {
  .dot { animation: none !important; }
}
.state-note { min-height: 1.5em; margin-top: 6px; color: var(--ink-2); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 24px; margin: 14px 0 18px; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin-top: 2px; font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.auto-off { padding-top: 14px; border-top: 1px solid var(--line); }
.auto-off form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; }
.auto-off label, .auto-off form > span:not(.unsaved) { color: var(--ink-2); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.actions button { min-width: 104px; }

/* --------------------------------------------------------------- right now */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
/* The number above its label; in the markup the label still comes first. */
.tile {
  display: flex;
  flex-direction: column-reverse;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tile dt { font-size: 13px; color: var(--ink-2); }
.tile dd { font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
th.n, td.n { text-align: right; font-variant-numeric: tabular-nums; }
td.when { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.who, td.detail { overflow-wrap: anywhere; }
td.empty { color: var(--muted); }

/* ---------------------------------------------------------------- question */
dialog.ask {
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
dialog.ask::backdrop { background: rgba(3, 8, 20, 0.72); }
dialog.ask h2 { font-size: 19px; font-weight: 650; }
dialog.ask p { margin: 8px 0 20px; color: var(--ink-2); }
.ask-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 880px) {
  .board { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .top { padding: 12px 16px; }
  .status { padding: 0 16px; }
  .status:not(:empty) { padding: 9px 16px; }
  main { padding: 16px 16px 32px; }
  .card { padding: 16px; }
  .state { font-size: 30px; }
}
