:root {
  --felt: #14532d;
  --felt-dark: #0f3d21;
  --paper: #fffdf7;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #b91c1c;
  --gold: #ca8a04;
  --ok: #15803d;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #f5f5f4;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: var(--felt); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; padding-top: max(0.6rem, env(safe-area-inset-top));
  background: var(--felt); color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
#nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
#nav a { color: #dcfce7; text-decoration: none; padding: 0.35rem 0.6rem; border-radius: 6px; font-size: 0.95rem; }
#nav a.active, #nav a:hover { background: var(--felt-dark); color: #fff; }

main { max-width: 960px; margin: 0 auto; padding: 1rem; padding-bottom: 4rem; }
h1 { font-size: 1.4rem; margin: 0.25rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; }
.card.link { display: block; color: inherit; text-decoration: none; }
.card.link:hover { border-color: var(--felt); }
.narrow { max-width: 420px; margin: 2rem auto; }

label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }
input, textarea, select {
  font: inherit; width: 100%; padding: 0.6rem 0.7rem; border: 1px solid #d6d3d1; border-radius: 8px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--felt); outline-offset: 0; border-color: var(--felt); }
textarea { min-height: 4rem; resize: vertical; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 8px;
  padding: 0.6rem 1rem; background: var(--felt); color: #fff; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--felt-dark); }
button.secondary, .btn.secondary { background: #e7e5e4; color: var(--ink); }
button.secondary:hover { background: #d6d3d1; }
button.danger { background: var(--accent); }
button.link { background: none; color: var(--accent); padding: 0.2rem 0.4rem; font-weight: 500; }
button:disabled { opacity: 0.5; cursor: default; }
.full { width: 100%; margin-top: 1rem; }

.error { color: var(--accent); background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 0.5rem 0.75rem; margin: 0.75rem 0; }
.notice { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 0.5rem 0.75rem; margin: 0.75rem 0; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.65rem; border-radius: 999px; background: #f5f5f4; border: 1px solid var(--line); font-size: 0.9rem; }
.chip.win { background: #fef9c3; border-color: #fde047; font-weight: 700; }
.chip .pts { font-variant-numeric: tabular-nums; color: var(--muted); }
.badge { font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: #e7e5e4; color: var(--ink); }
.badge.live { background: #dcfce7; color: var(--ok); }
.badge.guest { background: #e0e7ff; color: #3730a3; }

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.4rem; }
.pick { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 500; margin: 0; }
.pick input { width: auto; margin: 0; }
.pick.on { border-color: var(--felt); background: #f0fdf4; }
.seat { margin-left: auto; font-size: 0.8rem; color: var(--ok); font-weight: 700; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
table.scores { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.scores th, table.scores td { border-bottom: 1px solid var(--line); padding: 0.35rem; text-align: center; white-space: nowrap; }
table.scores thead th { background: #fafaf9; font-size: 0.9rem; position: sticky; top: 0; }
table.scores th.hand { position: sticky; left: 0; background: #fafaf9; min-width: 3.2rem; text-align: left; padding-left: 0.7rem; }
table.scores tfoot td, table.scores tfoot th { font-weight: 800; background: #f5f5f4; font-size: 1.05rem; border-bottom: 0; }
table.scores tfoot th.hand { background: #f5f5f4; }
table.scores td.win { background: #fef9c3; }
table.scores input { width: 3.6rem; text-align: center; padding: 0.45rem 0.25rem; font-variant-numeric: tabular-nums; }
table.scores input.saving { border-color: var(--gold); }
table.scores input.saved { border-color: var(--ok); }
table.scores input.failed { border-color: var(--accent); background: #fef2f2; }
table.scores .readonly { display: inline-block; min-width: 3rem; }
.colhead { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }

.invite-link { word-break: break-all; font-family: ui-monospace, monospace; font-size: 0.85rem; background: #f5f5f4; padding: 0.5rem; border-radius: 6px; }
.member { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member .invite-link { margin-top: 0.5rem; }

.mt-0 { margin-top: 0; }
.mt-half { margin-top: 0.5rem; }
.mt-1 { margin-top: 1rem; }
.grow { flex: 1; min-width: 10rem; }
.add-player { max-width: 16rem; margin-top: 0.75rem; }
.narrow.left { margin-left: 0; }
button.remove { background: none; color: #a8a29e; font-size: 0.75rem; font-weight: 500; padding: 0.1rem 0.3rem; }
button.remove:hover { background: #fef2f2; color: var(--accent); }
