:root {
    --navy: #132257;
    --navy-2: #1d2f6f;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f4f5f9;
    --card: #ffffff;
    --win: #16a34a;
    --draw: #9ca3af;
    --loss: #dc2626;
    --unknown: #e5e7eb;
    --radius: 12px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; color: var(--navy); }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--navy); }
h3 { font-size: .9rem; margin: 1.25rem 0 .5rem; color: var(--navy); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 32px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Header */
.topbar { background: var(--navy); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { background: #fff; color: var(--navy); font-size: .7rem; letter-spacing: .08em; padding: .25rem .45rem; border-radius: 6px; }
.nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.nav a, .nav .linklike { color: rgba(255,255,255,.8); padding: .4rem .7rem; border-radius: 8px; font-size: .92rem; }
.nav a:hover, .nav .linklike:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255,255,255,.16); }
.footer { color: var(--muted); font-size: .8rem; padding-bottom: 32px; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 16px; }
.page-head { margin-bottom: 16px; }
.empty { text-align: center; padding: 48px 20px; }

/* Forms */
input, select, textarea {
    font: inherit; padding: .5rem .65rem; border: 1px solid #d1d5db; border-radius: 8px;
    background: #fff; color: var(--ink); width: 100%;
}
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    background-size: 11px 8px;
    cursor: pointer;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; border-color: transparent; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; font-weight: 400; }
label.check input { width: auto; }
label.inline { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; color: var(--muted); }
label.inline input { width: auto; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.form-card { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: 1rem; }
.span-2 { grid-column: span 2; }
.error { color: var(--loss); font-size: .85rem; margin: 0; }
.auth-card { max-width: 420px; margin: 32px auto; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: 14px; }
.filters select, .filters input { width: auto; }
.filters .grow { flex: 1 1 260px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
    font: inherit; font-weight: 600; font-size: .88rem; padding: .5rem .9rem; border-radius: 8px;
    border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: #fff; color: var(--navy); border-color: #d1d5db; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-attended { background: #e8f5ec; color: #166534; border-color: #bbe5c8; }
.btn-attended:hover { background: #fde8e8; color: #991b1b; border-color: #f5c2c2; }
.btn.disabled { opacity: .45; pointer-events: none; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--navy-2); cursor: pointer; }
.linklike.danger { color: var(--loss); font-size: .85rem; }

.flash { background: #eef2ff; border: 1px solid #c7d2fe; color: var(--navy); padding: .7rem 1rem; border-radius: 10px; margin-bottom: 16px; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Games table */
.table-card { padding: 0; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.games th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.games td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.games tr:last-child td { border-bottom: 0; }
.games tr.is-attended td { background: #f6fbf7; }
.games tr.is-attended td:first-child { box-shadow: inset 3px 0 0 var(--win); }
.games form { display: inline; }
.opp { font-weight: 600; color: var(--ink); }

.venue { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; font-size: .7rem; font-weight: 700; margin-right: .35rem; vertical-align: 1px; }
.venue-h { background: var(--navy); color: #fff; }
.venue-a { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.venue-n { background: #fef3c7; color: #92400e; }

.score { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.score b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: .72rem; }
.score-w b { background: var(--win); }
.score-d b { background: var(--draw); }
.score-l b { background: var(--loss); }
.score-upcoming, .score-unknown { color: var(--muted); font-weight: 500; }

.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 16px 0; }

/* Match page */
.match-hero h1 { font-size: 1.9rem; margin: .3rem 0 .6rem; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; color: var(--muted); }

/* Stats */
.mini { font-size: .9rem; }
.mini th { text-align: left; font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.mini td { padding: 6px; border-bottom: 1px solid #f1f2f5; font-variant-numeric: tabular-nums; }
.mini tr:last-child td { border-bottom: 0; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.tile-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 1.8rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-sub { font-size: .8rem; color: var(--muted); }

.wdl-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; min-width: 4px; }
.wdl-bar.big { height: 34px; border-radius: 8px; }
.wdl-bar .seg { display: grid; place-items: center; color: #fff; font-size: .8rem; font-weight: 700; white-space: nowrap; overflow: hidden; }
.wdl-bar .seg[style="flex: 0"] { display: none; }
.seg.w, .dot.w { background: var(--win); }
.seg.d, .dot.d { background: var(--draw); }
.seg.l, .dot.l { background: var(--loss); }
.seg.u { background: var(--unknown); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 .2rem 0 .6rem; }
.legend { color: var(--muted); margin: .75rem 0 0; }

.lucky { margin: 1rem 0 0; padding: .7rem 1rem; border-radius: 10px; }
.lucky.good { background: #ecfdf3; color: #14532d; }
.lucky.neutral { background: #f1f3f9; color: var(--navy); }
.lucky.bad { background: #fef2f2; color: #7f1d1d; }

.highlight { display: flex; flex-direction: column; gap: .3rem; }
.highlight-line { font-weight: 700; font-size: 1.05rem; color: var(--ink); }

.season-chart { display: flex; flex-direction: column; gap: 4px; }
.season-row { display: grid; grid-template-columns: 64px 1fr 110px; gap: .75rem; align-items: center; color: var(--ink); padding: 2px 4px; border-radius: 6px; }
.season-row:hover { background: #f4f5f9; text-decoration: none; }
.season-label { font-size: .82rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.season-n { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: #f1f3f9; border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; flex-wrap: wrap; gap: .3rem .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid #f1f2f5; }
.recent li:last-child { border-bottom: 0; }

@media (max-width: 800px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 0; }
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .filters select, .filters input, .filters label.inline { flex: 1 1 45%; }
    .games th:nth-child(2), .games td:nth-child(2) { display: none; }
    .season-row { grid-template-columns: 56px 1fr 90px; gap: .5rem; }
    .match-hero h1 { font-size: 1.4rem; }
}
