:root {
  color-scheme: dark;
  --background: #1a1520;
  --text: #c8c0d8;
  --muted: #9a8aaa;
  --link: #b89ec4;
  --border: #3a3048;
  --panel: #211b29;
  --teal: #72c7bd;
  --gold: #e7b448;
}

* { box-sizing: border-box; }

body {
  max-width: 1000px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 30px;
  background: var(--background);
  color: var(--text);
  font: 16px/1.6 Georgia, "Times New Roman", serif;
}

a { color: var(--link); }
a:visited { color: #8a7a96; }

button, select, input {
  font: inherit;
}

button, select, input {
  border: 1px solid #665875;
  border-radius: 2px;
  background: #111;
  color: var(--text);
}

button {
  padding: 7px 12px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--gold);
  color: #f0d38d;
}

button:disabled {
  cursor: wait;
  opacity: .6;
}

button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  font-weight: bold;
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: .9em;
}

.connection-label { color: var(--teal); }
.text-button { padding: 2px 6px; border: 0; background: transparent; color: var(--link); }

main { padding: 26px 0 45px; }
h1 { margin: 0 0 4px; font-size: clamp(1.7rem, 5vw, 2.2rem); font-weight: normal; }
h2 { margin: 0 0 2px; font-size: 1.15rem; font-weight: normal; }
p { margin: 0 0 10px; }
.intro { max-width: 640px; color: var(--muted); }
.eyebrow { color: var(--teal); font-size: .8em; letter-spacing: .08em; }

.settings {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 23px 0 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.settings > label { color: var(--muted); }
.settings select, .settings input { padding: 6px 8px; }
.settings details { flex-basis: 100%; }
.settings summary { width: fit-content; color: var(--link); cursor: pointer; }
.settings summary span { color: var(--muted); }
.settings details input { display: block; width: min(100%, 380px); margin-top: 9px; }
.settings details p, .help-text { margin: 5px 0 0; color: var(--muted); font-size: .88em; }
.game-count { margin: 0 0 8px; color: var(--muted); font-size: .88em; }

.game-table { width: 100%; border-collapse: collapse; text-align: left; }
.game-table th {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: .82em;
  font-weight: normal;
}

.game-table td { padding: 8px 9px; border-bottom: 1px solid var(--border); }
.game-table th:nth-child(2), .game-table td:nth-child(2) { width: 115px; }
.game-table th:last-child, .game-table td:last-child { width: 85px; text-align: right; }
.game-name { color: var(--text); }
.game-id { color: var(--muted); font: .85em ui-monospace, monospace; }
.game-table button { min-width: 65px; padding: 4px 9px; }
.empty-state { padding: 16px 9px !important; color: var(--muted); }

hr { margin: 18px 0; border: 0; border-top: 1px solid var(--border); }
.desktop-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.desktop-row p { margin: 0; color: var(--muted); }
.desktop-row button, .primary-link {
  display: inline-block;
  padding: 8px 13px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: var(--gold);
  color: #171411;
  font-weight: bold;
  text-decoration: none;
}
.desktop-row button:hover:not(:disabled), .primary-link:hover { background: #f0ce7d; color: #171411; }

#starting-view, #session-view { max-width: 680px; padding: 22px 0; }
#starting-view progress { width: min(100%, 380px); height: 14px; accent-color: var(--teal); }
#starting-view .help-text { margin-top: 12px; }
.session-link-row { margin: 20px 0; }
.session-link-row .help-text { display: block; margin-top: 9px; }
.end-button { border-color: #9b6565; color: #e0b0b0; }

.notice {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  background: var(--panel);
  color: #f0d38d;
  overflow-wrap: anywhere;
}

dialog {
  width: min(420px, calc(100% - 28px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--background);
  color: var(--text);
}

dialog::backdrop { background: #09070bd9; }
dialog h2 { margin-bottom: 6px; }
dialog p { color: var(--muted); }
dialog label { display: block; margin: 14px 0 5px; }
dialog input { width: 100%; padding: 8px; margin-bottom: 10px; }
dialog button[type="submit"] { background: var(--gold); color: #171411; }
.close-button { float: right; padding: 0 5px; border: 0; background: transparent; font-size: 1.3em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .82em;
}

footer span:first-child { letter-spacing: .08em; }

@media (max-width: 600px) {
  body { padding: 0 14px; }
  main { padding-top: 20px; }
  .game-table th, .game-table td { padding: 7px 4px; }
  .game-table th:nth-child(2), .game-table td:nth-child(2) { width: 74px; }
  .game-table th:last-child, .game-table td:last-child { width: 68px; }
  .game-id { font-size: .75em; }
  footer { flex-direction: column; gap: 2px; }
}
