:root {
  --ground: #f6f7fa;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --ink: #1b2340;
  --muted: #59627f;
  --faint: #8a92ad;
  --border: #dfe3ee;
  --accent: #4053a3;
  --accent-ink: #ffffff;
  --accent-soft: #e7ebf9;
  --go: #2e8540;
  --go-soft: #e2f2e4;
  --danger: #b4364c;
  --danger-soft: #f9e6ea;
  --s1: #e8798a; --s2: #f2ae4e; --s3: #e8d05e; --s4: #a8d98a; --s5: #74c46d;
  --shadow: 0 1px 2px rgba(27,35,64,.06), 0 8px 24px -12px rgba(27,35,64,.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #12162a;
    --surface: #1a2038;
    --surface-2: #222947;
    --ink: #e8eaf4;
    --muted: #a3abc8;
    --faint: #7d86a8;
    --border: #2b3355;
    --accent: #92a5f0;
    --accent-ink: #12162a;
    --accent-soft: #262f55;
    --go: #63c278;
    --go-soft: #1e3a2a;
    --danger: #e0748a;
    --danger-soft: #3d2230;
    --s1: #d4687a; --s2: #d99b41; --s3: #cbb54e; --s4: #86bb6c; --s5: #5aac55;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 1rem 5rem;
}
#app { max-width: 860px; margin: 0 auto; }
h1 { font-size: 1.7rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 0.8rem; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
input, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
  width: 100%;
}
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin: 0.9rem 0 0.25rem; }

.topbar {
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 1.6rem 0 1.2rem;
}
.topbar .who { margin-left: auto; font-size: 0.8rem; color: var(--faint); }
.topbar .who button {
  background: none; border: none; color: var(--accent);
  font-size: 0.8rem; padding: 0; margin-left: 0.5rem; text-decoration: underline;
}
.pill {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.2rem 0.65rem; border-radius: 99px;
}
.pill.open { background: var(--accent-soft); color: var(--accent); }
.pill.voting { background: var(--go-soft); color: var(--go); }
.pill.finalized { background: var(--surface-2); color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.card.admin { border-left: 4px solid var(--accent); }
.card.login { max-width: 420px; margin: 5rem auto; text-align: center; }
.card.login #gsi-btn { display: flex; justify-content: center; margin-top: 1.2rem; }
.empty { text-align: center; color: var(--muted); padding: 4rem 1rem; }

.btn {
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 7px;
  padding: 0.55rem 1.1rem; font-weight: 600;
}
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.go { background: var(--go); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btnrow { display: flex; gap: 0.6rem; margin-top: 1.1rem; flex-wrap: wrap; }

.game {
  display: flex; gap: 0.9rem; align-items: flex-start;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.game:last-child { border-bottom: none; }
.game .icon {
  width: 52px; height: 52px; border-radius: 12px; flex: none;
  position: relative;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--muted); overflow: hidden;
}
.game .icon img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.game .body { flex: 1; min-width: 0; }
.game .name { font-weight: 700; }
.game .links { font-size: 0.82rem; margin: 0.1rem 0; }
.game .links a { margin-right: 0.8rem; }
.game .notes { font-size: 0.85rem; color: var(--muted); white-space: pre-wrap; }
.game .by { font-size: 0.75rem; color: var(--faint); margin-top: 0.2rem; }
.game .ops { display: flex; gap: 0.4rem; flex: none; }
.game .ops button {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.25rem 0.6rem; font-size: 0.78rem; color: var(--muted);
}

.legend { display: grid; gap: 0.35rem; margin: 0.6rem 0 1rem; }
.legend .row { display: flex; gap: 0.6rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.chip {
  width: 1.7rem; height: 1.7rem; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #1b2340;
  font-variant-numeric: tabular-nums;
}
.chip.c1 { background: var(--s1); } .chip.c2 { background: var(--s2); }
.chip.c3 { background: var(--s3); } .chip.c4 { background: var(--s4); }
.chip.c5 { background: var(--s5); }
.chip.dim { opacity: 0.25; }

.scorepick { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.scorepick button {
  width: 2.4rem; height: 2.4rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface);
  font-weight: 700; color: var(--muted);
}
.scorepick button.sel { border-color: var(--ink); color: #1b2340; }
.scorepick button.sel.c1 { background: var(--s1); }
.scorepick button.sel.c2 { background: var(--s2); }
.scorepick button.sel.c3 { background: var(--s3); }
.scorepick button.sel.c4 { background: var(--s4); }
.scorepick button.sel.c5 { background: var(--s5); }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); padding: 0.45rem 0.6rem; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.band td {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.4rem 0.6rem;
}
.band.go td { background: var(--go-soft); color: var(--go); }
.band.rest td { background: var(--surface-2); color: var(--muted); }
.sbadge {
  display: inline-block; min-width: 3.4rem; text-align: center;
  padding: 0.2rem 0.5rem; border-radius: 99px; font-weight: 700;
  background: var(--s2); color: #1b2340; font-variant-numeric: tabular-nums;
}
.sbadge.go { background: var(--go); color: #fff; }
.resicon {
  width: 30px; height: 30px; border-radius: 8px; vertical-align: middle;
  margin-right: 0.5rem; background: var(--surface-2); object-fit: cover;
}
.meta { font-size: 0.8rem; color: var(--faint); margin-bottom: 0.8rem; }

.people { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0 0.8rem; }
.person {
  font-size: 0.78rem; padding: 0.18rem 0.6rem; border-radius: 99px;
  background: var(--go-soft); color: var(--go); font-weight: 600;
}
.person.pending { background: var(--danger-soft); color: var(--danger); }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: var(--ground);
  padding: 0.6rem 1.2rem; border-radius: 8px; font-size: 0.88rem;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); color: #fff; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

.history { margin: 2rem 0 0; font-size: 0.85rem; color: var(--muted); }
.history select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.5rem;
  margin-left: 0.5rem;
}
