:root {
  --blue: #0b3a8c;
  --blue-dark: #082b68;
  --blue-light: #d4e6fb;
  --amber: #f6b829;
  --amber-ink: #3d2b00;
  --grey: #e3e6ea;
  --grey-ink: #3a4250;
  --ink: #16202e;
  --muted: #5b6575;
  --line: #d6dbe2;
  --bg: #ffffff;
  --bg-soft: #f4f6f9;
  --danger: #b42318;
  --success: #146c2e;
  --radius: 12px;
  --tap: 48px;
  font-size: 100%;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.45;
}

[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

main.wrap { flex: 1; padding-top: 20px; padding-bottom: 32px; }

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

:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* Header and footer */
.site-header { background: var(--blue); color: #fff; }

/* Compact on phones (one line), roomier from 560px */
.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.logo {
  display: block;
  width: 56px;
  height: 38px;
  flex: none;
  border-radius: 8px;
  background: #fff url("../img/logo.svg") center / 48px auto no-repeat;
}

.header-title { flex: 1 1 auto; min-width: 0; }
.header-title h1 { margin: 0; font-size: 1.15rem; line-height: 1.15; letter-spacing: 0.01em; }
.updated { margin: 2px 0 0; font-size: 0.75rem; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; gap: 6px; flex: none; }

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.header-link:hover { background: rgba(255, 255, 255, 0.12); }

@media (min-width: 560px) {
  .header-inner { gap: 14px; padding-top: 12px; padding-bottom: 12px; }
  .logo { width: 84px; height: 54px; border-radius: 10px; background-size: 72px auto; }
  .header-title h1 { font-size: 1.6rem; line-height: 1.1; }
  .updated { font-size: 0.875rem; }
  .header-actions { gap: 8px; }
  .header-link { padding: 0 14px; border-width: 2px; font-size: 0.9375rem; }
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
  padding: 18px 0 24px;
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border: 2px solid var(--blue);
  border-radius: 10px;
  background: #fff;
  color: var(--blue);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--bg-soft); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-big { min-height: 60px; font-size: 1.2rem; padding: 0 28px; width: 100%; }

/* Login */
.login { max-width: 420px; margin: 24px auto; }
.login h2 { margin-top: 0; }
.login label { display: block; font-weight: 700; margin-bottom: 6px; }
.login .btn { width: 100%; margin-top: 12px; }

input, textarea, select {
  font: inherit;
  color: inherit;
}

.text-input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.text-input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-light); }
textarea.text-input { min-height: 96px; resize: vertical; }

.error-text { color: var(--danger); font-weight: 600; margin: 8px 0 0; }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--bg-soft); }

/* Filter chips */
.chips { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.chip {
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--blue);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--blue); color: #fff; }
.chips .help-toggle { flex: none; }
@media (min-width: 560px) {
  .chips { gap: 8px; margin-bottom: 18px; }
  .chip { padding: 0 18px; font-size: 1rem; }
}

/* Match rows */
.month {
  margin: 24px 0 8px;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.list > .month:first-child { margin-top: 4px; }

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

/* Phones: full-width lines.
   [date · time .......... status]
   [club / place / note ... + Calendar]   (planner: buttons on their own line) */
.row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "when status"
    "main actions";
  column-gap: 12px;
  row-gap: 4px;
  align-items: center;
  padding: 10px 14px 12px 18px;
  border-top: 1px solid var(--line);
}
.page-admin .row {
  grid-template-areas:
    "when status"
    "main main"
    "actions actions";
}
.row:first-child { border-top: 0; }
.row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--status-colour, var(--grey));
}
.row.status-confirmed { --status-colour: var(--blue); }
.row.status-tentative { --status-colour: #8dbdf2; }
.row.status-hold_the_date { --status-colour: var(--amber); }
.row.status-reaching_out { --status-colour: #b8bfc9; }
.row.past { --status-colour: var(--line); background: var(--bg-soft); }

.row-when { grid-area: when; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; line-height: 1.2; }
.row-weekday { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.row-date { font-size: 1rem; font-weight: 800; white-space: nowrap; }
.row-time { font-size: 0.9375rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.row-time::before { content: "\00b7\00a0"; }

.row-main { grid-area: main; min-width: 0; }
.row-opponent { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.row-meta { margin: 2px 0 0; font-size: 0.9375rem; color: var(--muted); }
.row-meta a { color: var(--blue); font-weight: 600; }
.row-note { margin: 2px 0 0; font-size: 0.9375rem; font-style: italic; color: var(--muted); overflow-wrap: anywhere; }

.row-status { grid-area: status; justify-self: end; }
.row-actions { grid-area: actions; display: flex; gap: 8px; justify-content: flex-end; }
.page-admin .row-actions { margin-top: 8px; }
.row-actions .btn { flex: 1; min-height: 44px; padding: 0 16px; }

/* Wide screens: one line per match with a date column. */
@media (min-width: 768px) {
  .row,
  .page-admin .row {
    grid-template-columns: 96px minmax(0, 1fr) 128px var(--actions-width, 0px);
    grid-template-areas: "when main status actions";
    column-gap: 18px;
    row-gap: 0;
    padding: 12px 18px 12px 22px;
  }
  .row-when { flex-direction: column; align-items: flex-start; gap: 0; }
  .row-date { font-size: 1.1rem; }
  .row-time { margin-top: 2px; }
  .row-time::before { content: none; }
  .row-meta { margin-top: 3px; }
  .row-note { margin-top: 4px; }
  .row-status { justify-self: start; }
  .page-admin .row-actions { margin-top: 0; }
  .row-actions .btn { flex: none; }
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-status-confirmed { background: var(--blue); color: #fff; }
.badge-status-tentative { background: var(--blue-light); color: var(--blue-dark); }
.badge-status-hold_the_date { background: var(--amber); color: var(--amber-ink); }
.badge-status-reaching_out { background: var(--grey); color: var(--grey-ink); }
.badge-result { background: #fff; border: 2px solid var(--blue); color: var(--blue); }
.badge-result-loss, .badge-result-none { border-color: var(--line); color: var(--grey-ink); }

.link-button {
  border: 0;
  padding: 0 4px;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: underline;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
}
.section-title { font-size: 1.2rem; margin: 30px 0 12px; }

.empty { font-size: 1.15rem; color: var(--muted); padding: 24px 0; }

details.past-block { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 8px; }
details.past-block > summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
details.past-block > summary::-webkit-details-marker { display: none; }
details.past-block > summary::before { content: "\25B8"; display: inline-block; width: 1.2em; color: var(--blue); }
details.past-block[open] > summary::before { content: "\25BE"; }
details.past-block[open] > summary { margin-bottom: 12px; }

/* Admin */
.admin-top { display: grid; gap: 12px; margin-bottom: 8px; }

.flash {
  padding: 14px 16px;
  border-radius: 10px;
  background: #e7f6ec;
  color: var(--success);
  font-weight: 700;
  font-size: 1.1rem;
}

.editor { max-width: 640px; margin: 0 auto; }
.editor h2 { margin-top: 0; font-size: 1.5rem; }

.field { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; padding: 0; }
.field .hint { color: var(--muted); font-weight: 400; font-size: 0.9375rem; }

.toggle-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-group { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .status-group { grid-template-columns: 1fr 1fr; } }

.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
}
.toggle-group .choice span { justify-content: center; }
.choice input:checked + span { border-color: var(--blue); background: var(--blue); color: #fff; }
.choice input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 2px; }

.status-group .choice input:checked + span { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px var(--blue); }
.swatch { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 1px solid rgba(0, 0, 0, 0.15); }
.swatch-reaching_out { background: var(--grey); }
.swatch-hold_the_date { background: var(--amber); }
.swatch-tentative { background: var(--blue-light); }
.swatch-confirmed { background: var(--blue); }
.choice .check { margin-left: auto; visibility: hidden; color: var(--blue); font-size: 1.3rem; }
.choice input:checked + span .check { visibility: visible; }

.score-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.score-row label { display: block; font-weight: 600; margin-bottom: 4px; }
.score-row .text-input { width: 110px; font-size: 1.3rem; text-align: center; }
.score-outcome { font-weight: 800; font-size: 1.15rem; min-height: var(--tap); display: flex; align-items: center; }

.editor-actions { display: grid; gap: 10px; margin-top: 8px; }
@media (min-width: 560px) { .editor-actions { grid-template-columns: 2fr 1fr; } }

.form-error { margin: 0 0 18px; padding: 12px 16px; border-radius: 10px; background: #fdecea; color: var(--danger); font-weight: 700; }

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

/* Width reserved for row buttons on wide screens, so statuses line up. */
.page-overview { --actions-width: 96px; }
.page-admin { --actions-width: 220px; }

/* "?" help */
.help-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  vertical-align: middle;
}
.help-toggle[aria-expanded="true"] { background: var(--blue); color: #fff; }
.legend-with-help { display: flex; align-items: center; gap: 10px; }
.legend-with-help .help-toggle { width: 36px; height: 36px; }

.status-help {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.status-help dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: start; }
.status-help dt { margin: 0; }
.status-help dd { margin: 0; font-size: 0.9375rem; line-height: 1.4; }

/* Footer */
.site-footer p { margin: 0; }
.site-footer .copyright { margin-top: 4px; font-size: 0.8125rem; }
.site-footer a { color: inherit; }

/* Hidden on screen, still read by screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Shorter button labels on phones */
.wide-only { display: none; }
@media (min-width: 560px) {
  .wide-only { display: inline; }
  .narrow-only { display: none; }
}
