:root {
  --grass: #14532d;
  --grass-2: #166534;
  --lime: #dcfce7;
  --ink: #111827;
  --muted: #6b7280;
  --paper: #f7f7ef;
  --card: #ffffff;
  --line: #e5e7eb;
  --danger: #991b1b;
  --warn: #92400e;
  --shadow: 0 12px 35px rgba(17, 24, 39, .10);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #dcfce7, transparent 30rem), var(--paper);
}
button, input, select { font: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
  background: rgba(247,247,239,.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(229,231,235,.7);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.35rem; letter-spacing: -.03em; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
main { padding: 1rem 1rem 6.5rem; max-width: 880px; margin: 0 auto; }
.eyebrow { color: var(--grass-2); text-transform: uppercase; font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.card {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(229,231,235,.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  overflow: hidden;
}
.hero p:last-child { margin-top: .35rem; color: var(--muted); line-height: 1.35; }
.ball { font-size: 3.1rem; filter: drop-shadow(0 8px 14px rgba(0,0,0,.18)); }
.banner {
  margin: .9rem 0;
  padding: .8rem .9rem;
  border-radius: 18px;
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fde68a;
}
.updated { color: var(--muted); font-size: .86rem; padding: .85rem .1rem; }
.view { display: none; }
.view.active { display: block; animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: translateY(0);} }
.toolbar { display: flex; gap: .5rem; overflow-x: auto; padding: .2rem .1rem .8rem; scrollbar-width: none; }
.pill {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: #fff;
  padding: .55rem .8rem;
  border-radius: 999px;
  color: var(--ink);
}
.pill.active { background: var(--grass); color: white; border-color: var(--grass); }
.match { padding: .9rem; margin-bottom: .8rem; }
.match-meta, .venue, .small { color: var(--muted); font-size: .84rem; }
.match-meta { display: flex; justify-content: space-between; gap: .8rem; margin-bottom: .7rem; }
.teams-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .8rem; align-items: center; }
.team { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.team.away { text-align: right; align-items: flex-end; }
.team-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.team-code { color: var(--muted); font-size: .75rem; }
.logo { width: 26px; height: 26px; object-fit: contain; vertical-align: middle; margin-right: .25rem; }
.score-wrap { display: grid; gap: .28rem; justify-items: center; }
.score { min-width: 68px; text-align: center; font-weight: 900; font-size: 1.25rem; padding: .4rem .55rem; border-radius: 16px; background: var(--lime); color: var(--grass); }
.score-badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: .18rem .48rem; font-size: .65rem; font-weight: 900; letter-spacing: .02em; }
.score-badge.manual { background: #fef3c7; color: #78350f; border: 1px solid #fde68a; }
.score-badge.api { background: var(--lime); color: var(--grass); border: 1px solid rgba(20,83,45,.2); }
.score-badge.open { background: #f3f4f6; color: var(--muted); border: 1px solid var(--line); }
.venue { margin-top: .7rem; }
.details { margin-top: .65rem; border-top: 1px solid var(--line); padding-top: .55rem; }
summary { color: var(--grass); font-weight: 700; cursor: pointer; }
.detail-content { margin-top: .55rem; display: grid; gap: .45rem; color: var(--muted); font-size: .9rem; }
.manual-score-form { margin-top: .75rem; padding: .75rem; border: 1px solid var(--line); border-radius: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; background: rgba(220,252,231,.22); }
.manual-score-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .78rem; font-weight: 800; }
.manual-score-form input { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: .7rem; text-align: center; font-size: 1.05rem; font-weight: 900; color: var(--ink); background: var(--card); }
.manual-score-form .small-btn { padding: .7rem .75rem; border-radius: 14px; font-size: .82rem; }
.manual-note { margin-top: .55rem; }
.group-card, .status-card, .player-card, .team-card { padding: .95rem; margin-bottom: .8rem; }
.table-wrap { overflow-x: auto; margin-top: .7rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { padding: .55rem .35rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.rank { width: 2rem; font-weight: 800; color: var(--grass); }
.qualify td { background: rgba(220,252,231,.38); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .75rem; }
.team-card { display: flex; gap: .75rem; align-items: center; }
.team-card img, .player-card img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--lime); }
.player-card { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; }
.stat-big { font-size: 1.25rem; font-weight: 900; color: var(--grass); }
.status-grid { display: grid; gap: .7rem; }
.status-line { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.actions { display: grid; grid-template-columns: 1fr; gap: .7rem; margin-top: .9rem; }
.primary, .secondary, .ghost {
  border: 0;
  border-radius: 16px;
  padding: .85rem .95rem;
  font-weight: 800;
  cursor: pointer;
}
.primary { background: var(--grass); color: white; }
.secondary { background: var(--lime); color: var(--grass); }
.ghost { background: transparent; color: var(--grass); border: 1px solid rgba(20,83,45,.25); }
.danger { color: var(--danger); }
.warn { color: var(--warn); }
.log { max-height: 260px; overflow: auto; background: #f9fafb; border: 1px solid var(--line); border-radius: 16px; padding: .75rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; white-space: pre-wrap; }
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .25rem;
  padding: .55rem .6rem max(.65rem, env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.bottomnav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  border-radius: 18px;
  padding: .45rem .15rem;
  font-size: 1.05rem;
}
.bottomnav span { font-size: .67rem; font-weight: 700; }
.bottomnav button.active { background: var(--lime); color: var(--grass); }
.hidden { display: none !important; }
@media (min-width: 760px) {
  main { padding-bottom: 2rem; }
  .bottomnav { position: sticky; bottom: auto; top: 72px; max-width: 880px; margin: 0 auto; border-radius: 24px; border: 1px solid var(--line); box-shadow: var(--shadow); }
  .actions { grid-template-columns: repeat(2, 1fr); }
  .manual-score-form { grid-template-columns: 1fr 1fr auto auto; align-items: end; }
}
@media (prefers-color-scheme: dark) {
  :root { --paper:#07120c; --card:#0f1f16; --ink:#eef7ef; --muted:#a7b4aa; --line:#233327; --shadow:0 12px 35px rgba(0,0,0,.28); }
  .topbar, .bottomnav, .card { background: rgba(15,31,22,.92); }
  .pill { background: #0f1f16; color: var(--ink); }
  .log { background: #0a140e; }
  .score-badge.open { background: #17231b; }
}
