:root {
  --bg: #f3f5f8; --card: #fff; --text: #1b2430; --muted: #6b7684; --line: #e2e6ec;
  --brand: #14213d; --accent: #f2b705; --link: #1f5fbf;
  --win: #1e8e4a; --loss: #c0392b; --draw: #8a8f98; --me: #fff6d6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141b; --card: #18202b; --text: #e6ebf1; --muted: #93a0ae; --line: #2a3542;
    --brand: #0b1220; --link: #7fb0ff; --me: #3a3214; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.5rem; margin: 18px 0 10px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h2 a.small { font-weight: normal; margin-left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
code { background: var(--line); padding: 1px 4px; border-radius: 4px; }

.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-inner { display: flex; align-items: center; gap: 16px; min-height: 52px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #cfd8e6; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { color: #111; background: var(--accent); font-weight: 600; }
.nav .logout { margin-left: auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 0 0 16px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
details.card > summary { cursor: pointer; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.grid2 > .card { margin: 0; }
.grid2 { margin-bottom: 16px; }

.flash { padding: 10px 12px; border-radius: 8px; margin: 12px 0; background: #e5f5ea; color: #145c30; }
.flash.err { background: #fde8e6; color: #8c2318; }
.flash.warn { background: #fff4d6; color: #6d5200; }
@media (prefers-color-scheme: dark) {
  .flash { background: #173823; color: #bfe8cc; } .flash.err { background: #47201c; color: #ffd0ca; } .flash.warn { background: #3d3212; color: #ffe6a3; }
}

.tiles { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
@media (max-width: 980px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  .tiles { gap: 6px; }
  .tile { padding: 8px 4px; }
  .tile b { font-size: 1.3rem !important; }
  .tile span { font-size: .7rem; }
  .nav { flex-basis: 100%; padding-bottom: 6px; }
  .top-inner { gap: 4px; padding-top: 6px; }
}
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.tile b { display: block; font-size: 1.9rem; line-height: 1.1; }
.tile span { color: var(--muted); font-size: .85rem; display: block; hyphens: auto; overflow-wrap: anywhere; }
.tile.win b { color: var(--win); } .tile.loss b { color: var(--loss); } .tile.draw b { color: var(--draw); }
.tile.accent { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 8px 0 12px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); }
.filters select { min-width: 130px; }
.filters .reset { font-size: .85rem; padding-bottom: 8px; }

select, input, textarea, button { font: inherit; color: inherit; }
select, input, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; max-width: 100%; }
input.num { width: 3.4em; text-align: right; padding: 3px 4px; }
table.lineup td { padding: 4px 5px; }
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.form.cols, .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.form .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--text); }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--loss); border-color: var(--loss); margin-top: 12px; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.status.err, .err { color: var(--loss); } .ok { color: var(--win); font-weight: 600; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; }
td.strong { font-weight: 700; }
tfoot th { color: var(--text); }
tfoot td, tfoot th { border-top: 2px solid var(--line); font-weight: 700; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(127,127,127,.07); }
tr.me td { background: var(--me); font-weight: 600; }
tr.absent td { color: var(--muted); }
table.sortable th { cursor: pointer; }

.badge { display: inline-block; min-width: 24px; text-align: center; padding: 1px 6px; border-radius: 10px; font-size: .78rem; font-weight: 700; color: #fff; background: var(--draw); }
.badge.win { background: var(--win); } .badge.loss { background: var(--loss); } .badge.none { background: transparent; color: var(--muted); }

.gamehead h1 { margin: 4px 0; }
.gamehead .score { font-size: 1.6rem; font-weight: 700; margin: 4px 0; }
.note { background: var(--bg); padding: 8px 10px; border-radius: 6px; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.events li.period { font-weight: 700; background: var(--bg); padding: 4px 8px; border-radius: 4px; border: 0; margin-top: 6px; }
.events .t { width: 46px; color: var(--muted); font-variant-numeric: tabular-nums; }
.events .i { width: 20px; }
.events .d { flex: 1; }
.events li.them { opacity: .6; }
.events li.us.goal .d b { color: var(--win); }

.drop { display: block; border: 2px dashed var(--line); border-radius: 10px; padding: 34px 16px; text-align: center; cursor: pointer; color: var(--muted); }
.drop.over { border-color: var(--accent); background: rgba(242,183,5,.08); }
.import-card.saved { opacity: .75; }
.import-card .score { background: var(--brand); color: #fff; padding: 0 8px; border-radius: 6px; }
.lineup-preview { margin-top: 12px; }
.lineup-preview summary { cursor: pointer; margin: 6px 0; }
.me-line { background: var(--me); padding: 8px 10px; border-radius: 6px; }

.foot { color: var(--muted); font-size: .8rem; padding: 24px 16px; }

@media (max-width: 600px) {
  h1 { font-size: 1.25rem; }
  .tile b { font-size: 1.5rem; }
  .filters select { min-width: 0; width: 100%; }
  .filters label { flex: 1 1 45%; }
  th, td { padding: 6px 5px; }
}

@media (prefers-color-scheme: dark) {
  .btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
  .import-card .score { background: var(--accent); color: #111; }
}
