:root {
  /* Club colours: change these two to rebrand the app. */
  --brand: #EC1C24;
  --brand-contrast: #ffffff;

  --bg: #f3f1ee;
  --surface: #ffffff;
  --text: #1d1b1a;
  --muted: #6b6560;
  --line: #e4dfda;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --error-bg: #fde3e3;
  --error-text: #8a1c1c;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .06);
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141212;
    --surface: #211e1e;
    --text: #f2eeea;
    --muted: #a59e98;
    --line: #353030;
    --warn-bg: #3a3014;
    --warn-text: #f3d98c;
    --error-bg: #3d1a1a;
    --error-text: #f5b3b3;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px;
  background: var(--brand); color: var(--brand-contrast);
}
.appbar-text { flex: 1; min-width: 0; }
.appbar h1 { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-sub { margin: 0; font-size: 13px; opacity: .85; }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%;
  background: rgb(255 255 255 / .15); color: inherit;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Banner ---------- */
.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px; font-size: 14px; background: var(--warn-bg); color: var(--warn-text); }
.banner.error { background: var(--error-bg); color: var(--error-text); }

/* ---------- Main view ---------- */
main {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  outline: none;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.count { background: var(--line); color: var(--text); border-radius: 999px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }

.event { text-align: center; padding: 20px 16px; }
.event .when { font-size: 20px; font-weight: 700; margin: 0; }
.event .where { margin: 6px 0 0; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.event .where svg { width: 18px; height: 18px; }

.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px; }

/* ---------- Team grid ---------- */
.team-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.team-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  min-height: 116px; padding: 16px;
  border-radius: var(--radius);
  background: var(--team); color: #fff;
  text-decoration: none; box-shadow: var(--shadow);
  transition: transform .1s;
}
.team-btn:active { transform: scale(.97); }
.team-btn .avatar { width: 40px; height: 40px; border-radius: 50%; background: rgb(255 255 255 / .25); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.team-btn .name { font-size: 20px; font-weight: 800; line-height: 1.1; word-break: break-word; }
.team-btn .meta { font-size: 13px; opacity: .9; margin-top: auto; }
.team-btn .mine { position: absolute; top: 12px; right: 12px; background: #fff; color: var(--team); font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }

/* ---------- Team page ---------- */
.team-hero { background: var(--team); color: #fff; border-radius: var(--radius); padding: 18px 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.team-hero .avatar { width: 52px; height: 52px; border-radius: 50%; background: rgb(255 255 255 / .25); display: grid; place-items: center; font-weight: 800; font-size: 24px; flex: none; }
.team-hero h2 { margin: 0; font-size: 26px; line-height: 1.1; }
.team-hero p { margin: 2px 0 0; opacity: .9; font-size: 14px; }

.pitch-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.pitch-chip {
  min-width: 56px; height: 56px; padding: 0 12px;
  display: grid; place-items: center;
  border-radius: 14px; background: var(--team); color: #fff;
  font-size: 26px; font-weight: 800;
}
.pitch-chip.text { font-size: 16px; }
.pitch-chip.rest { background: var(--line); color: var(--muted); font-size: 15px; }
.arrow { color: var(--muted); width: 20px; height: 20px; }

.games-details summary {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px; padding: 6px 0;
  font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; list-style: none;
}
.games-details summary::-webkit-details-marker { display: none; }
.games-details summary::before { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; }
.games-details[open] summary::before { transform: rotate(45deg); }

.schedule { display: block; text-decoration: none; }
.schedule h2 { justify-content: space-between; }
.schedule h2 .chev { width: 18px; height: 18px; }
.schedule .pitch-flow { margin-bottom: 0; }

.games { list-style: none; margin: 0; padding: 0; }
.games li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.games li span:last-child { font-weight: 700; white-space: nowrap; }

.names { margin: 0; padding: 0; list-style: none; counter-reset: n; }
.names li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 17px; }
.names li:first-child { border-top: 0; }
.names.numbered li::before { counter-increment: n; content: counter(n); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.empty { color: var(--muted); margin: 0; }

/* ---------- Buttons & list rows ---------- */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn {
  flex: 1 1 140px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px;
  border-radius: 12px; border: 0;
  background: var(--brand); color: var(--brand-contrast);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn.secondary { background: var(--line); color: var(--text); }
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: scale(.97); }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none;
}
.list-row .thumb { width: 64px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.list-row .body { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.list-row .sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .chev { color: var(--muted); flex: none; }
.tag { font-size: 11px; font-weight: 800; text-transform: uppercase; background: var(--brand); color: var(--brand-contrast); border-radius: 999px; padding: 2px 8px; }

/* ---------- Venue page ---------- */
.layout-btn { display: block; width: 100%; padding: 0; border: 0; background: none; border-radius: 12px; overflow: hidden; cursor: zoom-in; position: relative; }
.layout-btn img { display: block; width: 100%; height: auto; }
.layout-btn .hint { position: absolute; right: 8px; bottom: 8px; background: rgb(0 0 0 / .6); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 999px; }
.venue-name { margin: 0 0 4px; font-size: 22px; }
.address { margin: 0; color: var(--muted); }
.notes { margin: 0; white-space: pre-line; }

/* ---------- Zoom overlay ---------- */
.zoom { position: fixed; inset: 0; z-index: 50; background: #000; }
/* flex + margin:auto centres the image without clipping it once zoomed */
.zoom-scroll { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; }
.zoom-scroll img { display: block; margin: auto; flex: none; width: 100%; max-width: none; height: auto; }
.zoom-controls { position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 16px); display: flex; gap: 10px; }
.zoom-controls .icon-btn { width: 52px; height: 52px; background: rgb(255 255 255 / .9); color: #111; }

/* ---------- Status screens ---------- */
.status { text-align: center; padding: 48px 16px; color: var(--muted); }
.status .big { font-size: 18px; color: var(--text); font-weight: 700; margin: 0 0 8px; }
.status.error .big { color: var(--error-text); }
.skeleton { height: 116px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line) 25%, var(--surface) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

details.warnings { margin-top: 20px; font-size: 14px; color: var(--muted); }
details.warnings summary { cursor: pointer; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar a span { max-width: 100%; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabbar a.active { color: var(--brand); }
@media (prefers-color-scheme: dark) { .tabbar a.active { color: #ff5a5f; } }
.tabbar a.disabled { opacity: .4; }
