/* Tippspiel design system.
   Mobile-first: one column on a phone, two on a tablet, full grid on desktop.
   Every interactive target is at least 44px so a six-year-old on a tablet can
   hit it. Colours are defined once as tokens on :root and only *redefined*
   under prefers-color-scheme, never defined for the first time there. */

:root {
  color-scheme: light dark;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #d8dee9;
  --text: #16202e;
  --text-dim: #5b6779;

  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e3edfd;

  --exact: #16794a;
  --exact-soft: #d8f0e3;
  --diff: #9a6b00;
  --diff-soft: #fbeecb;
  --tend: #4a5568;
  --tend-soft: #e6e9ee;
  --miss: #a3aab8;
  --live: #c2410c;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabular: "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161f;
    --surface: #1a212d;
    --surface-2: #222b39;
    --border: #303a4b;
    --text: #e7ecf3;
    --text-dim: #9aa7ba;

    --accent: #5b9bff;
    --accent-ink: #0b1220;
    --accent-soft: #1c2c47;

    --exact: #4ade80;
    --exact-soft: #14331f;
    --diff: #fbbf24;
    --diff-soft: #3a2e0d;
    --tend: #b6c0cf;
    --tend-soft: #2a3343;
    --miss: #5b6779;
    --live: #fb923c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

/* ---------- layout ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 14px 88px; }

header.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand span { color: var(--text-dim); font-weight: 500; font-size: .85rem; }
.top-spacer { flex: 1; }

.who {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--text-dim);
}
.chip {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 11px; font-size: .78rem;
}
.chip.kid { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- bottom navigation (thumb reach on a phone) ---------- */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a {
  flex: 1; text-align: center; padding: 10px 4px 12px;
  color: var(--text-dim); text-decoration: none;
  font-size: .72rem; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
nav.tabs a.active { color: var(--accent); font-weight: 600; }
nav.tabs .ico { font-size: 1.25rem; line-height: 1; }

@media (min-width: 760px) {
  nav.tabs {
    position: static; border-top: 0; border-bottom: 1px solid var(--border);
    background: transparent; max-width: 1180px; margin: 0 auto; padding: 0 14px;
  }
  nav.tabs a { flex: 0 0 auto; flex-direction: row; padding: 12px 16px; font-size: .9rem; min-height: 0; }
  nav.tabs a.active { border-bottom: 2px solid var(--accent); }
  .shell { padding-bottom: 40px; }
}

/* ---------- headings and cards ---------- */
h1 { font-size: 1.4rem; margin: 18px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 24px 0 10px; }
.sub { color: var(--text-dim); font-size: .88rem; margin: 0 0 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 14px; }

.banner {
  border-radius: var(--radius-sm); padding: 11px 13px; margin: 12px 0;
  font-size: .88rem; border: 1px solid var(--border); background: var(--surface-2);
}
.banner.warn { background: var(--diff-soft); border-color: var(--diff); color: var(--diff); }
.banner.live { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.banner.bad  { background: #fde8e8; border-color: #dc2626; color: #b91c1c; }
@media (prefers-color-scheme: dark) {
  .banner.bad { background: #3a1414; border-color: #ef4444; color: #fca5a5; }
}

/* ---------- match cards: the main kid-facing surface ---------- */
.matches { display: grid; gap: 10px; }
@media (min-width: 760px)  { .matches { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .matches { grid-template-columns: repeat(3, 1fr); } }

.match {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
}
.match .when {
  font-size: .74rem; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 9px; display: flex; justify-content: space-between;
}
.match.is-live .when { color: var(--live); font-weight: 700; }

.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.team { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.team img { width: 40px; height: 40px; object-fit: contain; }
.team .nm { font-size: .8rem; font-weight: 600; line-height: 1.15; }
.vs { color: var(--text-dim); font-size: .8rem; }

.result {
  text-align: center; font-family: var(--tabular); font-size: 1.05rem;
  font-weight: 700; margin: 8px 0 2px;
}
.result.pending { color: var(--text-dim); font-weight: 500; }

/* steppers — deliberately large */
.stepper-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 10px; align-items: center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 6px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 1.4rem; line-height: 1; cursor: pointer; touch-action: manipulation;
  display: flex; align-items: center; justify-content: center;
}
.stepper button:active { background: var(--accent); color: var(--accent-ink); }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper .val {
  min-width: 46px; height: 46px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--tabular); font-size: 1.5rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.stepper .val.set { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.colon { font-size: 1.3rem; font-weight: 700; color: var(--text-dim); }

.saved { font-size: .72rem; text-align: center; margin-top: 7px; height: 15px; color: var(--text-dim); }
.saved.ok { color: var(--exact); }
.saved.err { color: #dc2626; }

.locked-tip {
  margin-top: 10px; text-align: center; font-family: var(--tabular);
  font-size: 1.15rem; font-weight: 700;
}
.pts {
  display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-family: var(--font); font-weight: 700;
}
.pts.exact { background: var(--exact-soft); color: var(--exact); }
.pts.difference { background: var(--diff-soft); color: var(--diff); }
.pts.tendency { background: var(--tend-soft); color: var(--tend); }
.pts.miss, .pts.none { background: var(--surface-2); color: var(--miss); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none;
  font-family: inherit;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .82rem; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 14px 0; }

/* ---------- selects / pills ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 12px 0 16px; }
select, input[type=text], input[type=email] {
  min-height: 40px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: .9rem; font-family: inherit;
}
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills a {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); text-decoration: none; color: var(--text-dim); font-size: .84rem;
}
.pills a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- tables ---------- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 600; }
td.num, th.num { text-align: right; font-family: var(--tabular); }
tr.me { background: var(--accent-soft); }
tr.me td { font-weight: 700; }
.rank { font-family: var(--tabular); color: var(--text-dim); width: 34px; }

/* ---------- live grid ---------- */
.grid-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.grid td, table.grid th { border-bottom: 1px solid var(--border); font-size: .82rem; }
table.grid th.player { text-align: center; min-width: 74px; text-transform: none; font-size: .78rem; }
table.grid th.player.me { color: var(--accent); }
table.grid td.fixture { position: sticky; left: 0; background: var(--surface); z-index: 2; font-weight: 600; min-width: 150px; }
table.grid td.cell { text-align: center; font-family: var(--tabular); }
table.grid td.cell.exact { background: var(--exact-soft); color: var(--exact); font-weight: 700; }
table.grid td.cell.difference { background: var(--diff-soft); color: var(--diff); }
table.grid td.cell.tendency { background: var(--tend-soft); }
table.grid tfoot td { font-weight: 700; }

.muted { color: var(--text-dim); }
.small { font-size: .82rem; }
.mono { font-family: var(--tabular); }
.right { text-align: right; }
.stack { display: grid; gap: 14px; }
.split { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

.money { font-family: var(--tabular); }
.money.neg { color: #dc2626; }
.money.pos { color: var(--exact); }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  background: var(--surface); color: var(--text); max-width: 420px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }


/* Fallback badge shown when a team crest fails to load (icon URLs are supplied
   by OpenLigaDB and occasionally 404 or are blocked by a network policy). */
.crest-fallback {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: var(--text-dim);
}
