:root {
  --bg: #fff;
  --fg: #111;
  --muted: #777;
  --line: #ddd;
  --red: #d33;
  --blue: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111; --fg: #eee; --muted: #888; --line: #333; --red: #f66; --blue: #6ea0ff; }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
main { max-width: 720px; margin: 0 auto; padding: 16px; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
nav { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--fg); }
nav a.active { color: var(--fg); font-weight: bold; text-decoration: underline; text-underline-offset: 4px; }
#conn { margin-right: auto; }
button.link { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--fg); }
#nameBtn { text-decoration: none; }
.name-edit { width: 14ch; padding: 2px 6px; }

.hero { text-align: center; padding: 40px 0 24px; }
.huge { font-size: 26px; padding: 16px 64px; }
.setup-line { margin: 12px 0; }
#setupPanel { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.chips { display: flex; }
.chips button { background: var(--bg); color: var(--fg); margin-left: -1px; padding: 4px 12px; }
.chips button.on { background: var(--fg); color: var(--bg); }
.chips button.on + button.on { border-left-color: var(--bg); }
#recent p { font-size: 14px; }
.first-name { margin: 0 auto 20px; max-width: 280px; text-align: left; }
.friends-title { margin: 40px 0 10px; }
.strip { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 32px; }
.strip b { color: var(--fg); }
h2.section { margin-top: 28px; }
.logo { font-weight: bold; font-size: 20px; color: var(--fg); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.box { border: 1px solid var(--line); padding: 12px; margin: 16px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.spread { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; margin-bottom: 8px; }

label { display: block; margin: 8px 0; }
label.inline, label.check { display: inline-flex; gap: 6px; align-items: center; margin: 0 12px 0 0; }

input, select, button {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--fg);
  padding: 6px 10px;
}
input:focus, select:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
label > input:not([type=checkbox]) { display: block; width: 100%; margin-top: 4px; }
button { cursor: pointer; background: var(--fg); color: var(--bg); }
button.ghost { background: var(--bg); color: var(--fg); }
button:disabled { opacity: .4; cursor: default; }
button.big { width: 100%; padding: 12px; font-size: 18px; margin-top: 8px; }
.code-input { text-transform: uppercase; width: 8ch; }
.code { letter-spacing: .15em; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.table td.num, .table th.num { text-align: right; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.team { border: 2px solid; padding: 12px; }
.team.red { border-color: var(--red); }
.team.blue { border-color: var(--blue); }
.team.red h2 { color: var(--red); }
.team.blue h2 { color: var(--blue); }
.team ul { list-style: none; padding: 0; margin: 0 0 8px; min-height: 1.5em; }
.team li { display: flex; justify-content: space-between; }
.team .avg { font-weight: bold; }
.offline { color: var(--muted); text-decoration: line-through; }
.red-t { color: var(--red); }
.blue-t { color: var(--blue); }

#arena { text-align: center; padding: 48px 0; min-height: 180px; }
.problem { font-size: 36px; }
.problem input { width: 5ch; font-size: 36px; padding: 2px 6px; text-align: center; }
.countdown { font-size: 64px; font-weight: bold; }

.small { font-size: 13px; }
.mt { margin-top: 16px; }
.tabs { display: flex; }
.tabs button { padding: 2px 8px; font-size: 14px; }
.tabs button.active { background: var(--fg); color: var(--bg); }
.center { text-align: center; padding: 32px 0; }
.center-row { justify-content: center; }
.bigscore { font-size: 72px; font-weight: bold; line-height: 1.1; }
.pb { font-weight: bold; }
tr.me td { font-weight: bold; }

.match { font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); }

.ranges { text-align: center; }
.ranges > div { margin: 4px 0; white-space: nowrap; }
.ranges input { width: 4.5ch; padding: 2px 4px; text-align: right; }
.ranges p { margin: 4px 0 0; }
#settings .ranges { text-align: left; margin-top: 8px; }

/* learn */
.trick-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.trick-row:hover { background: var(--line); }
.tick-space { display: inline-block; width: 1ch; }
.back { color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 8px; }
.back:hover { color: var(--fg); }
.tips { padding-left: 20px; }
.tips li { margin: 6px 0; }
.steps { min-height: 1.5em; }
a.btn { display: inline-block; border: 1px solid var(--fg); padding: 6px 10px; text-decoration: none; background: var(--fg); color: var(--bg); }
a.btn.ghost { background: var(--bg); color: var(--fg); }

/* run analysis */
.bars { display: flex; gap: 1px; align-items: flex-end; height: 64px; border-bottom: 1px solid var(--line); }
.bars i { flex: 1 1 0; min-width: 1px; max-width: 14px; background: var(--muted); opacity: .6; }
.bars i.slow { background: var(--fg); opacity: 1; }
.suggest { border: 1px dashed var(--fg); padding: 8px 10px; margin-top: 16px; }
.suggest a { color: var(--fg); }
.analysis td.idx { width: 4ch; color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); }
details .table { margin-top: 6px; }
.section-row { margin-top: 28px; margin-bottom: 0; }
.small-btn { padding: 2px 8px; font-size: 14px; }
tr.click { cursor: pointer; }
tr.click:hover td, tr.open td { background: var(--line); }
tr.detail > td { padding: 10px 6px 16px; }
#matchRun h2 { margin: 0; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 8px 14px; z-index: 10; max-width: calc(100% - 32px);
}

@media (max-width: 480px) {
  .problem, .problem input { font-size: 28px; }
}
