:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2e2e0;
  --accent: #2f6f4e;
  --surface: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --fg: #e9e9ea;
    --muted: #9a9aa1;
    --line: #2c2d31;
    --accent: #6cc79a;
    --surface: #1e1f23;
  }
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--fg);
}

.topbar nav {
  display: flex;
  gap: 1rem;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
}

.topbar nav a:hover {
  color: var(--fg);
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

h1 {
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
}

.session {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.badge {
  background: var(--accent);
  color: var(--surface);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.linkish:hover {
  color: var(--fg);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.cards {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card h2 {
  font-size: 1.05rem;
  margin: 0;
}

.desc {
  margin: 0.4rem 0 0;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0.5rem 0 0;
}

.actions {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-top: 0.7rem;
}

.actions form {
  display: inline;
}

.danger {
  color: #b3261e;
}

.warn {
  background: #fdf0d5;
  color: #7a5200;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 650;
}

.error {
  background: #fdecea;
  border: 1px solid #f3b8b2;
  color: #8c1d18;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
}

.stack {
  display: grid;
  gap: 1rem;
  max-width: 42rem;
}

.stack label {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
}

.stack .check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--fg);
  width: 100%;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
}

.row {
  display: flex;
  gap: 1.2rem;
  align-items: end;
  flex-wrap: wrap;
}

.row > label {
  flex: 1 1 12rem;
}

.hero {
  text-align: center;
  padding: 4rem 1rem;
}

.section {
  margin-top: 2.2rem;
  font-size: 1.05rem;
}

.start-room {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
}

.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 44rem) {
  .room {
    grid-template-columns: 1fr;
  }
}

.grid {
  display: grid;
  gap: 0.4rem;
}

.grid.size-3 { grid-template-columns: repeat(3, 1fr); }
.grid.size-4 { grid-template-columns: repeat(4, 1fr); }
.grid.size-5 { grid-template-columns: repeat(5, 1fr); }

.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.25;
  cursor: pointer;
  overflow: hidden;
  hyphens: auto;
}

.cell:hover:not(:disabled) {
  border-color: var(--accent);
}

.cell.marked {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.cell.free {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.cell:disabled {
  cursor: default;
  opacity: 0.85;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.panel h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.roster,
.placings {
  margin: 0;
  padding: 0 0 0 0;
  list-style: none;
}

.placings {
  padding-left: 0;
}

.roster li,
.placings li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.9rem;
}

.roster .name {
  flex: 1;
}

.roster .progress {
  color: var(--muted);
  font-size: 0.8rem;
}

.place {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

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

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 10;
}

.toast {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.scores {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.scores th,
.scores td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.scores tbody tr:last-child td {
  border-bottom: 0;
}

.scores th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.scores .num {
  text-align: right;
}

.scores .rank {
  color: var(--muted);
  width: 2rem;
}

.scores tr.me {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.avatar {
  border-radius: 50%;
  vertical-align: middle;
  flex: none;
}

.whoami {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.scores .who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
