:root {
  --bg: #0b1a3a;
  --bg2: #10244f;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #6b7280;
  --accent: #1f6feb;
  --gold: #e0b43a;
  --ok: #16a34a;
  --bad: #dc2626;
  --line: #e5e7eb;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eef2f8;
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--bg), var(--bg2));
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; }
.who { font-size: .9rem; opacity: .85; }
main { max-width: 640px; margin: 0 auto; padding: 0 12px 12px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  margin: 10px 0; box-shadow: 0 2px 10px rgba(11, 26, 58, .08);
}
h2 { margin: 2px 0 10px; font-size: 1.2rem; }
h3 { margin: 16px 0 6px; font-size: 1rem; }
.day { color: var(--ink); margin: 18px 4px 4px; font-size: .95rem; text-transform: capitalize; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.loading { color: var(--muted); text-align: center; padding: 30px; }

label { display: block; font-size: .9rem; margin: 10px 0; color: var(--muted); }
label small { font-size: .78rem; }
input {
  display: block; width: 100%; margin-top: 4px; font-size: 1.05rem;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 0; padding: 11px 16px; }
button.primary { background: var(--accent); color: #fff; font-weight: 700; width: 100%; margin-top: 6px; }
button.small { padding: 7px 12px; width: auto; font-size: .9rem; margin: 0; }
button.ghost { background: #eef2f8; color: var(--ink); }
button.danger { background: #fde8e8; color: var(--bad); }
.switch { text-align: center; margin: 14px 0 2px; font-size: .92rem; }
.switch a { color: var(--accent); font-weight: 600; }
.help p { margin: 6px 0; font-size: .92rem; }

.summary { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; margin: 12px 4px 0; }
.warn { color: #b45309; font-weight: 600; }
.okmsg { color: var(--ok); font-weight: 600; }

.match .meta { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--muted); }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 10px 0; }
.team { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .98rem; min-width: 0; }
.teams .team:last-child { flex-direction: row-reverse; text-align: right; }
.team img { width: 26px; height: 26px; object-fit: contain; flex: none; }
.team span { overflow: hidden; text-overflow: ellipsis; }
.vs { color: var(--muted); }
.score { font-size: 1.35rem; font-weight: 800; padding: 2px 10px; background: var(--bg); color: #fff; border-radius: 8px; }

form.tip { display: grid; grid-template-columns: 64px auto 64px 1fr; align-items: center; gap: 8px; }
form.tip input { text-align: center; font-size: 1.3rem; font-weight: 700; padding: 8px 4px; margin: 0; }
form.tip .colon { font-weight: 800; font-size: 1.3rem; text-align: center; }
form.tip button { justify-self: end; }
form.tip.saved input { background: #f0f7ff; }

.badge { font-size: .76rem; padding: 3px 8px; border-radius: 999px; background: #eef2f8; color: var(--ink); white-space: nowrap; }
.badge.mine { background: #dcfce7; color: #166534; }
.badge.todo { background: #fff4d6; color: #92400e; }
.tips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .82rem; background: #eef2f8; border-radius: 999px; padding: 4px 10px; }
.winner { margin: 6px 0 0; font-weight: 700; }

table.standings { width: 100%; border-collapse: collapse; font-size: .95rem; }
.standings th { text-align: left; font-size: .76rem; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.standings td { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.standings tr.me td { background: #f0f7ff; font-weight: 600; }
.standings .num { text-align: right; white-space: nowrap; }
.standings .pl { color: var(--muted); width: 30px; }
.standings .actions { text-align: right; white-space: nowrap; }
.standings .actions button { margin-left: 4px; }
.delta { font-size: .78rem; margin-left: 4px; color: var(--muted); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
.grid button { grid-column: 1 / -1; }

.rules ul, .rules ol { padding-left: 20px; margin: 6px 0; }
.rules li { margin: 4px 0; line-height: 1.4; }
.rules p { line-height: 1.45; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  background: none; padding: 4px 2px; font-size: .72rem; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1;
}
.tabs button span { font-size: 1.25rem; }
.tabs button.active { color: var(--accent); font-weight: 700; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .92rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 10; max-width: 90vw; text-align: center;
}
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.card.notice { border: 1px solid #fde68a; background: #fffbeb; }
.card h3:first-child { margin-top: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0 4px; }
button.danger:not(.small) { width: 100%; font-weight: 700; }

tr.prow { cursor: pointer; }
.caret { color: var(--muted); font-size: .75rem; display: inline-block; transition: transform .15s; }
tr.prow.open .caret { transform: rotate(180deg); }
.net { font-weight: 700; }
.net.up, b.up { color: var(--ok); }
.net.down, b.down { color: var(--bad); }
tr.detail td { background: #f8fafc; padding: 10px 8px 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; text-align: center; }
.stats small { display: block; font-size: .66rem; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; font-size: .82rem; max-height: 260px; overflow: auto; }
.hist li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 2px; border-bottom: 1px dashed var(--line); }
.hist .delta { font-weight: 700; margin: 0; white-space: nowrap; }

.seg { display: flex; background: #eef2f8; border-radius: 10px; padding: 3px; margin: 0 0 10px; }
.seg button { flex: 1; background: none; padding: 8px 4px; font-size: .88rem; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.standings.cl .team { font-size: .9rem; }
.standings.cl .team img { width: 20px; height: 20px; }
.standings.cl tr.z1 td.pl { box-shadow: inset 3px 0 0 var(--ok); }
.standings.cl tr.z2 td.pl { box-shadow: inset 3px 0 0 var(--accent); }
.standings.cl tr.z3 td.pl { box-shadow: inset 3px 0 0 #cbd5e1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; }
.dot.z1 { background: var(--ok); } .dot.z2 { background: var(--accent); } .dot.z3 { background: #cbd5e1; }
.teamlist .tm { border-bottom: 1px solid var(--line); }
.tmhead { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; cursor: pointer; }
.tm.open .caret { transform: rotate(180deg); }
.squad { padding: 0 4px 10px; }
.squad h4 { margin: 10px 0 4px; font-size: .85rem; color: var(--accent); }
.squad ul { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.squad li { padding: 3px 0; }
.tabs button { font-size: .68rem; }

.tabs button { position: relative; }
.badge-n { position: absolute; top: 0; left: 55%; background: var(--bad); color: #fff; font-style: normal; font-size: .62rem; font-weight: 700; border-radius: 999px; padding: 1px 5px; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px - env(safe-area-inset-bottom)); }
.chathead { display: flex; justify-content: space-between; align-items: center; }
.toggle { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .85rem; }
.toggle input { width: auto; margin: 0; }
.msgs { flex: 1; overflow-y: auto; padding: 4px 2px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg .who { font-size: .75rem; font-weight: 700; color: var(--accent); margin: 0 4px 2px; }
.msg .bubble { display: inline-block; text-align: left; background: #eef2f8; padding: 8px 12px; border-radius: 16px 16px 16px 4px; line-height: 1.35; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg .when { font-size: .68rem; color: var(--muted); margin: 2px 6px 0; }
.msg .when a { color: var(--muted); }
.chatform { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.chatform textarea { flex: 1; font: inherit; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 18px; resize: none; max-height: 120px; }
.chatform button { border-radius: 18px; }
tr.left td { opacity: .5; }

.odds { display: flex; align-items: center; gap: 6px; margin: -2px 0 8px; font-size: .85rem; }
.odds span { background: #eef2f8; border-radius: 8px; padding: 3px 8px; font-weight: 700; }
.odds small { color: var(--muted); font-weight: 600; margin-right: 4px; }
.odds em { color: var(--muted); font-size: .72rem; font-style: normal; margin-left: auto; }
.changelog .ver { margin: 8px 0; }
.changelog ul { margin: 4px 0 0; padding-left: 18px; font-size: .88rem; }
.changelog li { margin: 2px 0; }

.gamebar { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: var(--bg2); position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 4; }
.gamebar button { flex: none; background: rgba(255,255,255,.12); color: #fff; border-radius: 999px; padding: 6px 14px; font-size: .85rem; }
.gamebar button.on { background: #fff; color: var(--ink); font-weight: 700; }
select { display: block; width: 100%; margin-top: 4px; font-size: 1rem; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); margin: 4px 0; }
label.check input { width: auto; margin: 0; }
.standings.cl tr.z4 td.pl { box-shadow: inset 3px 0 0 var(--bad); }
.dot.z4 { background: var(--bad); }

.gamebar button.arch { background: rgba(255,255,255,.05); color: rgba(255,255,255,.7); }
.gamebar button.arch.on { background: #e5e7eb; color: var(--ink); }
.card.champ { background: linear-gradient(135deg, #fff7d6, #fff); border: 1px solid #f3d27a; }
.grid label.full { grid-column: 1 / -1; }

.gamebar[hidden], [hidden] { display: none !important; }

.scorebox { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.scorebox small { font-size: .62rem; color: var(--muted); letter-spacing: .3px; }
.fullres { margin: -4px 0 6px; text-align: center; font-size: .78rem; color: var(--muted); }
