:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f0f3f2;
  --border: #dfe5e3;
  --text: #16201d;
  --muted: #5d6b66;
  --accent: #0f7b5f;
  --accent-soft: #e2f2ec;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf3e0;
  --male: #1d5fa8;
  --male-soft: #e6eefa;
  --female: #a33a72;
  --female-soft: #fae8f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 28, .06), 0 8px 24px rgba(16, 32, 28, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --surface: #171f1d;
    --surface-2: #1e2725;
    --border: #2c3835;
    --text: #e8efec;
    --muted: #9aaaa4;
    --accent: #35c39a;
    --accent-soft: #17332b;
    --accent-text: #04140f;
    --danger: #ff8a80;
    --danger-soft: #35201e;
    --warn: #f0c274;
    --warn-soft: #33280f;
    --male: #7fb2f0;
    --male-soft: #16283d;
    --female: #f09ac8;
    --female-soft: #351d2b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap { max-width: 940px; margin: 0 auto; padding: 20px 16px 64px; }
.narrow { max-width: 460px; }

header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
header.top .inner {
  max-width: 940px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.spacer { flex: 1; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 8px; }
p.sub { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--muted); }

input[type=text], input[type=tel], input[type=email], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 110px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; min-width: 0; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 9px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
}
button:hover:not(:disabled) { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); filter: none; }
button.danger { background: transparent; color: var(--danger); border-color: var(--border); }
button.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
button.full { width: 100%; }

.msg { padding: 10px 12px; border-radius: 9px; font-size: 14px; margin-bottom: 12px; }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.msg.ok { background: var(--accent-soft); color: var(--accent); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.hidden, .hidden { display: none !important; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.m { background: var(--male-soft); color: var(--male); border-color: transparent; }
.pill.f { background: var(--female-soft); color: var(--female); border-color: transparent; }

.tag-m { color: var(--male); font-weight: 700; font-size: 11px; }
.tag-f { color: var(--female); font-weight: 700; font-size: 11px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.court {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 12px; margin-bottom: 10px;
}
.court-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px;
}
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.team { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px; }
.team.won { border-color: var(--accent); background: var(--accent-soft); }
.team .who { font-weight: 600; }
.team .who + .who { margin-top: 3px; }
.vs { font-size: 12px; font-weight: 700; color: var(--muted); }
.score-box { display: flex; align-items: center; gap: 6px; margin-top: 10px; justify-content: center; }
.score-box input { width: 62px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-final { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; margin-top: 8px; }
.score-final .dim { color: var(--muted); font-weight: 500; }

.rules li { margin-bottom: 7px; }
.rules { padding-left: 20px; margin: 0; color: var(--text); }

.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item.inactive { opacity: .5; }
/* The one game a sign-up link was sent for, so it is not a list to search. */
.list-item.spotlight {
  background: var(--accent-soft); border-radius: 10px;
  padding: 10px; margin: 4px -10px; border-bottom: none;
}

.link-box {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px;
}
.link-box code {
  flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.tour-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  font-weight: 400;
}
.tour-item:hover { background: var(--surface-2); filter: none; }
.tour-item .name { font-weight: 700; }
.tour-item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

.code-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--warn-soft); color: var(--warn);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}

.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.stack > * + * { margin-top: 16px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .teams { grid-template-columns: 1fr; }
  .vs { text-align: center; }
  header.top .inner { gap: 8px; flex-wrap: nowrap; }
  /* The language switcher needs the room; the identity pill is decorative. */
  header.top #who { display: none; }
  header.top .brand {
    font-size: 14px; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  header.top .brand > span:last-child {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  header.top button.small { white-space: nowrap; padding: 6px 9px; }
}

.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch button.lang {
  border: none; border-radius: 0; background: transparent; color: var(--muted);
  padding: 5px 9px; font-size: 12px; font-weight: 700;
}
.lang-switch button.lang + button.lang { border-left: 1px solid var(--border); }
.lang-switch button.lang.on { background: var(--accent-soft); color: var(--accent); }
.lang-switch button.lang:hover:not(.on) { background: var(--surface-2); filter: none; }

.handicap {
  display: inline-block; margin-top: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn);
}
.handicap-note {
  margin: 8px 0 0; text-align: center;
  font-size: 12px; color: var(--muted);
}
.wave-head {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.wave-head::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.wave-head:first-child { margin-top: 0; }

.board-link {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: var(--text);
}
.board-link:hover { background: var(--surface-2); }
.board-link > span:first-child { flex: 1; min-width: 0; }

.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.tabs button {
  padding: 6px 12px; font-size: 13px; font-weight: 700; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.tabs button:hover:not(.on) { background: var(--surface); filter: none; }
.tabs button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tabs button .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-left: 5px; vertical-align: middle;
}
.tabs button.on .dot { background: var(--accent-text); }
.tabs button.draft { border-style: dashed; }

/* Page-level tabs sit above the cards and read a size up from the round pills,
   so the eye does not mistake one row of tabs for the other. */
.tabs.page-tabs { margin-bottom: 18px; }
.tabs.page-tabs button { padding: 9px 18px; font-size: 14px; }

/* The page-level alert floats over the viewport rather than sitting at the top
   of the document, where it is invisible once you have scrolled down a long
   round list. `top` is set in JS from the sticky header's real height. */
#msg:not(.hidden) {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: calc(100% - 32px);
  max-width: 720px;
  margin: 0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
  cursor: pointer;
}

/* ---------------------------------------------------------- your own page */

/* The personal panel is the one thing on the page that is about you, so it is
   the one thing with the accent border. */
.you-card {
  border: 1px solid var(--accent);
  background: linear-gradient(var(--accent-soft), var(--surface) 120px);
}
.you-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.you-head .name { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }

.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  flex: 1 1 88px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px;
}
.stat .k {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.stat .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .v small { font-size: 12px; font-weight: 600; color: var(--muted); }

.form-line { display: inline-flex; gap: 4px; vertical-align: middle; }
.form-line b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; font-size: 11px; font-weight: 800;
}
.form-line b.w { background: var(--accent-soft); color: var(--accent); }
.form-line b.l { background: var(--danger-soft); color: var(--danger); }

.next-up {
  margin-top: 14px; padding: 12px; border-radius: 10px;
  background: var(--surface); border: 1px dashed var(--accent);
}
.next-up .when {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent); margin-bottom: 4px;
}

/* One row per round: what happened, and where it left you. */
.timeline { display: flex; flex-direction: column; }
.tl {
  display: flex; gap: 12px; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.tl:last-child { border-bottom: none; }
.tl .rnd {
  flex: 0 0 34px; height: 34px; border-radius: 9px; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
  background: var(--surface-2); color: var(--muted);
}
.tl.win .rnd { background: var(--accent-soft); color: var(--accent); }
.tl.loss .rnd { background: var(--danger-soft); color: var(--danger); }
.tl .body { flex: 1; min-width: 0; font-size: 14px; }
.tl .body .with { color: var(--muted); font-size: 13px; }
.tl .score { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl .after { flex: 0 0 auto; font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

/* ------------------------------------------------------- organizer roster */

.roster-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.roster-row:last-child { border-bottom: none; }
.roster-row.inactive { opacity: .55; }
.roster-row .who { flex: 1 1 160px; min-width: 0; }
.roster-row .who .nm { font-weight: 600; }
.roster-row .who .contact {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.roster-row .acts { display: flex; gap: 6px; flex-wrap: wrap; }

.paid-tick {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  font-weight: 700; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.paid-tick.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.money-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* A drawer for the things an organizer needs rarely: editing contact details,
   swapping a player out. Closed, it is one line. */
details.drawer { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
details.drawer > summary {
  cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted);
  list-style: none;
}
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::before { content: '⌄ '; }
details.drawer[open] > summary::before { content: '⌃ '; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 12px; }
.seg button {
  flex: 1; border: none; border-radius: 0; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 700; padding: 9px 10px;
}
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.seg button:hover:not(.on) { background: var(--surface-2); filter: none; }

.log-row {
  display: flex; gap: 10px; align-items: baseline; padding: 6px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.log-row:last-child { border-bottom: none; }
.log-row .to { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------- club versus club */

.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 12px; align-items: center; margin: 4px 0 6px;
}
.team-score {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 12px; text-align: center;
}
.team-score.leading { border-color: var(--accent); background: var(--accent-soft); }
.team-score .club {
  font-size: 14px; font-weight: 700; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.team-score.leading .club { color: var(--accent); }
.team-score .tally {
  font-size: 40px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.team-score .sub { font-size: 12px; color: var(--muted); }
.scoreboard .versus { font-size: 13px; font-weight: 700; color: var(--muted); }

/* A QR code always sits on white, whatever the page is doing: a scanner
   needs the contrast, and a code that only works in light mode is a trap. */
.qr-box { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.qr-box a {
  display: block; background: #ffffff; padding: 8px; border-radius: 10px;
  border: 1px solid var(--border); line-height: 0;
}
.qr-box img { display: block; width: 150px; height: 150px; }
.qr-note { font-size: 13px; color: var(--muted); flex: 1 1 160px; }

/* The one-character club mark on a name two clubs share (奥 / 羽). Quiet
   enough to ignore when you already know who you mean. */
.club-tag {
  display: inline-block;
  font-size: .78em; font-weight: 700; line-height: 1;
  padding: .15em .3em; border-radius: 4px; vertical-align: baseline;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
