:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --line: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --accent: #2a78d6;
  --series: #2a78d6;
  --good: #0ca30c;
  --critical: #d03b3b;
  --warning: #fab219;
  --radius: 6px;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #1a1a19;
    --surface-2: #242423;
    --line: #383835;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --accent: #3987e5;
    --series: #3987e5;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.brand { font-weight: 600; }
.top nav { display: flex; flex-wrap: wrap; gap: 2px 4px; flex: 1; }
.top nav a { padding: 4px 8px; border-radius: var(--radius); color: var(--text-2); text-decoration: none; }
.top nav a:hover { color: var(--text); background: var(--surface); }
.top nav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: inset 0 -2px var(--accent); }
.who { color: var(--text-2); display: flex; gap: 8px; align-items: center; }

main { padding: 16px; max-width: 1280px; margin: 0 auto; }
main:focus { outline: none; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
p { margin: 0 0 8px; }
.muted { color: var(--text-2); }
.hint { color: var(--text-2); font-size: 13px; }
.swatch { display: inline-block; width: 16px; height: 16px; margin-left: 6px; vertical-align: middle; border-radius: 3px;
  border: 1px solid var(--line); }
code, pre, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
      overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }

/* player names are user input: isolated so right-to-left text cannot reorder the cells around it */
.name { unicode-bidi: isolate; overflow-wrap: break-word; }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--text-2); white-space: nowrap; background: var(--surface-2); }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tr.gone td { color: var(--text-2); text-decoration: line-through; }
tr.selected td { background: var(--surface-2); }

button, .button {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius);
  padding: 4px 10px; cursor: pointer;
}
button:hover { border-color: var(--text-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--critical); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-align: left; }
button.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input, select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 4px 8px;
  max-width: 100%;
}
textarea { width: 100%; min-height: 60px; }
label { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 12px; }
.row > label { min-width: 120px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
form.panel, .panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.panel > h2:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 22px; font-weight: 600; }
.tile .sub { color: var(--text-2); font-size: 12px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.chart { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; position: relative; }
.chart .title { font-weight: 600; font-size: 13px; }
.chart .now { color: var(--text-2); font-size: 12px; }
.chart svg { display: block; width: 100%; height: 120px; overflow: visible; }
.chart line, .chart polyline { vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--text-2); stroke-width: 1; }
.chart .tip { position: absolute; top: 28px; pointer-events: none; background: var(--surface-2);
              border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 6px; font-size: 12px; }

.badge { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 12px;
         color: var(--text-2); white-space: nowrap; }
.status { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); }
.status.good::before { background: var(--good); }
.status.bad::before { background: var(--critical); }
.status.warn::before { background: var(--warning); }

.error { color: var(--critical); }
.toast { position: fixed; bottom: 16px; left: 16px; right: 16px; max-width: 480px; margin: 0 auto; padding: 8px 12px;
         border-radius: var(--radius); background: var(--text); color: var(--surface); opacity: 0;
         pointer-events: none; transition: opacity .2s; }
.toast.shown { opacity: 1; }
.toast.bad { background: var(--critical); color: #fff; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
         max-width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; }
dl.fields dt { color: var(--text-2); }
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
dl.fields dl.fields { border-left: 2px solid var(--line); padding-left: 8px; }
.pager { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
/* a title as the game draws it (admin/titles.js): colours made for the game's dark menus, so on a dark chip in both themes */
.title-label { display: inline-block; padding: 1px 8px; border-radius: var(--radius); background: #101418;
               color: var(--title-color, #fff); font-weight: 600; white-space: nowrap; }
.title-label:not(.glow) > span { opacity: .6; }
.title-label.glow > span { text-shadow: 0 0 4px var(--title-glow), 0 0 4px var(--title-glow); }
.code { font-size: 16px; padding: 8px; border: 1px dashed var(--accent); border-radius: var(--radius); word-break: break-all; }
.login { max-width: 520px; margin: 48px auto; }
.login input { width: 100%; }

@media (max-width: 600px) {
  .top { justify-content: space-between; }
  .top nav { order: 3; flex-basis: 100%; }
  main { padding: 12px 16px; }
  .row > label { min-width: 0; flex: 1 1 140px; }
  .grid2 { grid-template-columns: 1fr; }
}
