:root {
  --blue: #163f8c;
  --blue-2: #0d2b64;
  --blue-soft: #eaf0fb;
  --yellow: #ffd52d;
  --red: #d9343b;
  --green: #17834f;
  --ink: #172033;
  --muted: #6b7280;
  --line: #dce2eb;
  --bg: #f4f7fb;
  --card: #ffffff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --name-col: min(34vw, 150px);
  --goal-col: 78px;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  background: var(--bg);
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, a { font: inherit; }
button, a { touch-action: manipulation; }

.screen {
  min-height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(92px + var(--safe-bottom));
  display: flex;
  align-items: center;
}
.screen-start {
  background: radial-gradient(circle at 50% 15%, #ffffff 0 14%, var(--blue-soft) 55%, #dfe8f7 100%);
}
.match-screen { align-items: flex-start; }
.summary-screen { background: linear-gradient(180deg, #eef3fb 0%, #ffffff 100%); }

.page-inner {
  width: min(100%, 720px);
  margin: 0 auto;
}
.page-inner-wide { width: min(100%, 980px); }
.start-inner {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}
.club-logo { width: min(34vw, 150px); max-height: 150px; object-fit: contain; }
.summary-logo { width: 84px; height: 84px; object-fit: contain; }
.eyebrow {
  margin: 0 0 3px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  font-size: .76rem;
  letter-spacing: .09em;
}
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 3.8rem); line-height: 1; color: var(--blue-2); }
h2 { margin: 0; font-size: clamp(1.45rem, 5vw, 2.2rem); }

.card {
  background: var(--card);
  border: 1px solid rgba(24, 55, 103, .10);
  border-radius: 22px;
  box-shadow: 0 10px 32px rgba(28, 51, 91, .10);
}
.setup-card {
  width: 100%;
  padding: 18px;
  text-align: left;
  display: grid;
  gap: 8px;
}
.field-label, .venue-fieldset legend { font-weight: 800; font-size: .92rem; }
.large-input {
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  border: 2px solid var(--line);
  padding: 0 14px;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff;
  outline: none;
  margin-bottom: 7px;
}
.large-input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(22, 63, 140, .12); }
.venue-fieldset { border: 0; padding: 0; margin: 2px 0 0; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 14px;
  font-weight: 900;
  cursor: pointer;
}
.segmented input:checked + label { background: var(--blue); color: #fff; border-color: var(--blue); }

.button, .icon-text-button {
  min-height: 52px;
  border-radius: 15px;
  border: 0;
  padding: 0 18px;
  font-weight: 900;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
.button.primary { background: var(--blue); color: #fff; }
.button.secondary { background: #fff; color: var(--blue); border: 2px solid var(--blue); }
.button.danger { background: var(--red); color: #fff; }
.next-link { margin-top: 16px; width: 100%; }
.full-button { width: 100%; }
.install-button { width: 100%; }
.button:active, .icon-text-button:active, .round-action:active, .score-button:active, .role-button:active { transform: scale(.98); }

.page-header { margin-bottom: 14px; }
.match-title { color: var(--blue-2); }
.roster-card { padding: 12px; }
.roster-list { display: grid; gap: 8px; }
.player-toggle {
  min-height: 56px;
  padding: 0 10px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8faff;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 800;
  font-size: 1.05rem;
}
.player-toggle input {
  appearance: none;
  width: 30px;
  height: 30px;
  border: 3px solid #9da9bb;
  border-radius: 9px;
  display: grid;
  place-content: center;
  flex: 0 0 30px;
}
.player-toggle input::before {
  content: "✓";
  font-weight: 1000;
  color: #fff;
  transform: scale(0);
  transition: transform .08s ease;
}
.player-toggle input:checked { background: var(--green); border-color: var(--green); }
.player-toggle input:checked::before { transform: scale(1); }
.roster-card > .button { margin-top: 12px; }
.guest-players { display: grid; gap: 8px; margin-top: 10px; }
.guest-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: center;
}
.guest-row input[type="checkbox"] { width: 30px; height: 30px; justify-self: center; }
.guest-row input[type="text"] { margin: 0; }

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px;
}
.scoreline { color: var(--blue-2); font-size: clamp(1.25rem, 5.4vw, 2rem); }
.icon-text-button { background: var(--blue); color: #fff; min-width: 116px; padding: 0 12px; }
.icon-text-button > span:first-child { font-size: 1.5rem; line-height: 1; }
.validation-banner {
  min-height: 0;
  border-radius: 13px;
  margin: 0 0 10px;
  font-weight: 800;
  font-size: .9rem;
}
.validation-banner.ok, .validation-banner.warn { padding: 10px 12px; }
.validation-banner.ok { background: #e8f7ef; color: #11643c; }
.validation-banner.warn { background: #fff3d9; color: #7a4a00; }
.match-tools { display: grid; gap: 8px; margin-bottom: 10px; }
.compact-card {
  min-height: 72px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.timer > div:first-child { display: grid; }
.tool-label { font-size: .78rem; text-transform: uppercase; font-weight: 900; color: var(--muted); letter-spacing: .05em; }
.timer-display { font-variant-numeric: tabular-nums; font-size: 1.8rem; line-height: 1.1; color: var(--blue-2); }
.timer-buttons { display: flex; gap: 8px; }
.round-action {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
}
.round-action.subtle { background: #e7ebf1; color: var(--ink); }
.interaction-help { margin: 0 4px; font-size: .78rem; color: var(--muted); text-align: center; }

.table-wrap { width: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.match-table, .summary-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.match-table th, .match-table td,
.summary-table th, .summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 7px;
  text-align: center;
  height: 60px;
  background: #fff;
}
.match-table thead th, .summary-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  font-size: .78rem;
  background: #f5f8fd;
  color: var(--blue-2);
}
.match-table tr:last-child td, .summary-table tr:last-child td { border-bottom: 0; }
.match-table .sticky-name {
  position: sticky;
  left: 0;
  z-index: 3;
  width: var(--name-col);
  min-width: var(--name-col);
  max-width: var(--name-col);
  text-align: left;
  font-weight: 900;
  padding-left: 12px;
  box-shadow: 6px 0 10px rgba(23,32,51,.03);
}
.match-table thead .sticky-name { z-index: 6; background: #f5f8fd; }
.match-table .sticky-goals {
  position: sticky;
  left: var(--name-col);
  z-index: 3;
  width: var(--goal-col);
  min-width: var(--goal-col);
  max-width: var(--goal-col);
  box-shadow: 6px 0 10px rgba(23,32,51,.03);
}
.match-table thead .sticky-goals { z-index: 6; background: #f5f8fd; }
.lineup-heading { min-width: 84px; }
.lineup-number { display: block; font-size: .72rem; }
.lineup-check { display: block; margin-top: 2px; font-size: .72rem; font-weight: 900; }
.lineup-check.ok { color: var(--green); }
.lineup-check.warn { color: #a45d00; }
.goals-control { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; align-items: center; }
.goal-count { grid-column: 1 / -1; font-weight: 1000; font-size: 1rem; line-height: 1; }
.score-button {
  width: 29px;
  height: 29px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--blue-soft);
  color: var(--blue-2);
  font-weight: 1000;
  font-size: 1.05rem;
  justify-self: center;
}
.role-button {
  width: 50px;
  height: 50px;
  border: 2px solid transparent;
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 0;
  margin: auto;
  font-size: 1.6rem;
  background: #f5f7fa;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.role-button.field { background: #e8effd; border-color: #b7c9f3; }
.role-button.keeper { background: #fff7cf; border-color: #f4d65c; }
.role-button.bench { background: #fde9eb; border-color: #f2b8bd; }
.opponent-row td { background: #fff7dc; }
.opponent-row .sticky-name, .opponent-row .sticky-goals { background: #fff1ba; color: #713f00; }
.opponent-row .sticky-name { border-left: 5px solid var(--yellow); }
.no-role { color: #a5adba; }

.summary-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin: 8px 2px 16px;
}
.summary-date { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
.final-score { margin: 4px 0 0; color: var(--blue-2); font-size: clamp(1.5rem, 7vw, 2.6rem); font-weight: 1000; }
.summary-card { overflow-x: auto; }
.summary-table { width: 100%; min-width: 470px; }
.summary-table th:first-child, .summary-table td:first-child { text-align: left; font-weight: 900; padding-left: 14px; }
.summary-table td:not(:first-child) { font-variant-numeric: tabular-nums; font-size: 1.06rem; font-weight: 900; }
.summary-actions { display: grid; gap: 10px; margin-top: 14px; }

.page-dock {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 5px;
  padding: 6px;
  border-radius: 20px;
  background: rgba(13, 43, 100, .92);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(8, 26, 60, .28);
}
.page-dock a {
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  text-decoration: none;
  font-weight: 1000;
}
.page-dock a:active { background: rgba(255,255,255,.18); }

.time-signal {
  position: fixed;
  z-index: 100;
  inset: 0;
  background: rgba(9, 24, 48, .84);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #fff;
  text-align: center;
  font-size: clamp(2.4rem, 11vw, 5rem);
  padding: 20px;
}
.time-signal[hidden] { display: none; }
.time-signal button {
  min-width: 160px;
  min-height: 58px;
  border: 0;
  border-radius: 15px;
  background: var(--yellow);
  color: #222;
  font-weight: 1000;
  font-size: 1.1rem;
}

@media (min-width: 700px) {
  :root { --name-col: 180px; --goal-col: 90px; }
  .screen { padding-inline: 24px; }
  .match-tools { grid-template-columns: 310px 1fr; align-items: center; }
  .interaction-help { text-align: left; }
}

@media (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
  input { user-select: text; -webkit-user-select: text; }
}
