:root {
  --bg: #f3f5f2;
  --card: #ffffff;
  --ink: #15201a;
  --muted: #5f6b64;
  --line: #e1e6e2;
  --accent: #128a4a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f4ea;
  --gold: #b7791f;
  --gold-soft: #fbf0dc;
  --danger: #c0392b;
  --live: #d63031;
  --field: #f7f9f7;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 2px 8px rgba(16, 32, 24, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1411;
    --card: #17201b;
    --ink: #e8eee9;
    --muted: #93a29a;
    --line: #26322b;
    --accent: #2bb36a;
    --accent-ink: #06130b;
    --accent-soft: #173826;
    --gold: #e3a94a;
    --gold-soft: #3a2c13;
    --danger: #ef6b5b;
    --live: #ff6b6b;
    --field: #1d2822;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; }
.who { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }

.avatar { flex: none; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; color: #fff; font-weight: 800; background: var(--field); }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 76px; height: 76px; font-size: 26px; }

.profile-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; }
.profile-name { font-size: 22px; font-weight: 850; letter-spacing: -.01em; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; min-width: 0; }
.stat b { display: block; font-size: 20px; font-weight: 850; }
.stat span { display: block; font-size: 11px; color: var(--muted); line-height: 1.25; margin-top: 2px; }
.stat.strong { background: var(--accent-soft); border-color: transparent; }
.stat.strong b { color: var(--accent); }
.history-row { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 12px; text-align: left; }
.history-row:last-child { border-bottom: 0; }
.history-main { display: flex; flex-direction: column; min-width: 0; }
.history-score { font-weight: 700; font-size: 14px; }
.history-main .sub { font-size: 12px; color: var(--muted); }
.mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; }
.mark.hit { background: var(--accent-soft); color: var(--accent); }
.mark.miss { background: var(--field); color: var(--muted); }
.settings { padding: 4px 12px; }
.setting { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 13px 2px; text-align: left; font-weight: 600; }
.setting:last-child { border-bottom: 0; }
.setting.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }
.pred-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.link { border: 0; background: none; padding: 0; font-weight: 700; text-align: left; }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px 96px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 150px; border: 0; background: none; padding: 6px 4px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabs button svg { width: 22px; height: 22px; }
.tabs button[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.chips { display: flex; gap: 6px; margin: 4px 0 12px; overflow-x: auto; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

h2.day { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 2px 8px; }
h2.day:first-of-type { margin-top: 6px; }
.section-title { font-size: 17px; margin: 16px 2px 8px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 12px; margin-bottom: 10px;
}
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.meta .time { font-weight: 700; color: var(--ink); white-space: nowrap; }
.meta .live { color: var(--live); font-weight: 800; }

.team-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 4px 0; }
.logo { width: 28px; height: 28px; object-fit: contain; }
.logo.blank { border-radius: 50%; background: var(--field); }
.team-name { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-input {
  width: 48px; height: 44px; text-align: center; font-size: 20px; font-weight: 800;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--field);
}
.goal-input:focus { outline: none; border-color: var(--accent); background: var(--card); }
.score { min-width: 32px; text-align: center; font-size: 20px; font-weight: 800; }

.scorer-btn {
  width: 100%; margin-top: 8px; display: flex; align-items: center; gap: 8px; justify-content: space-between;
  border: 1.5px dashed var(--line); background: none; border-radius: 10px; padding: 10px 12px; text-align: left;
}
.scorer-btn.set { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.scorer-btn .label { color: var(--muted); font-size: 12px; display: block; }
.scorer-btn strong { display: block; }
.scorer-btn .chev { color: var(--muted); font-size: 18px; }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); min-height: 18px; }
.saved { color: var(--accent); font-weight: 700; }
.warn { color: var(--gold); font-weight: 700; }
.error { color: var(--danger); font-weight: 700; }

.mine { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--field); font-size: 13px; }
.mine b { font-weight: 700; }
.pts {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-weight: 800; font-size: 13px;
  background: var(--accent-soft); color: var(--accent);
}
.pts.zero { background: var(--field); color: var(--muted); }
.pts.big { font-size: 15px; padding: 3px 11px; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 4px 0; font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* table */
.rank { width: 100%; display: grid; grid-template-columns: 26px 32px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.rank-main { min-width: 0; }
.rank:last-child { border-bottom: 0; }
.rank .place { font-weight: 800; color: var(--muted); text-align: center; }
.rank.top1 .place { color: var(--gold); }
.rank.me { background: var(--accent-soft); }
.rank .name { font-weight: 700; }
.rank .stats { font-size: 12px; color: var(--muted); }
.rank .total { font-size: 20px; font-weight: 850; text-align: right; }
.rank .total small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.table-card { padding: 0; overflow: hidden; }
.rules { font-size: 13px; color: var(--muted); }
.rules li { margin: 4px 0; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet-head h3 { margin: 0; font-size: 17px; }
.close { border: 0; background: var(--field); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; line-height: 1; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; margin: 0 -16px; padding: 0 16px; }
.search {
  width: 100%; height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--field); margin-bottom: 8px;
}
.search:focus { outline: none; border-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--field); padding: 4px; border-radius: 12px; margin-bottom: 8px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 8px 6px; font-weight: 700; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; }
.seg button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg button img { width: 18px; height: 18px; flex: none; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.player {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  border: 0; border-bottom: 1px solid var(--line); background: none; padding: 9px 2px; text-align: left;
}
.player .num { width: 34px; height: 34px; border-radius: 50%; background: var(--field); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.player .pos { font-size: 12px; color: var(--muted); }
.player.selected { background: var(--accent-soft); }
.player.selected .num { background: var(--accent); color: var(--accent-ink); }
.badge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: var(--field); color: var(--muted); }
.badge.titular { background: var(--accent-soft); color: var(--accent); }
.group-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 2px 2px; }

/* detail */
.detail-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; margin: 4px 0 6px; }
.detail-score .t { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; }
.detail-score .t img { width: 40px; height: 40px; object-fit: contain; }
.detail-score .big { font-size: 30px; font-weight: 850; letter-spacing: .02em; }
.detail-note { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.goal-line { display: flex; gap: 8px; font-size: 13px; padding: 4px 0; }
.goal-line .min { color: var(--muted); width: 44px; flex: none; }
.goal-line.void { opacity: .55; }
.pred-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.pred-row:last-child { border-bottom: 0; }
.pred-row .sub { font-size: 12px; color: var(--muted); }
.pred-row.me .who-name { color: var(--accent); }

/* forms / admin */
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--field); color: var(--ink); }
.btn.danger { background: none; color: var(--danger); padding: 6px 8px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.field input { width: 100%; height: 44px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--field); font-size: 16px; }
.field input:focus { outline: none; border-color: var(--accent); }
.user-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row .line1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.user-row .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.edit-scorer { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--field); font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  z-index: 40; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}

/* login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { justify-content: center; font-size: 26px; margin-bottom: 4px; }
.login .brand img { width: 40px; height: 40px; }
.login p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.login .btn { width: 100%; height: 46px; font-size: 16px; }
.login .login-hint { margin: 0 0 14px; text-align: center; color: var(--muted); font-size: 14px; }
.login .login-switch { display: block; width: 100%; margin-top: 12px; text-align: center; font-size: 14px; }
.center { text-align: center; }
.invite-code { font-size: 44px; font-weight: 900; letter-spacing: .18em; text-align: center; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.invite-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.invite-row:last-child { border-bottom: 0; }
.invite-row b { font-size: 20px; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.banner { background: var(--gold-soft); color: var(--ink); border-radius: 12px; padding: 12px; margin-bottom: 12px; font-size: 14px; }
.banner .btn { margin-top: 8px; }
.login .msg { min-height: 20px; margin-top: 10px; text-align: center; font-size: 14px; }
