/* Popitz Semmeln: colours from the club badge (court green, roll-crust brown, flour cream).
   Layout: one narrow column of Thursday cards, phone first. */
:root {
  --page: #f6efdc;
  --paper: #fffaf0;
  --ink: #1f2a22;
  --muted: #6b705f;
  --line: #e2d6b8;
  --brand: #1f5434;
  --brand-ink: #fff8e6;
  --crust: #b97a2c;
  --bread: #f3dca0;
  --yes: #2d8547;
  --maybe: #c08414;
  --no: #b6463a;
  --open: #a39d88;
  --focus: #e0a43a;
  --radius: 14px;
  --font-display: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #111813;
    --paper: #19231c;
    --ink: #eee7d2;
    --muted: #a2a690;
    --line: #2d3a30;
    --brand: #163d26;
    --brand-ink: #fff3d6;
    --crust: #dba65a;
    --bread: #4a3a1c;
    --yes: #58b973;
    --maybe: #e2a93c;
    --no: #e07264;
    --open: #7d8270;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
}
a { color: var(--brand); }
@media (prefers-color-scheme: dark) { a { color: var(--crust); } }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
h2 { font-size: 1.35rem; }
p { margin: 0; }

/* Masthead: court green with a white baseline like a court's back line. */
.masthead {
  background: var(--brand);
  color: var(--brand-ink);
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 4px solid #f6f1e2;
  box-shadow: 0 6px 0 var(--brand);
  margin-bottom: 28px;
}
.masthead-inner {
  display: flex;
  flex-wrap: wrap; /* on small phones the name pill / admin menu moves to its own line */
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding-block: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand img { width: 64px; height: 64px; flex: none; margin: -4px 0 -14px; }
.brand strong { display: block; font-family: var(--font-display); font-size: 1.35rem; letter-spacing: 0.01em; white-space: nowrap; }
.brand small { display: block; opacity: 0.8; font-size: 0.8rem; white-space: nowrap; }
@media (max-width: 440px) {
  .brand { gap: 10px; }
  .brand img { width: 52px; height: 52px; }
  .brand strong { font-size: 1.12rem; }
  .admin-nav a { padding: 4px 8px; }
}
.me {
  flex: none;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--brand-ink);
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--brand-ink) 45%, transparent);
  border-radius: 999px;
  padding: 4px 12px;
}
.admin-nav { display: flex; gap: 4px; flex: none; margin-left: auto; }
.me { margin-left: auto; }
.admin-nav a {
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 4px 10px;
  border-radius: 999px;
}
.admin-nav a[aria-current="page"] { background: color-mix(in srgb, var(--brand-ink) 18%, transparent); }

main { display: flex; flex-direction: column; gap: 20px; padding-bottom: 24px; }
.cards { display: flex; flex-direction: column; gap: 20px; }

/* Panels and cards */
.panel, .card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.panel.narrow { max-width: 420px; }
.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--crust);
  margin: 0;
}
.eyebrow a { color: inherit; }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.time {
  flex: none;
  font: 700 0.8rem/1.15 var(--font-display);
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--brand-ink);
  background: var(--brand);
  border-radius: 8px;
  padding: 6px 8px;
}

/* Tally */
.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.t {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 3px solid currentColor;
  padding-top: 4px;
}
.t b { font: 700 1.4rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.t.yes { color: var(--yes); }
.t.maybe { color: var(--maybe); }
.t.no { color: var(--no); }
.t.open { color: var(--open); }

/* Answer buttons */
.answer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
button, .button {
  font: 600 0.95rem/1.2 var(--font-body);
  border-radius: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.answer button { --c: var(--ink); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); color: var(--c); }
.answer .yes { --c: var(--yes); }
.answer .maybe { --c: var(--maybe); }
.answer .no { --c: var(--no); }
.answer button[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.answer button[aria-pressed="true"]::before { content: "✓"; }
.htmx-request .answer button, .answer.htmx-request button { opacity: 0.6; }

.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.secondary { background: transparent; }
.danger { background: var(--no); border-color: var(--no); color: #fff; }
.ghost-danger { background: transparent; color: var(--no); border-color: color-mix(in srgb, var(--no) 40%, var(--line)); }
button.link { background: none; border: none; padding: 0; min-height: 0; color: var(--brand); text-decoration: underline; font-weight: 400; }
@media (prefers-color-scheme: dark) {
  .primary { background: #2c6b45; border-color: #2c6b45; }
  button.link { color: var(--crust); }
}

/* Roster */
.roster { display: flex; flex-direction: column; gap: 6px; border-top: 1px dashed var(--line); padding-top: 12px; }
.group { display: flex; align-items: baseline; gap: 10px; }
.group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.group li.is-open { color: var(--muted); }
.self { font-weight: 700; }
.dot { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--open); margin-right: 6px; }
.dot.yes { background: var(--yes); }
.dot.maybe { background: var(--maybe); }
.dot.no { background: var(--no); }

/* Cancelled */
.card.cancelled { background: color-mix(in srgb, var(--paper) 60%, var(--page)); }
.card.cancelled h2 { text-decoration: line-through; text-decoration-color: var(--no); text-decoration-thickness: 2px; }
.cancel-note { display: flex; align-items: center; gap: 14px; }
.cancel-note img { opacity: 0.45; filter: grayscale(0.6); width: 72px; height: 72px; }
.stamp {
  display: inline-block;
  font: 800 1.1rem var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--no);
  border: 2px solid var(--no);
  border-radius: 6px;
  padding: 2px 10px;
  transform: rotate(-3deg);
  margin-bottom: 4px;
}

/* Line-up display */
.lineup { display: flex; flex-direction: column; gap: 10px; background: color-mix(in srgb, var(--bread) 35%, var(--paper)); border-radius: 10px; padding: 12px; }
.round { display: flex; flex-direction: column; gap: 6px; }
.round-head { font: 700 0.9rem var(--font-display); }
.round-head span { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 6px; }
.court {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: var(--brand);
  color: var(--brand-ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
}
.court-empty { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.court-no { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; white-space: nowrap; }
.side { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.side:last-child { text-align: right; }
.vs { font-size: 0.7rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.08em; }
.pl.out { text-decoration: line-through; opacity: 0.7; }
.pause { font-size: 0.85rem; color: var(--muted); }
.pause > span:first-child { font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.08em; margin-right: 6px; }
@media (max-width: 420px) {
  .court { grid-template-columns: 1fr auto 1fr; }
  .court-no { grid-column: 1 / -1; }
}

/* Name picker */
.picker { border: 2px solid var(--crust); }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pick { justify-content: flex-start; text-align: left; }
.pick.current { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--paper)); }

/* Feedback */
.flash, .warn, .error { border-radius: 10px; padding: 10px 14px; font-size: 0.95rem; }
.flash { background: color-mix(in srgb, var(--yes) 15%, var(--paper)); border: 1px solid color-mix(in srgb, var(--yes) 40%, var(--line)); margin-bottom: 4px; }
.warn { background: color-mix(in srgb, var(--maybe) 15%, var(--paper)); border: 1px solid color-mix(in srgb, var(--maybe) 45%, var(--line)); }
.error { background: color-mix(in srgb, var(--no) 14%, var(--paper)); border: 1px solid color-mix(in srgb, var(--no) 45%, var(--line)); }
.warn ul, .error ul { margin: 4px 0 0; padding-left: 20px; }
.code { background: var(--page); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }

/* Forms */
input, select {
  font: inherit;
  color: var(--ink);
  background: var(--page);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  min-height: 44px;
  min-width: 0;
  max-width: 100%;
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline input { flex: 1 1 180px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Admin rows */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: none; }
.row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.row.is-cancelled .row-main strong { text-decoration: line-through; }
.mini-tally { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--muted); }
.mini-tally .yes { color: var(--yes); font-weight: 700; }
.mini-tally .maybe { color: var(--maybe); font-weight: 700; }
.mini-tally .no { color: var(--no); font-weight: 700; }
.badge { font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.badge.yes { background: color-mix(in srgb, var(--yes) 18%, transparent); color: var(--yes); }
.badge.maybe { background: color-mix(in srgb, var(--maybe) 20%, transparent); color: var(--maybe); }
.badge.no { background: color-mix(in srgb, var(--no) 16%, transparent); color: var(--no); }
.cancel-box summary { cursor: pointer; color: var(--no); font-size: 0.9rem; padding: 10px 4px; }
.cancel-box[open] { flex-basis: 100%; }
.hidden-players summary { cursor: pointer; color: var(--muted); }
.players .row { flex-wrap: nowrap; gap: 6px; padding: 8px 0; }
.players .row .inline { flex-wrap: nowrap; gap: 6px; }
.players .row input { flex: 1 1 auto; width: 100%; }
.players .row button { padding: 8px 10px; font-size: 0.85rem; }

/* Line-up editor */
.status-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.9rem; }
.pool p { font-size: 0.9rem; }
.round-edit { margin: 0; }
.round-edit legend { font: 700 1.1rem var(--font-display); padding: 0 6px; }
.round-edit legend span { font-weight: 400; color: var(--muted); font-size: 0.9rem; }
.court-edit {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 8%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line));
}
.court-edit .court-no { grid-column: 1 / -1; color: var(--brand); opacity: 1; font-weight: 700; }
@media (prefers-color-scheme: dark) { .court-edit .court-no { color: var(--crust); } }
.side-edit { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.side-edit select { width: 100%; }
.court-edit .vs { color: var(--muted); }
@media (max-width: 520px) {
  /* Stack the two sides so full names fit in the dropdowns. */
  .court-edit { grid-template-columns: 1fr; }
  .court-edit .vs { text-align: center; }
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.finish { border: 2px solid var(--brand); }
.finish .big { width: 100%; font-size: 1.1rem; min-height: 52px; }
.unsaved { font-weight: 600; color: var(--maybe); }
#lineup-form { display: flex; flex-direction: column; gap: 20px; }

/* Stats */
.range label { font-size: 0.9rem; color: var(--muted); }
.range .field { display: flex; align-items: center; gap: 8px; }
.range label { width: 2.2em; }
.range input { flex: 0 1 170px; }
.summary { font-size: 1.05rem; }
.table-scroll { overflow-x: auto; margin: 0 -4px; }
table.stats { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.stats th, .stats td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.stats th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); cursor: pointer; user-select: none; }
.stats th[aria-sort="descending"]::after { content: " ▼"; }
.stats th[aria-sort="ascending"]::after { content: " ▲"; }
.stats .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats tr.muted td { color: var(--muted); }
.quote { position: relative; display: inline-flex; justify-content: flex-end; width: 72px; border-radius: 4px; overflow: hidden; background: color-mix(in srgb, var(--yes) 10%, transparent); }
.quote-bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--yes) 35%, transparent); }
.quote span:last-child { position: relative; padding: 0 6px; }
.history { border-top: 1px solid var(--line); padding: 10px 0; }
.history summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.history[open] { display: flex; flex-direction: column; gap: 8px; }

.footer { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; padding-block: 8px 32px; font-size: 0.85rem; color: var(--muted); }
.footer a { color: var(--muted); }
.footer button.link { color: var(--muted); font-size: inherit; }

@media (prefers-reduced-motion: no-preference) {
  .answer button { transition: background-color 0.15s, color 0.15s; }
}
