:root {
  /* Club colours, font and radius live in brand.css. These are the fixed status colours. */
  --brand-surface: #ffffff;
  --brand-danger: #b42318;
  --brand-ok: #1a7f37;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--brand-ink); background: var(--brand-page); line-height: 1.45; font-size: 16px; }
a { color: var(--brand-primary); }
h1 { font-size: 1.6rem; margin: 0 0 10px; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
.wrap { max-width: 900px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--brand-muted); }
.small { font-size: .85rem; }
.error { color: var(--brand-danger); }

header.site { background: var(--brand-primary); color: #fff; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
header.site .brand { font-weight: 700; font-size: 1.05rem; margin-right: auto; }
header.site a { color: #fff; text-decoration: none; font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 6px 10px; border-radius: 6px; }
.tabs a.active, .tabs a:hover { background: rgba(255,255,255,.18); }
.live-dot { font-size: .85rem; opacity: .85; }
.live-dot.on { color: #b9f6c8; opacity: 1; }
.site-foot { text-align: center; color: var(--brand-muted); font-size: .9rem; padding: 24px 16px 40px; }

.card { background: var(--brand-surface); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.back { display: inline-block; margin: 4px 0 12px; font-weight: 600; }

/* fixture cards */
.fixture { display: block; color: inherit; text-decoration: none; margin: 0; }
.fixture:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .9rem; margin-bottom: 8px; }
.line { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.team { font-weight: 600; }
.team.home { text-align: left; }
.team.away { text-align: right; }
.score { font-weight: 800; font-size: 1.5rem; font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: center; }
.score.big { font-size: 2.6rem; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #e8eef7; color: var(--brand-primary); }
.pill.live { background: #d92d20; color: #fff; }
.pill.ok { background: #e6f4ea; color: var(--brand-ok); }
.pill.warn { background: #fff4d6; color: #7a5b00; }

.match .scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 10px; font-size: 1.1rem; }
.match .scoreboard a { text-decoration: none; color: var(--brand-ink); font-weight: 700; }
.match .scoreboard a:last-child { text-align: right; }
.chip { display: inline-block; background: var(--c); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: .8rem; margin: 0 6px; vertical-align: middle; }
.goals { padding-left: 1.2em; margin: 0; }
.goals li { margin: 6px 0; }
.min { display: inline-block; min-width: 3.5ch; font-weight: 700; color: var(--brand-muted); }

.team-card { display: block; text-decoration: none; color: inherit; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid #e3e7ee; vertical-align: middle; }
th { color: var(--brand-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.scroll { overflow-x: auto; }

/* admin */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid #c8cfd9; border-radius: 8px; font: inherit; background: #fff; min-height: 40px; }
input[type=checkbox] { width: auto; min-height: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
button, .btn { background: var(--brand-primary); color: #fff; border: 0; padding: 10px 14px; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; min-height: 42px; }
button.secondary { background: #fff; color: var(--brand-primary); border: 1px solid var(--brand-primary); }
button.danger { background: #fff; color: var(--brand-danger); border: 1px solid var(--brand-danger); }
button.goal { background: var(--brand-ok); font-size: 1rem; }
button:disabled { opacity: .5; cursor: default; }
.banner { border-left: 4px solid var(--brand-accent); background: #fff8e1; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.status-line { min-height: 1.4em; font-size: .95rem; margin: 6px 0; }
.status-line.err { color: var(--brand-danger); }
.status-line.ok { color: var(--brand-ok); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.hidden { display: none !important; }
.block { border: 1px solid #e3e7ee; border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.block h3 { margin: 0 0 8px; font-size: 1rem; }
.addform { margin-top: 10px; }

@media (max-width: 560px) {
  .score.big { font-size: 2rem; }
  .match .scoreboard { grid-template-columns: 1fr; text-align: center; }
  .match .scoreboard a:last-child { text-align: center; }
}

/* Division switcher, shown under the header on the public site. */
.division-bar { display: flex; align-items: center; gap: 0.5rem; padding-top: 0.75rem; }
.division-bar label { font-weight: 600; }
.division-bar select { min-width: 12rem; }
[hidden] { display: none !important; }

/* Referee console: large touch targets for use on a phone at the pitch side. */
.console-page .wrap { max-width: 40rem; }
.console-page button { min-height: 3rem; font-size: 1.05rem; margin: 0.25rem 0.25rem 0.25rem 0; }
.console-page .next { width: 100%; margin-top: 0.75rem; font-size: 1.2rem; }
.console-page .goal-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0; }
.console-page .goal-buttons button { flex: 1 1 10rem; }
.console-page .game-row { display: block; width: 100%; text-align: left; margin: 0.5rem 0; }
.console-page .big-score { font-size: 3rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.console-page .period { text-align: center; color: #555; }
.console-page .minute { width: 6rem; }
.console-page .player { display: block; width: 100%; text-align: left; }
.console-page .picker-players { margin: 0.5rem 0; }

/* Floating messages: confirmations and errors stay visible wherever the page is scrolled. Hidden when empty. */
#notice, .console-page #status {
  position: fixed; top: 4.5rem; right: 1rem; left: auto; z-index: 100;
  max-width: 26rem; margin: 0; padding: 0.75rem 1rem;
  background: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  border-left: 5px solid var(--brand-ok, #2e7d32); font-size: 1rem;
}
.console-page #status { left: 1rem; right: 1rem; max-width: none; }
#notice:empty, .console-page #status:empty { display: none; }
#notice.err, .console-page #status.err { border-left-color: var(--brand-danger, #c62828); }

/* ---- Admin shell (competitions, tabs, tables, dialogs) ---- */
.wrap.wide { max-width: 1180px; }
header.site .signed-in { font-size: .9rem; opacity: .95; }
.admin-page header.site button.secondary { min-height: 34px; padding: 6px 12px; }
.page-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.page-head h1, .page-head h2, .page-head h3 { margin: 0; }
.crumb { margin: 4px 0 8px; font-weight: 600; }
.subtabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid #dde3ec; margin-bottom: 16px; }
.subtabs a { padding: 10px 16px; text-decoration: none; font-weight: 700; color: var(--brand-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.subtabs a:hover { color: var(--brand-primary); }
.subtabs a.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
table.data th, table.data td { padding: 10px 10px; }
table.data tbody tr:hover { background: #f7f9fc; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.small-btn { min-height: 34px; padding: 6px 12px; font-size: .9rem; }
a.btn { display: inline-block; background: var(--brand-primary); color: #fff; text-decoration: none; padding: 10px 14px; border-radius: 8px; font-weight: 700; }
a.btn.small-btn { padding: 6px 12px; line-height: 1.4; }
button.danger-solid { background: var(--brand-danger); color: #fff; border: 0; }
.empty { color: var(--brand-muted); padding: 18px 4px; margin: 0; }
.field { margin-bottom: 4px; }
.field small { display: block; margin-top: 3px; }
.field.inline { display: flex; align-items: center; gap: 10px; max-width: 360px; margin-bottom: 12px; }
.field.inline label { margin: 0; white-space: nowrap; }
.narrow-card { max-width: 480px; }
.round { margin-top: 14px; }
.round h3 { font-size: 1rem; }

/* highlight the record that was just saved */
@keyframes flash-row { from { background: #fff0b3; } to { background: transparent; } }
tr.flash td { animation: flash-row 3s ease-out; }

/* overview */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); text-align: center; }
.stat strong { display: block; font-size: 2rem; color: var(--brand-primary); }
.stat span { color: var(--brand-muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 10px 4px; border-bottom: 1px solid #e3e7ee; }
.checklist .tick { display: inline-block; width: 1.6em; color: var(--brand-muted); font-weight: 700; }
.checklist li.done .tick { color: var(--brand-ok); }
.checklist a { font-weight: 700; }

/* dialog used for every form and delete */
dialog#dlg { border: 0; border-radius: 12px; padding: 22px; width: min(560px, calc(100vw - 24px)); box-shadow: 0 12px 48px rgba(0,0,0,.3); }
dialog#dlg::backdrop { background: rgba(20, 28, 40, .5); }
dialog#dlg h2 { margin-top: 0; }
dialog#dlg .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 12px 0; }
dialog#dlg .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }
dialog#dlg .status-line { min-height: 1.4em; }
ul.impact { margin: 6px 0 14px; padding-left: 1.3em; }
ul.impact li { margin: 3px 0; }
dialog#dlg ol.goals { margin: 0 0 8px; }
dialog#dlg ol.goals li { display: flex; gap: 8px; align-items: center; }

@media (max-width: 560px) {
  .subtabs a { padding: 9px 10px; }
  .page-head { align-items: flex-start; }
}

/* ---- Knockout bracket (public site, projector screen) ---- */
.bracket { display: flex; gap: 22px; overflow-x: auto; padding: 4px 2px 10px; }
.b-round { display: flex; flex-direction: column; min-width: 230px; flex: 1; }
.b-title { margin: 0 0 8px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-muted); }
.b-games { display: flex; flex-direction: column; justify-content: space-around; gap: 14px; flex: 1; }
.b-game { display: block; color: inherit; text-decoration: none; background: #fff; border: 1px solid #d5dce7; border-radius: 10px; padding: 8px 10px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
a.b-game:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.b-game.is-live { border-color: #d92d20; }
.b-label { font-size: .75rem; color: var(--brand-muted); font-weight: 700; margin-bottom: 4px; }
.b-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.b-row + .b-row { border-top: 1px solid #eef1f6; }
.b-row.win { font-weight: 800; }
.b-score { font-variant-numeric: tabular-nums; min-width: 1.5ch; text-align: right; }
.b-pens { font-size: .75rem; color: var(--brand-muted); margin-top: 3px; }

/* ---- Matchday home: division filter chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { background: #fff; color: var(--brand-primary); border: 1px solid #c8cfd9; min-height: 38px; padding: 6px 14px; border-radius: 999px; font-weight: 700; }
.chips button[aria-pressed="true"] { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.division-tag { font-size: .75rem; font-weight: 700; color: var(--brand-primary); background: #e8eef7; border-radius: 6px; padding: 2px 7px; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: baseline; margin: 6px 0 2px; }
.day-head h1 { margin: 0; }
.division-head { margin: 22px 0 8px; font-size: 1.05rem; color: var(--brand-primary); }
.knockout-note { font-weight: 700; }

/* admin: screens builder, knockout dialog */
.fields.wide-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 10px; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
#screen-url { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
ul.impact.warn { background: #fff4d6; border-radius: 8px; padding: 10px 10px 10px 28px; color: #5c4400; }
