/* Light theme by default; the dark theme only swaps the colour variables. */
:root {
  color-scheme: light dark;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #1c1e24;
  --muted: #5a5f6e;
  --border: #cfd3dc;
  --accent: #3451c9;
  --accent-text: #ffffff;
  --chosen-bg: #e2e8ff;
  --correct: #1d7533;
  --correct-bg: #d8f4de;
  --notice-bg: #fff2bd;
  --notice-text: #4a3900;
  --error-bg: #ffe0e0;
  --error-text: #8a1414;
  --online: #2f9e44;
  --offline: #9aa0ad;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1c1f26;
    --text: #e6e8ee;
    --muted: #a3a9b8;
    --border: #3a3f4b;
    --accent: #8ea3ff;
    --accent-text: #0e1224;
    --chosen-bg: #28325e;
    --correct: #7ee08f;
    --correct-bg: #183d23;
    --notice-bg: #3b3210;
    --notice-text: #ffe9a3;
    --error-bg: #4a1a1a;
    --error-text: #ffc4c4;
    --online: #69db7c;
    --offline: #6c7280;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

main {
  max-width: 36rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 { font-size: 1.2rem; margin: 0 0 1rem; color: var(--muted); }
h2 { font-size: 1.4rem; margin: 0 0 1rem; }
h2:focus { outline: none; } /* focused by script on screen changes, not interactive */
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; color: var(--muted); }

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

/* Forms and buttons */

label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }

input {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
}

.code-input { text-transform: uppercase; letter-spacing: 0.2em; }

button {
  font: inherit;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button:disabled { cursor: default; opacity: 0.6; }

form button, button.wide { width: 100%; margin-top: 0.75rem; }
.or { text-align: center; color: var(--muted); margin: 0.75rem 0 0; }

/* Messages */

.notice, .error {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin: 0 0 1rem;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--notice-bg);
  color: var(--notice-text);
}

.error { background: var(--error-bg); color: var(--error-text); }
.status { color: var(--muted); min-height: 1.45em; }

/* Lobby */

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.15em;
}

.share { display: flex; gap: 0.5rem; }
.share input { flex: 1; min-width: 0; }
.share button { flex: none; }

/* Player lists and labels */

.players { list-style: none; margin: 0; padding: 0; }

.players li, .player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.players li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

.dot {
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--online);
}

.dot.off { background: var(--offline); }
.offline .name { color: var(--muted); }

.tag {
  font-size: 0.8rem;
  font-weight: 400;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

.tag.done { border-color: var(--correct); color: var(--correct); }

/* Question and reveal */

.bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: 1rem;
}

.timer { margin: 0 0 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.category { margin: 0 0 0.25rem; color: var(--muted); }
.question-text { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; }

.options {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 34rem) {
  .options { grid-template-columns: 1fr 1fr; }
}

.option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
  text-align: left;
}

.option .text { flex: 1; min-width: 0; }

.letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--bg);
  font-weight: 700;
}

button.option:disabled { opacity: 0.55; }
button.option.chosen:disabled { opacity: 1; }
.option.chosen { border-color: var(--accent); background: var(--chosen-bg); }
.option.correct { border-color: var(--correct); background: var(--correct-bg); }

.result { font-weight: 600; margin: 1rem 0 0; }

/* Standings tables */

.table-wrap { overflow-x: auto; }

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

th, td {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.num { text-align: right; }
tr.me td { font-weight: 700; }
