/* Shared Predictable UI: theme tokens, page shell (hero, tabs, navigation) and common components.
   Page-specific layout stays in each page's own <style>. */

:root {
    --page: #f4f2f7;
    --surface: #ffffff;
    --surface-2: #f3f0f6;
    --line: #ece8f1;
    --ink: #37003c;
    --ink-2: #6e5c77;
    --ink-3: #a093a8;
    --brand: #963cff;
    --cyan: #04f5ff;
    --won: #00a259;
    --won-bg: #e1f6ea;
    --lost: #e0003c;
    --lost-bg: #fde7ed;
    --p-home: #963cff;
    --p-draw: #cfc6d8;
    --p-away: #18c5dc;
    --series-1: #963cff;
    --series-2: #0893a8;
    --hero: linear-gradient(105deg, #7b2bf9 0%, #963cff 32%, #4ba3ff 72%, #04f5ff 100%);
    --shadow: 0 1px 2px rgba(55,0,60,.04), 0 4px 16px rgba(55,0,60,.05);
    --radius: 16px;
    --col: 760px;
}
:root[data-theme="dark"] {
    --page: #12041a;
    --surface: #1e0c29;
    --surface-2: #2b1638;
    --line: #2f1b3c;
    --ink: #f7f0fb;
    --ink-2: #c4b3cf;
    --ink-3: #8a7797;
    --won: #2fd388;
    --won-bg: rgba(47,211,136,.14);
    --lost: #ff4f7b;
    --lost-bg: rgba(255,79,123,.14);
    --p-draw: #4d3a5a;
    --series-1: #a868ff;
    --series-2: #129fb3;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
}
* { margin:0; padding:0; box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--page); color: var(--ink);
    min-height: 100vh; overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2, h3, .num { font-family: 'Outfit', sans-serif; }
[hidden] { display: none !important; }
.app { max-width: var(--col); margin: 0 auto; padding-bottom: 96px; }

/* === Hero === */
.hero {
    position: relative; overflow: hidden;
    background: var(--hero); color: #fff;
    padding: 16px 20px 22px;
    border-radius: 0 0 24px 24px;
}
.hero::before, .hero::after {
    content: ''; position: absolute; top: -40%; height: 180%; width: 38%;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.16));
    transform: skewX(-28deg); pointer-events: none;
}
.hero::before { right: 6%; }
.hero::after { right: -22%; background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.22)); }
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { color: #fff; text-decoration: none; font-family: 'Outfit'; font-weight: 700; font-size: 15px; letter-spacing: .2px; opacity: .92; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.hero-actions { display: flex; align-items: center; gap: 8px; }
.top-links { display: flex; gap: 4px; }
.top-links a { color: rgba(255,255,255,.85); text-decoration: none; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px; transition: background .2s; white-space: nowrap; }
.top-links a:hover { background: rgba(255,255,255,.16); color: #fff; }
.top-links a.active { background: rgba(255,255,255,.22); color: #fff; }
.theme-btn {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: rgba(255,255,255,.18); color: #fff; transition: background .2s;
}
.theme-btn:hover { background: rgba(255,255,255,.3); }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn .moon, :root[data-theme="dark"] .theme-btn .sun { display: block; }
.theme-btn .sun, :root[data-theme="dark"] .theme-btn .moon { display: none; }
.hero h1 { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.3px; }
.hero-sub { font-size: 13px; color: rgba(255,255,255,.85); margin-top: 6px; max-width: 460px; line-height: 1.45; }
.season-pill {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 10px;
    font-size: 12px; font-weight: 600; color: #fff;
    background: rgba(55,0,60,.22); padding: 5px 6px 5px 12px; border-radius: 999px;
}
.season-pill b { background: rgba(255,255,255,.22); padding: 2px 8px; border-radius: 999px; }

/* === Tabs === */
.tabs { display: flex; gap: 22px; padding: 16px 20px 0; border-bottom: 1px solid var(--line); }
.tab { font-size: 15px; font-weight: 600; color: var(--ink-3); padding: 0 1px 10px; position: relative; transition: color .2s; text-decoration: none; }
.tab:hover { color: var(--ink-2); }
.tab[aria-selected="true"], .tab.active { color: var(--ink); }
.tab[aria-selected="true"]::after, .tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--ink); }

.circle-btn {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    background: var(--surface-2); color: var(--ink); transition: background .2s, opacity .2s;
}
.circle-btn:hover:not(:disabled) { background: var(--line); }
.circle-btn:disabled { opacity: .35; cursor: default; }

/* === Cards === */
.panel { padding: 0 12px; }
.panel-top { padding-top: 16px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card + .card, .panel > * + * { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 4px; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--ink-2); padding: 0 16px 12px; line-height: 1.45; }
.card-body { padding: 4px 16px 16px; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-3); padding: 14px 16px 6px; }

/* Team badge */
.crest {
    flex: none; width: 28px; height: 28px; border-radius: 50%;
    background: var(--c1); color: var(--c2);
    display: grid; place-items: center;
    font-family: 'Outfit'; font-size: 8.5px; font-weight: 800; letter-spacing: .2px;
    box-shadow: inset 0 0 0 2px var(--c2), 0 0 0 1px var(--line);
}
.crest.has-img { background: none; box-shadow: none; border-radius: 0; }
.crest img { display: block; width: 100%; height: 100%; object-fit: contain; }
:root[data-theme="dark"] .crest img { filter: drop-shadow(0 0 1px rgba(255,255,255,.45)); }

/* Home v away row: <div class="matchup"><div class="matchup-side home">…</div><div class="vs-box">…</div><div class="matchup-side">…</div></div> */
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.matchup-side { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; font-weight: 600; }
.matchup-side.home { justify-content: flex-end; text-align: right; }
.matchup-side span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-box {
    min-width: 56px; padding: 6px 10px; border-radius: 8px; text-align: center;
    background: var(--surface-2); font-family: 'Outfit'; font-size: 15px; font-weight: 700; color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.vs-box.final { color: var(--ink); font-size: 17px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.tile-label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.tile-value { font-family: 'Outfit'; font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: 11px; color: var(--ink-2); margin-top: 1px; }
.tile-value.won, .tile-sub.won { color: var(--won); }
.tile-value.lost, .tile-sub.lost { color: var(--lost); }

/* Badges & chips */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.won { background: var(--won-bg); color: var(--won); }
.badge.lost { background: var(--lost-bg); color: var(--lost); }
.chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
}
.chip b { color: var(--ink); font-weight: 700; }
.chip.won { background: var(--won-bg); color: var(--won); }
.chip.lost { background: var(--lost-bg); color: var(--lost); }
.chip.won b, .chip.lost b { color: inherit; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--ink); color: var(--surface); font-weight: 700; font-size: 15px;
    padding: 13px 20px; border-radius: 12px; transition: opacity .2s, transform .1s;
}
.btn:hover:not(:disabled) { opacity: .9; }
.btn:active:not(:disabled) { transform: scale(.99); }
.btn.block { width: 100%; }
.btn.accent { background: var(--hero); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn:disabled, .btn.accent:disabled { background: var(--line); color: var(--ink-3); cursor: not-allowed; }

/* Segmented choices (one pick per group) */
.choices { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.choice { flex: 1; min-width: 0; text-align: center; padding: 9px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink-2); transition: background .15s, color .15s; }
.choice:hover { color: var(--ink); }
.choice.sel, .choice[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(55,0,60,.12); }
:root[data-theme="dark"] .choice.sel, :root[data-theme="dark"] .choice[aria-checked="true"] { background: var(--brand); color: #fff; }

/* Form fields */
.field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 8px; }
.field-label:first-child { margin-top: 0; }
.field-label .value { font-family: 'Outfit'; font-size: 16px; font-weight: 700; color: var(--ink); }
.input, .select {
    width: 100%; font: inherit; font-size: 15px; color: var(--ink);
    background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 11px 14px;
    outline: none; transition: border-color .2s;
}
.input:focus, .select:focus { border-color: var(--brand); }
.select {
    appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a093a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
.select option { background: var(--surface); color: var(--ink); }
.range { width: 100%; accent-color: var(--brand); cursor: pointer; }

/* Toggle switch: <label class="switch"><input type="checkbox"><span></span> Text</label> */
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Data table */
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-3); text-align: center; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table td { text-align: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .left { text-align: left; }
.table .won { color: var(--won); font-weight: 700; }
.table .lost { color: var(--lost); font-weight: 700; }

/* Loading & empty states */
.skel { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 48px 24px; color: var(--ink-2); font-size: 14px; }
.empty strong { display: block; font-family: 'Outfit'; font-size: 17px; color: var(--ink); margin-bottom: 4px; }

footer { text-align: center; font-size: 12px; color: var(--ink-3); padding: 28px 20px 8px; }

/* === Bottom nav (mobile) === */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: none; justify-content: space-around;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 600; padding: 4px 0; }
.bottom-nav a.active { color: var(--ink); }
.bottom-nav svg { width: 22px; height: 22px; }

@media (max-width: 760px) {
    .top-links { display: none; }
    .bottom-nav { display: flex; }
}
@media (min-width: 761px) {
    .app { padding-top: 16px; }
    .hero { border-radius: 24px; padding: 18px 28px 28px; }
    .hero h1 { font-size: 36px; }
    .panel { padding: 0; }
    .tabs { padding-left: 4px; padding-right: 4px; }
}
@media (max-width: 380px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .crest { width: 24px; height: 24px; font-size: 7.5px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
