/* Padel Homies — Dutch flag palette (white / red #AE1C28 / blue #21468B) */

:root {
  --red: #AE1C28;
  --red-dark: #8d1620;
  --red-soft: #fdeced;
  --blue: #21468B;
  --blue-dark: #18336a;
  --blue-soft: #eaf0fb;
  --white: #ffffff;

  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --line: #e4e7ec;
  --line-2: #f2f4f7;
  --bg: #f7f8fa;

  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* stop iOS inflating text when the phone is turned sideways */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* no blue flash on tap, but keep real focus rings for keyboards */
button, .pick, .toggle { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; }
a  { color: var(--blue); }

/* ---------- Flag accent ---------- */
.flag-bar {
  height: 4px;
  background: linear-gradient(
    to bottom,
    var(--red) 0 33.33%,
    var(--white) 33.33% 66.66%,
    var(--blue) 66.66% 100%
  );
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--blue-soft), transparent 60%),
    radial-gradient(900px 460px at 92% 108%, var(--red-soft), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 396px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.login-body { padding: 28px; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 22px;
  min-width: 0;
}

/* avatar beside a form column — the column must be allowed to shrink */
.photo-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.photo-row > * { min-width: 0; }
.photo-row .grow { flex: 1; min-width: 0; }

/* club crest */
.crest {
  height: 34px;
  width: auto;
  display: block;
  flex: none;
}

.brand-stack { text-align: center; margin-bottom: 24px; }
.brand-stack .crest {
  height: 116px;
  margin: 0 auto 12px;
}

.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand-sub  { font-size: 12px; color: var(--ink-3); margin-top: -2px; }
.brand-stack .brand-name { font-size: 21px; }
.brand-stack .brand-sub { font-size: 12.5px; margin-top: 2px; }

/* ---------- App shell ---------- */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav {
  display: flex;
  gap: 3px;
  margin-left: 10px;
  flex-wrap: wrap;
  /* a flex item defaults to min-width:auto and refuses to shrink below its
     content — without this the tab row widens the whole page on a phone */
  min-width: 0;
}

.nav button {
  background: none;
  border: 0;
  padding: 8px 13px;
  border-radius: var(--r-sm);
  font: inherit;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
}
.nav button:hover { background: var(--line-2); color: var(--ink); }
.nav button.active { background: var(--blue); color: var(--white); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.who { text-align: right; line-height: 1.25; }
.who-name { font-weight: 600; font-size: 13px; }
.who-role { font-size: 11.5px; color: var(--ink-3); }

.main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 20px 64px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head .sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--line-2); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.btn-red { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-red:hover { background: var(--red-dark); border-color: var(--red-dark); }

.btn-ghost-red { color: var(--red); border-color: #f0c4c8; background: var(--white); }
.btn-ghost-red:hover { background: var(--red-soft); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  background: var(--line-2);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 550;
  font-size: 13px;
  color: var(--ink-2);
  padding: 6px 15px;
  border-radius: 5px;
  cursor: pointer;
}
.seg button.active {
  background: var(--white);
  color: var(--blue);
  box-shadow: var(--shadow);
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-body { padding: 16px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--r);
  padding: 12px 14px;
}
.stat.red { border-left-color: var(--red); }
.stat-v { font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.stat-l { font-size: 12px; color: var(--ink-2); }

/* ---------- Date bar ---------- */
.datebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.datebar .range {
  font-weight: 650;
  font-size: 15px;
  min-width: 210px;
}
.nav-btns { display: flex; gap: 4px; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 15px;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* ---------- Game card ---------- */
.game {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--r);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.game.evening { border-left-color: var(--red); }
.game-top { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-bottom: 3px; }
.game-time { font-weight: 700; font-size: 15px; }
.game-meta { font-size: 12.5px; color: var(--ink-2); margin-bottom: 9px; }
.game-actions { margin-top: 10px; display: flex; gap: 6px; }

.players { display: flex; flex-wrap: wrap; gap: 6px; }

.pchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  font-size: 12.5px;
  font-weight: 550;
}
.pchip.unavailable {
  opacity: .45;
  text-decoration: line-through;
  background: var(--white);
}
/* picked from outside the poule for this slot */
.pchip.guest {
  background: var(--white);
  border-style: dashed;
  border-color: var(--blue);
}
.pchip.empty {
  border-style: dashed;
  background: var(--white);
  color: var(--ink-3);
  padding: 3px 10px;
  font-weight: 500;
  font-style: italic;
}

/* ---------- Avatar ---------- */
.av {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--blue);
  color: var(--white);
  display: inline-grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  flex: none;
  overflow: hidden;
  text-transform: uppercase;
}
.av.lg { width: 46px; height: 46px; font-size: 16px; }
.av.xl { width: 84px; height: 84px; font-size: 28px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-blue { background: var(--blue-soft); color: var(--blue-dark); border-color: #d3e0f6; }
.badge-red  { background: var(--red-soft); color: var(--red-dark); border-color: #f5cdd1; }
.badge-ok   { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.badge-grey { background: var(--line-2); color: var(--ink-2); border-color: var(--line); }

/* ---------- Week grid ---------- */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}
.week-col {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-height: 130px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.week-col.today { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.week-col-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-2);
  background: #fbfcfe;
}
.week-col-head .d { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 650; }
.week-col-head .n { font-size: 16px; font-weight: 700; }
.week-col-body { padding: 8px; display: flex; flex-direction: column; gap: 7px; flex: 1; }

.mini {
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  background: var(--white);
}
.mini:hover { background: var(--line-2); }
.mini.evening { border-left-color: var(--red); }
.mini .t { font-weight: 700; font-size: 12.5px; }
.mini .l { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .p { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Month grid ---------- */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.month-head {
  background: #fbfcfe;
  padding: 8px 6px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.month-cell {
  background: var(--white);
  min-height: 104px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.month-cell.dim { background: #fbfbfc; }
.month-cell.dim .month-n { color: var(--ink-3); }
.month-cell.today .month-n {
  background: var(--blue);
  color: var(--white);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: grid; place-items: center;
}
.month-n { font-size: 12.5px; font-weight: 650; }
.month-chip {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  border-left: 2px solid var(--blue);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}
.month-chip.evening { background: var(--red-soft); color: var(--red-dark); border-left-color: var(--red); }
.month-chip:hover { filter: brightness(.96); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.field .hint { font-size: 11.5px; color: var(--ink-3); font-weight: 400; margin-top: 4px; }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  color: var(--ink);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
/* A file input has a wide intrinsic minimum. Left alone it refuses to shrink and
   pushes the whole card past the edge of a narrow phone. */
input[type="file"] {
  font-size: 12.5px;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- Availability grid ---------- */
.avail {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px 10px;
  align-items: center;
}
.avail-head { font-size: 11.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; text-align: center; }
.avail-day { font-weight: 600; font-size: 13px; }

.toggle {
  width: 62px;
  padding: 5px 0;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--white);
  color: var(--ink-3);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.toggle:hover { border-color: var(--ink-3); }
.toggle.on { background: var(--blue); border-color: var(--blue); color: var(--white); }
.toggle.on.eve { background: var(--red); border-color: var(--red); }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.is-unavailable td { opacity: .5; }
.tbl-wrap { overflow-x: auto; }

/* ---------- Poule ---------- */
.poule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(266px, 1fr)); gap: 14px; }
.poule-head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.poule-head.morning { background: var(--blue-soft); }
.poule-head.evening { background: var(--red-soft); }
.poule-title { font-weight: 700; font-size: 14px; }
.poule-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; }
.poule-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.poule-row.out { opacity: .42; text-decoration: line-through; }
.poule-row .why { margin-left: auto; font-size: 11px; }

/* ---------- Player picker ---------- */
.picker { display: flex; flex-direction: column; gap: 5px; max-height: 250px; overflow-y: auto; padding: 3px; }
.pick {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--white);
  cursor: pointer;
  font: inherit;
  text-align: left;
  width: 100%;
}
.pick:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-soft); }
.pick.sel { border-color: var(--blue); background: var(--blue-soft); }
.pick:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.pick .nm { font-weight: 600; font-size: 13px; }
.pick .tag { margin-left: auto; font-size: 11px; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,.5);
  display: grid;
  place-items: start center;
  padding: 32px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  width: 100%;
  max-width: 620px;
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal.narrow { max-width: 460px; }
.modal-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: #fbfcfe;
}
.x-btn {
  margin-left: auto;
  border: 0; background: none;
  font-size: 21px; line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0 4px;
}
.x-btn:hover { color: var(--ink); }

/* ---------- Misc ---------- */
.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-3);
}
.empty .big { font-size: 34px; margin-bottom: 8px; }

.alert {
  padding: 10px 13px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-err { background: var(--red-soft); color: var(--red-dark); border-color: #f5cdd1; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.alert-info { background: var(--blue-soft); color: var(--blue-dark); border-color: #d3e0f6; }

.email-prev {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px;
  font-size: 12.5px;
  white-space: pre-wrap;
  /* a long sign-in URL must not push the whole page sideways */
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  line-height: 1.6;
  color: var(--ink-2);
}

/* long names and email addresses must wrap rather than widen the card */
.card-head h3, .who-name, .pick .nm { overflow-wrap: anywhere; }
.card-head { flex-wrap: wrap; }

.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.sep { height: 1px; background: var(--line); margin: 18px 0; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: var(--white);
  padding: 11px 16px;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 550;
  z-index: 200;
  max-width: 340px;
}

/* ========================================================================
   Responsive — phones (iPhone and Android), tablets, desktop
   ======================================================================== */

/* Tablets and small laptops */
@media (max-width: 1000px) {
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-3 { grid-template-columns: 1fr; }
  .month-cell { min-height: 78px; }
  .month-chip { font-size: 10px; padding: 2px 4px; }
}

/* ---------------------------- Phones ---------------------------------- */
@media (max-width: 680px) {

  /* iOS zooms the page in when a focused input is under 16px. Never let that
     happen — every field goes to 16px on touch layouts. */
  input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
  input[type="date"], input[type="time"], input[type="number"], select, textarea {
    font-size: 16px;
    padding: 11px 12px;
  }

  body { font-size: 15px; }

  /* Comfortable touch targets everywhere */
  .btn { padding: 11px 16px; min-height: 44px; }
  .btn-sm { padding: 8px 12px; min-height: 38px; font-size: 13px; }
  .icon-btn { width: 44px; height: 44px; font-size: 18px; }
  .seg button { padding: 9px 16px; min-height: 40px; }
  .toggle { min-height: 44px; }
  .pick { min-height: 52px; padding: 9px 11px; }
  .nav button { padding: 10px 14px; min-height: 42px; }

  /* --- shell --- */
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px) * 0);
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .topbar-right { gap: 9px; }
  .who { display: none; }                 /* avatar + Sign out is enough */
  .topbar .brand-sub { display: none; }   /* header only — the sign-in screen keeps it */
  .brand-stack .crest { height: 96px; }

  /* The tab bar scrolls sideways rather than wrapping onto three rows */
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { white-space: nowrap; flex: none; }

  .main {
    padding: 16px 14px 56px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  h1 { font-size: 20px; }

  /* --- page header: action buttons go full width --- */
  .page-head { gap: 12px; }
  .page-head-actions { margin-left: 0; width: 100%; }
  .page-head-actions .btn { flex: 1; }

  /* --- stats: two across, not four --- */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat { padding: 10px 12px; }
  .stat-v { font-size: 20px; }

  /* --- date bar --- */
  .datebar { gap: 8px; }
  .datebar .range { min-width: 0; flex: 1; font-size: 14px; }
  .datebar .seg { width: 100%; margin-left: 0 !important; }
  .datebar .seg button { flex: 1; }

  /* --- week view: one day per row, empty days stay short --- */
  .week-grid { grid-template-columns: 1fr; gap: 8px; }
  .week-col { min-height: 0; }
  .week-col-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
  .week-col-head .n { font-size: 15px; }

  /* --- month view: no room for text, so show a dot per game --- */
  .month-cell { min-height: 54px; padding: 4px 3px; gap: 3px; }
  .month-n { font-size: 11px; }
  .month-cell.today .month-n { width: 19px; height: 19px; font-size: 10.5px; }
  .month-chip {
    font-size: 0;                 /* hide the label */
    padding: 0;
    height: 6px;
    border-radius: 3px;
    border-left: 0;
    background: var(--blue);
  }
  .month-chip.evening { background: var(--red); }
  .month-head { font-size: 9.5px; padding: 6px 2px; letter-spacing: 0; }

  /* --- forms --- */
  .av.xl { width: 64px; height: 64px; font-size: 22px; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  .card-body { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }

  /* --- availability grid: let the toggles breathe --- */
  .avail { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .toggle { width: 100%; }
  .avail-day { font-size: 12.5px; }

  /* --- poules --- */
  .poule-grid { grid-template-columns: 1fr; gap: 12px; }

  /* --- tables: on the players list drop the widest column --- */
  .tbl th, .tbl td { padding: 9px 10px; }
  .tbl-players th:nth-child(3), .tbl-players td:nth-child(3) { display: none; }

  /* --- games --- */
  .game { padding: 11px 12px; }
  .game-actions .btn { flex: 1; }

  /* --- modals become a sheet anchored to the bottom of the screen --- */
  .overlay {
    padding: 0;
    place-items: end stretch;
    overscroll-behavior: contain;
  }
  .modal {
    max-width: none;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 94vh;
    max-height: 94dvh;
    display: flex;
    flex-direction: column;
  }
  .modal.narrow { max-width: none; }
  .modal-head { padding: 14px 16px; position: sticky; top: 0; background: var(--white); z-index: 2; }
  .modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
  .modal-foot {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .modal-foot .btn { flex: 1; }
  .picker { max-height: none; }

  /* --- toast sits above the home indicator --- */
  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }
}

/* Very narrow phones (iPhone SE and similar) */
@media (max-width: 380px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .avail { grid-template-columns: 1fr auto auto; }
  .toggle { width: 74px; font-size: 11.5px; }
  .month-head { font-size: 9px; }
  .brand-name { font-size: 15px; }
}

/* Phones held sideways: keep the modal usable when the keyboard is up */
@media (max-height: 480px) and (orientation: landscape) {
  .modal { max-height: 100vh; border-radius: 0; }
  .overlay { place-items: stretch; }
}

/* ---------- Help links (open the player guide) ---------- */
.nav a.nav-help {
  display: inline-flex;
  align-items: center;
  padding: 8px 13px;
  border-radius: var(--r-sm);
  font-weight: 550;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  flex: none;
}
.nav a.nav-help:hover { background: var(--line-2); color: var(--ink); }
.login-help { margin: 16px 0 0; text-align: center; font-size: 13px; }
.login-help a { color: var(--blue); font-weight: 600; text-decoration: none; }
.login-help a:hover { text-decoration: underline; }

/* ---------- Booked, but has since registered unavailability ---------- */
.pick.sel.out { border-color: var(--red); background: var(--red-soft); }
.pick.sel.out .nm { text-decoration: line-through; }

@media (max-width: 680px) {
  .nav a.nav-help { padding: 10px 14px; min-height: 42px; }
}

/* ---------- talking to the server ---------- */
body.is-busy, body.is-busy * { cursor: progress !important; }
.loading { color: var(--ink-3); font-weight: 600; font-size: 15px; }
.setup-list { margin: 0 0 18px; padding-left: 20px; display: grid; gap: 10px; font-size: 13.5px; line-height: 1.5; }
.mail-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.card-head .badge + .badge { margin-left: 6px; }

/* ---------- Courts: the club booking page in a window ---------- */
a.btn { text-decoration: none; }
.datebar .court-date { width: auto; padding: 6px 10px; }
.courts-frame {
  display: block;
  width: 100%;
  height: 78vh;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  box-shadow: var(--shadow);
}
@media (max-width: 680px) {
  .courts-frame { height: 72vh; min-height: 480px; }
  .datebar .court-date { flex: 1; min-width: 0; }
}
@media (max-width: 680px) {
  /* Courts on a phone: the day in words gets its own line, the date field keeps its width */
  .courts-bar .range { flex-basis: 100%; order: 5; }
  .courts-bar .court-date { flex: 1 1 150px; }
}
