/* Reset and typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    color-scheme: light;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    background-color: #f5f5f5;
    line-height: 1.6;
}

/* Layout */
header {
    background-color: #2c3e50;
    color: #fff;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

header nav {
    display: flex;
    gap: 1.5rem;
}

header nav a {
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}

header nav a:hover {
    opacity: 0.8;
}

/* Nav dropdown */
.nav-dropdown {
    position: relative;
}
.nav-dropdown-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s;
}
.nav-dropdown-btn:hover { opacity: 0.8; background: none; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;           /* flush with button — no gap to cross */
    left: 50%;
    transform: translateX(-50%);
    background: #1e2d3d;
    border-radius: 0 0 6px 6px;
    min-width: 130px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    overflow: hidden;
    z-index: 100;
    padding-top: 0.4rem; /* visual breathing room inside the menu */
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    color: #fff;
    text-decoration: none;
    opacity: 1;
    transition: background 0.15s;
}
.nav-dropdown-menu a:hover { background: rgba(255,255,255,0.1); opacity: 1; }

main {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 2rem 1rem;
    min-height: 60vh;
}

footer {
    max-width: 1100px;
    margin: 2rem auto 0;
    padding: 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: #666;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

/* Paragraphs */
p {
    margin-bottom: 1rem;
}

/* Links */
a {
    color: #0066cc;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Forms */
form {
    margin: 1rem 0;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

button,
input[type="submit"] {
    background-color: #0066cc;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover,
input[type="submit"]:hover {
    background-color: #0052a3;
}

/* Utility */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }

.muted { color: #888; font-size: 0.9rem; }
.footer-staff-link {
    margin-left: 1rem;
    font-size: 0.78rem;
    color: #9ca3af;
    text-decoration: none;
    opacity: 0.6;
}
.footer-staff-link:hover { opacity: 1; text-decoration: none; }
.view-all { margin-top: 0.5rem; font-size: 0.9rem; }
.back-link { margin-top: 2rem; font-size: 0.9rem; }
.coming-soon { padding: 3rem; text-align: center; color: #888; }

.division-listing {
    margin: 1.5rem 0 2rem;
}

.division-listing-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.division-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.division-card {
    border: 1px solid #dbe3ea;
    border-radius: 6px;
    padding: 0.9rem 1rem;
    background: linear-gradient(180deg, #fafcff 0%, #f4f7fb 100%);
}

.division-card h4 {
    margin-bottom: 0.2rem;
}

.division-code {
    margin-bottom: 0;
    color: #52606d;
    font-size: 0.9rem;
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.alert-error {
    background: #fee2e2;
    border: 1px solid #f87171;
    color: #991b1b;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.badge-played    { background: #d1fae5; color: #065f46; }
.badge-on_field  { background: #fef3c7; color: #92400e; }
.badge-scheduled { background: #e5e7eb; color: #374151; }
.badge-win       { background: #d1fae5; color: #065f46; }
.badge-loss      { background: #fee2e2; color: #991b1b; }
.badge-tie       { background: #e0e7ff; color: #3730a3; }

/* ── Tables (shared) ─────────────────────────────────────────────────────── */
/* ── Responsive table wrapper ─────────────────────────────────────────────
   Wrap any overflow-prone table in .table-scroll for horizontal scroll on
   mobile. Adds a right-shadow hint that more content exists off-screen.     */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Fade hint on right edge when scrollable */
    background:
        linear-gradient(to right, white 30%, rgba(255,255,255,0)),
        linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.08), transparent),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.08), transparent) 0 100%;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th {
    background: #f3f4f6;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 2px solid #d1d5db;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* Match row status coloring */
.match-row.status-played   { opacity: 0.8; }
.match-row.status-on_field { background: #fffbeb !important; }
.match-row.status-on_field td { border-bottom-color: #fde68a; }

/* Win/loss/tie outcome row tinting on team page */
.match-row.outcome-win  td { background: #f0fdf4; }
.match-row.outcome-loss td { background: #fef2f2; }
.match-row.outcome-tie  td { background: #eef2ff; }

/* ── Match table ──────────────────────────────────────────────────────────── */
.match-table { margin-bottom: 0.5rem; }
.match-table .match-num { font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.match-table .col-field { width: 3rem; text-align: center; color: #6b7280; }
.match-table .col-time  { width: 5rem; color: #6b7280; white-space: nowrap; }

/* Score columns */
.score-red, .score-blue {
    width: 3.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}
.score-red  { color: #b91c1c; }
.score-blue { color: #1d4ed8; }
.score-red.winner, .score-blue.winner {
    font-size: 1.1rem;
}

/* Alliance team cells */
.red-cell, .blue-cell {
    white-space: nowrap;
}
.red-cell  { border-left: 3px solid #fca5a5; }
.blue-cell { border-left: 3px solid #93c5fd; }

/* Table header alignment for score cols */
.match-table th.score-red  { color: #b91c1c; }
.match-table th.score-blue { color: #1d4ed8; }

/* Compact variant (home page upcoming) */
.match-table.compact td { padding: 0.35rem 0.5rem; }
.match-table.compact .col-time { font-size: 0.8rem; }

/* ── Team links ───────────────────────────────────────────────────────────── */
.team-link {
    display: inline-block;
    margin: 1px 3px;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s;
    min-width: 58px;
    text-align: center;
}
.team-link:hover { opacity: 0.75; text-decoration: none; }

.red-team  { color: #991b1b; background: #fee2e2; }
.blue-team { color: #1e3a8a; background: #dbeafe; }

.team-link.this-team {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}
.team-link.surrogate { opacity: 0.6; font-style: italic; }

/* ── Match section headers ────────────────────────────────────────────────── */
.match-section { margin-bottom: 2.5rem; }
.match-section h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.4rem;
    margin-bottom: 0.75rem;
}
.section-progress {
    font-size: 0.75rem;
    font-weight: 400;
    color: #9ca3af;
    margin-left: auto;
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.page-header h2 { margin-bottom: 0; }
.page-header .muted { margin-bottom: 0; }

/* ── Event landing ────────────────────────────────────────────────────────── */
.event-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.event-header h2 { margin-bottom: 0.25rem; }
.event-meta { color: #6b7280; font-size: 0.9rem; margin-bottom: 0.25rem; }

/* Section titles */
.section-title {
    font-size: 1rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.3rem;
    margin-bottom: 0.75rem;
}

/* Full-width upcoming section */
.section-upcoming {
    margin-bottom: 2rem;
}

/* 2-column rankings grid */
.section-rankings { margin-top: 0.5rem; }
.rankings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    align-items: start;
}
@media (max-width: 600px) {
    .rankings-grid { grid-template-columns: 1fr; }
}
.rankings-grid-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.rankings-card-header {
    background: #f3f4f6;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}
.rankings-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #374151;
    text-decoration: none;
}
.rankings-card-title:hover { color: #1d4ed8; text-decoration: none; }
.rankings-grid-card .rankings-table { font-size: 0.82rem; }
.rankings-grid-card .rankings-table th,
.rankings-grid-card .rankings-table td { padding: 0.3rem 0.5rem; }

/* ── Division strip (event header) ───────────────────────────────────────── */
.division-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}
.division-strip-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.25rem;
    white-space: nowrap;
}
.division-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #c7d2fe;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}
.division-pill:hover {
    background: #3730a3;
    color: #fff;
    text-decoration: none;
}

/* ── Team search ─────────────────────────────────────────────────────────── */
.team-search-wrap {
    position: relative;
    max-width: 480px;
    margin: 0 auto 1.25rem;
}
.team-search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s;
}
.team-search-box:focus-within { border-color: #1d4ed8; }
.team-search-icon { font-size: 0.95rem; color: #9ca3af; flex-shrink: 0; }
.team-search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
    padding: 0;
    margin: 0;
    width: 100%;
}
.team-search-clear {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    line-height: 1;
}
.team-search-clear:hover { color: #374151; background: none; }
.team-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 200;
    max-height: 320px;
    overflow-y: auto;
}
.tsd-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}
.tsd-item:last-child { border-bottom: none; }
.tsd-item:hover, .tsd-item.tsd-active { background: #eff6ff; text-decoration: none; }
.tsd-num { font-size: 0.9rem; font-weight: 700; color: #1d4ed8; min-width: 3.5rem; }
.tsd-name { font-size: 0.85rem; color: #6b7280; }

/* Division sub-heading inside rankings panel */
.division-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0.75rem 0 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid #e5e7eb;
}
.division-label:first-child { margin-top: 0; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 0.75rem;
}
.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.5rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 0;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: #374151; background: none; }
.tab-btn.active {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
    background: none;
}
.tab-progress {
    font-size: 0.72rem;
    font-weight: 400;
    color: #9ca3af;
}
.tab-btn.active .tab-progress { color: #93c5fd; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Inner division tabs (nested within outer tab panels) */
.inner-tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 0.75rem;
    margin-top: 0.25rem;
}
.inner-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s, border-color 0.15s;
}
.inner-tab-btn:hover { color: #374151; background: none; }
.inner-tab-btn.active { color: #1d4ed8; border-bottom-color: #1d4ed8; background: none; }
.inner-tab-btn .tab-progress { color: #d1d5db; }
.inner-tab-btn.active .tab-progress { color: #93c5fd; }

.inner-tab-panel { display: none; }
.inner-tab-panel.active { display: block; }

/* ── Mobile responsive tables ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Main content area — remove side padding so tables use full width */
    main { padding: 1rem 0.5rem; }

    /* Make all data tables horizontally scrollable */
    .match-table,
    .rankings-table,
    .rankings-grid-card .rankings-table,
    .pred-table,
    .pred-compare-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Re-allow wrapping inside cells that need it */
    .match-table td.red-cell,
    .match-table td.blue-cell,
    .match-table td.col-red,
    .match-table td.col-blue {
        white-space: normal;
        min-width: 80px;
    }

    /* Hide lowest-priority columns on small screens */
    .col-field, .col-time { display: none; }

    /* Compact team chips */
    .team-link { font-size: 0.75rem; padding: 0.08rem 0.25rem; margin: 1px 2px; }

    /* Shrink score columns */
    .score-red, .score-blue, .col-score { font-size: 0.85rem; width: 2.5rem; }

    /* Rankings grid: single column on mobile */
    .rankings-grid { grid-template-columns: 1fr; }

    /* Division strip: wrap pills */
    .division-strip { flex-wrap: wrap; }

    /* Header: stack on very small screens */
    .header-inner { flex-wrap: wrap; gap: 0.5rem; }
    header h1 { font-size: 1.1rem; }
    header nav { gap: 0.75rem; }
    header nav a { font-size: 0.82rem; }

    /* Tab bars: scroll horizontally if many tabs */
    .tab-bar, .inner-tab-bar { overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn, .inner-tab-btn { white-space: nowrap; flex-shrink: 0; }

    /* Upcoming divisions: single column */
    .upcoming-divisions { grid-template-columns: 1fr; }

    /* Team header: stack */
    .team-header { flex-direction: column; }
    .team-rank-card { align-self: flex-start; }

    /* Gears photos: single column */
    .gears-photos { grid-template-columns: 1fr; }
    .gears-photo img { height: 160px; }

    /* OPR cards: 2 cols instead of 4 */
    .opr-cards { grid-template-columns: repeat(2, 1fr); }

    /* Modal: full width */
    .modal-box { max-width: 100%; margin: 0.5rem; }
    .pred-score { font-size: 1.5rem; }
    .pred-score.winner { font-size: 1.75rem; }

    /* Next match card: stack */
    .next-match-card { flex-direction: column; gap: 0.75rem; }
    .next-match-teams { margin-left: 0; }

    /* Admin cards: single column */
    .admin-cards { grid-template-columns: 1fr; }

    /* Queue ops: tighten action grid */
    .queue-action-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    /* Very small: hide team names in rankings, just show number */
    .rankings-table .team-name { display: none; }
    /* Match label column narrower */
    .match-num { font-size: 0.78rem; }
}

/* Sortable table headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: #e9ecef; }
th.sort-active { background: #e0e7ff; color: #1d4ed8; }
.sort-icon { font-size: 0.7rem; opacity: 0.6; }
th.sort-active .sort-icon { opacity: 1; }
.num-col { text-align: right; }

/* ── Per-division upcoming match blocks ──────────────────────────────────── */
.upcoming-divisions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 1000px) {
    .upcoming-divisions { grid-template-columns: 1fr; }
}
.upcoming-div-block {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}
.upcoming-div-header {
    background: #f3f4f6;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid #e5e7eb;
}
.upcoming-div-name {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #374151;
    text-decoration: none;
}
.upcoming-div-name:hover { color: #1d4ed8; text-decoration: none; }
.upcoming-div-empty { padding: 0.4rem 0.6rem; margin: 0; font-size: 0.82rem; }
.upcoming-div-block .match-table { margin: 0; }
.upcoming-div-block .match-table td { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
.upcoming-div-block .match-num { min-width: 2.5rem; }

/* ── Rankings table ───────────────────────────────────────────────────────── */
.rankings-table .rank-num { font-weight: 700; text-align: center; width: 2.5rem; }
.rankings-table .wlt { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rankings-table .rp  { text-align: right; font-variant-numeric: tabular-nums; width: 4rem; }
.rankings-table .team-name { color: #6b7280; font-size: 0.8rem; }

/* ── Announcements ────────────────────────────────────────────────────────── */
.announcements {
    margin-bottom: 1.5rem;
}
.announcements h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}
.announcement-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 4px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    position: relative;
}
.announcement-card.targeted {
    background: #eff6ff;
    border-color: #93c5fd;
    border-left-color: #3b82f6;
}
.ann-time {
    float: right;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-left: 1rem;
}
.ann-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #1d4ed8;
    background: #dbeafe;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-bottom: 0.3rem;
}

/* ── Gears supplemental data ─────────────────────────────────────────────── */
.team-meta-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}
.team-meta-link {
    font-size: 0.82rem;
    color: #4b5563;
}

/* Photos panel */
.gears-panel {
    margin-bottom: 1.25rem;
}

/* Photo strip — horizontal row, equal height */
.gears-photos {
    display: grid;
    grid-template-columns: 1fr 1.6fr 1fr; /* logo | robot | team */
    gap: 0.6rem;
    min-width: 0;
}
/* When only some photos exist, collapse gracefully */
.gears-photos:has(.gears-photo-logo:only-of-type)    { grid-template-columns: 1fr; }

.gears-photo {
    margin: 0;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}
.gears-photo img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}
.gears-photo-logo img  { object-fit: contain; background: #f9fafb; }
.gears-photo figcaption {
    font-size: 0.7rem;
    color: #9ca3af;
    text-align: center;
    padding: 0.2rem 0;
    background: #f9fafb;
}

/* Stats column: vertical stack of cards */
.gears-stats {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 110px;
}
.gears-stat-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    text-align: center;
}
.gears-stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: #9ca3af; font-weight: 700; }
.gears-stat-score { font-size: 1.1rem; font-weight: 800; color: #111827; line-height: 1.2; }
.gears-stat-rank  { font-size: 0.72rem; color: #6b7280; }
.gears-credit     { font-size: 0.7rem; color: #d1d5db; margin: 0.25rem 0 0; text-align: center; }
.gears-credit a   { color: #9ca3af; }

/* ── OPR panel (ftcscout) ────────────────────────────────────────────────── */
.opr-panel {
    margin-bottom: 1.5rem;
}
.opr-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}
@media (max-width: 600px) {
    .opr-cards { grid-template-columns: repeat(2, 1fr); }
}
.opr-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem 0.5rem;
    text-align: center;
}
.opr-card-total {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.opr-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: #9ca3af;
    margin-bottom: 0.2rem;
}
.opr-card-total .opr-label { color: #3b82f6; }
.opr-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111827;
    line-height: 1.1;
}
.opr-card-total .opr-value { color: #1d4ed8; }
.opr-rank {
    font-size: 0.72rem;
    color: #6b7280;
    margin-top: 0.15rem;
}
.opr-credit {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
}
.opr-credit a { color: #6b7280; }

/* ── Modal internal tabs (OPR | Results) ────────────────────────────────── */
.modal-tab-bar {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1rem;
}
.modal-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.45rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.modal-tab-btn:hover  { color: #374151; }
.modal-tab-btn.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }
.modal-tab-panel        { display: none; }
.modal-tab-panel.active { display: block; }

/* ── Predict button (inline in result cell) ──────────────────────────────── */
.result-cell { white-space: nowrap; }
.predict-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 0 0 0.4rem;
    font-size: 0.85rem;
    line-height: 1;
    vertical-align: middle;
    transition: color 0.15s;
}
.predict-btn:hover { color: #1d4ed8; background: none; }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}
.modal-close:hover { color: #374151; background: #f3f4f6; }
.modal-body { padding: 1.25rem; }
.modal-loading { text-align: center; color: #9ca3af; padding: 2rem; }
.modal-error   { text-align: center; color: #ef4444; padding: 1rem; }

/* ── Prediction content ──────────────────────────────────────────────────── */
.pred-verdict {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}
.pred-verdict.red-wins  { background: #fef2f2; border-color: #fca5a5; }
.pred-verdict.blue-wins { background: #eff6ff; border-color: #93c5fd; }
.pred-score-block { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.pred-score { font-size: 2rem; font-weight: 800; line-height: 1; }
.pred-score.red-score  { color: #b91c1c; }
.pred-score.blue-score { color: #1d4ed8; }
.pred-score.winner     { font-size: 2.4rem; }
.pred-vs { font-size: 1.1rem; color: #9ca3af; font-weight: 500; }
.pred-winner-label { font-size: 0.9rem; font-weight: 600; color: #374151; }
.pred-margin { font-size: 0.8rem; font-weight: 400; color: #6b7280; margin-left: 0.4rem; }
.pred-actual {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.85rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.pred-actual-label { color: #9ca3af; }
.pred-actual .pred-score { font-size: 1.1rem; }
.pred-actual .winner     { font-size: 1.2rem; color: #111827; }
.pred-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 0.75rem; }
.pred-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #9ca3af; padding: 0.35rem 0.5rem; border-bottom: 2px solid #e5e7eb; text-align: right; }
.pred-table th:first-child { text-align: left; }
.pred-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #f3f4f6; text-align: right; }
.pred-table td:first-child { text-align: left; }
.pred-team.red  { color: #b91c1c; font-weight: 600; }
.pred-team.blue { color: #1d4ed8; font-weight: 600; }
.pred-tot { font-weight: 700; }
.pred-team-winner td { font-weight: 700; }
.pred-na  { color: #9ca3af; font-style: italic; }
.pred-subtotal td { font-weight: 600; border-top: 2px solid #e5e7eb; border-bottom: none; }
.red-subtotal  td { background: #fef2f2; color: #b91c1c; }
.blue-subtotal td { background: #eff6ff; color: #1d4ed8; }
.pred-note { font-size: 0.72rem; color: #9ca3af; margin: 0; text-align: center; }

/* ── Played match analysis view ──────────────────────────────────────────── */
.pred-analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.pred-analysis-outcome {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
}
.pred-correct   { font-size: 0.8rem; font-weight: 600; color: #065f46; background: #d1fae5; padding: 0.2rem 0.6rem; border-radius: 4px; }
.pred-incorrect { font-size: 0.8rem; font-weight: 600; color: #991b1b; background: #fee2e2; padding: 0.2rem 0.6rem; border-radius: 4px; }

.pred-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}
.pred-compare-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
    padding: 0.35rem 0.6rem;
    border-bottom: 2px solid #e5e7eb;
    text-align: right;
}
.pred-compare-table th:first-child { text-align: left; }
.pred-compare-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #f3f4f6;
    text-align: right;
}
.pred-compare-table td:first-child { text-align: left; }
.pred-compare-row.pred-team-winner td { font-weight: 700; }

.pred-actual-score { font-size: 1.1rem; font-weight: 800; color: #111827; }
.pred-pct          { font-weight: 600; color: #374151; }
.delta-pos { color: #065f46; }
.delta-neg { color: #991b1b; }

/* ── Team header ──────────────────────────────────────────────────────────── */
.team-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
}
.team-header h2 { margin-bottom: 0.2rem; }
.team-fullname  { font-size: 1.1rem; font-weight: 500; color: #374151; margin-bottom: 0.2rem; }
.team-location  { font-size: 0.9rem; }

.team-rank-card {
    text-align: center;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    min-width: 100px;
    flex-shrink: 0;
}
.rank-number { font-size: 2.5rem; font-weight: 800; color: #1d4ed8; line-height: 1; }
.rank-label  { font-size: 0.75rem; text-transform: uppercase; color: #9ca3af; letter-spacing: 0.05em; }
.rank-record { font-size: 1rem; font-weight: 600; margin-top: 0.4rem; }
.rank-rp     { font-size: 0.8rem; color: #6b7280; }

/* ── Next match callout ───────────────────────────────────────────────────── */
.next-match-card {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.next-match-card.red-alliance  { background: #fef2f2; border-color: #fca5a5; }
.next-match-card.blue-alliance { background: #eff6ff; border-color: #93c5fd; }
.next-match-card.red-alliance .next-match-label  { color: #991b1b; }
.next-match-card.blue-alliance .next-match-label { color: #1e3a8a; }

.next-match-label  { font-size: 0.7rem; text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; }
.next-match-id     { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.next-match-detail { font-size: 0.85rem; color: #6b7280; }

.next-match-teams {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-left: auto;
}
.nmt-side { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.nmt-vs   { font-weight: 700; color: #9ca3af; font-size: 1.1rem; }
.side-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.red-side  .side-label { color: #991b1b; }
.blue-side .side-label { color: #1e3a8a; }
