/* Tuesday FC — phone first. Pitch green, chalk white, the two kits, and a referee-card yellow for jokes. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("/fonts/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage"; font-weight: 700; font-display: swap; src: url("/fonts/bricolage-grotesque-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage"; font-weight: 800; font-display: swap; src: url("/fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }

:root {
  --bg: #edf2eb;
  --surface: #ffffff;
  --surface-2: #f5f8f4;
  --ink: #142019;
  --ink-2: #4b5a51;
  --ink-3: #7c8982;
  --line: rgb(20 40 28 / 0.1);
  --border: rgb(20 40 28 / 0.18);
  --accent: #1d8a4b;
  --accent-hover: #17773f;
  --accent-ink: #ffffff;
  --accent-soft: rgb(29 138 75 / 0.12);
  --accent-text: #15703b;
  --head: #14432a;
  --head-ink: #ffffff;
  --gold: #f2c230;
  --gold-ink: #2e2400;
  --gold-soft: rgb(242 194 48 / 0.2);
  --danger: #c2412d;
  --danger-soft: rgb(194 65 45 / 0.12);
  --pitch: #2f9a58;
  --stripe: #2a8d50;
  --chalk: rgb(255 255 255 / 0.88);
  --kit-white: #fbfbf8;
  --kit-black: #17191a;
  --label: rgb(8 22 14 / 0.8);
  --shadow: 0 1px 2px rgb(20 40 28 / 0.06), 0 6px 20px rgb(20 40 28 / 0.06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Bricolage", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1410; --surface: #162019; --surface-2: #1c2820; --ink: #e5eee8; --ink-2: #a3b2a9; --ink-3: #74827a;
    --line: rgb(255 255 255 / 0.08); --border: rgb(255 255 255 / 0.15);
    --accent: #2f9e5d; --accent-hover: #38ad68; --accent-soft: rgb(102 211 149 / 0.14); --accent-text: #6bd497;
    --head: #0f2c1c; --gold-soft: rgb(242 194 48 / 0.16); --danger: #e8705c; --danger-soft: rgb(232 112 92 / 0.14);
    --pitch: #26804a; --stripe: #227443;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; overflow-wrap: anywhere;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
}
h1, h2, h3, p { margin: 0; }
h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 17px; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.field-stars { display: flex; flex-direction: column; gap: 4px; }
svg { flex: none; }

/* ── Header ───────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--head); color: var(--head-ink);
  padding-top: env(safe-area-inset-top, 0px);
}
.top-inner {
  max-width: 1160px; margin: 0 auto; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-ball { width: 30px; height: 30px; }
.ball-skin { fill: #ffffff; stroke: #0b0d0c; stroke-width: 1.6; }
.ball-patch { fill: #0b0d0c; }
.ball-seam { fill: none; stroke: #0b0d0c; stroke-width: 1.4; stroke-linecap: round; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: -0.01em; white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sync { font-size: 12.5px; color: rgb(255 255 255 / 0.72); white-space: nowrap; }
.sync.error { color: var(--gold); }
.lock {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgb(255 255 255 / 0.28); background: rgb(255 255 255 / 0.08); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.lock:hover { background: rgb(255 255 255 / 0.16); }
.lock svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lock.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

/* ── Tabs: bottom bar on phones, under the header on big screens ── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tabs button {
  flex: 1; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--ink-3); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--accent-text); }

main {
  max-width: 1160px; margin: 0 auto; padding-block: 16px 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tab { display: flex; flex-direction: column; gap: 14px; }
.loading { color: var(--ink-2); padding: 40px 0; text-align: center; }

@media (min-width: 920px) {
  body { padding-bottom: 0; }
  .tabs {
    position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); bottom: auto; z-index: 15; justify-content: center; gap: 4px;
    border-top: 0; border-bottom: 1px solid var(--line); padding: 6px 16px;
  }
  .tabs button { flex: none; flex-direction: row; height: 38px; padding: 0 16px; border-radius: 999px; font-size: 14px; gap: 8px; }
  .tabs svg { width: 18px; height: 18px; }
  .tabs button[aria-current="page"] { background: var(--accent-soft); }
  main { padding-block: 22px 48px; }
}

/* ── Cards, fields, buttons ───────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hint { color: var(--ink-2); font-size: 13.5px; }
.muted { color: var(--ink-3); }
.count { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink); font-size: 15px; font-weight: 400;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.7; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger.sure { background: var(--danger); color: #fff; }
.btn.big { min-height: 52px; font-size: 16px; border-radius: 14px; width: 100%; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { width: 42px; min-width: 42px; padding: 0; }
:is(.btn, .tabs button, .lock, .pchip, .tok, input, select, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 520px) { .actions { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 14px; background: var(--gold-soft); font-size: 14px; }
.banner b { font-weight: 600; }
.empty { padding: 18px; border: 1px dashed var(--border); border-radius: 14px; color: var(--ink-2); text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ── Player chips ─────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px 0 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.pchip .dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.pchip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.pchip.on .dot { background: var(--accent); border-color: var(--accent); }
.pchip .dot.white { background: var(--kit-white); border-color: var(--kit-black); }
.pchip .dot.black { background: var(--kit-black); border-color: var(--ink-2); }
.pchip .tag { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.pchip:disabled { cursor: default; }

/* ── Line-up layout ───────────────────────────── */
.lineup { display: flex; flex-direction: column; gap: 14px; }
.controls, .field { display: contents; }
.o-banner { order: 0; } .o-match { order: 1; } .o-coming { order: 2; } .o-actions { order: 3; }
.o-team-black { order: 4; } .o-pitch { order: 5; } .o-team-white { order: 6; } .o-make { order: 7; }
.o-waiting { order: 8; } .o-caption { order: 9; }
@media (min-width: 920px) {
  .lineup { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 500px); gap: 20px; align-items: start; }
  .controls, .field { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .field { position: sticky; top: 124px; }
}

.team-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team-row input { min-height: 38px; font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.team-row select { width: auto; min-height: 38px; flex: none; }
.kit { flex: none; display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 999px; font-family: var(--font-display); font-weight: 800; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; }
.kit.white { background: var(--kit-white); color: var(--kit-black); border: 1.5px solid var(--kit-black); }
.kit.black { background: var(--kit-black); color: var(--kit-white); border: 1.5px solid var(--kit-black); }
.team-block { display: flex; flex-direction: column; gap: 8px; }
.bench { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.bench .pchip { min-height: 30px; font-size: 13px; padding: 0 10px; }

/* ── The pitch ────────────────────────────────── */
.pitch {
  position: relative; width: 100%; aspect-ratio: 1000 / 1220; max-width: 100%; border-radius: 18px; overflow: hidden;
  background: repeating-linear-gradient(180deg, var(--stripe) 0 8.3333%, var(--pitch) 8.3333% 16.6667%);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08), var(--shadow); touch-action: none; user-select: none; -webkit-user-select: none;
}
.pitch-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pitch-lines * { fill: none; stroke: var(--chalk); stroke-width: 5; vector-effect: non-scaling-stroke; }
.pitch-lines .spot { fill: var(--chalk); stroke: none; }
.pitch-lines .goal { stroke: #fff; stroke-width: 6; }
.pitch-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 3px rgb(0 0 0 / 0.4); pointer-events: none; }

.tok {
  /* the shirt's centre sits on the player's spot: half the shirt height is 0.262 x token width */
  position: absolute; transform: translateX(-50%); margin-top: calc(var(--tok, 15%) * -0.262);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: var(--tok, 15%); padding: 0; border: 0; background: none; cursor: pointer; touch-action: none; z-index: 2;
}
.tok.locked { cursor: default; }
.tok.dragging { z-index: 5; cursor: grabbing; }
.tok .shirt { width: 64%; height: auto; overflow: visible; filter: drop-shadow(0 3px 4px rgb(0 0 0 / 0.35)); }
.tok.white .shirt path { fill: var(--kit-white); stroke: var(--kit-black); }
.tok.black .shirt path { fill: var(--kit-black); stroke: var(--kit-white); }
.tok .shirt path { stroke-width: 5; stroke-linejoin: round; }
.tok .shirt text { font-family: var(--font-display); font-weight: 800; font-size: 34px; text-anchor: middle; dominant-baseline: middle; }
.tok.white .shirt text { fill: var(--kit-black); }
.tok.black .shirt text { fill: var(--kit-white); }
.tok .tname { max-width: 180%; padding: 1px 7px; border-radius: 999px; background: var(--label); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tok .tnick { max-width: 150%; color: var(--gold); font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgb(0 0 0 / 0.6); }
.tok .tbadge { position: absolute; z-index: 1; top: 0; left: 50%; transform: translate(-50%, -45%); max-width: 190%; box-shadow: 0 0 0 1px var(--gold-ink); padding: 1px 6px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: 9.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 520px) { .tok .tname { font-size: 12.5px; } .tok .tnick { font-size: 11px; } .tok .tbadge { font-size: 10.5px; } }
/* On a small phone pitch there's no room for nicknames; they still show on the picture. */
@media (max-width: 519px) { .tok .tnick { display: none; } }

/* ── Bottom sheet / dialog ────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(5 15 9 / 0.55); }
.sheet-panel {
  position: relative; width: min(560px, 100%); max-height: calc(100% - 24px); overflow: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; display: flex; flex-direction: column; gap: 14px;
  padding: 20px max(18px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  box-shadow: 0 -10px 40px rgb(0 0 0 / 0.25);
}
@media (min-width: 620px) { .sheet { align-items: center; } .sheet-panel { border-radius: 20px; max-height: calc(100% - 48px); } }
.sheet-panel.full { min-height: 60%; justify-content: center; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet-sub { color: var(--ink-2); font-size: 14px; }
.close { flex: none; }
.menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.menu .btn { justify-content: flex-start; }
.menu .btn.current { border-color: var(--accent); background: var(--accent-soft); }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 1.3em; }
.pic-preview { width: 100%; max-height: 58vh; object-fit: contain; border-radius: 12px; background: #0b2a19; }
.pin-input { font-size: 26px; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }

/* ── Lists ────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line); min-width: 0; }
.list-row:first-child { border-top: 0; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-title { font-weight: 600; }
.list-sub { color: var(--ink-2); font-size: 13px; }
.list-row.current .list-title::after { content: "Showing"; margin-left: 8px; font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; vertical-align: 1px; }
.pos { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }

.stars { display: inline-flex; gap: 2px; }
.stars button { width: 34px; height: 34px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink-3); }
.stars button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.stars button.on { color: var(--gold); }
.stars button.on svg { fill: currentColor; }
.stars-text { color: var(--gold); letter-spacing: 1px; font-size: 13px; }

details.builtin summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
details.builtin ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; display: grid; gap: 3px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; }

/* ── Toast ────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 12px;
  background: #102619; color: #fff; font-size: 14px; box-shadow: 0 8px 30px rgb(0 0 0 / 0.3);
}
.toast button { border: 0; background: none; color: var(--gold); font-weight: 700; cursor: pointer; padding: 4px; }
@media (min-width: 920px) { .toast { bottom: 24px; } }

@media (prefers-reduced-motion: no-preference) {
  .sheet-panel { animation: rise 0.18s cubic-bezier(0.2, 0, 0, 1); }
  @keyframes rise { from { transform: translateY(16px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}
