/* One stylesheet, no framework. Section 3 keeps the client to browser-native
   custom elements, semantic HTML and CSS. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eceef1;
  --text: #14171a;
  --muted: #5b6570;
  --line: #d9dde2;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #b42318;
  --radius: 10px;
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1b1f23;
    --surface-2: #22272c;
    --text: #e6edf3;
    --muted: #9aa4af;
    --line: #2d333b;
    --accent: #4c8dff;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  /* Safe areas, so the app is usable added to a Home Screen. */
  padding-top: max(0.75rem, env(safe-area-inset-top));
}

.bar h1 { font-size: 1rem; margin: 0; letter-spacing: 0.01em; }

.foot {
  margin-top: auto;
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

main {
  padding: var(--gap);
  display: grid;
  gap: var(--gap);
  max-width: 60rem;
  width: 100%;
  margin: 0 auto;
}

button, select {
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

section.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--gap);
}

section.card > h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Stat tiles: the glance layer. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.75rem;
}

.tile {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
}

.tile .value {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.tile .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tile.ok .value { color: var(--ok); }
.tile.warn .value { color: var(--warn); }
.tile.bad .value { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* Wide content scrolls inside its own box rather than the page. */
.scroll { overflow-x: auto; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.pill.open { color: var(--accent); border-color: var(--accent); }
.pill.published { color: var(--ok); border-color: var(--ok); }
.pill.frozen { color: var(--warn); border-color: var(--warn); }

.posture {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--warn);
  color: var(--warn);
}

.muted { color: var(--muted); }
.loading { color: var(--muted); }

.notice {
  border-left: 3px solid var(--warn);
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.notice.bad { border-left-color: var(--bad); }

.signin {
  display: grid;
  gap: 0.75rem;
  max-width: 26rem;
}

@media (max-width: 30rem) {
  .tile .value { font-size: 1.3rem; }
  main { padding: 0.75rem; }
}

/* Booker screen. */
.tabs { display: flex; gap: 0.25rem; }
.tabs button {
  background: none; border: 1px solid transparent; color: inherit;
  padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer;
  font: inherit; opacity: 0.65;
}
.tabs button.on { opacity: 1; border-color: currentColor; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.actions button {
  font: inherit; padding: 0.5rem 0.9rem; border-radius: 0.5rem;
  border: 1px solid currentColor; background: none; color: inherit;
  cursor: pointer;
}
.actions button[disabled] { opacity: 0.4; cursor: not-allowed; }
.weekpick { display: block; margin: 0 0 0.75rem; font-size: 0.9rem; }
.weekpick select { font: inherit; margin-left: 0.4rem; }
.session { padding: 0.5rem 0; border-top: 1px solid rgba(127,127,127,0.25); }
.session:first-of-type { border-top: none; }
.session h3 { margin: 0 0 0.15rem; font-size: 1rem; }
.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grid th { text-align: left; font-weight: 600; opacity: 0.7; }
.grid th, .grid td { padding: 0.3rem 0.5rem 0.3rem 0; }
.grid tr.warn td { color: #b26a00; }
.notice.good { border-left-color: var(--ok); }

.notice.warn { border-left-color: var(--warn); }
/* Player screen. */
.session.mine { border-left: 3px solid var(--ok); padding-left: 0.6rem; }
.prefs { display: grid; gap: 0.75rem; }
.prefs input[type="number"] { font: inherit; width: 4rem; margin-left: 0.4rem; }
.prefs fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}
.prefs legend { font-size: 0.85rem; color: var(--muted); }
.prefs .day { display: inline-flex; align-items: center; gap: 0.25rem;
  margin-right: 0.75rem; }
.prefs button {
  font: inherit; padding: 0.5rem 0.9rem; border-radius: 0.5rem;
  border: 1px solid currentColor; background: none; color: inherit;
  cursor: pointer; justify-self: start;
}
.prefs button[disabled] { opacity: 0.4; cursor: not-allowed; }
.pill.room { color: var(--ok); border-color: var(--ok); }
.pill.contested { color: var(--warn); border-color: var(--warn); }
/* The sign-in link is a link, not a button, because it navigates. It should
   still look like the primary action on an otherwise empty page. */
.button {
  display: inline-block; font: inherit; text-decoration: none;
  padding: 0.6rem 1.1rem; border-radius: 0.5rem;
  border: 1px solid currentColor; color: var(--accent);
}
/* Roster screen. */
.grid input.games { width: 3.5rem; font: inherit; }
.grid .day { margin-right: 0.4rem; white-space: nowrap; font-size: 0.85rem; }
.grid button.save {
  font: inherit; padding: 0.3rem 0.7rem; border-radius: 0.4rem;
  border: 1px solid currentColor; background: none; color: inherit;
  cursor: pointer;
}
.grid button.invite { margin-left: 0.3rem; }
.invite-link { width: 100%; font: inherit; padding: 0.4rem; }
