/* Padely — the court is the interface. */
:root {
  --bg: #EDF1F6;
  --surface: #FFFFFF;
  --surface-2: #F6F8FB;
  --ink: #0F1E3A;
  --muted: #55627C;
  --hair: #D5DCE7;
  --court: #2156C7;
  --court-deep: #173F99;
  --court-line: rgba(255, 255, 255, .42);
  --ball: #E2EF3F;
  --ball-ink: #2B3000;
  --danger: #B42318;
  --danger-bg: #FDEDEB;
  --font-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --font-body: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 1180px; margin: 0 auto;
  padding: 32px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
button, a, input, summary, label { touch-action: manipulation; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1; letter-spacing: .005em; margin: 0; }
p { margin: 0; }
a { color: var(--court); }
abbr[title] { text-decoration: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--court); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--hair); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 800 28px/1 var(--font-display); }
.brand-ball { width: 28px; height: 28px; }
.brand-ball circle { stroke: var(--ball-ink); stroke-width: .8; stroke-opacity: .25; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font: 600 15px/1.2 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--court); color: #fff; }
.btn-primary:hover { background: var(--court-deep); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--hair); }
.btn-ghost:hover { border-color: var(--court); color: var(--court); }
.btn-quiet { background: transparent; color: var(--muted); padding-inline: 10px; }
.btn-quiet:hover { color: var(--ink); background: rgba(15, 30, 58, .05); }
.btn-danger:hover { color: var(--danger); background: var(--danger-bg); }
.btn-sm { padding: 7px 14px; font-size: 14px; }
.btn-lg { padding: 14px 26px; font-size: 17px; }
.link-btn { background: none; border: 0; padding: 0; margin-top: 4px; color: var(--court); font: 600 14px var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* ---------- Court (the signature element) ---------- */
.court {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 8px 1fr;
  min-height: 128px;
  background: var(--court);
  border-radius: 10px;
  overflow: hidden;
  isolation: isolate;
}
/* boundary line */
.court::before {
  content: ""; position: absolute; inset: 7px; border: 2px solid var(--court-line); border-radius: 3px;
  pointer-events: none; z-index: -1;
}
.half { position: relative; display: flex; align-items: center; gap: 10px; padding: 16px 18px; min-width: 0; }
.half-a { justify-content: space-between; }
.half-b { justify-content: space-between; }
/* service line + centre service line */
.half::before, .half::after { content: ""; position: absolute; background: var(--court-line); z-index: -1; pointer-events: none; }
.half::before { top: 7px; bottom: 7px; width: 2px; }
.half::after { top: calc(50% - 1px); height: 2px; }
.half-a::before { left: 30%; }
.half-a::after { left: 30%; right: 0; }
.half-b::before { right: 30%; }
.half-b::after { right: 30%; left: 0; }
.net {
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.75) 0 2px, transparent 2px 6px),
    var(--court-deep);
  box-shadow: inset 2px 0 0 #fff, inset -2px 0 0 #fff;
}
.names { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: #fff; font-weight: 600; font-size: 15px; line-height: 1.25; text-shadow: 0 1px 0 rgba(10, 30, 80, .35); }
.names span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.half-b .names { text-align: right; align-items: flex-end; }
.earned {
  align-self: flex-start; margin-top: 6px; padding: 2px 8px; border-radius: 999px;
  font: 800 16px/1.2 var(--font-display); letter-spacing: .02em;
  background: rgba(255,255,255,.18); color: #fff; text-shadow: none;
}
.half-b .earned { align-self: flex-end; }
.won .earned { background: var(--ball); color: var(--ball-ink); }
.lost .names span { opacity: .72; }

.score {
  flex: none; width: 66px; height: 66px; padding: 0;
  border: 2px solid rgba(255,255,255,.55); border-radius: 10px;
  background: rgba(10, 30, 80, .22); color: #fff;
  font: 800 42px/1 var(--font-display); text-align: center; font-variant-numeric: tabular-nums;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.score::placeholder { color: rgba(255,255,255,.45); }
.score:focus::placeholder { color: transparent; }
.score:focus { outline: none; border-color: var(--ball); background: rgba(10, 30, 80, .34); box-shadow: 0 0 0 4px rgba(226, 239, 63, .3); }
.score-static { display: grid; place-items: center; }
.won .score { color: var(--ball); border-color: var(--ball); }
.lost .score { border-color: rgba(255,255,255,.3); }
.has-error .score { border-color: #FFB4A9; }

/* Court card: names use the full width of their half; underneath, the score
   sits next to the net with the points badge beside it. Long names never run
   into the score. */
.game .half, .hero-demo .half { display: grid; grid-template-rows: auto auto 1fr; gap: 2px 8px; padding: 14px 16px; }
.game .half-a, .hero-demo .half-a { grid-template-columns: minmax(0, 1fr) auto; }
.game .half-b, .hero-demo .half-b { grid-template-columns: auto minmax(0, 1fr); }
.game .names, .hero-demo .names { display: contents; }
.game .names > span, .hero-demo .names > span { grid-column: 1 / -1; }
.game .half-b .names > span, .hero-demo .half-b .names > span { text-align: right; }
/* Scores sit on the bottom row so both sides line up, whatever the name lengths. */
.game .score, .hero-demo .score { grid-row: 3; align-self: end; margin-top: 8px; }
.game .half-a .score, .hero-demo .half-a .score { grid-column: 2; }
.game .half-b .score, .hero-demo .half-b .score { grid-column: 1; }
.game .earned, .hero-demo .earned { grid-row: 3; align-self: end; margin: 0 0 17px; }
.game .half-a .earned, .hero-demo .half-a .earned { grid-column: 1; justify-self: end; }
.game .half-b .earned, .hero-demo .half-b .earned { grid-column: 2; justify-self: start; }
.game .score, .hero-demo .score { width: 60px; height: 60px; font-size: 38px; }
/* Long names wrap onto a second line instead of being cut off. */
.game .names > span, .hero-demo .names > span, .sheet-side .names > span {
  white-space: normal; overflow-wrap: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: center; padding: 24px 0 56px; }
.hero h1 { font-size: clamp(44px, 6vw, 76px); font-weight: 900; line-height: .92; max-width: 12ch; margin-bottom: 20px; }
.hero p { color: var(--muted); font-size: 18px; max-width: 42ch; margin-bottom: 28px; }
.hero-demo { margin: 0; transform: rotate(-1.5deg); }
.hero-demo .court { min-height: 168px; box-shadow: 0 24px 48px -24px rgba(23, 63, 153, .55); }
.hero-demo figcaption { margin-top: 18px; color: var(--muted); font-size: 14px; max-width: 46ch; transform: rotate(1.5deg); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.list-head h1 { font-size: clamp(36px, 5vw, 52px); font-weight: 900; }

.list h2 { font-size: 32px; margin-bottom: 16px; }
.t-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list .list-group { margin: 24px 0 10px; font: 600 13px/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.list .list-head + .list-group { margin-top: 8px; }
.t-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: center;
  padding: 16px 20px; background: var(--surface); border: 1px solid var(--hair); border-radius: 14px;
  text-decoration: none; color: inherit; transition: border-color .15s;
}
.t-row:hover { border-color: var(--court); }
.t-row-main { display: grid; gap: 2px; min-width: 0; }
.t-name { font: 800 26px/1.05 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta, .t-status { color: var(--muted); font-size: 14px; }
.t-meta-place { color: var(--ink); font-weight: 500; }
.t-row-progress { display: grid; gap: 6px; }

.bar { display: block; height: 8px; border-radius: 999px; background: var(--hair); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--court); border-radius: inherit; transition: width .4s ease; }
.bar-done > span { background: var(--ball); box-shadow: inset 0 0 0 1px rgba(43, 48, 0, .15); }

.empty { background: var(--surface); border: 1.5px dashed var(--hair); border-radius: 16px; padding: 32px; display: grid; gap: 16px; justify-items: start; }
.empty p { color: var(--muted); max-width: 52ch; }
.empty strong { color: var(--ink); }
.empty-page { max-width: 560px; margin: 48px auto; }
.empty-page h1 { font-size: 44px; }

/* ---------- Wizard ---------- */
.wizard { max-width: 760px; margin: 0 auto; }
.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 20px; counter-reset: none; }
.steps li { flex: 1; }
.steps button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: transparent; border: 0; border-bottom: 3px solid var(--hair);
  font: 600 15px var(--font-body); color: var(--muted); cursor: pointer; text-align: left;
}
.step-num { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font: 800 16px/1 var(--font-display); border: 1.5px solid currentColor; }
.steps .is-active button { color: var(--ink); border-bottom-color: var(--court); }
.steps .is-active .step-num { background: var(--court); border-color: var(--court); color: #fff; }
.steps .is-done button { color: var(--ink); border-bottom-color: var(--court); }
.steps .is-done .step-num { background: var(--ball); border-color: var(--ball); color: var(--ball-ink); }

.card { background: var(--surface); border: 1px solid var(--hair); border-radius: 22px; padding: 32px; }
.step + .step { margin-top: 20px; }
html.js .step:not(.is-active) { display: none; }
html.js .step + .step { margin-top: 0; }
.step h1, .step h2 { font-size: 44px; margin-bottom: 24px; }

.field { display: block; margin: 0 0 24px; padding: 0; border: 0; min-width: 0; }
.field-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; padding: 0; }
.hint { color: var(--muted); font-size: 14px; }
.field > .hint { margin: -2px 0 12px; }
.field-grid > .field .hint { margin-top: 8px; }
.wizard input[type="text"], .wizard input[type="number"], .wizard input[type="date"], .wizard input[type="time"], .wizard textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 10px;
  background: var(--surface-2); color: var(--ink); font: 16px var(--font-body);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.wizard input[type="text"]:focus, .wizard input[type="number"]:focus, .wizard input[type="date"]:focus, .wizard input[type="time"]:focus, .wizard textarea:focus { outline: none; border-color: var(--court); background: #fff; box-shadow: 0 0 0 4px rgba(33, 86, 199, .14); }
.wizard input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-bg); }
/* Date and time pickers: keep iOS from shrinking empty ones or centring the value. */
.wizard input[type="date"], .wizard input[type="time"] { display: block; min-height: 49px; -webkit-appearance: none; appearance: none; }
.wizard input::-webkit-date-and-time-value { text-align: left; }
.wizard textarea { display: block; resize: vertical; min-height: 84px; line-height: 1.45; }
.review-about { white-space: pre-line; }
.when-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.when-grid label { display: block; min-width: 0; }
.edit-details h1 { font-size: 44px; margin-bottom: 24px; }
.edit-details .back-link { margin-bottom: 14px; }
.field-error:not(:empty) { margin-top: 12px; color: var(--danger); font-size: 14px; font-weight: 500; }
.field-error p + p { margin-top: 2px; }

.teams { display: grid; gap: 10px; }
.team-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 36px; gap: 10px; align-items: center; }
.team-num { font: 800 22px/1 var(--font-display); color: var(--muted); text-align: center; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; }
.amp { font: 700 22px/1 var(--font-display); color: var(--muted); }
.teams-foot { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-body { display: grid; gap: 4px; height: 100%; padding: 16px 18px; border: 1.5px solid var(--hair); border-radius: 14px; background: var(--surface); transition: border-color .15s, background-color .15s; }
.choice:hover .choice-body { border-color: #9DB2DA; }
.choice input:checked + .choice-body { border-color: var(--court); background: rgba(33, 86, 199, .05); box-shadow: inset 0 0 0 1px var(--court); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--court); outline-offset: 2px; }
.choice-title { font-weight: 700; }
.choice-text { color: var(--muted); font-size: 14px; }
.choice-icon { width: 48px; height: 32px; margin-bottom: 4px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.choice input:checked + .choice-body .choice-icon { stroke: var(--court); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--hair); border-radius: 999px; background: var(--surface-2); padding: 3px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; font: 600 22px/1 var(--font-body); color: var(--ink); cursor: pointer; }
.stepper button:hover { background: #fff; color: var(--court); }
.stepper input[type="number"] {
  width: 64px; border: 0; background: transparent; text-align: center; padding: 4px 0;
  font: 800 28px/1 var(--font-display); -moz-appearance: textfield; appearance: textfield;
}
.wizard .stepper input:focus { box-shadow: none; background: transparent; }
.stepper:focus-within { border-color: var(--court); box-shadow: 0 0 0 4px rgba(33, 86, 199, .14); }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.points-wrap { margin-top: 18px; }
.points-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-width: 48px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--hair); background: var(--surface); font: 800 18px/1 var(--font-display); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--court); color: var(--court); }
.chip[aria-pressed="true"] { background: var(--court); border-color: var(--court); color: #fff; }

.step-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--hair); }

.review { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px 20px; margin: 0 0 24px; }
.review dt { color: var(--muted); font-size: 15px; padding-top: 2px; }
.review dd { margin: 0; font-weight: 600; }
.review .team-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.team-chip { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--hair); font-weight: 500; font-size: 14px; }
.review small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.rule-box { padding: 16px 18px; border-radius: 14px; background: rgba(226, 239, 63, .28); border: 1px solid rgba(160, 172, 20, .35); font-size: 15px; }

.alert { background: var(--danger-bg); border: 1px solid #F3C1BB; color: var(--danger); border-radius: 14px; padding: 14px 18px; margin-bottom: 20px; font-size: 15px; }
.alert p { font-weight: 600; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Tournament ---------- */
.t-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.back-link { display: inline-block; margin-bottom: 10px; font-size: 14px; color: var(--muted); text-decoration: none; }
.back-link::before { content: "‹ "; }
.back-link:hover { color: var(--court); }
.t-title h1 { font-size: clamp(40px, 5vw, 60px); font-weight: 900; }
.t-place { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 10px; font-weight: 600; }
.t-place-item { display: inline-flex; align-items: center; gap: 6px; }
.t-place-item svg { width: 18px; height: 18px; flex: none; color: var(--court); }
.t-place-edit { font-size: 14px; font-weight: 500; color: var(--court); }
.t-place + .t-sub { margin-top: 4px; }
.t-sub { color: var(--muted); margin-top: 8px; }
.t-side { display: flex; align-items: flex-end; gap: 16px; }
.t-progress { min-width: 240px; display: grid; gap: 8px; }
.share-btn.is-copied { border-color: var(--court); color: var(--court); }
.t-progress p { color: var(--muted); font-size: 15px; }
.t-progress strong { color: var(--ink); font: 800 28px/1 var(--font-display); }

.champions {
  display: flex; gap: 20px; align-items: center; margin-bottom: 28px; padding: 24px 28px;
  border-radius: 18px; background: var(--court-deep); color: #fff;
  animation: rise .5s ease-out both;
}
.champions-ball { width: 56px; height: 56px; flex: none; }
.champions-kicker { color: rgba(255,255,255,.75); font-size: 14px; }
.champions h2 { font-size: clamp(30px, 4vw, 44px); color: var(--ball); margin-top: 4px; }
.podium { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; color: rgba(255,255,255,.9); font-size: 15px; }
.podium-rank { font: 800 18px/1 var(--font-display); color: #fff; margin-right: 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-tabs { display: none; }
.t-grid { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 32px; align-items: start; }

.round { margin-bottom: 32px; scroll-margin-top: 72px; }
.round-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.round-head h2 { font-size: 30px; }
.round-count { margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.tag { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.tag-now { background: var(--ball); color: var(--ball-ink); }
.tag-done { background: rgba(33, 86, 199, .1); color: var(--court-deep); }
.resting { color: var(--muted); font-size: 14px; margin: -4px 0 12px; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.game { background: var(--surface); border: 1px solid var(--hair); border-radius: 16px; padding: 8px; scroll-margin-top: 80px; transition: opacity .15s; }
.game.is-saving { opacity: .6; pointer-events: none; }
.game.just-saved { animation: saved 1.1s ease-out; }
@keyframes saved { 0% { box-shadow: 0 0 0 0 rgba(226, 239, 63, 0); } 25% { box-shadow: 0 0 0 5px rgba(226, 239, 63, .9); } 100% { box-shadow: 0 0 0 5px rgba(226, 239, 63, 0); } }
.game-head { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; min-height: 22px; padding: 2px 6px 8px; }
.court-label { color: var(--ink); font-size: 14px; font-weight: 600; }
.game-foot { display: flex; align-items: center; gap: 10px; padding: 8px 4px 0 8px; }
/* On desktop an unplayed game has no buttons, so there's nothing to show below the court. */
html.js:not(.sheet-mode) .game:not(.is-scored) .game-foot { display: none; }
/* On phones there are no score buttons: tapping the court opens the keypad. */
html.sheet-mode .game .game-foot { padding: 0; }
html.sheet-mode form.game:not(.is-scored) .game-status:empty::before { content: "Tap the court to enter the score"; }
.game-status { color: var(--muted); font-size: 14px; }
.game-status.is-error { color: var(--danger); font-weight: 500; }
.game-status.is-saved { color: var(--court-deep); font-weight: 600; }
.game-status.is-saved::before { content: "✓ "; }
html:not(.sheet-mode) .game:focus-within .game-status:empty::before { content: "Saves when you click away"; }
html.js .nojs-only { display: none !important; }
.game-actions .btn-danger { color: var(--muted); }
.game-actions { margin-left: auto; display: flex; flex-direction: row-reverse; gap: 4px; }

/* Standings and Info share the sticky side column; it scrolls on its own when taller than the window. */
.panel-standings { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 16px; border-radius: 18px; scrollbar-width: thin; }
.info-card { background: var(--surface); border: 1px solid var(--hair); border-radius: 18px; padding: 22px 20px 20px; scroll-margin-top: 80px; }
.info-card h2 { font-size: 32px; margin-bottom: 14px; }
.info-card h3 { font: 700 16px/1.3 var(--font-body); margin: 22px 0 6px; }
.info-card p { font-size: 15px; }
.info-list { display: grid; gap: 12px; margin: 0; font-size: 15px; }
.info-list dt { font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.info-list dd { margin: 2px 0 0; }
.info-card .hero-demo { margin-top: 16px; }
.info-card .hero-demo, .info-card .hero-demo figcaption { transform: none; }
.info-card .hero-demo .court { min-height: 150px; box-shadow: none; }
.info-note { margin-top: 16px; color: var(--muted); font-size: 14px !important; }
.t-about { margin-top: 10px; max-width: 65ch; white-space: pre-line; }
.standings-card { background: var(--surface); border: 1px solid var(--hair); border-radius: 18px; padding: 22px 20px 18px; }
.standings-card h2 { font-size: 32px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; padding: 6px 8px; }
.table td { padding: 10px 8px; border-top: 1px solid var(--hair); vertical-align: middle; }
.table .c-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .c-pos { width: 40px; }
.table .c-name { width: 100%; font-weight: 600; }
.table .c-name small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.table td.c-pts { font: 800 22px/1 var(--font-display); }
.pos { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font: 800 16px/1 var(--font-display); color: var(--muted); }
.rank-1 .pos { background: var(--ball); color: var(--ball-ink); }
.rank-2 .pos { background: #DCE3EE; color: var(--ink); }
.rank-3 .pos { background: #EBD8C6; color: #5A3A1C; }
.rule { color: var(--muted); font-size: 13px; margin-top: 14px; }

.danger-zone { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--hair); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .t-grid { grid-template-columns: minmax(0, 1fr); }
  .panel-standings { position: static; max-height: none; overflow: visible; }
  .view-tabs {
    display: flex; position: sticky; top: 0; z-index: 5; gap: 4px; padding: 4px; margin: 0 0 20px;
    background: var(--surface); border: 1px solid var(--hair); border-radius: 999px;
    box-shadow: 0 6px 16px -10px rgba(15, 30, 58, .35);
  }
  .view-tabs button { flex: 1; padding: 10px; border: 0; border-radius: 999px; background: transparent; font: 600 15px var(--font-body); color: var(--muted); cursor: pointer; }
  .view-tabs button[aria-selected="true"] { background: var(--court); color: #fff; }
  html.js .t-grid[data-view="matches"] .panel-standings,
  html.js .t-grid:not([data-view="matches"]) .panel-matches,
  html.js .t-grid[data-view="standings"] .info-card,
  html.js .t-grid[data-view="info"] .standings-card { display: none; }
}
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-bottom: 40px; }
  .hero-demo { transform: none; }
  .hero-demo figcaption { transform: none; }
}
@media (max-width: 640px) {
  main { padding-top: 20px; }
  .card { padding: 22px 18px; border-radius: 18px; }
  .step h1, .step h2 { font-size: 36px; }
  .choices, .field-grid { grid-template-columns: 1fr; }
  .when-grid { grid-template-columns: 1fr 1fr; }
  .when-date { grid-column: 1 / -1; }
  .edit-details h1 { font-size: 36px; }
  .pair { grid-template-columns: 1fr; gap: 6px; }
  .teams { gap: 18px; }
  .amp { display: none; }
  .team-row { align-items: start; }
  .team-num { padding-top: 12px; }
  .team-row .remove { margin-top: 4px; }
  .steps button { flex-direction: column; gap: 4px; text-align: center; font-size: 13px; }
  .review { grid-template-columns: 1fr; gap: 2px; }
  .review dd { margin-bottom: 12px; }
  .t-row { grid-template-columns: 1fr; gap: 12px; }
  .games { grid-template-columns: 1fr; }
  .half { padding: 14px 12px; gap: 8px; }
  .score { width: 58px; height: 58px; font-size: 36px; }
  .step-nav .btn-lg { padding: 12px 20px; font-size: 16px; }
  .champions { padding: 20px; align-items: flex-start; }
  .champions-ball { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


/* ---------- Finished rounds collapse into result lines ---------- */
.round-details > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px 12px; padding: 4px 0 2px; }
.round-details > summary::-webkit-details-marker { display: none; }
.round-details > summary h2 { font-size: 30px; }
.round-edit { justify-self: end; color: var(--court); font-size: 14px; font-weight: 600; padding: 8px 0; }
.round-details[open] .when-closed, .round-details:not([open]) .when-open { display: none; }
.results { grid-column: 1 / -1; display: grid; gap: 6px; }
.round-details[open] .results { display: none; }
.round-details[open] > summary { margin-bottom: 12px; }
.result {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; font-size: 15px;
}
.r-team { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.r-a { text-align: right; }
.r-won { color: var(--ink); font-weight: 700; }
.r-score { font: 800 22px/1 var(--font-display); font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 8px; background: var(--court); color: #fff; min-width: 64px; text-align: center; }
.round-details > summary:hover .result { border-color: #B9C6DD; }
.round-details > summary:focus-visible { outline: 2px solid var(--court); outline-offset: 4px; border-radius: 8px; }

/* ---------- Score sheet (phones and touch screens) ---------- */
.sheet-only { display: none !important; }
html.sheet-mode .sheet-only { display: inline-flex !important; }
html.sheet-mode .inline-only { display: none !important; }
html.sheet-mode .game .court { cursor: pointer; transition: transform .1s; }
html.sheet-mode .game .court:active { transform: scale(.985); }
html.sheet-mode .game .score { pointer-events: none; }

.sheet {
  width: 100%; max-width: 100%; max-height: 100dvh; margin: auto 0 0; padding: 0; border: 0;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 -12px 40px -12px rgba(15, 30, 58, .35);
}
.sheet::backdrop { background: rgba(15, 30, 58, .5); }
.sheet[open] { animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-inner { padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.sheet-inner::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--hair); margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { font-size: 26px; }
.sheet-close { width: 44px; height: 44px; margin-right: -8px; }
.sheet-close:hover { background: var(--surface-2) !important; color: var(--ink) !important; }
.sheet-court { min-height: 132px; }
.sheet-side { border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; text-align: inherit; flex-direction: column; align-items: stretch; justify-content: center; gap: 8px; padding: 14px; }
.sheet-side.half-a .score { align-self: flex-end; }
.sheet-side.half-b .score { align-self: flex-start; order: 2; }
.sheet-side .score { width: 76px; height: 76px; font-size: 50px; display: grid; place-items: center; border-color: rgba(255,255,255,.35); background: rgba(10, 30, 80, .18); }
.sheet-side .score:empty::before { content: "–"; color: rgba(255,255,255,.4); }
.sheet-side[aria-pressed="true"] .score { border-color: var(--ball); background: rgba(10, 30, 80, .4); box-shadow: 0 0 0 4px rgba(226, 239, 63, .35); }
.sheet-side[aria-pressed="false"] .names { opacity: .7; }
.sheet-side:focus-visible { outline: 2px solid var(--ball); outline-offset: -6px; }
.sheet-msg { min-height: 22px; margin: 8px 2px 6px; font-size: 14px; color: var(--muted); }
.sheet-msg.is-error { color: var(--danger); font-weight: 500; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  height: 58px; border-radius: 14px; border: 1px solid var(--hair); background: var(--surface-2); color: var(--ink);
  font: 800 30px/1 var(--font-display); cursor: pointer; display: grid; place-items: center;
  transition: background-color .08s, transform .08s;
}
.keypad button:active { background: var(--hair); transform: scale(.97); }
.keypad svg { width: 28px; height: 28px; }
.keypad .key-next { font: 600 15px/1.2 var(--font-body); color: var(--court); }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-actions [data-sheet-save] { flex: 1; min-height: 54px; }
@media (min-width: 641px) {
  .sheet { margin: auto; width: min(460px, calc(100% - 32px)); border-radius: 22px; }
  .sheet-inner { padding: 12px 20px 20px; }
  .sheet-inner::before { display: none; }
}
@media (max-height: 680px) {
  .keypad button { height: 48px; }
  .sheet-court { min-height: 112px; }
  .sheet-side .score { width: 64px; height: 64px; font-size: 42px; }
}

/* ---------- Phone layout ---------- */
@media (max-width: 640px) {
  .btn { min-height: 44px; }
  .btn-sm { padding: 8px 16px; font-size: 15px; }
  .icon-btn { width: 44px; height: 44px; }
  .topbar .btn { min-height: 40px; }

  .t-head { gap: 16px; margin-bottom: 20px; }
  .t-side { width: 100%; align-items: center; }
  .t-progress { flex: 1; min-width: 0; }

  .game .half, .hero-demo .half { padding: 12px; }
  .game .score, .hero-demo .score { width: 56px; height: 56px; font-size: 36px; }
  .game-foot { padding: 8px 2px 0 6px; }
  .game-head { padding: 0 4px 8px; }
  .game-actions .btn { min-width: 120px; }

  .round-details > summary h2, .round-head h2 { font-size: 28px; }
  .result { padding: 10px; gap: 8px; font-size: 14px; }
  .r-score { min-width: 56px; font-size: 20px; padding: 4px 6px; }

  .standings-card { padding: 18px 12px 14px; }
  .table { font-size: 14px; }
  .table th, .table td { padding-left: 5px; padding-right: 5px; }

  /* Wizard: keep the next step within thumb reach. */
  .step-nav {
    position: sticky; bottom: 0; z-index: 3;
    margin: 24px -18px -22px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--hair); border-radius: 0 0 18px 18px;
  }
  .step-nav .btn-primary { flex: 1; }
  .list-head .btn { flex: none; }
  .explainer { margin-top: 40px; }
}
@media (max-width: 360px) {
  .game .half { padding: 10px; }
  .r-team { font-size: 13px; }
}


/* ---------- Accounts ---------- */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-2); border: 1.5px solid var(--hair); color: var(--ink); text-decoration: none;
  font: 800 19px/1 var(--font-display); position: relative;
}
.avatar svg { width: 22px; height: 22px; }
.avatar:hover { border-color: var(--court); color: var(--court); }
/* A small dot until the account is saved with a passkey. */
.avatar:not(.is-secured)::after { content: ""; position: absolute; top: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ball); border: 2px solid var(--surface); }

.flash { max-width: 760px; margin: 0 auto 20px; padding: 12px 16px; border-radius: 12px; background: rgba(33, 86, 199, .09); border: 1px solid rgba(33, 86, 199, .22); color: var(--court-deep); font-weight: 500; animation: rise .3s ease-out both; }

.page-narrow { max-width: 560px; margin: 0 auto; }
.page-title { font-size: clamp(38px, 6vw, 52px); font-weight: 900; margin-bottom: 10px; }
.lede { color: var(--muted); font-size: 17px; margin-bottom: 24px; max-width: 52ch; }
.account-card { padding: 24px; margin-bottom: 16px; }
.account-card h2 { font-size: 28px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.account-card > .muted + form { margin-top: 16px; }
.note { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 14px; }
.center-note { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.form-msg { min-height: 20px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.form-msg.is-error { color: var(--danger); font-weight: 500; }
.btn-block { width: 100%; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.account-card .field input[type="text"], .code-form input[type="text"] {
  width: 100%; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 10px; background: var(--surface-2); font: 16px var(--font-body); color: var(--ink);
}
.account-card .field input[type="text"]:focus { outline: none; border-color: var(--court); background: #fff; box-shadow: 0 0 0 4px rgba(33, 86, 199, .14); }
.account-card .field .hint { display: block; margin-top: 6px; }
.code-form input[name="code"] { font: 800 26px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; text-align: center; }
.code-form input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-bg); }
.code-form .field { margin-bottom: 12px; }
.code-form .form-msg { margin: -4px 0 12px; }

.pk-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.pk-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 12px; }
.pk-icon { width: 24px; height: 24px; color: var(--court); flex: none; }
.pk-text { flex: 1; min-width: 0; display: grid; }
.pk-text small { color: var(--muted); font-size: 13px; }
.pk-create { margin-top: 16px; }
.pk-create .field { margin-bottom: 16px; }

.code-box { display: flex; gap: 20px; align-items: center; }
.qr { width: 180px; height: 180px; flex: none; border-radius: 12px; border: 1px solid var(--hair); image-rendering: pixelated; }
.code { font: 900 40px/1 var(--font-display); letter-spacing: .08em; margin: 10px 0; color: var(--court-deep); }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--hair); }

.signout { margin-top: 12px; }

.nudge {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 18px 20px; margin-bottom: 28px; border-radius: 16px;
  background: rgba(226, 239, 63, .3); border: 1px solid rgba(160, 172, 20, .4);
}
.nudge-icon { width: 32px; height: 32px; color: var(--ball-ink); }
.nudge h2 { font-size: 24px; margin-bottom: 4px; }
.nudge p { font-size: 15px; color: #3d4a1a; }
.nudge-actions { display: flex; gap: 6px; align-items: center; }

.viewer-note { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2AA563; box-shadow: 0 0 0 0 rgba(42, 165, 99, .5); animation: live 2s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(42, 165, 99, .5); } 70% { box-shadow: 0 0 0 8px rgba(42, 165, 99, 0); } 100% { box-shadow: 0 0 0 0 rgba(42, 165, 99, 0); } }
.game.is-readonly .court { cursor: default; }
html.sheet-mode .game.is-readonly .court:active { transform: none; }

@media (max-width: 640px) {
  .nudge { grid-template-columns: auto minmax(0, 1fr); }
  .nudge-actions { grid-column: 1 / -1; }
  .nudge-actions .btn-primary { flex: 1; }
  .code-box { flex-direction: column; align-items: flex-start; }
  .account-card { padding: 20px 18px; }
}
@media (max-width: 420px) {
  .hide-sm { display: none; }
}
