/* PRG32 Multiplayer Server. The colours of the official PRG32 logo, shared with
   the PRG32 Construction Kit and Cartridge Store: black, deep purple, electric
   blue, cyan, and neon magenta. Text and control colours meet WCAG 2.2 AA
   contrast in both Day and Night; magenta and cyan are decorative on light. */
:root {
  color-scheme: light;
  --navy: #2a0f45;
  --deep: #000000;
  --bright: #3d1670;
  --neon-line: linear-gradient(90deg, #ff2094, #9050dc 50%, #00d2ff);
  --page-top: #f5efff;
  --page-bottom: #ffffff;
  --ink: #160c24;
  --muted: #574a68;
  --panel: #ffffff;
  --line: #ddd3ea;
  --link: #0062dd;
  --accent: #3d1670;
  --button: #0062dd;
  --button-hover: #004aab;
  --button-ink: #ffffff;
  --secondary: #f1ebfa;
  --secondary-ink: #2a0f45;
  --danger: #b42318;
  --danger-ink: #ffffff;
  --focus: #0062dd;
  --pill-bg: #fde4f2;
  --pill-ink: #9a0b70;
  --ok-bg: #dcf5e6;
  --ok-ink: #11612e;
  --bad-bg: #fde3e1;
  --bad-ink: #8f1a10;
  --warn-bg: #fff4d6;
  --warn-line: #b37a00;
  --bar: #0062dd;
  --shadow: 0 0.5rem 1rem rgba(42, 15, 69, 0.06);
  --font:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page-top: #07030d;
  --page-bottom: #110820;
  --ink: #ece6f5;
  --muted: #bfb2d3;
  --panel: #1a0f2b;
  --line: #3a2a52;
  --link: #6fb6ff;
  --accent: #00d2ff;
  --button: #4da3ff;
  --button-hover: #80bdff;
  --button-ink: #07030d;
  --secondary: #2a1b40;
  --secondary-ink: #ece6f5;
  --danger: #ff8a80;
  --danger-ink: #1a0503;
  --focus: #00d2ff;
  --pill-bg: #4a1145;
  --pill-ink: #ffd0ec;
  --ok-bg: #0f3b22;
  --ok-ink: #a8f0c4;
  --bad-bg: #4a1410;
  --bad-ink: #ffc4bd;
  --warn-bg: #3a2c08;
  --warn-line: #f0c36d;
  --bar: #00d2ff;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--page-top) 0%, var(--page-bottom) 45%) fixed;
  background-color: var(--page-bottom);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

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

main:focus {
  outline: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: #ffffff;
  color: #2a0f45;
  border-radius: 6px;
  font-weight: 700;
}

.skip-link:focus {
  top: 1rem;
}

/* Menu bar: the deep gradient and neon line of the Construction Kit. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  min-height: 64px;
  padding: 0.5rem 1.5rem;
  background: linear-gradient(
    90deg,
    var(--deep) 0%,
    var(--navy) 55%,
    var(--bright) 100%
  );
  border-bottom: 2px solid transparent;
  border-image: var(--neon-line) 1;
  color: #ffffff;
}

.topbar :focus-visible {
  outline-color: #00d2ff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: #ffffff;
  text-decoration: none;
}

.brand-logo {
  height: 40px;
  width: auto;
  border-radius: 6px;
  image-rendering: pixelated;
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-title {
  font-weight: 800;
  font-size: 1.05rem;
}

.brand-tagline {
  color: #dcd0ef;
  font-size: 0.8rem;
  font-weight: 600;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.nav-list,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: inline-block;
  padding: 0.35rem 0.15rem;
  color: #e8def7;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.nav-list a:hover {
  color: #ffffff;
  border-bottom-color: #9050dc;
}

.nav-list a[aria-current='page'] {
  color: #ffffff;
  border-bottom-color: #00d2ff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0.3rem 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  color: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.theme-toggle-icon {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  box-shadow: inset -0.3rem -0.1rem 0 0 #ffd0ec;
}

.theme-toggle[aria-pressed='true'] .theme-toggle-icon {
  background: #00d2ff;
  box-shadow: none;
}

.shell {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.6rem;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

h2 {
  font-size: 1.25rem;
}

.page-title {
  margin-bottom: 1rem;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
}

/* Hero: the Construction Kit welcome panel. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 2rem;
  border-radius: 1rem;
  color: #ffffff;
  background:
    radial-gradient(circle at 85% 10%, rgba(255, 32, 148, 0.35), transparent 22rem),
    linear-gradient(135deg, var(--deep) 0%, var(--navy) 50%, var(--bright) 100%);
  box-shadow: 0 1rem 3rem rgba(20, 33, 61, 0.2);
}

.hero a,
.hero .muted {
  color: #dcd0ef;
}

.hero :focus-visible {
  outline-color: #00d2ff;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: #7fe6ff;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  max-width: 38rem;
  font-size: 1.1rem;
  color: #f1eaff;
}

.service-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0;
}

.pill,
.badge {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.pill {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.pill::before {
  content: '';
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #bfb2d3;
}

.pill[data-state='online'] {
  background: #0f3b22;
  color: #a8f0c4;
}

.pill[data-state='online']::before {
  background: #3ddc84;
}

.pill[data-state='offline'] {
  background: #4a1410;
  color: #ffc4bd;
}

.pill[data-state='offline']::before {
  background: #ff6b5e;
}

.hero .metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero .metric {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.hero .metric dt {
  color: #dcd0ef;
}

.hero .metric dd {
  color: #ffffff;
}

.hero-actions {
  grid-column: 1 / -1;
}

.hero .button.secondary {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.55);
  color: #ffffff;
}

.hero .button.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Metric cards. */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.cards {
  margin-bottom: 1rem;
}

.metric {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric dd {
  margin: 0.2rem 0 0;
  color: var(--accent);
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Panels. */
.panel,
.notice {
  margin-bottom: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

.panel-grid .panel {
  margin: 0;
}

.panel-grid .panel p:last-child {
  margin-bottom: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.panel-actions,
.toolbar,
.dialog-actions,
.action-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.toolbar {
  margin-bottom: 1rem;
}

.toolbar p {
  margin: 0 auto 0 0;
}

.notice.warning {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  border-left-width: 6px;
}

.notice h2 {
  font-size: 1.05rem;
}

.notice p {
  margin: 0;
}

/* Forms and buttons: 44px targets (WCAG 2.5.8 asks for 24px). */
.signin {
  max-width: 34rem;
}

.field {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

input[aria-invalid='true'] {
  border: 2px solid var(--danger);
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.field-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-weight: 700;
}

.field-error:empty {
  display: none;
}

.search-field {
  max-width: 28rem;
  margin-top: 1rem;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--button);
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--button-hover);
}

.button.secondary {
  background: var(--secondary);
  border-color: var(--line);
  color: var(--secondary-ink);
}

.button.secondary:hover {
  border-color: var(--muted);
  background: var(--secondary);
}

.button.danger {
  background: var(--danger);
  color: var(--danger-ink);
}

.button.danger:hover {
  filter: brightness(1.1);
}

.button.small {
  min-height: 32px;
  padding: 0.25rem 0.65rem;
  font-size: 0.9rem;
}

/* Tables. */
.table-scroll {
  /* Positioned, so visually hidden labels inside are clipped with the table. */
  position: relative;
  overflow-x: auto;
  margin-top: 0.75rem;
  border-radius: 6px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td time {
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.badge.allowed {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.badge.blocked {
  background: var(--bad-bg);
  color: var(--bad-ink);
}

/* Chart. */
.chart-figure {
  margin: 0 0 0.75rem;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  border-radius: 6px;
  background: var(--secondary);
}

.chart-bar {
  fill: var(--bar);
}

.chart-axis {
  stroke: var(--muted);
  stroke-width: 1;
}

.chart-figure figcaption {
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--link);
  min-height: 24px;
}

/* Dialog. */
dialog {
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(7, 3, 13, 0.6);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Notices rendered from Markdown. */
.prose {
  max-width: 46rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
}

.prose h2 {
  margin-top: 1.75rem;
}

.prose li + li {
  margin-top: 0.3rem;
}

/* Footer. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--secondary);
  font-size: 0.9rem;
}

.footer-links a {
  color: var(--ink);
}

.footer-note {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .topbar,
  .shell,
  .site-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 1.25rem;
  }

  .prose {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .chart-bar {
    fill: CanvasText;
  }

  .pill::before {
    forced-color-adjust: none;
  }
}

@media print {
  .topbar,
  .site-footer,
  .toolbar,
  .skip-link {
    display: none;
  }
}

/* Device IDs and row actions stay on one line; the table region scrolls. */
.data-table code {
  overflow-wrap: normal;
  white-space: nowrap;
}

.data-table .action-cell {
  flex-wrap: nowrap;
}
