/* Layout: photo-led hero with a scoreboard strip, then one 1100px column; sections open on a court service-line rule. */
:root {
  --ground: #edf1f8;          /* sky over the cypresses */
  --surface: #ffffff;
  --ink: #0e1a33;             /* the dark-blue steel frame */
  --muted: #56627a;
  --line: #d3dbe8;
  --court: #2a5bd7;           /* cobalt court surface */
  --court-hover: #2049b4;
  --court-ink: #ffffff;
  --court-soft: #dde6fb;
  --frame: #13203f;           /* scoreboards */
  --frame-ink: #f4f7fc;
  --frame-muted: #9fb0d4;
  --cypress: #2f6b3a;         /* winners */
  --cypress-soft: #e2efe4;
  --earth: #8a6440;           /* timber edging */
  --danger: #b4322a;
  --danger-soft: #f8e3e1;

  --font-display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "Barlow", "Helvetica Neue", Arial, sans-serif;

  --radius: 10px;
  --gutter: clamp(16px, 4vw, 32px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #09101f;
    --surface: #101a30;
    --ink: #e7ecf6;
    --muted: #9aa6be;
    --line: #22304d;
    --court: #5b87f3;
    --court-hover: #7a9ff7;
    --court-ink: #08101f;
    --court-soft: #182a52;
    --frame: #050a15;
    --frame-ink: #f4f7fc;
    --frame-muted: #8a9cc4;
    --cypress: #6cc283;
    --cypress-soft: #13301d;
    --earth: #c49a6c;
    --danger: #f07a70;
    --danger-soft: #3a1715;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #09101f; --surface: #101a30; --ink: #e7ecf6; --muted: #9aa6be; --line: #22304d;
  --court: #5b87f3; --court-hover: #7a9ff7; --court-ink: #08101f; --court-soft: #182a52;
  --frame: #050a15; --frame-ink: #f4f7fc; --frame-muted: #8a9cc4;
  --cypress: #6cc283; --cypress-soft: #13301d; --earth: #c49a6c; --danger: #f07a70; --danger-soft: #3a1715;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: var(--court); }
:focus-visible { outline: 3px solid var(--court); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.02; margin: 0; text-wrap: balance; letter-spacing: 0.005em; }
h2 { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; text-transform: uppercase; }
h3 { font-size: 1.45rem; font-weight: 800; text-transform: uppercase; }
p { margin: 0; }
.eyebrow {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--court);
}

.wrap { width: 100%; max-width: 1100px; margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 2px solid transparent;
  font: 700 1rem/1 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn-court { background: var(--court); color: var(--court-ink); }
.btn-court:hover { background: var(--court-hover); }
.btn-court:disabled { opacity: .55; cursor: progress; }
.btn-ghost { color: #fff; border-color: rgba(255,255,255,.7); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-plain { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-plain:hover { border-color: var(--ink); }
.btn-plain-dark { background: transparent; color: var(--frame-ink); border-color: rgba(255,255,255,.3); }
.btn-plain-dark:hover { border-color: var(--frame-ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: .92rem; }

/* ---------- hero ---------- */
.hero { position: relative; color: #fff; background: var(--frame); overflow: hidden; isolation: isolate; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; z-index: -2; }
.hero-shade {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(8,14,30,.15) 0%, rgba(8,14,30,.35) 40%, rgba(8,14,30,.92) 100%);
}
.builder {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; width: fit-content;
  background: rgba(10,18,38,.72); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(6px);
  color: #9fb0d4; text-decoration: none;
  font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  transition: border-color .15s;
}
.builder:hover { border-color: rgba(255,255,255,.5); }
.builder img { height: 18px; width: auto; display: block; }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; padding-block: clamp(140px, 22vw, 260px) 40px; }
.hero-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (min-width: 900px) {
  .hero-inner { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
}
/* Countdown: the same scoreboard language as the date strip, with bigger digits. */
.countdown {
  display: flex; flex-direction: column; gap: 10px; width: fit-content; max-width: 100%;
  padding: 16px 18px; border-radius: var(--radius);
  background: rgba(10,18,38,.72); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(6px);
}
.cd-label { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #9fb0d4; font-weight: 700; }
.cd-grid { display: grid; grid-template-columns: repeat(4, auto); gap: 6px; }
.cd-cell { display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 8px 6px 6px; border-radius: 6px; background: rgba(255,255,255,.07); }
.cd-num { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.2rem, 6vw, 3rem); line-height: 1; font-variant-numeric: tabular-nums; color: #fff; }
.cd-unit { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: #9fb0d4; font-weight: 600; margin-top: 4px; }
@media (max-width: 380px) { .cd-cell { min-width: 0; } }
.hero .eyebrow { color: #c9d7ff; }
.hero h1 {
  font-size: clamp(2.9rem, 9vw, 6.2rem); font-weight: 900; text-transform: uppercase;
  max-width: 13ch; text-shadow: 0 2px 24px rgba(0,0,0,.35);
}
.scoreboard {
  display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%;
  background: rgba(10,18,38,.82); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius);
  backdrop-filter: blur(6px);
}
.sb-cell { display: flex; flex-direction: column; padding: 10px 20px; border-right: 1px solid rgba(255,255,255,.14); }
.sb-cell:last-child { border-right: 0; }
.sb-label { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: #9fb0d4; font-weight: 600; }
.sb-value { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }

/* ---------- sticky subnav ---------- */
.subnav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--frame); border-bottom: 3px solid var(--court);
}
.subnav-inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.subnav a {
  flex: none; padding: 14px 14px; color: var(--frame-ink); text-decoration: none;
  font-weight: 600; font-size: .95rem; letter-spacing: .02em;
}
.subnav a:hover { color: #fff; background: rgba(255,255,255,.07); }

/* ---------- sections ---------- */
.section { padding-block: clamp(48px, 8vw, 88px) 0; display: flex; flex-direction: column; gap: 28px; }
.section:last-child { padding-bottom: clamp(48px, 8vw, 88px); }
/* Court service line: a full-width rule with a centre "T". */
.sec-head { display: flex; flex-direction: column; gap: 6px; padding-bottom: 18px; position: relative; }
.sec-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line);
}
.sec-head::before {
  content: ""; position: absolute; left: 0; bottom: 0; width: 72px; height: 4px; background: var(--court); z-index: 1;
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 4vw, 32px); }
.panel h2 { font-size: 1.8rem; }
.panel-quiet { display: flex; flex-direction: column; gap: 8px; }
.panel-done { display: flex; flex-direction: column; gap: 12px; border-color: var(--cypress); background: var(--cypress-soft); }
.panel-done h3 { color: var(--cypress); }

/* ---------- invite + rules ---------- */
.invite { max-width: 62ch; display: flex; flex-direction: column; gap: 10px; font-size: 1.2rem; }
.invite-when { font-weight: 700; }
.notice { border-left: 4px solid var(--earth); padding: 12px 18px; background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; max-width: 62ch; }
.notice-label { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--earth); }
#notice-text { white-space: pre-line; }

.rules { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 560px) { .rules { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .rules { grid-template-columns: repeat(4, 1fr); } }
.rule { display: flex; flex-direction: column; gap: 8px; padding: 20px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); }
.rule h3 { font-size: 1.35rem; }
.rule p { color: var(--muted); }
.rule strong { color: var(--ink); }
.rule-score { background: var(--court); border-color: var(--court); color: var(--court-ink); }
.rule-score p { color: inherit; opacity: .85; }
.score-chips { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.score-chips span {
  font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; line-height: 1;
  padding: 8px 12px; border-radius: 6px; background: var(--frame); color: var(--frame-ink); font-variant-numeric: tabular-nums;
}
.score-chips i { font-style: normal; color: var(--frame-muted); padding-inline: 2px; }

/* ---------- form ---------- */
.reg-form { display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field legend, .label { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: 6px; }
.label { margin-bottom: 0; }
.label em { font-style: normal; font-weight: 500; color: var(--muted); }
.hint { font-size: .85rem; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
input[type="text"], input[type="tel"], input[type="password"], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--ground); color: var(--ink);
  font: 500 1rem/1.3 var(--font-body);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--court); box-shadow: 0 0 0 3px var(--court-soft); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-body {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 16px 18px 16px 50px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--ground);
  position: relative; transition: border-color .15s, background-color .15s;
}
.choice-body::before {
  content: ""; position: absolute; left: 18px; top: 19px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--muted); background: var(--surface);
}
.choice input:checked + .choice-body { border-color: var(--court); background: var(--court-soft); }
.choice input:checked + .choice-body::before { border-color: var(--court); box-shadow: inset 0 0 0 4px var(--surface); background: var(--court); }
.choice input:focus-visible + .choice-body { outline: 3px solid var(--court); outline-offset: 2px; }
.choice input:disabled + .choice-body { opacity: .5; cursor: not-allowed; }
.choice-title { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; text-transform: uppercase; line-height: 1.1; }
.choice-desc { color: var(--muted); font-size: .95rem; }
.choice-note { color: var(--danger); font-size: .85rem; font-weight: 600; }
.choice-note:empty { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- teams ---------- */
.teams-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.team-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.team-col-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--frame); color: var(--frame-ink); }
.count {
  font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; line-height: 1; min-width: 44px; text-align: center;
  padding: 6px 10px; border-radius: 6px; background: var(--court); color: #fff; font-variant-numeric: tabular-nums;
}
.team-list { list-style: none; margin: 0; padding: 0; counter-reset: team; }
.team-list li { counter-increment: team; display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.team-list li:first-child { border-top: 0; }
.team-list li::before {
  content: counter(team); grid-row: span 2; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; color: var(--court);
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.team-name { font-weight: 700; overflow-wrap: anywhere; }
.team-players { color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.team-empty { padding: 20px; color: var(--muted); }

/* ---------- bracket ---------- */
.bracket-block { display: flex; flex-direction: column; gap: 12px; }
.bracket-title { font-size: 1.6rem; }
.bracket-empty { padding: 18px 20px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.champion {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px; border-radius: var(--radius); background: var(--cypress-soft); border: 2px solid var(--cypress);
}
.champion-label { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--cypress); }
.champion-name { font-family: var(--font-display); font-weight: 900; font-size: 1.8rem; text-transform: uppercase; line-height: 1; overflow-wrap: anywhere; }
.bracket-scroll { overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.bracket { display: flex; gap: 22px; min-width: min-content; }
.round { display: flex; flex-direction: column; width: 230px; flex: none; }
.round-name { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--muted); padding-bottom: 10px; }
.round-matches { display: flex; flex-direction: column; justify-content: space-around; gap: 14px; flex: 1; }
.match { background: var(--frame); color: var(--frame-ink); border-radius: 8px; overflow: hidden; border: 1px solid var(--frame); }
.slot { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; min-height: 48px; }
.slot + .slot { border-top: 1px solid rgba(255,255,255,.1); }
.slot-team { min-width: 0; display: flex; flex-direction: column; }
.slot-name { font-weight: 600; font-size: .95rem; line-height: 1.2; overflow-wrap: anywhere; }
.slot-sub { font-size: .78rem; color: var(--frame-muted); line-height: 1.2; overflow-wrap: anywhere; }
.slot-score { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; min-width: 1ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--frame-muted); }
.slot.tbd .slot-name, .slot.bye .slot-name { color: var(--frame-muted); font-weight: 500; font-style: italic; }
.slot.win { background: rgba(91,135,243,.22); }
.slot.win .slot-score { color: #fff; }
.slot.win .slot-name::after { content: " ✓"; color: #8fd6a2; }
.slot.lose .slot-name { color: var(--frame-muted); }
.match-edit { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(255,255,255,.06); border-top: 1px solid rgba(255,255,255,.1); }
.match-edit label { font-size: .75rem; color: var(--frame-muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.match-edit select { min-height: 36px; padding: 4px 8px; background: var(--frame); color: var(--frame-ink); border-color: rgba(255,255,255,.25); font-size: .9rem; }

/* ---------- footer ---------- */
.footer { background: var(--frame); color: var(--frame-muted); padding-block: 28px; font-size: .9rem; border-top: 6px solid var(--earth); }
.footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.footer a { color: var(--frame-ink); text-decoration-color: var(--frame-muted); text-underline-offset: 3px; }
.footer a:hover { text-decoration-color: var(--frame-ink); }

/* ---------- admin ---------- */
.admin-bar { background: var(--frame); color: var(--frame-ink); border-bottom: 3px solid var(--court); }
.admin-bar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-block: 12px; }
.admin-bar-actions { display: flex; gap: 8px; }
.admin-main { display: flex; flex-direction: column; gap: 20px; padding-block: 28px 64px; }
#admin-app { display: flex; flex-direction: column; gap: 20px; }
.login { max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.settings { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--court); }
.toast { position: sticky; top: 8px; z-index: 20; padding: 10px 16px; border-radius: 8px; background: var(--frame); color: var(--frame-ink); font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); color: #fff; }

.admin-t { display: flex; flex-direction: column; gap: 18px; }
.admin-t-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.admin-t-head h2 { display: flex; align-items: center; gap: 12px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.admin-table th { text-align: left; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; background: var(--ground); white-space: nowrap; }
.admin-table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.admin-table td.num { font-variant-numeric: tabular-nums; color: var(--muted); width: 1%; }
.admin-table td.actions { white-space: nowrap; width: 1%; }
.admin-table td.actions .btn + .btn { margin-left: 6px; }
.phone { font-variant-numeric: tabular-nums; user-select: all; white-space: nowrap; }
.draw-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; background: var(--ground); border-radius: 8px; }
.status-pill { font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .08em; }
.status-pill.live { background: var(--cypress-soft); color: var(--cypress); }
.status-pill.draft { background: var(--court-soft); color: var(--court); }
.status-pill.none { background: var(--ground); color: var(--muted); border: 1px solid var(--line); }
.subtle { color: var(--muted); font-size: .92rem; }

.dialog { border: 0; border-radius: 12px; padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
.dialog::backdrop { background: rgba(5,10,21,.6); }
.dialog form { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.dialog h2 { font-size: 1.7rem; }
