/* Dark, readable, no framework, no CDN. Phone width first. */
:root {
  --bg: #12141a;
  --panel: #1b1f27;
  --panel-2: #232833;
  --line: #333a48;
  --text: #e8ecf3;
  --muted: #9aa4b5;
  --accent: #6fd3c7;
  --accent-ink: #10201f;
  --danger: #ff8f8f;
}

* {
  box-sizing: border-box;
}

/* Author styles beat the browser's [hidden] rule, so say it loudly. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 20px;
  margin: 0 8px 0 0;
  letter-spacing: 0.02em;
}

.auth {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

input,
button {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

input {
  min-width: 0;
  width: 9.5em;
}

button {
  cursor: pointer;
}

button.primary,
button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.who {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

main {
  display: grid;
  gap: 16px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  main {
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    grid-template-areas:
      "picker board"
      "stage  board";
    align-content: start;
  }

  #picker {
    grid-area: picker;
  }

  #stage {
    grid-area: stage;
  }

  aside {
    grid-area: board;
  }
}

.panel,
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

h2 {
  font-size: 16px;
  margin: 0 0 10px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.games {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.games button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
}

.games .title {
  font-weight: 600;
}

.games .desc {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.stage-bar h2 {
  margin: 0;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #0b0d12;
  border: 1px solid var(--line);
  border-radius: 10px;
  touch-action: none;
}

.status {
  margin: 10px 0 4px;
  min-height: 1.5em;
  font-variant-numeric: tabular-nums;
}

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.board li {
  display: grid;
  grid-template-columns: 2.5em 1fr auto;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel-2);
}

.board li.me {
  outline: 1px solid var(--accent);
}

.board .rank {
  color: var(--muted);
}

.board .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board .score {
  font-weight: 600;
}

footer {
  padding: 0 16px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.error {
  color: var(--danger);
}
