:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #17202b;
  --muted: #667085;
  --line: #e3e6eb;
  --brand: #e86a1a;
  --brand-ink: #ffffff;
  --navy: #14233c;
  --win: #157a3c;
  --loss: #c0392b;
  --tie: #8a6d00;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --card: #18202a; --ink: #e8ecf1; --muted: #98a2b3; --line: #2a3441;
    --navy: #0b1220; --win: #3fbf6f; --loss: #f06b5d; --tie: #e0b93a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
main a:not(.btn):not(.game-card):not(.team-tile):not(.player-tile) { color: var(--brand); text-decoration: none; }
main a:not(.btn):hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 1.25rem 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 680px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pos { color: var(--win); }
.neg { color: var(--loss); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

/* header */
.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 56px; }
.brand { font-weight: 800; font-size: 1.2rem; text-decoration: none; display: flex; align-items: center; gap: .5rem; letter-spacing: .02em; }
.brand-logo { width: 40px; height: 40px; border-radius: 50%; background: #fff; }
.nav { display: flex; align-items: center; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a, .nav .link { color: #dfe6f0; text-decoration: none; padding: .4rem .65rem; border-radius: 6px; font-size: .95rem; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav .btn.small { color: var(--brand-ink); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }
.badge { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 56px; left: 0; right: 0; background: var(--navy); flex-direction: column; align-items: stretch; padding: .5rem 16px 1rem; }
  .nav-open .nav { display: flex; }
}
.site-footer { color: var(--muted); font-size: .85rem; padding: 2rem 16px; }

/* buttons & forms */
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px; padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { filter: brightness(1.07); }
.btn.small { padding: .35rem .7rem; font-size: .875rem; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: var(--loss); }
.btn[disabled] { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--brand); }
form.inline { display: inline; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem; width: 100%; }
input[type=checkbox] { width: auto; }
input[type=color] { width: 3rem; padding: .15rem; height: 2.4rem; }
input[type=file] { border: 1px dashed var(--line); }
input.tiny { width: 4.5rem; display: inline-block; }
input.short { width: 9rem; display: inline-block; }
.form label, .row-form label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .75rem; }
.form label input, .form label select, .form label textarea { margin-top: .25rem; font-weight: 400; }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; background: var(--card); }
.form legend { float: left; width: 100%; padding: 0; margin: 0 0 .75rem; font-weight: 700; font-size: 1.05rem; }
.form legend + * { clear: both; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
label.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 400; margin: .5rem 0 1rem; }
label.check.inline { display: inline-flex; margin: 0 0 0 .5rem; }
.inline-label { display: block; margin: 0 0 1rem; }
.row-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row-form input:not([type=color]), .row-form select { width: auto; flex: 1 1 160px; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select, .filters input { width: auto; }
.filters label { display: flex; gap: .5rem; align-items: center; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.current-photo { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; }

/* flash */
.flash { padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0; background: #e8f1ff; color: #12366b; }
.flash.success { background: #e3f6ea; color: #0f5130; }
.flash.error { background: #fdecea; color: #7d1d14; }
.flash ul { margin: 0; padding-left: 1.2rem; }

/* layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .grid.two { grid-template-columns: 1fr; } }
.more { margin-left: auto; font-size: .85rem; font-weight: 500; }
.hero { padding: 1.5rem 0 .5rem; display: flex; align-items: center; gap: 1.5rem; }
.hero-logo { width: 180px; height: 180px; flex-shrink: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
@media (max-width: 640px) { .hero { flex-direction: column; text-align: center; } .hero-logo { width: 140px; height: 140px; } }
.hero h1 { font-size: 2.1rem; margin: 0 0 .25rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .8rem; border-radius: 999px; text-decoration: none !important; color: var(--ink) !important; box-shadow: inset 0 0 0 1px var(--line); font-size: .9rem; }
.tabs a.active { background: var(--brand); color: #fff !important; box-shadow: none; }
.admin-tabs { margin-bottom: 1rem; }

/* tables */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .45rem; text-align: center; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th.left, td.left { text-align: left; }
tr.totals td { font-weight: 700; border-top: 2px solid var(--line); }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .4rem; vertical-align: baseline; }

/* streaks & form */
.streak { display: inline-block; font-weight: 700; font-size: .8rem; padding: .1rem .45rem; border-radius: 999px; }
.streak.W { background: color-mix(in srgb, var(--win) 15%, transparent); color: var(--win); }
.streak.L { background: color-mix(in srgb, var(--loss) 15%, transparent); color: var(--loss); }
.streak.T { background: color-mix(in srgb, var(--tie) 15%, transparent); color: var(--tie); }
.last5 { display: inline-flex; gap: 3px; }
.last5 i { font-style: normal; font-size: .7rem; font-weight: 700; width: 1.25rem; height: 1.25rem; display: inline-grid; place-items: center; border-radius: 4px; color: #fff; }
.last5 i.W { background: var(--win); } .last5 i.L { background: var(--loss); } .last5 i.T { background: var(--tie); }

/* pills */
.pill { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .5rem; border-radius: 999px; background: var(--line); color: var(--ink); }
.pill.live { background: var(--brand); color: #fff; }
.pill.warn { background: #fde7c7; color: #7a4a00; }

/* games */
.game-list { display: grid; gap: .5rem; }
.game-card { display: block; text-decoration: none; border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; background: var(--card); }
.game-card:hover { border-color: var(--brand); }
.game-when { font-size: .8rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; }
.game-team { display: flex; align-items: center; font-weight: 500; }
.game-team b { margin-left: auto; font-size: 1.05rem; }
.game-team.won { font-weight: 700; }
.game-where { font-size: .8rem; }
.game-card.cancelled { opacity: .6; }
h3.day { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin: 1.25rem 0 .5rem; }
.score-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.score-row .game-card { flex: 1 1 280px; }

.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; background: var(--navy); color: #fff; border-radius: var(--radius); padding: 1.25rem; margin: 1.25rem 0 1rem; text-align: center; }
.scoreboard a { color: #fff !important; font-weight: 700; font-size: 1.1rem; }
.scoreboard .muted { color: #b8c3d4; }
.sb-score { font-size: 3rem; font-weight: 800; line-height: 1.1; opacity: .75; }
.sb-team.won .sb-score { opacity: 1; color: var(--brand); }
.sb-mid { font-size: .9rem; }

/* teams */
.team-grid, .player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.team-tile { background: var(--card); border: 1px solid var(--line); border-top: 6px solid var(--team); border-radius: var(--radius); padding: 1rem; text-decoration: none; }
.team-tile h2 { margin-bottom: .25rem; }
.team-tile .record { font-size: 1.6rem; font-weight: 800; }
.team-head { border-left: 8px solid var(--team); padding-left: 1rem; margin: 1.25rem 0 1rem; }
.team-head h1 { margin: 0 0 .25rem; }
.team-meta { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.team-meta .record { font-size: 1.3rem; font-weight: 800; }
.team-edit { display: flex; gap: .5rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.team-edit > form:first-child { flex: 1; }

/* players */
.avatar { border-radius: 50%; object-fit: cover; background: var(--line); display: inline-grid; place-items: center; font-weight: 700; color: var(--muted); flex-shrink: 0; text-transform: uppercase; }
.avatar.sm { width: 34px; height: 34px; font-size: .75rem; }
.avatar.md { width: 48px; height: 48px; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.2rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.6rem; border-radius: 12px; }
.player-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; text-decoration: none; }
.player-tile .avatar { margin: 0 auto .5rem; width: 96px; height: 96px; }
.player-tile .name { font-weight: 700; }
.profile { display: grid; grid-template-columns: 240px 1fr; gap: 1.5rem; margin: 1.25rem 0; }
.profile-photo img, .profile-photo .avatar { width: 240px; height: 240px; border-radius: 14px; object-fit: cover; font-size: 3rem; }
.profile h1 { margin-top: 0; }
@media (max-width: 640px) { .profile { grid-template-columns: 1fr; } .profile-photo img, .profile-photo .avatar { width: 100%; height: auto; aspect-ratio: 1; } }
.jersey { color: var(--brand); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.bio { white-space: pre-line; }
.contact { margin-bottom: 1rem; }
.contact summary { cursor: pointer; color: var(--muted); margin-bottom: .5rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.stat-tiles > * { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; text-align: center; text-decoration: none !important; color: var(--ink) !important; }
.stat-tiles b { display: block; font-size: 1.5rem; }
.stat-tiles span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.leaders { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.leaders h3 { margin-top: 0; }
.leaders ol { padding-left: 1.2rem; margin: 0 0 1rem; }
.leaders li { display: flex; gap: .4rem; align-items: baseline; }
.leaders li b { margin-left: auto; }
.leaders li .muted { font-size: .8rem; }
.review-row { display: flex; gap: 1rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.assign { display: flex; gap: .4rem; align-items: center; }
.assign select { width: auto; padding: .3rem .5rem; }

/* score sheet */
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; background: var(--navy); color: #fff; border-radius: var(--radius); padding: 1rem; margin: 1rem 0 .5rem; text-align: center; position: sticky; top: 56px; z-index: 5; }
.sheet-head .muted { color: #b8c3d4; }
.sheet-team { font-weight: 700; }
.score-input { font-size: 2rem; font-weight: 800; text-align: center; max-width: 7rem; margin: .25rem auto 0; display: block; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); }
.sheet-tabs { margin: .75rem 0; }
.sheet-side { display: none; }
.sheet-side.shown { display: block; }
@media (min-width: 1000px) {
  .scoresheet { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
  .scoresheet > :not(.sheet-side) { grid-column: 1 / -1; }
  .sheet-side { display: block; }
  .sheet-tabs { display: none; }
}
.sk-player { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin-bottom: .6rem; opacity: .75; }
.sk-player.on { opacity: 1; border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); }
.sk-player.foul-trouble { box-shadow: inset 4px 0 0 var(--loss); }
.sk-id { display: flex; gap: .75rem; align-items: center; }
.sk-name { font-weight: 700; font-size: 1.1rem; }
.sk-id label.check { margin: .15rem 0; }
.sk-line { font-size: .85rem; color: var(--muted); }
.sk-line b { color: var(--ink); font-size: 1rem; }
.sk-buttons { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; margin-top: .6rem; }
.sk-buttons button { font: inherit; font-weight: 700; font-size: .85rem; padding: .7rem .2rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.sk-buttons button.make { background: color-mix(in srgb, var(--win) 14%, var(--card)); border-color: color-mix(in srgb, var(--win) 35%, var(--line)); }
.sk-buttons button.miss { background: color-mix(in srgb, var(--loss) 10%, var(--card)); }
.sk-buttons button.foul { color: var(--loss); }
.sk-buttons button.flash-tap { background: var(--brand); color: #fff; }
@media (max-width: 420px) { .sk-buttons { grid-template-columns: repeat(4, 1fr); } }
.sk-manual summary { cursor: pointer; font-size: .85rem; color: var(--muted); margin-top: .5rem; }
.sk-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .4rem; margin-top: .5rem; }
.sk-fields label { font-size: .75rem; color: var(--muted); }
.sk-fields input { padding: .35rem .5rem; }
.sheet-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; display: flex; gap: .5rem; justify-content: flex-end; border-top: 1px solid var(--line); z-index: 5; }
.btn.finalize { background: var(--win); }
.game-team small { margin-left: .35rem; }
.game-list + h2 { margin-top: 1.25rem; }
