/* Mock scores control panel. Plain CSS, light and dark. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5b6270;
  --line: #dde0e6;
  --accent: #2357d9;
  --accent-text: #ffffff;
  --danger: #c22a2a;
  --ok: #17803d;
  --warn: #a55a00;
  --chip: #eceef2;
  --code: #f0f1f4;
  --radius: 10px;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1b1e24;
    --text: #e9ebef;
    --muted: #9aa1ae;
    --line: #2d313a;
    --accent: #5b8cff;
    --accent-text: #0b0d12;
    --danger: #ff6b6b;
    --ok: #4cd480;
    --warn: #f2a541;
    --chip: #272b33;
    --code: #23262e;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 12px;
  line-height: 1.4;
  font-size: 15px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}
h1 {
  font-size: 1.3rem;
}
h2 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}
h3 {
  font-size: 1rem;
}
p {
  margin: 0 0 8px;
}
code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}
code {
  background: var(--code);
  padding: 1px 4px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: flex-start;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto 12px;
}
.topbar-side {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sub,
.hint,
.refresh {
  color: var(--muted);
  font-size: 0.85rem;
}
.hint:empty {
  display: none;
}

.message {
  max-width: 1200px;
  margin: 0 auto 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok);
  overflow-wrap: anywhere;
}
.message.is-error {
  border-left-color: var(--danger);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.key-card {
  max-width: 480px;
  margin: 24px auto;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}
.side {
  display: grid;
  gap: 12px;
  align-content: start;
}
.games {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
/* On a phone the games come first: watching them is the main job. */
@media (max-width: 899px) {
  .games {
    order: -1;
  }
}
.games-title {
  margin: 4px 0 0;
}
.game-list {
  display: grid;
  gap: 12px;
}
.empty {
  color: var(--muted);
}

@media (min-width: 900px) {
  body {
    padding: 20px;
  }
  .layout {
    grid-template-columns: 360px minmax(0, 1fr);
    align-items: start;
  }
  .side {
    position: sticky;
    top: 20px;
  }
  .games {
    grid-row: 1;
    grid-column: 2;
  }
}
@media (min-width: 1400px) {
  .game-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Forms */
form {
  display: grid;
  gap: 10px;
}
.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.field > span {
  font-size: 0.8rem;
  color: var(--muted);
}
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
}
input,
select,
button {
  font: inherit;
  color: inherit;
}
input,
select {
  width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
input:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.9rem;
}
.check input {
  width: auto;
  min-height: 0;
  margin-top: 3px;
}

button {
  white-space: nowrap;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--chip);
  cursor: pointer;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--line);
}
button.ghost {
  background: transparent;
}
button.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.segmented {
  display: flex;
  border: 0;
  padding: 0;
  margin: 0;
  gap: 0;
}
.segmented label {
  flex: 1;
}
.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.segmented span {
  display: block;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.9rem;
}
.segmented label:first-of-type span {
  border-radius: 8px 0 0 8px;
}
.segmented label:last-of-type span {
  border-radius: 0 8px 8px 0;
  border-left: 0;
}
.segmented input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

details summary {
  cursor: pointer;
  padding: 6px 0;
  font-weight: 600;
}
details form {
  margin-top: 8px;
}

.error {
  color: var(--danger);
  font-weight: 600;
}

/* Faults */
.fault-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.fault-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--chip);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.fault-list li button {
  flex: none;
}
.fault-list li.none {
  background: none;
  padding: 0;
  color: var(--muted);
}
.fault-kind {
  font-weight: 700;
  color: var(--danger);
}

/* Feed */
.feed {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 12px;
  font-size: 0.9rem;
}
.feed dt {
  color: var(--muted);
}
.feed dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Games */
.game {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.game p {
  margin: 0;
}
.game-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.game-id {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}
.chip {
  flex: none;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
}
.chip.playing {
  color: var(--ok);
}
.chip.paused {
  color: var(--warn);
}
.scoreline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
}
.status {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.updated {
  color: var(--muted);
  font-size: 0.8rem;
}
.scripted {
  color: var(--danger);
  font-weight: 600;
}
.table-wrap {
  overflow-x: auto;
}
.score {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.score th,
.score td {
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  min-width: 2.2em;
}
.score th:first-child,
.score td:first-child {
  text-align: left;
}
.score th {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}
.score td:first-child {
  font-weight: 700;
}
.score .total {
  font-weight: 800;
  font-size: 1.1rem;
}
.score .side {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 4px;
}

.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--chip);
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s linear;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.controls button {
  flex: 1 1 auto;
}
.jump-label,
.sync-label {
  font-size: 0.8rem;
  color: var(--muted);
  flex-basis: 100%;
}

.sync {
  display: grid;
  gap: 4px;
}
.sync-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.sync-row code {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  user-select: all;
  -webkit-user-select: all;
}

.raw pre {
  margin: 4px 0 0;
  padding: 8px;
  background: var(--code);
  border-radius: 8px;
  overflow-x: auto;
  max-height: 320px;
}
