/* Scorbot. Red and blue only ever mean the two alliances; amber is the brand and focus
   color. Light and dark share one set of names and follow the system unless the visitor
   picks one (theme.js sets data-theme). */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #dce1e7;
  --text: #111418;
  --muted: #5a6472;
  --accent: #f2b705;
  --on-accent: #111418;
  --accent-soft: #fdf3d0;
  --accent-ink: #7a4f00;
  --red: #b42824;
  --red-soft: #fcedec;
  --red-fill: #c42b28;
  --blue: #1a56b8;
  --blue-soft: #eaf1fc;
  --blue-fill: #1d5fc4;
  --on-fill: #ffffff;
  --green: #17793f;
  --green-soft: #e2f4e9;
  --shadow: 0 1px 2px rgba(17, 20, 24, .06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1014;
    --surface: #151a20;
    --surface-2: #1c232b;
    --border: #2a323c;
    --text: #e9edf2;
    --muted: #9aa5b3;
    --accent: #f5c033;
    --accent-soft: #3a2e0a;
    --accent-ink: #f5c033;
    --red: #ff8a80;
    --red-soft: #3a1d1f;
    --red-fill: #c93a36;
    --blue: #8ab4ff;
    --blue-soft: #172a45;
    --blue-fill: #2f6bd8;
    --green: #65cf92;
    --green-soft: #12301f;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1014;
  --surface: #151a20;
  --surface-2: #1c232b;
  --border: #2a323c;
  --text: #e9edf2;
  --muted: #9aa5b3;
  --accent: #f5c033;
  --accent-soft: #3a2e0a;
  --accent-ink: #f5c033;
  --red: #ff8a80;
  --red-soft: #3a1d1f;
  --red-fill: #c93a36;
  --blue: #8ab4ff;
  --blue-soft: #172a45;
  --blue-fill: #2f6bd8;
  --green: #65cf92;
  --green-soft: #12301f;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 Inter, system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; line-height: 1.4; margin: 0; font-weight: 600; }
h3 { font-size: .85rem; color: var(--muted); font-weight: 600; margin: 0; }
h4 { font-size: .85rem; margin: 0 0 .35rem; }
p { margin: 0 0 .75rem; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 20; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }
.note { font-size: .82rem; color: var(--muted); margin-top: .5rem; }
.note-inline { font-size: .82rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.content { padding-top: 28px; padding-bottom: 48px; }
.page-title { font-size: 1.6rem; margin-bottom: 1.25rem; }
.section { margin-top: 32px; }
.content > .section:first-child, .overview-main > .section:first-child, .content > h1 + .section { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head a { font-size: .875rem; font-weight: 500; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 500; }
.btn-secondary:hover, .btn-primary:hover { text-decoration: none; filter: brightness(.96); }
.btn-sm { height: 36px; padding: 0 14px; font-size: .875rem; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-block { width: 100%; }

/* Navigation bar */
.navbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.navbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; text-decoration: none; order: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; }
.brand-mark svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.nav-panel { display: contents; }
.nav-links { display: flex; gap: 4px; order: 1; }
.nav-links a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; text-decoration: none; }
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.nav-search {
  order: 2; margin-left: auto; display: flex; align-items: center; gap: 8px; width: 280px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--muted);
}
.nav-search:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-search input { flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; color: var(--text); font: inherit; font-size: .9rem; outline: none; }
.nav-search input::-webkit-search-cancel-button { cursor: pointer; }
.theme-row { order: 3; display: flex; align-items: center; gap: 12px; }
.theme-caption { display: none; font-weight: 500; }
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-switch button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 34px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
}
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }
.theme-switch .icon { width: 18px; height: 18px; }
.theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-divider { order: 4; width: 1px; height: 24px; background: var(--border); }
.account { order: 5; display: flex; align-items: center; gap: 8px; }
.account-login { height: 40px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: 10px; font-weight: 500; text-decoration: none; }
.account-login:hover { background: var(--surface-2); }
.nav-dashboard { height: 40px; }
.account-menu { position: relative; }
.account-menu summary { list-style: none; cursor: pointer; }
.account-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.avatar .icon { width: 18px; height: 18px; }
.avatar.small { width: 30px; height: 30px; flex: none; position: relative; }
.avatar.small .icon { width: 16px; height: 16px; }
.account-dot { position: absolute; top: -1px; right: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.account-chip {
  height: 40px; padding: 0 8px 0 5px; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 999px; font-weight: 500;
}
.account-chip:hover, .account-menu[open] .account-chip { background: var(--surface-2); }
.account-chip-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip > .icon { width: 16px; height: 16px; color: var(--muted); }
.account-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.account-head .muted { margin-bottom: 0; }
.account-links a[aria-current="page"] { color: var(--accent-ink); font-weight: 600; }
.account-inline { display: none; }
/* Keep the bar on one row: the follow shortcut is also in the account menu. */
@media (max-width: 1279px) { .account .nav-dashboard { display: none; } }
@media (max-width: 1120px) { .nav-search { width: 200px; } }
.account-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 14px; z-index: 11;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.account-pop p { margin: 0; }
.account-name { font-weight: 600; overflow-wrap: anywhere; }
.account-pop .muted { font-size: .85rem; margin-bottom: 12px; }
.nav-mobile { display: none; order: 1; align-items: center; gap: 2px; }
.nav-icon { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.nav-icon .icon { width: 20px; height: 20px; }
.nav-icon .icon-close, .navbar.menu-open .nav-icon .icon-menu { display: none; }
.navbar.menu-open .nav-icon .icon-close { display: block; }
.nav-mobile-login { height: 44px; padding: 0 10px; display: inline-flex; align-items: center; font-weight: 500; text-decoration: none; }

@media (max-width: 960px) {
  .wrap { padding: 0 16px; }
  .navbar-row { gap: 0 4px; min-height: 56px; }
  .brand { margin-right: auto; font-size: 1.1rem; }
  .nav-mobile { display: flex; }
  .nav-search { display: none; order: 2; flex-basis: 100%; width: auto; height: 44px; margin: 0 0 10px; }
  .navbar.search-open .nav-search { display: flex; }
  .nav-search input { font-size: 16px; }
  .nav-panel { display: none; order: 3; flex-basis: 100%; flex-direction: column; gap: 4px; padding: 8px 0 16px; border-top: 1px solid var(--border); }
  .navbar.menu-open .nav-panel { display: flex; }
  .nav-links { flex-direction: column; }
  .nav-links a { min-height: 44px; display: flex; align-items: center; font-size: 1rem; padding: 0 8px; }
  .theme-row { justify-content: space-between; padding: 8px 8px 0; }
  .theme-caption { display: inline; }
  .theme-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .theme-switch .icon { display: none; }
  .theme-switch button { height: 40px; padding: 0 14px; }
  .nav-divider { display: none; }
  .account { flex-direction: column; align-items: stretch; padding: 12px 8px 0; }
  .account-login { display: none; }
  .account .btn { height: 44px; }
  .account-menu, .account .nav-dashboard { display: none; }
  .account-inline { display: block; padding-top: 12px; border-top: 1px solid var(--border); }
  .account-inline .account-links a { min-height: 44px; display: flex; align-items: center; font-size: 1rem; }
}

/* Event info bar */
.event-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
.event-bar .wrap { padding-top: 14px; }
.event-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.event-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.event-title h1 { font-size: 1.3rem; line-height: 1.4; margin: 0; }
.crumb { color: var(--muted); font-size: .9rem; text-decoration: none; }
.crumb:hover { color: var(--text); }
.crumb-sep { color: var(--muted); }
.event-meta { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .9rem; color: var(--muted); }
.event-meta li { display: inline-flex; align-items: center; gap: 6px; }
.event-meta .icon { width: 15px; height: 15px; }
.event-links { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { display: flex; gap: 4px; margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 12px 14px; color: var(--muted); font-weight: 500; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { color: var(--text); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent); }

.phase { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: .78rem; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.phase.live { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.phase.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.phase.upcoming { background: transparent; border: 1px solid var(--border); color: var(--text); }
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; border: 1px dashed var(--muted); color: var(--muted); font-size: .72rem; font-weight: 500; white-space: nowrap; }

/* Event lists */
.event-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.event-card { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.event-card:hover { border-color: var(--muted); text-decoration: none; }
.event-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .85rem; }
.event-card-name { font-size: 1.2rem; font-weight: 600; line-height: 1.4; }
.event-card .muted { font-size: .875rem; }
.event-list, .team-list, .award-list, .match-list, .mini-list { list-style: none; margin: 0; padding: 0; }
.event-list, .team-list, .award-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.event-list li + li, .team-list li + li, .award-list li + li { border-top: 1px solid var(--border); }
.event-list a { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 20px; text-decoration: none; }
.event-main { display: flex; flex-direction: column; min-width: 0; }
.event-name { font-weight: 600; }
.event-main .muted, .event-dates { font-size: .875rem; }
.event-list a:hover, .team-list a:hover { background: var(--surface-2); text-decoration: none; }
.team-list a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-height: 48px; text-decoration: none; }
.team-list strong { min-width: 3.5rem; }
.team-list .icon { margin-left: auto; color: var(--muted); }
.award-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 14px 20px; }
.award-list a { text-decoration: none; }
.pager { display: flex; justify-content: space-between; margin-top: 16px; }

/* Search pages */
.search { display: flex; align-items: center; gap: 10px; max-width: 640px; margin-bottom: 24px; padding: 0 6px 0 14px; height: 52px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); }
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.search input { flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.search .btn { height: 40px; }

/* Overview */
.overview { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.overview-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 32px; }
.overview-main > .section { margin-top: 0; }
.overview-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel > h2, .panel .section-head h2 { font-size: 1rem; }
.panel > h2 { margin-bottom: 14px; }
.stage-steps { list-style: none; margin: 0 0 14px; padding: 0; display: flex; gap: 4px; font-size: .8rem; }
.stage-steps li { flex: 1; padding: 6px 4px 0; border-top: 3px solid var(--surface-2); color: var(--muted); text-align: center; }
.stage-steps li.done { border-top-color: var(--muted); }
.stage-steps li.current { border-top-color: var(--accent); color: var(--text); font-weight: 600; }
.progress-row { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 6px; }
progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; color: var(--accent); }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.live-note { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: .82rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.mini-list li:first-child { border-top: 0; padding-top: 0; }
.mini-value { text-align: right; font-weight: 600; }
.mini-value a { text-decoration: none; }
.champion-card { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: var(--radius); }
.champion-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.champion-icon .icon { width: 28px; height: 28px; }
.champion-text { flex: 1 1 200px; min-width: 0; }
.champion-text h2 { font-size: .85rem; color: var(--muted); }
.champion-seed { margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.3; }
.champion-teams { display: flex; flex-wrap: wrap; gap: 8px; }
.team-pill { padding: 8px 14px; border-radius: 10px; background: var(--surface-2); font-size: 1.15rem; font-weight: 700; text-decoration: none; }
.team-pill:hover { text-decoration: none; background: var(--border); }

/* Matches */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter label { font-size: .875rem; color: var(--muted); }
.filter input { width: 9rem; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-size: .82rem; color: var(--muted); }
.legend > span > :first-child { color: var(--text); }
.legend-win { padding: 1px 6px; border-radius: 4px; background: var(--surface-2); font-weight: 700; }
.match-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.match, .match-head { display: grid; grid-template-columns: 7.5rem 4.5rem minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 12px; padding: 8px 16px; }
.match + .match { border-top: 1px solid var(--border); }
.match-head { padding-top: 10px; padding-bottom: 10px; background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 500; }
.match-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; text-decoration: none; }
.match-label { font-weight: 600; }
.match-info:hover .match-label { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.match-time { font-size: .875rem; color: var(--muted); white-space: nowrap; }
.side { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 5px 5px 5px 14px; border-radius: 10px; min-width: 0; }
.side.red { background: var(--red-soft); color: var(--red); }
.side.blue { background: var(--blue-soft); color: var(--blue); }
.teams { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; min-width: 0; font-weight: 500; }
.alliance { font-size: .75rem; font-weight: 600; opacity: .85; white-space: nowrap; }
.pending { color: var(--muted); font-weight: 400; }
.team { color: inherit; white-space: nowrap; text-decoration: none; }
.team:hover { text-decoration: underline; text-decoration-color: currentColor; }
.team.dq { text-decoration: line-through; text-decoration-thickness: 2px; }
.team.sub { text-decoration: underline dotted; text-decoration-color: currentColor; text-underline-offset: 4px; }
/* The team the page is about: a solid underline, unlike a substitute's dotted one. */
.team.focus { font-weight: 700; text-decoration: underline solid; text-decoration-color: currentColor; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.team.focus.dq { text-decoration-line: underline line-through; }
.team-cell { display: inline-flex; flex-wrap: wrap; gap: 2px 14px; }
.score { margin-left: auto; min-width: 56px; padding: 5px 10px; border-radius: 8px; text-align: center; color: var(--text); font-size: 1.2rem; font-weight: 500; line-height: 1.4; }
.score.unplayed { color: var(--muted); }
.side.red.won .score { background: var(--red-fill); color: var(--on-fill); font-weight: 700; }
.side.blue.won .score { background: var(--blue-fill); color: var(--on-fill); font-weight: 700; }
.card { display: inline-block; width: .55em; height: .8em; border-radius: 1px; margin-left: .25em; vertical-align: -.05em; }
.card.yellow { background: #e6b800; }
.card.red { background: #d32626; }

/* Match detail */
.back { margin-bottom: 8px; font-size: .9rem; }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--text); }
.match-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.match-title { font-size: 1.5rem; font-weight: 700; }
.match-times { font-size: .9rem; margin: 4px 0 16px; }
.score-hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.score-panel { padding: 18px 20px; border-radius: 14px; display: flex; flex-direction: column; gap: 8px; }
.score-panel p { margin: 0; }
.score-panel.red { background: var(--red-soft); color: var(--red); }
.score-panel.blue { background: var(--blue-soft); color: var(--blue); }
.score-panel.red.won { background: var(--red-fill); color: var(--on-fill); }
.score-panel.blue.won { background: var(--blue-fill); color: var(--on-fill); }
.score-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; }
.win-tag { padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .22); }
.big-score { font-size: 3rem; line-height: 1.1; font-weight: 500; color: var(--text); }
.score-panel.won .big-score { color: inherit; font-weight: 700; }
.panel-teams { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 1rem; font-weight: 500; }

/* Tables */
.table-scroll, .bracket-scroll { overflow-x: auto; }
.table-scroll { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: .93rem; }
.data th, .data td { padding: 11px 16px; text-align: left; border-top: 1px solid var(--border); white-space: nowrap; }
.data thead th { border-top: 0; background: var(--surface-2); font-size: .8rem; color: var(--muted); font-weight: 500; }
.data thead th.strong-head { color: var(--text); font-weight: 600; }
.data .num { text-align: right; }
.data a { text-decoration: none; }
.data a:hover strong { text-decoration: underline; text-decoration-color: var(--accent); }
.team-name { font-weight: 400; font-size: .875rem; }
.rank { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 8px; background: var(--surface-2); font-weight: 700; }
.rank.first { background: var(--accent); color: var(--on-accent); }
.data tr.group th { background: var(--surface-2); font-size: .78rem; letter-spacing: .04em; color: var(--muted); }
.red-text { color: var(--red) !important; }
.blue-text { color: var(--blue) !important; }
/* Score breakdown: red on the left, the item in the middle, blue on the right. */
.breakdown { table-layout: fixed; }
.breakdown .side-value { width: 30%; text-align: center; font-weight: 600; }
.breakdown .item { text-align: center; white-space: normal; color: var(--muted); font-weight: 500; }
.breakdown thead .item { color: var(--muted); }
.breakdown tr.group th { text-align: center; }
.breakdown tbody td.side-value:first-child { background: color-mix(in srgb, var(--red-soft) 55%, transparent); }
.breakdown tbody td.side-value:last-child { background: color-mix(in srgb, var(--blue-soft) 55%, transparent); }

.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.status.winner, .status.finalist, .status.corrected { background: var(--accent-soft); color: var(--accent-ink); }
.status.active { background: var(--green-soft); color: var(--green); }

/* Bracket */
.bracket-scroll { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.bracket { display: block; font-size: 12px; }
.bracket a { text-decoration: none; }
.bracket a:hover .bk-box { stroke: var(--accent); }
.bracket text { fill: var(--text); }
.bracket text.bk-section { font-size: 15px; font-weight: 700; }
.bracket text.bk-round, .bracket text.bk-drop, .bracket text.bk-teams, .bracket text.bk-pending { fill: var(--muted); }
.bracket text.bk-drop, .bracket text.bk-teams { font-size: 11px; }
.bracket text.bk-label, .bracket text.bk-alliance, .bracket text.bk-result { font-weight: 600; }
.bracket text.bk-result { font-size: 13px; }
.bk-line { fill: none; stroke: var(--muted); stroke-width: 1; }
.bk-box { fill: var(--surface); stroke: var(--border); }
.bk-card.final .bk-box { stroke: var(--accent); stroke-width: 1.5; }
.bk-rule { stroke: var(--border); }
.bk-won { fill: var(--accent-soft); }
.bracket .bk-side.won text.bk-alliance, .bracket .bk-side.won text.bk-result { fill: var(--accent-ink); font-weight: 700; }
.bk-side.lost text { opacity: .65; }
.bracket text.bk-game { fill: var(--muted); }
.bracket text.bk-game.played { fill: var(--text); font-weight: 600; text-decoration: underline; }

/* Team */
.team-head { margin-bottom: 8px; }
.team-head h1 { font-size: 1.8rem; }
.team-number { color: var(--accent-ink); }
.team-head h1 { display: flex; align-items: center; flex-wrap: wrap; gap: 0 .35em; }
.team-avatar { width: 40px; height: 40px; border-radius: 6px; image-rendering: pixelated; flex: none; }
.team-avatar.small { width: 20px; height: 20px; border-radius: 3px; vertical-align: -4px; margin-right: 6px; }
.team-name { display: inline-flex; align-items: center; }
.team-source { font-size: .85rem; margin-top: 4px; }
.team-event { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.team-event-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.team-event-head a { text-decoration: none; }
.team-event-head .muted { font-size: .875rem; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0; }
.stats div { min-width: 96px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.stats dt { font-size: .75rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.2rem; font-weight: 700; }
.award-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.notfound { max-width: 560px; margin: 48px auto; text-align: center; }

/* Footer */
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; padding-top: 20px; padding-bottom: 28px; }
.footer p { margin: 0; }

/* Admin */
.admin h1 { margin-bottom: 1rem; }
.admin h2 { margin: 1.75rem 0 .75rem; }
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.admin-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 1.5rem; display: grid; gap: 14px; }
.admin-form.narrow { max-width: 28rem; }
.admin-form h2 { margin: 0; }
.admin-form button { justify-self: start; }
.admin-form p { margin: 0; }
.field { display: grid; gap: 4px; }
.field > span { font-size: .85rem; color: var(--muted); font-weight: 500; }
.field small { font-size: .78rem; }
.admin input, .admin select, .admin textarea {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; width: 100%; min-width: 0;
}
.admin input[type="checkbox"], .admin input[type="radio"] { width: auto; }
.admin button {
  font: inherit; font-weight: 600; color: var(--bg); background: var(--text);
  border: 1px solid transparent; border-radius: 10px; min-height: 40px; padding: 0 16px; cursor: pointer;
}
.admin button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 500; }
.admin button.danger { background: var(--red-fill); color: var(--on-fill); }
.admin textarea.code, .secret-box pre { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.danger-zone { border-color: var(--red-fill); }
.form-error { color: var(--red); margin: 0; }
.form-error:empty { display: none; }
.secret-box, .warning-box { background: var(--accent-soft); border-radius: var(--radius); padding: .25rem 1rem .75rem; margin: 1rem 0; }
.secret-box pre { background: var(--surface); padding: .6rem; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.status.event-published { background: var(--green-soft); color: var(--green); }
.status.event-draft { background: var(--surface-2); color: var(--text); }
.admin code { font-size: .85rem; }
.status.account-active { background: var(--green-soft); color: var(--green); }
.status.account-pending { background: var(--accent-soft); color: var(--accent-ink); }
.status.account-rejected { background: var(--surface-2); color: var(--muted); }
.notice { background: var(--accent-soft); color: var(--text); border-radius: var(--radius); padding: .7rem 1rem; display: flex; flex-wrap: wrap; gap: .75rem; }
.applications { display: grid; gap: .75rem; }
.application { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.application h3 { margin: 0 0 .4rem; font-size: 1.05rem; color: var(--text); overflow-wrap: anywhere; }
.application-meta { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin: 0 0 .5rem; font-size: .85rem; }
.application-meta dt { color: var(--muted); font-size: .75rem; }
.application-meta dd { margin: 0; overflow-wrap: anywhere; }
.application-purpose { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 8px; padding: .5rem .75rem; margin: 0 0 .75rem; }
.review-cell { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.review-cell input { flex: 1 1 12rem; min-width: 0; }
.review-cell:has(.field) { align-items: flex-end; }
.review-cell .field.compact { flex: 0 1 12rem; }
.review-cell .field.compact input { width: 100%; }
.block { display: block; }
.form-notice { color: var(--green); margin: 0; }
.form-notice:empty { display: none; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.inline-form input { flex: 0 1 16rem; min-width: 0; }
.admin-tabs { margin: 0 0 1rem; border-bottom: 1px solid var(--border); }
.crumbs { margin: 0 0 .25rem; font-size: .85rem; }
.status.application-pending { background: var(--accent-soft); color: var(--accent-ink); }
.status.application-approved { background: var(--green-soft); color: var(--green); }
.status.application-rejected, .status.application-withdrawn { background: var(--surface-2); color: var(--muted); }
.account-warning { font-size: .85rem; margin: -6px 0 10px; }
.account-warning a { color: var(--accent-ink); font-weight: 600; }
.account-links { display: grid; gap: 2px; margin: 0 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.account-links a { padding: 6px 0; color: var(--text); text-decoration: none; }
.account-links a:hover { color: var(--accent-ink); }
.follow-btn .icon { fill: none; }
.follow-btn.following { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.follow-btn.following .icon { fill: currentColor; }
.team-head .follow-btn { margin-top: 8px; }
.follow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: .75rem; }
.follow-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: grid; gap: 6px; align-content: start; }
.follow-card h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.follow-card p { margin: 0; }
.follow-card .team-number { font-variant-numeric: tabular-nums; }
.follow-stats { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 2px 0; }
.follow-stats dt { color: var(--muted); font-size: .75rem; }
.follow-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.follow-line { font-size: .9rem; }
.follow-actions { margin-top: 4px !important; }
.outcome { font-weight: 700; }
.outcome-win { color: var(--green); }
.outcome-loss { color: var(--red); }
.admin button.small { padding: 4px 12px; font-size: .85rem; }
.device-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.device-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.device-list li > span { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.device-list li button { margin-left: auto; }
.kinds { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.kinds legend { font-weight: 600; margin-bottom: .5rem; }
.prose { max-width: 42rem; line-height: 1.75; }
.prose h2 { margin-top: 2rem; font-size: 1.15rem; }
.prose li + li { margin-top: .35rem; }

@media (max-width: 720px) {
  .content { padding-top: 20px; }
  .page-title { font-size: 1.4rem; }
  .event-bar .wrap { padding-top: 12px; }
  .event-title h1 { font-size: 1.15rem; }
  .crumb, .crumb-sep { display: none; }
  .event-meta { font-size: .82rem; gap: 4px 14px; }
  .event-links { margin-left: 0; }
  .tabs { margin: 4px -16px 0; padding: 0 8px; }
  .tabs a { padding: 12px 10px; }
  .event-list a { grid-template-columns: minmax(0, 1fr) auto; padding: 14px 16px; }
  .event-dates { grid-column: 1; grid-row: 2; }
  .event-list .phase { grid-column: 2; grid-row: 1 / span 2; }
  .match-list { background: transparent; border: 0; border-radius: 0; overflow: visible; display: flex; flex-direction: column; gap: 10px; }
  .match-head { display: none; }
  .match { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .match + .match { border-top: 1px solid var(--border); }
  .match-info { padding: 0 4px; }
  .match-time { text-align: right; padding-right: 4px; }
  .match .side { grid-column: 1 / -1; }
  .side { min-height: 40px; padding: 4px 4px 4px 12px; }
  .score { min-width: 52px; font-size: 1.1rem; }
  .big-score { font-size: 2.6rem; }
  .score-panel { padding: 16px; }
  .panel-teams { flex-direction: column; gap: 2px; }
  .data th, .data td { padding: 10px 12px; }
  .toolbar { margin-bottom: 16px; }
  .filter input { flex: 1 1 8rem; height: 44px; font-size: 16px; }
  .filter .btn { height: 44px; }
  /* Keep who a ranking row belongs to in view while its numbers scroll. */
  .ranking th:nth-child(-n+2), .ranking td:nth-child(-n+2) { position: sticky; background: var(--surface); }
  .ranking thead th:nth-child(-n+2) { background: var(--surface-2); }
  .ranking th:nth-child(1), .ranking td:nth-child(1) { left: 0; min-width: 3.2rem; }
  .ranking th:nth-child(2), .ranking td:nth-child(2) { left: 3.2rem; max-width: 8rem; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border); }
  .award-list li, .team-list a { padding-left: 16px; padding-right: 16px; }
}
