:root {
  --bg: #f3f5f2; --card: #fff; --ink: #1b241d; --muted: #66706a; --line: #dde3de;
  --accent: #1f7a3f; --accent-ink: #fff; --warn: #b26a00; --danger: #b3261e; --sel: #e3f3e8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111613; --card: #1b221d; --ink: #e8ede9; --muted: #9aa49d; --line: #2c362f; --sel: #183a24; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
main { max-width: 640px; margin: 0 auto; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.4rem; margin: 8px 4px 12px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* safe-area insets keep content clear of the notch / home bar when launched from the home screen */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
  background: var(--accent); color: var(--accent-ink); }
.topbar .brand { display: flex; text-decoration: none; }
.topbar .brand img { border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.4); }
.topbar nav { display: flex; gap: 0; flex: 1; overflow-x: auto; }
.topbar nav a { text-decoration: none; padding: 6px 8px; border-radius: 8px; opacity: .85; white-space: nowrap; font-size: .95rem; }
.topbar nav a.on { background: rgba(255,255,255,.2); opacity: 1; }
button.link { background: none; border: 0; color: inherit; font: inherit; font-size: .8rem; opacity: .85; cursor: pointer; white-space: nowrap; }

.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  margin-bottom: 12px; text-decoration: none; }
.card.ok { border-color: var(--accent); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 12px; padding-bottom: 2px; }
.tabs a { white-space: nowrap; padding: 8px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  text-decoration: none; font-size: .9rem; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 3.1em; padding: 3px 6px;
  border-radius: 6px; font-weight: 700; font-size: .8rem; letter-spacing: .03em; color: #fff; background: var(--c);
  text-shadow: 0 1px 1px rgba(0,0,0,.35); }

/* Team logos sit on a light tile so dark logos stay visible in dark mode. */
.tlogo { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: .8rem; letter-spacing: .03em; }
.tlogo img { width: 26px; height: 26px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px;
  box-shadow: 0 0 0 1px var(--line); }
.tlogo.md img { width: 40px; height: 40px; padding: 3px; }
.tlogo.lg img { width: 52px; height: 52px; padding: 4px; border-radius: 10px; }

/* Match card */
.match .meta { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted);
  margin-bottom: 10px; gap: 8px; }
.match .row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.match .label { font-size: .85rem; color: var(--muted); margin-right: auto; }
.match.saving { opacity: .8; }
.match.locked { opacity: .65; }
.match button { flex: 1; min-height: 44px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; font: inherit; cursor: pointer; transition: background .1s, border-color .1s; }
.match button.sel { border-color: var(--accent); background: var(--sel); font-weight: 600; }
.match button:disabled { cursor: not-allowed; }
.match .winner .team { flex: 3; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; }
.match .winner .draw { flex: 1; font-size: .85rem; }
.match .team .name { font-size: .9rem; }
.match .margin .label { margin-right: 0; flex: 0 0 auto; }
.match .first button { flex: 0 0 72px; }
.lockmsg { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.tbc { font-size: .75rem; color: var(--warn); }

.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pill.ok { background: var(--sel); color: var(--accent); }
.pill.draft { background: #fff1d6; color: #7a4a00; }
.pill.warn { background: #fde4e1; color: var(--danger); }

.primary { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 10px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.primary.big { width: 100%; padding: 14px; font-size: 1.05rem; }
.danger { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: 10px; padding: 9px 14px;
  font: inherit; cursor: pointer; }

.review-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.review-row .pick { text-align: right; font-size: .9rem; max-width: 55%; }
.review-row .status { margin-top: 4px; }
.teams { display: flex; align-items: center; gap: 6px; }
.confirm { margin: 16px 0; }

.card.table { display: table; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; padding: 4px 0; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table tr.me td { background: var(--sel); }

.result-head { justify-content: center; gap: 14px; font-size: 1.1rem; }
.score { font-size: 1.4rem; }
.entries { list-style: none; padding: 0; margin: 10px 0 0; }
.entries li { display: grid; grid-template-columns: 5.5em 1fr 2em 6.2em; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line);
  align-items: center; }
.entries li.me { font-weight: 600; }
.entries .pts { text-align: right; font-weight: 700; }

.login { max-width: 360px; margin: 12vh auto; display: grid; gap: 12px; }
.login h1 { text-align: center; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select { font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); }
.error { color: var(--danger); margin: 0; }

.admin-match .grid { margin: 10px 0; }
.admin-match .check { display: flex; align-items: center; gap: 6px; }
.admin-match .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Forms & account */
.form { display: grid; gap: 12px; }
.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.wide { width: 100%; padding: 12px; }
.spaced { margin-top: 18px; }

/* Admin: invites & players */
.invite-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.link-row { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.link-row.fresh { background: var(--sel); margin: 0 -14px; padding: 10px 14px; }
.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; font-size: .8rem; padding: 8px; }
.copy-row .primary, .copy-row .danger { padding: 8px 12px; font-size: .85rem; }
.users { list-style: none; padding: 0; margin: 0; }
.users li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--line); }
.users li:first-child { border-top: 0; }
.users li.inactive { opacity: .6; }
.users .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* WhatsApp sharing */
.share-row { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 10px; }
.share-row .lockmsg { margin: 0 auto 0 0; }
.wa { display: inline-flex; align-items: center; gap: 6px; background: #25d366; color: #063b1c; font-weight: 600;
  font-size: .85rem; padding: 7px 12px; border-radius: 999px; text-decoration: none; }
.wa::before { content: "💬"; }
.share-card { text-align: center; }
.share-card h1 { margin: 14px 0 4px; }
.share-card .result-head { margin: 10px 0 4px; }
.crowd { margin: 18px 0; text-align: left; }
.crowd-row { display: grid; grid-template-columns: 7.5em 1fr 2em; gap: 8px; align-items: center; margin: 6px 0; font-size: .9rem; }
.crowd .bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.crowd .bar span { display: block; height: 100%; background: var(--accent); }
.crowd .n { text-align: right; font-weight: 600; }
.center.primary { display: block; text-align: center; }
.wa.sm { font-size: .75rem; padding: 4px 9px; justify-self: end; }
.match button:disabled:not(.sel) { opacity: .55; }

/* Mates' picks */
.mates { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.mates summary { cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--accent); padding: 4px 0; }
.mates ul { list-style: none; padding: 0; margin: 6px 0 0; }
.mates li { display: grid; grid-template-columns: 6.5em 1fr auto; gap: 8px; align-items: center; padding: 7px 0;
  border-top: 1px solid var(--line); font-size: .85rem; }
.mates .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mates-note { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }

/* One-tap lock-in and compact locked-in cards */
.lockin-row { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 12px; }
.lockin-row .primary { padding: 12px 20px; font-size: 1rem; }
.match.compact .meta { margin-bottom: 6px; }
.match .summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.match .summary .v { color: var(--muted); font-size: .85rem; }
.match .summary .mine { margin-left: auto; font-weight: 600; font-size: .9rem; }
.match { scroll-margin-top: calc(70px + env(safe-area-inset-top)); }  /* clear the sticky top bar */
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 44px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0;
  font-size: 1.1rem; padding: 6px 8px; cursor: pointer; opacity: .7; }
.match .lockin-row button.primary { flex: 0 0 auto; background: var(--accent); color: var(--accent-ink); border: 0;
  font-weight: 700; min-width: 9.5em; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.two input { width: 100%; min-width: 0; }
.warn-card { border-color: var(--warn); background: #fff6e6; color: #5c3b00; }
@media (prefers-color-scheme: dark) { .warn-card { background: #3a2a0c; color: #ffe2a8; } }

/* Pick options (one row of buttons per question) */
.match .dim[data-kind]:not(.winner) { margin-top: 12px; }
.match .dim .label { display: block; font-size: .8rem; color: var(--muted); margin: 0 0 6px; }
.match .dim .row.opts { margin-top: 0; flex-wrap: wrap; }
.match .dim .row.opts button { flex: 1 1 0; min-width: 3.5em; }

/* Competition bar under the header */
.compbar { max-width: 640px; margin: 0 auto; padding: 8px 12px 0; font-size: .85rem; color: var(--muted); }
.compbar .compname { font-weight: 600; }
.compswitch { font: inherit; font-weight: 600; padding: 6px 8px; border-radius: 8px; max-width: 100%; }

/* Admin: competition settings */
.opt-row { border-top: 1px solid var(--line); padding: 10px 0; display: grid; gap: 8px; }
.opt-row.off { opacity: .55; }
.opt-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.opt-edit { display: grid; grid-template-columns: minmax(0, 2fr) 5em auto auto auto; gap: 8px; align-items: end; }
.opt-edit input { min-width: 0; width: 100%; }


/* Form grids: let fields shrink to the column instead of pushing the page wider than the phone. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 10px; align-items: end; }
.grid label, .two label { min-width: 0; }
.grid input, .grid select, .two input, .opt-edit input { width: 100%; min-width: 0; }
.grid input[type=checkbox] { width: auto; }
.grid input[type=color] { height: 42px; padding: 4px; }

.fetch-card { display: grid; gap: 8px; }
.fetch-card p { margin: 0; }
.ok-text { color: var(--accent); font-weight: 600; }

.attention { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.attention a { font-weight: 600; }
.admin-match .actions { flex-wrap: wrap; }

/* Banter */
.social { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reacts { display: flex; gap: 4px; flex-wrap: wrap; }
.reacts button, .verdicts button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 3px 8px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 30px; }
.reacts button.sel, .verdicts button.sel { border-color: var(--accent); background: var(--sel); }
.reacts button .n, .verdicts button .n { font-size: .75rem; font-weight: 700; margin-left: 2px; }
.reacts.readonly button { cursor: default; }
.verdicts { display: flex; gap: 4px; }
.verdicts button { font-size: .78rem; }
.entries li .social { padding-top: 2px; }
.callouts { list-style: none; padding: 10px 12px; margin: 10px 0 0; background: var(--sel); border-radius: 10px; display: grid; gap: 6px; font-size: .88rem; }
.callouts .e { display: inline-block; width: 1.4em; }
.talking ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; font-size: .9rem; }
.talking h2 { margin-bottom: 6px; }
.joker-row { margin-top: 10px; }
.joker { width: 100%; border: 1.5px dashed var(--line); background: none; color: var(--ink); border-radius: 10px; padding: 9px; font: inherit; font-size: .9rem; cursor: pointer; }
.joker.on { border-style: solid; border-color: #7a4a00; background: #fff1d6; color: #5c3b00; font-weight: 600; }
@media (prefers-color-scheme: dark) { .joker.on { background: #3a2a0c; color: #ffe2a8; } }
.joker-status { margin: 0 4px 12px; color: var(--muted); }
.about-me { margin: 8px 0 0; color: var(--muted); }
.mates li { grid-template-columns: 6.5em 1fr auto; }
.verdicts button, .reacts button { white-space: nowrap; }

/* Picks-to-make count and install helper */
.topbar nav .count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.35em; height: 1.35em;
  padding: 0 4px; margin-left: 2px; border-radius: 999px; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700; }
.install-card { position: relative; border-color: var(--accent); }
.install-card h2 { margin-right: 1.5em; }
.install-card p { margin: 6px 0; }
.install-card .close { position: absolute; top: 8px; right: 10px; color: var(--muted); font-size: 1rem; opacity: 1; }
.deadline p { margin: 4px 0; }
.deadline.closed { border-color: var(--accent); background: var(--sel); }
.mates li.nopick { grid-template-columns: 6.5em 1fr; opacity: .7; }
.match .meta .saved { font-size: .75rem; font-weight: 700; color: var(--accent); opacity: 0; transition: opacity .2s; }
.match .meta .saved.show { opacity: 1; }
.copy-row .wa { padding: 8px 10px; font-size: .8rem; white-space: nowrap; }
.copy-row .wa::before { content: ""; }
