:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
  --text: #23272c;
  --page: #f4f5f6;
  --surface: #ffffff;
  --muted: #58616b;
  --line: #d8dde2;
  --accent: #245c9c;
  --accent-soft: #eaf1f9;
  --heading: #1c2228;
  --control-border: #7c8997;
  --disabled-text: #59616a;
  --disabled-bg: #eef0f2;
  --on-accent: #ffffff;
  --accent-hover: #194c86;
  --status-text: #434c56;
  --status-bg: #f5f6f7;
  --brand-text: #20262c;
  --brand-divider: #a2aab3;
  --sidebar: #f0f2f4;
  --brand-secondary: #454e58;
  --nav-text: #3b4550;
  --nav-icon: #6b737c;
  --nav-hover: #e4e8ec;
  --scope-border: #8a949f;
  --scope-text: #4e5863;
  --scope-strong: #323b45;
  --context-bg: #f6f7f8;
  --empty-border: #b6bec7;
  --empty-bg: #fafbfc;
}

/* The system palette also works when JavaScript is disabled or unavailable. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --text: #e3e8ee;
    --page: #141a21;
    --surface: #1b232d;
    --muted: #b3becb;
    --line: #3c4a5b;
    --accent: #9fcaff;
    --accent-soft: #243a52;
    --heading: #f0f4f9;
    --control-border: #7e8ea2;
    --disabled-text: #b3becb;
    --disabled-bg: #29333f;
    --on-accent: #122235;
    --accent-hover: #bedbff;
    --status-text: #cbd5e0;
    --status-bg: #27323e;
    --brand-text: #eef3f8;
    --brand-divider: #718198;
    --sidebar: #17202a;
    --brand-secondary: #bac6d3;
    --nav-text: #c9d4e0;
    --nav-icon: #a3b1c2;
    --nav-hover: #2c3846;
    --scope-border: #7e8ea2;
    --scope-text: #bfcbd8;
    --scope-strong: #e4ebf3;
    --context-bg: #202b37;
    --empty-border: #65768b;
    --empty-bg: #18212b;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #e3e8ee;
  --page: #141a21;
  --surface: #1b232d;
  --muted: #b3becb;
  --line: #3c4a5b;
  --accent: #9fcaff;
  --accent-soft: #243a52;
  --heading: #f0f4f9;
  --control-border: #7e8ea2;
  --disabled-text: #b3becb;
  --disabled-bg: #29333f;
  --on-accent: #122235;
  --accent-hover: #bedbff;
  --status-text: #cbd5e0;
  --status-bg: #27323e;
  --brand-text: #eef3f8;
  --brand-divider: #718198;
  --sidebar: #17202a;
  --brand-secondary: #bac6d3;
  --nav-text: #c9d4e0;
  --nav-icon: #a3b1c2;
  --nav-hover: #2c3846;
  --scope-border: #7e8ea2;
  --scope-text: #bfcbd8;
  --scope-strong: #e4ebf3;
  --context-bg: #202b37;
  --empty-border: #65768b;
  --empty-bg: #18212b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
p { margin: 0 0 1rem; }
h1, h2, h3 { line-height: 1.25; color: var(--heading); }
h1 { font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 650; letter-spacing: -0.035em; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 0 0 1rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.65rem; }
p, dd, strong, a, time, .domain { overflow-wrap: anywhere; }
button, input { font: inherit; }
button, input { min-height: 2.75rem; border: 1px solid var(--control-border); border-radius: 4px; padding: 0.6rem 0.9rem; }
button { background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { color: var(--disabled-text); background: var(--disabled-bg); border-color: var(--line); cursor: not-allowed; }
input { background: var(--surface); color: inherit; width: 100%; min-width: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.primary { display: flex; align-items: center; justify-content: space-between; background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--on-accent); }
.skip-link { position: fixed; top: 0.75rem; left: 0.75rem; transform: translateY(-200%); z-index: 10; padding: 0.75rem 1rem; color: var(--on-accent); background: var(--accent); }
.skip-link:focus { transform: translateY(0); }
.eyebrow { color: var(--muted); font-size: 0.75rem; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; margin-bottom: 1rem; }
.muted, .field-hint { color: var(--muted); }
.field-hint { display: block; font-size: 0.8rem; font-weight: 400; margin: 0.5rem 0 0; }
.domain { font-size: 0.8rem; color: var(--muted); }
.status-label { display: inline-block; padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: 3px; color: var(--status-text); background: var(--status-bg); font-size: 0.75rem; font-weight: 600; }
.wordmark { font-weight: 750; letter-spacing: -0.03em; font-size: 1.35rem; color: var(--brand-text); }
.brand-divider { padding: 0 0.75rem; font-weight: 400; color: var(--brand-divider); }
.notice { padding: 0.85rem 1rem; border-left: 3px solid var(--accent); background: var(--accent-soft); overflow-wrap: anywhere; }

.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; flex-shrink: 0; font-size: 0.8rem; }
.theme-indicator { position: relative; width: 2rem; height: 1.125rem; flex-shrink: 0; border: 1px solid var(--muted); border-radius: 1rem; background: var(--surface); }
.theme-indicator::after { content: ""; position: absolute; left: 0.125rem; top: 0.125rem; width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--muted); }
.theme-toggle[aria-checked="true"] .theme-indicator { background: var(--accent); border-color: var(--accent); }
.theme-toggle[aria-checked="true"] .theme-indicator::after { transform: translateX(0.875rem); background: var(--on-accent); }

/* Public sign-in page: no script or private navigation required. */
.login-page { min-height: 100svh; display: flex; flex-direction: column; }
.login-brand, .login-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.5rem clamp(1rem, 5vw, 5rem); }
.login-brand { border-bottom: 1px solid var(--line); background: var(--surface); }
.login-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; }
.login-layout { flex: 1; width: 100%; max-width: 78rem; margin: auto; padding: clamp(2rem, 7vw, 6rem) clamp(1rem, 5vw, 4rem); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: clamp(2rem, 7vw, 6rem); }
.login-context { padding-top: 1.5rem; max-width: 32rem; }
.login-context h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.16; margin-bottom: 1.5rem; }
.login-context .status-label { margin-top: 1rem; }
.login-panel { max-width: 34rem; padding: clamp(1.5rem, 3vw, 2.5rem); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 4px; }
.login-panel h2 { font-size: 1.65rem; }
.login-form { display: grid; gap: 1.25rem; margin-top: 1.75rem; }
.field label { display: block; margin-bottom: 0.45rem; font-weight: 600; font-size: 0.9rem; }
.login-form .primary { margin-top: 0.25rem; }
.login-help { font-size: 0.85rem; color: var(--muted); margin: 1.75rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.login-footer { font-size: 0.75rem; color: var(--muted); border-top: 1px solid var(--line); }

/* Server-rendered private workspace. */
.workspace { display: grid; grid-template-columns: 15rem minmax(0, 1fr); max-width: 100rem; min-height: 100svh; margin: auto; border-right: 1px solid var(--line); }
.sidebar { display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); padding: 2rem 1rem; }
.brand { display: flex; flex-direction: column; align-items: flex-start; text-decoration: none; color: var(--brand-secondary); font-size: 0.8rem; margin: 0 0.75rem 3.5rem; }
.brand .wordmark { font-size: 1.8rem; }
.nav-label { margin-left: 0.75rem; margin-bottom: 0.75rem; }
.sidebar nav { display: grid; gap: 0.3rem; }
.sidebar nav a { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 2.9rem; color: var(--nav-text); text-decoration: none; padding: 0.65rem 0.75rem; border-left: 3px solid transparent; border-radius: 3px; font-size: 0.9rem; }
.sidebar nav a > span { color: var(--nav-icon); }
.sidebar nav a:hover { background: var(--nav-hover); }
.sidebar nav a[aria-current="page"] { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent); font-weight: 650; }
.sidebar-note { margin: auto 0.75rem 0; padding-top: 4rem; font-size: 0.8rem; color: var(--muted); }
.sidebar-note .status-label { margin-bottom: 0.75rem; }
.work-area { display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.workspace-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1.5rem; min-height: 6rem; padding: 1.1rem clamp(1rem, 3vw, 3rem); border-bottom: 1px solid var(--line); }
.header-context { font-size: 0.85rem; font-weight: 600; margin: 0; }
.header-context span { display: block; font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.account { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 1rem; min-width: 0; max-width: 100%; }
.account p { margin: 0; font-size: 0.85rem; min-width: 0; }
.account .field-hint { margin-top: 0; font-size: 0.7rem; }
.account strong { display: block; max-width: 24rem; }
.account button { font-size: 0.8rem; }
main#main:not(.login-layout) { flex: 1; padding: 2.5rem clamp(1rem, 3vw, 3rem) 3rem; min-width: 0; }
.page-heading { margin-bottom: 1.75rem; }
.page-heading .eyebrow { font-size: 0.7rem; }
.lead { color: var(--muted); max-width: 45rem; margin: 0; }
.scope-note { display: flex; align-items: baseline; gap: 0.5rem 1.25rem; flex-wrap: wrap; padding: 1rem 1.1rem; margin-bottom: 2.5rem; background: var(--page); border-left: 3px solid var(--scope-border); font-size: 0.8rem; color: var(--scope-text); }
.scope-note strong { color: var(--scope-strong); white-space: nowrap; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.65fr); gap: clamp(1.5rem, 3vw, 3rem); align-items: start; }
.content-grid > * { min-width: 0; }
.context-panel { padding: 1.5rem; background: var(--context-bg); border: 1px solid var(--line); border-radius: 4px; font-size: 0.85rem; }
.context-panel > :last-child { margin-bottom: 0; }
.area-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.area-list li { position: relative; border-bottom: 1px solid var(--line); padding: 1rem 0; }
.area-list a { display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-decoration: none; }
.area-list a:hover strong { text-decoration: underline; }
.area-list a strong { display: block; font-size: 0.95rem; margin-bottom: 0.25rem; }
.area-list a span span { display: block; color: var(--muted); font-size: 0.85rem; }
.area-state { display: block; font-size: 0.7rem; color: var(--muted); margin-top: 0.55rem; }
.definition-list { margin: 0; }
.definition-list > div { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.definition-list > div:first-child { padding-top: 0; }
.definition-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.definition-list dt { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.35rem; }
.definition-list dd { margin: 0; color: var(--muted); font-size: 0.85rem; }
time { font-variant-numeric: tabular-nums; }
.section-block { margin-top: 3rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.steps { margin: 0; padding-left: 1.35rem; }
.steps li { padding: 0.5rem 0 0.75rem 0.4rem; }
.steps li::marker { color: var(--muted); font-size: 0.85rem; }
.steps strong, .steps span { display: block; font-size: 0.85rem; }
.steps span { color: var(--muted); margin-top: 0.25rem; }
.empty-state { margin: 1.5rem 0; padding: 1.5rem; border: 1px dashed var(--empty-border); background: var(--empty-bg); }
.empty-state h3 { margin-top: 0.75rem; }
.empty-state p { margin-bottom: 0; font-size: 0.85rem; color: var(--muted); }
.disabled-actions { display: grid; gap: 0.65rem; margin: 1.25rem 0; }
.disabled-actions button { text-align: left; font-size: 0.85rem; }
.workspace-footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem clamp(1rem, 3vw, 3rem); color: var(--muted); border-top: 1px solid var(--line); font-size: 0.7rem; }

/* Read-only game status uses the existing light/dark palette. */
.server-toolbar { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.server-toolbar h2 { margin: 0; }
.server-toolbar button { font-size: 0.85rem; }
.server-directory { list-style: none; margin: 1.25rem 0 0; padding: 0; border-top: 1px solid var(--line); }
.server-directory li { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.server-directory button { width: 100%; text-align: left; overflow-wrap: anywhere; }
.server-directory button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.server-directory li > span { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.35rem; overflow-wrap: anywhere; }
.server-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.server-facts > div, .server-facts > div:first-child, .server-facts > div:last-child { padding: 0 0 0.75rem; border-bottom: 1px solid var(--line); }
.server-roster { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 1.5rem; font-size: 0.85rem; }
.server-roster caption { text-align: left; font-weight: 650; margin-bottom: 0.75rem; }
.server-roster th, .server-roster td { text-align: left; vertical-align: top; padding: 0.65rem 0.4rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.server-roster th { background: var(--context-bg); }
.server-roster th:first-child { width: 25%; }
.server-roster th:last-child { width: 25%; }

@media (max-width: 70rem) {
  .workspace { grid-template-columns: 13rem minmax(0, 1fr); }
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .context-panel { max-width: none; }
}
@media (max-width: 48rem) {
  .workspace, .login-layout { grid-template-columns: minmax(0, 1fr); }
  .login-layout { gap: 2rem; }
  .login-context { padding-top: 0; max-width: none; }
  .login-panel { max-width: none; }
  .login-brand, .login-footer { flex-wrap: wrap; }
  .login-brand .wordmark { font-size: 1.1rem; }
  .sidebar { padding: 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { flex-direction: row; align-items: baseline; gap: 0.75rem; margin: 0 0 1rem; }
  .brand .wordmark { font-size: 1.4rem; }
  .nav-label { margin: 0 0 0.5rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 0.3rem; }
  .sidebar nav a { font-size: 0.8rem; padding: 0.65rem; }
  .sidebar nav a > span { display: none; }
  .sidebar-note { margin: 1rem 0 0; padding: 0; }
  .sidebar-note p:not(.status-label), .sidebar-note .domain { display: none; }
  .sidebar-note .status-label { margin: 0; }
  .workspace-header { flex-wrap: wrap; gap: 1rem; }
  .account { flex: 1; justify-content: space-between; }
  .header-context { width: 100%; }
  .header-context span { display: inline; margin-left: 0.5rem; }
  main#main:not(.login-layout) { padding-top: 1.75rem; }
  .scope-note { margin-bottom: 1.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
