/* Layout: a night-match arena. Navy ground, red vs blue paddle colours for the two sides,
   white balls for anything countable, chunky slab type like a club crest. Single dark look by choice. */
:root {
  --bg: #0b1d45;
  --bg-2: #0f2659;
  --deep: #081633;
  --card: #122d66;
  --ink: #f4f7ff;
  --muted: #a9bbe3;
  --line: rgba(244, 247, 255, .14);
  --blue: #2f86ff;
  --red: #ff3d3d;
  --red-ink: #ff6b6b;
  --ball: #f4f7ff;
  --gold: #ffd23f;
  --good: #3ddc97;
  --display: "Alfa Slab One", Rockwell, "Roboto Slab", Georgia, serif;
  --text: "Rubik", "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, Menlo, monospace;
  --r: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 400 16px/1.55 var(--text); min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -10%, #1a3f8f 0%, transparent 60%), radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0);
  background-size: auto, 22px 22px;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; text-wrap: balance; line-height: 1.05; margin: 0; letter-spacing: .01em; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.loading { padding-block: 80px; color: var(--muted); }

/* header */
.top { background: rgba(8, 22, 51, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: var(--deep); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { width: 38px; height: 38px; border-radius: 9px; background: #fff; }
.brand .x svg { width: 12px; height: 12px; display: block; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.brand .mini-crest { width: 34px; height: 38px; display: block; }
.brand .mini-crest .crest { width: 100%; height: 100%; }
.brand-name { font: 400 18px/1 var(--display); letter-spacing: .03em; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.nav::-webkit-scrollbar { display: none; }
.nav a { white-space: nowrap; text-decoration: none; padding: 7px 14px; border-radius: 999px; font: 600 15px/1.2 var(--text); color: var(--muted); }
.nav a:hover { color: var(--ink); background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { color: var(--deep); background: var(--ball); }

main { flex: 1; padding-block: 28px 72px; display: flex; flex-direction: column; gap: 40px; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 32px; align-items: center; position: relative; }
.eyebrow { font: 600 12px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin: 0 0 16px; }
.hero h1 { font-size: clamp(48px, 8vw, 96px); line-height: .95; text-transform: uppercase; }
.hero h1 .r { color: var(--red); } .hero h1 .b { color: var(--blue); }
.hero .lede { font-size: 19px; max-width: 32em; margin: 20px 0 0; color: var(--muted); }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.crest-wrap { position: relative; display: grid; place-items: center; }
.crest-wrap .crest { width: min(360px, 100%); height: auto; filter: drop-shadow(0 24px 30px rgba(0,0,0,.45)); animation: bob 4s ease-in-out infinite; }
.crest-ball { animation: hop 1.1s cubic-bezier(.3,0,.7,1) infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-1.5deg); } }
@keyframes hop { to { transform: translateY(-10px); } }
.rally { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.rally i { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--ball); box-shadow: 0 6px 10px rgba(0,0,0,.35); animation: arc 2.4s linear infinite; left: 0; top: 60%; }
@keyframes arc {
  0% { left: 2%; top: 70%; } 12% { top: 10%; } 25% { left: 48%; top: 80%; } 37% { top: 20%; } 50% { left: 96%; top: 65%; }
  62% { top: 15%; } 75% { left: 48%; top: 80%; } 87% { top: 10%; } 100% { left: 2%; top: 70%; }
}
@media (prefers-reduced-motion: reduce) { .crest-wrap .crest, .crest-ball, .rally i { animation: none; } .rally { display: none; } }

/* countdown + key dates */
.dates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dates > div { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.dates .k { font: 600 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.dates .v { font: 400 20px/1.2 var(--display); }
.dates .now { background: var(--red); border-color: var(--red); }
.dates .now .k { color: #fff; opacity: .85; }

/* signup */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 26px; box-shadow: 0 20px 40px -24px rgba(0,0,0,.6); }
.card h2 { font-size: 30px; margin-bottom: 8px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.sec-h h2 { font-size: clamp(32px, 5vw, 48px); text-transform: uppercase; }
form.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label.f small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=date], input[type=time], input[type=number], input[type=password], select {
  font: inherit; color: var(--ink); background: var(--deep); border: 2px solid transparent; border-radius: 10px; padding: 11px 13px; width: 100%; min-width: 0;
}
input::placeholder { color: #6f82ad; }
input:focus, select:focus { outline: none; border-color: var(--blue); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.check input { margin-top: 4px; accent-color: var(--red); width: 16px; height: 16px; }
.btn { font: 700 16px/1 var(--text); border: 0; border-radius: 999px; padding: 14px 24px; cursor: pointer; background: var(--red); color: #fff; display: inline-flex; align-items: center; gap: 8px; justify-content: center; text-decoration: none; box-shadow: 0 4px 0 #a51d24; transition: transform .1s, box-shadow .1s; }
.btn:hover { transform: translateY(-2px) rotate(-1deg); box-shadow: 0 6px 0 #a51d24; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a51d24; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 #1b4fa8; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:hover { background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 2px var(--line); transform: none; }
.btn.small { padding: 9px 15px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--red-ink); box-shadow: inset 0 0 0 2px currentColor; }
.err { color: var(--red-ink); font-size: 14px; margin: 0; font-weight: 500; }
.done { background: rgba(61, 220, 151, .12); border: 1px solid rgba(61, 220, 151, .35); border-radius: 10px; padding: 14px; }
.linkbox { display: flex; gap: 8px; align-items: center; margin: 14px 0 6px; }
.linkbox code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 13px var(--mono); background: var(--deep); padding: 10px 12px; border-radius: 10px; }

/* the ball box: one ball per place */
.balls { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 7px; margin: 16px 0 8px; padding: 14px; background: var(--deep); border-radius: 12px; }
.balls i { aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(255,255,255,.18); }
.balls i.on { border: 0; background: radial-gradient(circle at 35% 30%, #fff, #dfe6f7 60%, #b9c5e4); box-shadow: 0 2px 3px rgba(0,0,0,.35); animation: drop .5s cubic-bezier(.3,1.6,.6,1) backwards; }
.balls i.on:nth-child(odd) { animation-delay: .05s; }
@keyframes drop { from { transform: translateY(-14px) scale(.6); opacity: 0; } }
.meter-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; font-size: 15px; }
.meter-row b { font: 400 40px/1 var(--display); color: var(--gold); }

.roster { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.chip { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.08); white-space: nowrap; }
.chip.me { background: var(--red); color: #fff; font-weight: 600; }
.chip .t { color: var(--muted); }
.chip.me .t { color: #ffe0e0; }
.wl-h { margin: 20px 0 0; font: 600 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* banner */
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); }
.banner p { margin: 0; }
.banner.hot { background: var(--blue); border-color: var(--blue); }
.banner.gold { background: var(--gold); color: var(--deep); border: 0; font-size: 18px; }

/* my matches */
.mine { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mm { background: var(--card); border: 2px solid transparent; border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.mm.sel { border-color: var(--gold); }
.mm .meta { font: 500 11px/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mm .who { font: 400 20px/1.2 var(--display); }
.mm .when { font-size: 15px; }
.mm .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.vs { display: inline-block; width: .7em; height: .7em; margin: 0 .4em; vertical-align: baseline; }
.vs path { stroke: var(--gold); stroke-width: 2.8; stroke-linecap: round; fill: none; }

/* calendar */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-bar .wk { font: 400 24px/1.2 var(--display); }
.cal-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.scroll-x { overflow-x: auto; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); }
.cal { display: grid; grid-template-columns: 64px repeat(5, minmax(120px, 1fr)); min-width: 680px; }
.cal .h { position: sticky; top: 0; background: var(--deep); padding: 12px 8px; font: 400 16px/1.2 var(--display); }
.cal .h small { display: block; font: 400 12px var(--mono); color: var(--muted); }
.cal .h.today { color: var(--gold); }
.cal .t { font: 12px/1 var(--mono); color: var(--muted); padding: 10px 8px 0; border-top: 1px solid var(--line); }
.cal .c { border-top: 1px solid var(--line); border-left: 1px solid var(--line); min-height: 42px; padding: 3px; }
.cal .c.out { background: repeating-linear-gradient(135deg, rgba(255,255,255,.04) 0 6px, transparent 6px 12px); }
.cal .c.past { opacity: .4; }
.slot { width: 100%; height: 100%; min-height: 36px; border-radius: 8px; border: 0; font: 500 12px/1.2 var(--text); text-align: left; padding: 5px 8px; display: flex; flex-direction: column; justify-content: center; color: #fff; }
.slot.booked { background: var(--blue); }
.slot.booked.mine { background: var(--red); }
.slot.booked .g { font: 500 10px var(--mono); opacity: .85; letter-spacing: .06em; }
button.slot.free { background: transparent; cursor: pointer; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.15); color: var(--muted); font-weight: 500; }
button.slot.free:hover { background: var(--gold); color: var(--deep); box-shadow: none; }

/* groups */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.grp { background: var(--card); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.grp-h { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(90deg, var(--blue), #5a6cf0 50%, var(--red)); }
.grp-h h3 { font-size: 22px; text-transform: uppercase; text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.grp-h span { font: 600 12px var(--mono); background: rgba(8,22,51,.35); padding: 3px 9px; border-radius: 999px; }
table.st { width: 100%; border-collapse: collapse; font-size: 14px; }
table.st th { font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: right; padding: 10px 10px 6px; }
table.st th:first-child, table.st td:first-child { text-align: left; padding-left: 16px; }
table.st td { padding: 7px 10px; text-align: right; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.st td:last-child, table.st th:last-child { padding-right: 16px; }
table.st tr.lead td { font-weight: 700; }
table.st tr.lead td:first-child::after { content: "👑"; margin-left: 6px; font-size: 12px; }
table.st tr.me td:first-child { color: var(--red-ink); }
.fx { list-style: none; margin: 0; padding: 0; background: rgba(8,22,51,.4); }
.fx li { padding: 9px 16px; display: flex; gap: 10px; justify-content: space-between; align-items: center; font-size: 14px; flex-wrap: wrap; }
.fx li + li { border-top: 1px dashed var(--line); }
.fx .p { min-width: 0; }
.fx .s { font: 13px var(--mono); color: var(--muted); display: flex; gap: 8px; align-items: center; }
.fx .w { font-weight: 700; color: var(--gold); }
.linkbtn { font: 700 13px var(--text); color: var(--gold); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* bracket */
.bracket { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 36px; min-width: max-content; padding: 20px; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 16px; }
.round h3 { font: 600 11px/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.bm { background: var(--card); border-radius: 12px; overflow: hidden; position: relative; border: 1px solid var(--line); }
.bm .row { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; font-size: 14px; }
.bm .row:first-child { box-shadow: inset 4px 0 0 var(--blue); }
.bm .row + .row { border-top: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--red); }
.bm .row.w { font-weight: 700; color: var(--gold); }
.bm .row .tbd { color: var(--muted); font-style: italic; }
.bm .foot { background: var(--deep); padding: 6px 12px; font: 12px var(--mono); color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.round.final .bm { border: 2px solid var(--gold); box-shadow: 0 0 30px -6px rgba(255, 210, 63, .45); }
.round.final h3 { color: var(--gold); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--r); }
.empty strong { display: block; color: var(--ink); font: 400 24px/1.3 var(--display); margin-bottom: 6px; }
.empty .big { font-size: 48px; display: block; margin-bottom: 8px; }

/* rules */
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.rule { background: var(--card); border-radius: var(--r); padding: 22px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.rule.wide { grid-column: 1 / -1; }
.rule h2 { font-size: 24px; display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.rule h2 .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--deep); }
.rule:nth-child(odd) h2 .ico { box-shadow: inset 0 0 0 2px var(--blue); }
.rule:nth-child(even) h2 .ico { box-shadow: inset 0 0 0 2px var(--red); }
.rule p { margin: 0; color: var(--muted); }
.rule p + p { margin-top: 8px; }
.rule ul { padding-left: 18px; margin: 0; color: var(--muted); }
.rule li { margin: 5px 0; }
.rule li::marker { color: var(--gold); }
.court { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 6px 0 12px; }
.court div { background: var(--deep); border-radius: 12px; padding: 14px; text-align: center; }
.court b { font: 400 40px/1 var(--display); display: block; color: var(--gold); }
.court span { font-size: 13px; color: var(--muted); }

/* admin */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.row-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
table.pl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
table.pl th, table.pl td { text-align: left; padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
table.pl th { font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-top: 0; }
table.pl td.num { color: var(--muted); }
.pill { font: 600 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: rgba(61,220,151,.15); color: var(--good); }
.pill.wl { background: rgba(255,210,63,.15); color: var(--gold); }

/* dialog + toast + confetti */
.dlg { border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); }
.dlg::backdrop { background: rgba(4, 10, 26, .7); }
.dlg .in { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dlg h3 { font-size: 26px; }
.games { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.games .gh { font: 700 13px var(--text); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.games .gh:nth-child(2) { color: var(--blue); } .games .gh:nth-child(3) { color: var(--red-ink); }
.games .gl { font: 12px var(--mono); color: var(--muted); }
.games input { text-align: center; font-family: var(--mono); font-size: 18px; }
.dlg .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--gold); color: var(--deep); font-weight: 700; padding: 12px 20px; border-radius: 999px; font-size: 15px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

.foot { border-top: 1px solid var(--line); background: var(--deep); }
.foot-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 18px; font-size: 13px; color: var(--muted); }

@media (max-width: 860px) {
  .hero, .split, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .crest-wrap { order: -1; }
  .crest-wrap .crest { width: min(240px, 70%); }
  .dates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .balls { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .rally { display: none; }
  .dates .v { font-size: 17px; }
}
@media (max-width: 520px) {
  .brand-name, .brand .x, .brand .mini-crest { display: none; }
  .groups, .rules { grid-template-columns: minmax(0, 1fr); }
  .court b { font-size: 30px; }
}
