@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/inter-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin-700-normal.woff2') format('woff2');
}

:root {
  --page: #F4F4F1;
  --card: #FFFFFF;
  --ink: #111418;
  --muted: #52525B;
  --muted-2: #3F3F46;
  --border: #C9C9C2;
  --divider: #E4E4DE;
  --yellow: #FFD23F;
  --red: #B91C1C;
  --link: #1F4FD8;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

/* The app fills the viewport; the screen layer takes what the warning leaves. */
.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.screen-layer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 16px; }

.warning {
  margin: 0;
  padding: 10px 16px;
  background: var(--red);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary {
  flex: none;
  height: 60px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 19px;
  font-weight: 700;
}

.outline {
  flex: none;
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}

/* ---- set-up ---- */
.setup { gap: 16px; overflow-y: auto; padding-top: 20px; padding-bottom: 20px; }
.title { display: flex; flex-direction: column; gap: 4px; }
.title h1 { margin: 0; font-family: var(--display); font-size: 32px; font-weight: 700; }
.setup .card:first-of-type { gap: 14px; }
.team-block { display: flex; flex-direction: column; gap: 8px; }
.name-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field-label { font-size: 14px; font-weight: 600; }
.input {
  height: 48px;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 17px;
  background: var(--card);
  color: var(--ink);
}
.input.short { font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 44px; height: 44px; border-radius: 10px; border: 0; padding: 0; }
.swatch[aria-pressed="true"] { border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px #FFFFFF; }
.divider { height: 1px; background: var(--divider); }
.halves { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.half {
  height: 48px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 16px;
  font-weight: 600;
}
.half[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }
.hint { font-size: 13px; color: var(--muted); }
.note { margin: 0; padding: 0 4px; font-size: 14px; line-height: 1.45; color: var(--muted-2); }
.spacer { flex: 1; min-height: 0; }

/* ---- live scoring: must fit 390 x 844 without scrolling ---- */
/* On shorter screens the buttons shrink (never under 44 px) and the screen scrolls as a fallback,
   so the phase button and Highlight are always reachable. Each clamp tops out at 844 px tall. */
.live { gap: 8px; overflow-y: auto; }
.live-head { flex: none; display: flex; align-items: center; justify-content: space-between; height: 52px; }
.clock {
  font-family: var(--display);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
}
.pair { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.score-card {
  background: var(--card);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.score-card.away { align-items: flex-end; }
.team-name {
  max-width: 100%;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score {
  font-family: var(--display);
  font-size: 64px;
  font-size: clamp(44px, 7.6vh, 64px);
  font-size: clamp(44px, 7.6dvh, 64px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.score-btn {
  height: 58px;
  height: clamp(44px, 7vh, 58px);
  height: clamp(44px, 7dvh, 58px);
  border: 0;
  border-radius: 12px;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 14px;
  font-size: min(18px, 4.6vw);
  font-weight: 600;
  white-space: nowrap;
}
.score-btn .pts { font-size: min(16px, 4.2vw); opacity: 0.85; }
.score-btn.small { height: 44px; font-size: 15px; padding: 0 14px; }
.score-btn.small .pts { font-size: 14px; }
.score-btn:active, .highlight:active, .outline:active, .primary:active { filter: brightness(0.85); }
.highlight {
  flex: none;
  height: 84px;
  height: clamp(56px, 10vh, 84px);
  height: clamp(56px, 10dvh, 84px);
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.hl-text { display: flex; flex-direction: column; align-items: flex-start; }
.hl-title { font-size: 24px; font-weight: 700; line-height: 1.1; }
.hl-sub { font-size: 13px; color: #E8E6DC; }
.phase-btn { height: 52px; height: clamp(44px, 6.2vh, 52px); height: clamp(44px, 6.2dvh, 52px); }
/* The recent list takes what is left and clips rows that do not fit; its heading (All events)
   always shows. */
.recent { flex: 1; min-height: 44px; overflow: hidden; display: flex; flex-direction: column; gap: 6px; }
.recent-head { flex: none; display: flex; align-items: center; gap: 8px; height: 44px; }
.recent-head .eyebrow { flex: 1; }
.link {
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
  padding: 0 4px;
}
.event-row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  background: var(--card);
  border-radius: 10px;
  padding: 0 12px;
}
.event-row .time { width: 44px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.event-row .dot { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.event-row .what {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-row .pts { font-size: 15px; font-weight: 600; color: var(--muted-2); }

/* ---- All events ---- */
.all { gap: 12px; overflow-y: auto; padding-bottom: 96px; }   /* room to scroll past the Undo bar */
.all-head { flex: none; display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.all-head h2 { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 700; }
.done { padding: 0 16px; font-size: 16px; }
.periods, .events { flex: none; display: flex; flex-direction: column; gap: 8px; }
.period { display: flex; flex-direction: column; gap: 8px; }
.period-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  padding: 0 14px;
  text-align: left;
}
.period-row .what { flex: 1; font-size: 16px; font-weight: 500; }
.period-row .time { font-size: 15px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.period-row .more { min-width: 56px; text-align: right; font-size: 15px; font-weight: 600; color: var(--link); }
.period-row:disabled { cursor: default; }
.period-row:disabled .time { color: var(--muted); }
.adjusts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.adjust, .choice {
  min-height: 44px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 15px;
  font-weight: 600;
  padding: 4px 6px;
  overflow-wrap: anywhere;
}
.choice[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }
.reopen { font-size: 16px; }
.choices { display: grid; gap: 6px; }
.choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.missed .primary { height: 52px; font-size: 17px; }
.all .event-row { height: auto; min-height: 56px; border-radius: 12px; padding: 0 6px 0 14px; }
.all .event-row .what { font-size: 16px; }
.remove {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1.5px solid var(--red);
  background: var(--card);
  color: var(--red);
  font-size: 15px;
  font-weight: 600;
}

/* ---- after full time ---- */
.final { gap: 16px; overflow-y: auto; padding-top: 20px; padding-bottom: 96px; }
.final-board {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: #FFFFFF;
  border-radius: 16px;
  padding: 18px;
}
.final-side { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.final-side.away { align-items: flex-end; }
.final-name { display: flex; align-items: center; gap: 6px; max-width: 100%; font-size: 14px; font-weight: 700; }
.final-name .dot { flex: none; width: 10px; height: 10px; border-radius: 3px; box-shadow: 0 0 0 1.5px #FFFFFF; }
.final-name .name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.final-side.away .final-name { flex-direction: row-reverse; }
.final-score {
  font-family: var(--display);
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.final-mid { font-size: 14px; color: var(--border); }
.stats { flex: none; padding: 14px 16px; }
.stat { display: flex; justify-content: space-between; font-size: 15px; }
.stat .value { color: var(--muted-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.file-actions { flex: none; display: flex; flex-direction: column; gap: 10px; }
.share { height: 56px; }
.file-name { text-align: center; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.final > .outline { min-height: 52px; }

/* ---- matches on the phone (set-up screen) ---- */
.matches { flex: none; gap: 8px; }
.match { display: flex; flex-direction: column; gap: 8px; }
.previous-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--divider);
  border-radius: 12px;
  background: var(--card);
  padding: 4px 12px;
  text-align: left;
}
.previous-row .when { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.previous-row .what { flex: 1; min-width: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.previous-row .status { font-size: 13px; color: var(--muted-2); }
.match-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.outline.danger { border-color: var(--red); color: var(--red); }

/* ---- Undo bar: overlays the bottom of the screen ---- */
.bar {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  min-height: 56px;
  background: var(--ink);
  color: #FFFFFF;
  border-radius: 14px;
  padding: 6px 6px 6px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.bar-text { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.undo {
  flex: none;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}
