/* ═══════════════════════════════════════════════════════════
   FRC Caster's Tool — Premium Dark Theme v2
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    --bg:              #06060e;
    --bg-gradient:     linear-gradient(145deg, #06060e 0%, #0c0c1e 50%, #080814 100%);
    --surface:         #0d0d1a;
    --surface-glass:   rgba(16, 16, 32, .72);
    --card:            #12122a;
    --card-hover:      #16163a;
    --border:          rgba(99, 102, 241, .12);
    --border-subtle:   rgba(255, 255, 255, .04);
    --text:            #e8ecf4;
    --text-secondary:  #b0b8cc;
    --text-muted:      #6b7394;
    --primary:         #6366f1;
    --primary-glow:    rgba(99, 102, 241, .25);
    --primary-hover:   #818cf8;
    --primary-soft:    rgba(99, 102, 241, .08);
    --red:             #f87171;
    --red-deep:        #ef4444;
    --red-bg:          rgba(239, 68, 68, .06);
    --red-border:      rgba(239, 68, 68, .15);
    --blue:            #60a5fa;
    --blue-deep:       #3b82f6;
    --blue-bg:         rgba(59, 130, 246, .06);
    --blue-border:     rgba(59, 130, 246, .15);
    --green:           #34d399;
    --green-deep:      #22c55e;
    --yellow:          #fbbf24;
    --radius:          10px;
    --radius-lg:       14px;
    --shadow-sm:       0 2px 8px rgba(0,0,0,.3);
    --shadow-md:       0 4px 20px rgba(0,0,0,.4);
    --shadow-lg:       0 8px 40px rgba(0,0,0,.5);
    --shadow-glow:     0 0 30px rgba(99,102,241,.08);
    --font:            'Inter', system-ui, -apple-system, sans-serif;
    --mono:            'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --transition:      .25s cubic-bezier(.4, 0, .2, 1);
}

/* ═══ LIGHT THEME OVERRIDES ════════════════════════════════ */
[data-theme="light"] {
    --bg:              #f4f5f9;
    --bg-gradient:     linear-gradient(145deg, #f4f5f9 0%, #e8eaf0 50%, #f0f1f6 100%);
    --surface:         #ffffff;
    --surface-glass:   rgba(255, 255, 255, .82);
    --card:            #ffffff;
    --card-hover:      #f0f0f8;
    --border:          rgba(99, 102, 241, .15);
    --border-subtle:   rgba(0, 0, 0, .06);
    --text:            #1a1a2e;
    --text-secondary:  #4a4a6a;
    --text-muted:      #8888a8;
    --primary:         #5b5ef0;
    --primary-glow:    rgba(91, 94, 240, .18);
    --primary-hover:   #6366f1;
    --primary-soft:    rgba(99, 102, 241, .08);
    --red:             #dc2626;
    --red-deep:        #b91c1c;
    --red-bg:          rgba(239, 68, 68, .06);
    --red-border:      rgba(239, 68, 68, .18);
    --blue:            #2563eb;
    --blue-deep:       #1d4ed8;
    --blue-bg:         rgba(59, 130, 246, .06);
    --blue-border:     rgba(59, 130, 246, .18);
    --green:           #16a34a;
    --green-deep:      #15803d;
    --yellow:          #d97706;
    --shadow-sm:       0 1px 4px rgba(0,0,0,.08);
    --shadow-md:       0 2px 12px rgba(0,0,0,.08);
    --shadow-lg:       0 4px 24px rgba(0,0,0,.1);
    --shadow-glow:     0 0 20px rgba(99,102,241,.06);
}

[data-theme="light"] body::before { opacity: 0; }

[data-theme="light"] #loading-overlay {
    background: rgba(244, 245, 249, .92);
}

[data-theme="light"] header h1 {
    background: linear-gradient(135deg, #1a1a2e 0%, #5b5ef0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="light"] .brand-icon {
    color: #5b5ef0;
    filter: none;
}

[data-theme="light"] .brand-sub {
    color: var(--text-muted);
}

[data-theme="light"] .settings-btn {
    background: rgba(0,0,0,.04);
    border-color: rgba(0,0,0,.1);
}

[data-theme="light"] .settings-menu {
    background: #fff;
    border-color: rgba(0,0,0,.1);
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
}

[data-theme="light"] .toggle-slider {
    background: rgba(0,0,0,.15);
}
[data-theme="light"] .toggle-slider::after {
    background: #fff;
}

[data-theme="light"] .custom-tooltip {
    background: #fff;
    border-color: rgba(0,0,0,.1);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: #f0f1f6;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(99,102,241,.25);
}

[data-theme="light"] ::selection {
    background: rgba(99,102,241,.2);
    color: #1a1a2e;
}

[data-theme="light"] input[type="checkbox"] {
    color-scheme: light;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    touch-action: manipulation;   /* prevent double-tap zoom on mobile */
}

body {
    font-family: var(--font);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise overlay */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='.02'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

body > * { position: relative; z-index: 1; }

/* ═══ HEADER ═══════════════════════════════════════════════ */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 2.5rem;
    background: var(--surface-glass);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 20px rgba(0,0,0,.3);
    position: relative;
    z-index: 1000;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.brand-icon {
    color: var(--primary);
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

header h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -.02em;
    background: linear-gradient(135deg, #e8ecf4 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-sub {
    font-size: .68rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: .04em;
}

#event-badge {
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    color: #fff;
    padding: .3rem 1.1rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .01em;
    box-shadow: 0 2px 12px var(--primary-glow);
    animation: badge-in .4s ease-out;
    transition: background .4s ease, box-shadow .4s ease;
}
#event-badge.status-ongoing {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    box-shadow: 0 2px 12px rgba(16,185,129,.35);
}
#event-badge.status-upcoming {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    box-shadow: 0 2px 12px rgba(245,158,11,.35);
    color: #1a1a2e;
}
#event-badge.status-completed {
    background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%);
    box-shadow: 0 2px 12px rgba(107,114,128,.25);
}
@keyframes badge-in {
    from { opacity: 0; transform: translateY(-6px) scale(.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══ HEADER RIGHT / SETTINGS ══════════════════════════════ */
.header-right {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.settings-wrapper {
    position: relative;
}

.settings-btn {
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .45rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-btn:hover {
    background: var(--primary-soft);
    color: var(--text);
    border-color: rgba(99,102,241,.3);
}

.settings-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .75rem 1rem;
    min-width: 240px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    z-index: 9999;
}
.settings-menu.hidden { display: none; }

.settings-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .6rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}

.settings-toggle {
    display: flex;
    align-items: center;
    gap: .6rem;
    cursor: pointer;
    padding: .35rem 0;
}
.settings-toggle input { display: none; }

.toggle-slider {
    width: 34px;
    height: 18px;
    background: rgba(255,255,255,.1);
    border-radius: 999px;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}
.settings-toggle input:checked + .toggle-slider {
    background: var(--primary);
}
.settings-toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
    background: #fff;
}

.toggle-label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ═══ FOREIGN / INTERNATIONAL TEAM HIGHLIGHT ══════════════ */
.team-badge.foreign-team,
.team-num.foreign-team {
    outline: 2px solid var(--yellow);
    outline-offset: 1px;
    border-radius: 4px;
}
tr.foreign-team-row {
    background: rgba(250, 204, 21, .10) !important;
    box-shadow: inset 3px 0 0 var(--yellow);
}
.pbp-team.foreign-team {
    background: rgba(250, 204, 21, .10);
    box-shadow: inset 3px 0 0 var(--yellow);
}

/* ── Dark-mode checkboxes ─────────────────────────────────── */
input[type="checkbox"] {
    accent-color: var(--primary);
    color-scheme: dark;
}

/* ═══ TAB BAR ══════════════════════════════════════════════ */
.tabs-wrap {
    position: relative;
}
.tabs-wrap::before,
.tabs-wrap::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 32px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity .25s;
}
.tabs-wrap::before {
    left: 0;
    background: linear-gradient(to right, var(--surface), transparent);
}
.tabs-wrap::after {
    right: 0;
    background: linear-gradient(to left, var(--surface), transparent);
}
.tabs-wrap.scroll-right::after { opacity: 1; }
.tabs-wrap.scroll-left::before { opacity: 1; }

.tabs {
    display: flex;
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0 2.5rem;
    gap: .25rem;
}

.tab {
    position: relative;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: .85rem 1.5rem;
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: .01em;
}

.tab:hover {
    color: var(--text-secondary);
    background: var(--primary-soft);
    border-radius: var(--radius) var(--radius) 0 0;
}

.tab.disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}

.tab.active {
    color: var(--primary-hover);
    font-weight: 600;
    background: var(--primary-soft);
    border-radius: var(--radius) var(--radius) 0 0;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: .5rem; right: .5rem;
    height: 2.5px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 0 10px var(--primary-glow);
}

.tab-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke-width: 2;
    opacity: .7;
    transition: opacity var(--transition);
}

.tab:hover .tab-icon,
.tab.active .tab-icon {
    opacity: 1;
}

/* ═══ MAIN CONTAINER ═══════════════════════════════════════ */
main {
    padding: 2rem 2.5rem;
    max-width: 1440px;
    margin: 0 auto;
}

.tab-content {
    display: none;
    animation: tab-fade .35s ease-out;
}
.tab-content.active { display: block; }
@keyframes tab-fade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

/* ═══ INPUTS & BUTTONS ════════════════════════════════════ */
.input-row {
    display: flex;
    gap: .75rem;
    align-items: center;
    margin-bottom: 1.6rem;
    flex-wrap: wrap;
}

input[type="text"] {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .65rem 1.1rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .9rem;
    outline: none;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm), 0 0 0 3px var(--primary-glow);
}

input[type="text"].input-sm {
    max-width: 130px;
}

button {
    background: linear-gradient(135deg, var(--primary) 0%, #7c7ff7 100%);
    color: #fff;
    border: none;
    padding: .65rem 1.6rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .88rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
    box-shadow: 0 2px 10px var(--primary-glow);
    letter-spacing: .01em;
}

button:hover {
    background: linear-gradient(135deg, #7c7ff7 0%, var(--primary-hover) 100%);
    box-shadow: 0 4px 18px var(--primary-glow);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 6px var(--primary-glow);
}

/* ═══ EVENT INFO CARD ══════════════════════════════════════ */
.event-info-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.6rem;
    margin-bottom: 1.6rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.event-info-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 50%, var(--blue) 100%);
}

.event-info-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: .35rem;
    letter-spacing: -.01em;
}

.event-info-card p {
    color: var(--text-secondary);
    font-size: .88rem;
    line-height: 1.7;
}

/* ═══ ACTIVE EVENT BANNER ══════════════════════════════════ */
.active-event-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(99,102,241,.1) 0%, rgba(99,102,241,.04) 100%);
    border: 1px solid rgba(99,102,241,.25);
    border-radius: var(--radius-lg);
    padding: .85rem 1.3rem;
    margin-bottom: 1.2rem;
    gap: 1rem;
    animation: banner-in .35s ease-out;
}
@keyframes banner-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.aeb-left {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}
.aeb-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(52,211,153,.5);
    flex-shrink: 0;
    animation: dot-pulse 2s ease-in-out infinite;
}
.aeb-dot.dot-ongoing {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16,185,129,.5);
}
.aeb-dot.dot-upcoming {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245,158,11,.5);
    animation: dot-pulse-amber 2s ease-in-out infinite;
}
.aeb-dot.dot-completed {
    background: #6b7280;
    box-shadow: 0 0 6px rgba(107,114,128,.3);
    animation: none;
}
@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(52,211,153,.5); }
    50% { box-shadow: 0 0 14px rgba(52,211,153,.8); }
}
@keyframes dot-pulse-amber {
    0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,.4); }
    50% { box-shadow: 0 0 14px rgba(245,158,11,.7); }
}
.aeb-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.aeb-name {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aeb-meta {
    font-size: .78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}
.aeb-status-badge {
    display: inline-block;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .15rem .55rem;
    border-radius: 999px;
    line-height: 1.1;
    color: #fff;
    vertical-align: middle;
}
.aeb-status-badge.status-ongoing {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    box-shadow: 0 1px 6px rgba(16,185,129,.35);
}
.aeb-status-badge.status-upcoming {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    box-shadow: 0 1px 6px rgba(245,158,11,.35);
    color: #1a1a2e;
}
.aeb-status-badge.status-completed {
    background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%);
    box-shadow: 0 1px 6px rgba(107,114,128,.25);
}
.aeb-status-badge.status-unknown {
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    box-shadow: 0 1px 6px var(--primary-glow);
}
.aeb-change-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: .35rem .8rem;
    font-size: .75rem;
    font-weight: 500;
    border-radius: var(--radius);
    box-shadow: none;
}
.aeb-change-btn:hover {
    background: rgba(239,68,68,.08);
    border-color: rgba(239,68,68,.3);
    color: var(--red);
    box-shadow: none;
    transform: none;
}

/* ═══ SAVE EVENT ══════════════════════════════════════════ */
.aeb-right {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-shrink: 0;
}
.aeb-cache-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    color: var(--accent);
    background: rgba(99,102,241,.08);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: var(--radius);
    padding: .2rem .6rem;
    white-space: nowrap;
    transition: all .3s;
}
.cache-badge-icon {
    flex-shrink: 0;
    vertical-align: middle;
}
.aeb-cache-badge.cache-badge-flash {
    color: #22c55e;
    background: rgba(34,197,94,.1);
    border-color: rgba(34,197,94,.3);
}
.btn-save-event {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(99,102,241,.1);
    border: 1px solid rgba(99,102,241,.3);
    color: var(--accent);
    padding: .4rem .85rem;
    font-size: .78rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.btn-save-event:hover:not(:disabled) {
    background: rgba(99,102,241,.18);
    border-color: rgba(99,102,241,.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99,102,241,.2);
}
.btn-save-event:disabled {
    opacity: .6;
    cursor: not-allowed;
}
.btn-save-event.saving {
    animation: save-pulse 1s ease-in-out infinite;
}
.btn-save-event.saved {
    background: rgba(34,197,94,.12);
    border-color: rgba(34,197,94,.4);
    color: #22c55e;
}
@keyframes save-pulse {
    0%, 100% { opacity: .6; }
    50%      { opacity: 1; }
}

/* ═══ SAVED EVENTS LIST ═══════════════════════════════════ */
.saved-events-card {
    border-color: rgba(99,102,241,.2) !important;
    background: linear-gradient(135deg, rgba(99,102,241,.04) 0%, rgba(99,102,241,.01) 100%);
}
.saved-events-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-top: .5rem;
}
.saved-event-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem .85rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all .15s;
    gap: .5rem;
}
.saved-event-item:hover {
    background: rgba(99,102,241,.08);
    border-color: rgba(99,102,241,.3);
    transform: translateX(2px);
}
.saved-event-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}
.saved-event-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.saved-event-status {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: .1rem .45rem;
    border-radius: 999px;
    color: #fff;
    flex-shrink: 0;
}
.saved-event-status.status-ongoing   { background: #10b981; }
.saved-event-status.status-upcoming  { background: #f59e0b; color: #1a1a2e; }
.saved-event-status.status-completed { background: #6b7280; }
.saved-event-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}
.saved-event-time {
    font-size: .7rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.saved-event-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: .85rem;
    cursor: pointer;
    padding: .15rem .3rem;
    border-radius: 3px;
    transition: all .15s;
    opacity: .5;
    box-shadow: none;
}
.saved-event-delete:hover {
    opacity: 1;
    color: #ef4444;
    background: rgba(239,68,68,.1);
    box-shadow: none;
    transform: none;
}

/* ═══ EVENT SELECTION — SEASON PICKER ═════════════════════ */
.event-section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.6rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow-sm);
}
.event-section-card .input-row { margin-bottom: 0; }
.event-section-alt {
    background: var(--surface);
    border-color: var(--border-subtle);
}
.event-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.event-section-header.clickable {
    cursor: pointer;
    user-select: none;
}
.event-section-header.clickable:hover .event-section-title {
    color: var(--primary-hover);
}
.event-section-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    transition: color .2s;
}
.event-section-desc {
    font-size: .8rem;
    color: var(--text-muted);
    margin: .4rem 0 .8rem 0;
    line-height: 1.5;
}
.season-count-badge {
    font-size: .7rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid rgba(99,102,241,.2);
    padding: .15rem .55rem;
    border-radius: 999px;
}
.season-header-right {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.season-refresh-btn {
    background: var(--primary-soft);
    border: 1px solid rgba(99,102,241,.2);
    color: var(--primary);
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
    padding: .15rem .55rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .2s;
}
.season-refresh-btn:hover {
    background: rgba(99,102,241,.18);
}
.season-refresh-btn.spinning {
    animation: spin .8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Collapsible manual entry */
.manual-entry-body {
    overflow: hidden;
    max-height: 200px;
    opacity: 1;
    transition: max-height .3s ease, opacity .2s ease, margin .2s ease;
    margin-top: .4rem;
}
.manual-entry-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.season-controls {
    display: flex;
    flex-direction: column;
    gap: .65rem;
}
.season-filter-row {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}
.season-filter-row select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .5rem .9rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .85rem;
    cursor: pointer;
    min-width: 160px;
    outline: none;
    transition: var(--transition);
}
.season-filter-row select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.season-search-wrap {
    position: relative;
}
.season-search-wrap input {
    width: 100%;
    box-sizing: border-box;
    padding-left: 2.4rem;
}
.search-icon {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}
.season-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 100;
}
.season-dropdown-item {
    padding: .6rem 1rem;
    cursor: pointer;
    font-size: .85rem;
    color: var(--text);
    transition: background .15s;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.season-dropdown-item:last-child { border-bottom: none; }
.season-dropdown-item:hover,
.season-dropdown-item.highlighted {
    background: var(--primary-glow);
}
.sdi-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.sdi-week {
    font-size: .7rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: .1rem .45rem;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.sdi-loc {
    font-size: .75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.season-status {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .5rem;
}

/* ═══ DATA TABLES ══════════════════════════════════════════ */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-size: .86rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.data-table thead {
    background: linear-gradient(180deg, rgba(99,102,241,.08) 0%, var(--surface) 100%);
}

.data-table th {
    padding: .75rem 1.1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
}
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: color .2s;
    white-space: nowrap;
}
.sortable-th:hover {
    color: var(--text);
}
.sortable-th.sorted {
    color: var(--primary);
}

.data-table td {
    padding: .6rem 1.1rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--primary-soft);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .rank {
    font-weight: 700;
    color: var(--primary-hover);
    font-family: var(--mono);
}

.data-table .team-num {
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
}

.team-avatar-cell {
    padding: .35rem .4rem !important;
    width: 36px;
    text-align: center;
}

.team-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    vertical-align: middle;
    object-fit: contain;
    background: var(--surface);
}

.team-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .55rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
}

.data-table .stat {
    font-family: var(--mono);
    font-size: .82rem;
}

.data-table .location {
    color: var(--text-muted);
    font-size: .8rem;
}

.data-table.compact td,
.data-table.compact th { padding: .25rem .5rem; }
.data-table.compact    { font-size: .8rem; }
.data-table.compact .team-avatar { width: 22px; height: 22px; font-size: .55rem; }
.data-table.compact .team-avatar-cell { width: 22px; padding: .15rem .35rem; }
.data-table.compact .rank { font-size: .78rem; }
.data-table.compact .stat { font-size: .78rem; }

.rankings-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
    padding: 0 .25rem;
}

.stat-opr { color: var(--green) !important; }
.stat-dpr { color: var(--red) !important; }

.winner-text { color: var(--green); font-weight: 700; }

/* ═══ BRACKET TREE ═════════════════════════════════════════ */
.bracket-tree {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ── Section labels ─────────────────────────────────────── */
.bracket-section-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 1rem;
    padding: .4rem .8rem;
    border-radius: 6px;
    width: fit-content;
}
.upper-label {
    color: #818cf8;
    background: rgba(99, 102, 241, .1);
    border: 1px solid rgba(99, 102, 241, .2);
}
.lower-label {
    color: #fbbf24;
    background: rgba(245, 158, 11, .1);
    border: 1px solid rgba(245, 158, 11, .2);
}
.final-label {
    color: #34d399;
    background: rgba(16, 185, 129, .1);
    border: 1px solid rgba(16, 185, 129, .2);
}

/* ── Bracket flow: rounds flow left → right ─────────────── */
.bracket-flow {
    display: flex;
    align-items: stretch;
    gap: 0;
}
.bracket-upper-section .bracket-flow {
    min-height: 420px;
}
.bracket-lower-section .bracket-flow {
    min-height: 210px;
}
.bracket-flow-single {
    min-height: auto !important;
}

/* ── Round column ────────────────────────────────────────── */
.bkt-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 220px;
    gap: .5rem;
    padding: .5rem 0;
}

/* ── Pair wrapper (groups two slots that merge) ──────────── */
.bkt-pair {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    gap: .5rem;
}

/* ── Match slot ──────────────────────────────────────────── */
.bkt-slot {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
}
.bkt-slot:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(99,102,241,.25);
}
.bkt-slot.bkt-tbd {
    opacity: .5;
}
.bkt-slot.bkt-upcoming {
    opacity: .6;
}
.bkt-slot.bkt-decided {
    border-color: rgba(52,211,153,.2);
}

.bkt-slot-header {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: .4rem .75rem;
    background: linear-gradient(180deg, rgba(99,102,241,.05) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-subtle);
}

.bkt-slot-desc {
    font-size: .78rem;
    color: var(--text-muted);
    padding: .25rem .75rem .35rem;
    background: rgba(99,102,241,.02);
    border-top: 1px solid var(--border-subtle);
    font-family: var(--mono);
    letter-spacing: .02em;
}

.bkt-slot-body {
    padding: .5rem .6rem;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: .82rem;
}
.bkt-tbd-text {
    opacity: .6;
}

.bkt-replay {
    font-size: .75rem;
    font-weight: 600;
    color: #f59e0b;
    background: rgba(245,158,11,.12);
    padding: .1rem .35rem;
    border-radius: 3px;
    margin-left: .3rem;
}

/* ── Alliance row inside a slot ──────────────────────────── */
.bkt-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    font-size: .92rem;
    transition: var(--transition);
}
.bkt-row.bkt-red {
    background: var(--red-bg);
    border-bottom: 1px solid rgba(248,113,113,.08);
}
.bkt-row.bkt-blue {
    background: var(--blue-bg);
}
.bkt-row.bkt-won {
    background: rgba(34,197,94,.08) !important;
    box-shadow: inset 3px 0 0 var(--green);
}
.bkt-row.bkt-won .bkt-score {
    color: var(--green) !important;
    font-weight: 900;
}

.bkt-seed {
    font-size: .88rem;
    font-weight: 800;
    color: var(--primary);
    min-width: 24px;
    flex-shrink: 0;
    font-family: var(--mono);
}
.bkt-teams {
    flex: 1;
    font-weight: 700;
    font-family: var(--mono);
    font-size: .92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bkt-row.bkt-red .bkt-teams { color: var(--red); }
.bkt-row.bkt-blue .bkt-teams { color: var(--blue); }

.bkt-score {
    font-weight: 800;
    font-family: var(--mono);
    min-width: 34px;
    flex-shrink: 0;
    text-align: right;
    font-size: 1rem;
}
.bkt-row.bkt-red .bkt-score { color: var(--red); }
.bkt-row.bkt-blue .bkt-score { color: var(--blue); }

/* ═══ CONNECTOR LINES between rounds ═════════════════════ */
.bkt-connectors {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    min-width: 28px;
    position: relative;
}

/* Merge connector: 2 inputs → 1 output (the "]" bracket) */
.bkt-conn-pair {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}
.bkt-conn-top, .bkt-conn-bot {
    flex: 1;
    position: relative;
}
.bkt-conn-top::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 50%;
    bottom: 0;
    border-top: 2px solid var(--border);
    border-right: 2px solid var(--border);
    border-top-right-radius: 4px;
}
.bkt-conn-bot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 50%;
    bottom: 50%;
    border-bottom: 2px solid var(--border);
    border-right: 2px solid var(--border);
    border-bottom-right-radius: 4px;
}
/* Output horizontal line from merge point */
.bkt-conn-pair::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    right: 0;
    height: 0;
    border-top: 2px solid var(--border);
}

/* Straight connector: 1 → 1 (horizontal lines) */
.bkt-conn-straight {
    justify-content: space-around;
}
.bkt-conn-horiz {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
}
.bkt-conn-horiz::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px solid var(--border);
}
.bkt-conn-single {
    justify-content: center;
}
.bkt-conn-single .bkt-conn-horiz {
    flex: none;
    height: 2px;
    width: 100%;
}

/* ═══ Responsive bracket ════════════════════════════════════ */
@media (max-width: 900px) {
    .bracket-flow {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
        min-height: auto;
    }
    .bkt-round {
        flex-direction: row;
        flex-wrap: wrap;
        min-width: auto;
        gap: .5rem;
    }
    .bkt-pair {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .bkt-slot {
        flex: 1;
        min-width: 160px;
    }
    .bkt-connectors {
        display: none;
    }
}

.red-text  { color: var(--red); }
.blue-text { color: var(--blue); }

/* ═══ ALLIANCE SELECTION GRID ═════════════════════════════ */
#alliance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 1.1rem;
}
#alliance-grid > .empty {
    grid-column: 1 / -1;
}

/* ── Alliance toolbar ── */
.alliance-toolbar {
    display: flex;
    gap: 1.2rem;
    align-items: center;
    padding: .6rem 1rem;
    margin-bottom: .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.alliance-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.alliance-card.alliance-winner {
    border-color: rgba(251,191,36,.35);
    box-shadow: var(--shadow-sm), 0 0 12px rgba(251,191,36,.08);
}
.alliance-card.alliance-finalist {
    border-color: rgba(192,192,210,.25);
}

.alliance-card:hover {
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: rgba(99,102,241,.2);
    margin-top: -2px;
    margin-bottom: 2px;
}

.alliance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .8rem 1.3rem;
    background: linear-gradient(180deg, rgba(99,102,241,.06) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    gap: .6rem;
    flex-wrap: wrap;
}

.alliance-header-left {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.alliance-header h3 {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.alliance-header-stats {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
}

.combined-opr {
    font-family: var(--mono);
    font-size: .82rem;
    color: var(--primary-hover);
    font-weight: 600;
    background: var(--primary-soft);
    padding: .2rem .7rem;
    border-radius: 999px;
}

.combined-dpr {
    font-family: var(--mono);
    font-size: .82rem;
    color: var(--green);
    font-weight: 600;
    background: rgba(52,211,153,.1);
    padding: .2rem .7rem;
    border-radius: 999px;
}

.combined-ccwm {
    font-family: var(--mono);
    font-size: .82rem;
    color: var(--yellow);
    font-weight: 600;
    background: rgba(251,191,36,.1);
    padding: .2rem .7rem;
    border-radius: 999px;
}

/* ── Playoff ribbon ── */
.playoff-ribbon {
    font-size: .68rem;
    font-weight: 700;
    padding: .15rem .6rem;
    border-radius: 999px;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.ribbon-winner {
    background: rgba(251,191,36,.18);
    color: #f59e0b;
    border: 1px solid rgba(251,191,36,.3);
}
.ribbon-finalist {
    background: rgba(192,192,210,.12);
    color: #a0a0b8;
    border: 1px solid rgba(192,192,210,.25);
}
.ribbon-eliminated {
    background: rgba(239,68,68,.08);
    color: var(--red);
    border: 1px solid rgba(239,68,68,.15);
}
.ribbon-playing {
    background: rgba(52,211,153,.08);
    color: var(--green);
    border: 1px solid rgba(52,211,153,.15);
}

/* ── Alliance strength bar ── */
.alliance-strength-bar {
    height: 3px;
    background: var(--surface);
}
.alliance-strength-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: 0 3px 3px 0;
    transition: width .4s ease;
}

.alliance-teams-list { padding: .5rem; }

.alliance-team-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    transition: background var(--transition);
}

.alliance-team-row:hover {
    background: var(--primary-soft);
}

.alliance-team-row.intl-highlight {
    background: rgba(250, 204, 21, .10);
    box-shadow: inset 3px 0 0 var(--yellow);
}

.team-role {
    font-size: .68rem;
    color: var(--text-muted);
    min-width: 56px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}

/* Team avatar in alliance row */
.alliance-team-avatar {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: contain;
    background: var(--surface);
    flex-shrink: 0;
}
.alliance-team-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: var(--surface);
    flex-shrink: 0;
}

.alliance-team-row .team-num {
    font-weight: 800;
    font-family: var(--mono);
    font-size: 1rem;
    min-width: 50px;
    color: var(--text);
}

.team-nick {
    font-size: .78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

.team-stats-mini {
    display: flex;
    gap: .8rem;
    font-size: .76rem;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Partnership summary row at bottom of card ── */
.alliance-partners-row {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    padding: .45rem .85rem .55rem;
    border-top: 1px solid var(--border);
}

.badge {
    font-size: .66rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 600;
    letter-spacing: .01em;
}

.badge.returning {
    background: rgba(52,211,153,.1);
    color: var(--green);
    border: 1px solid rgba(52,211,153,.18);
}

/* ═══ PARTNERSHIP TOOLTIP ══════════════════════════════════ */
.has-tooltip {
    position: relative;
    cursor: pointer;
}

.custom-tooltip {
    display: none;
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .75rem;
    min-width: 220px;
    max-width: 340px;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    pointer-events: none;
}

.has-tooltip:hover .custom-tooltip {
    display: block;
}

.custom-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
}

.custom-tooltip.above::after {
    top: 100%;
    border-top-color: var(--border);
}

.custom-tooltip.below::after {
    bottom: 100%;
    border-bottom-color: var(--border);
}

.tip-row {
    font-size: .72rem;
    font-weight: 500;
    color: var(--text);
    padding: .18rem 0;
    white-space: nowrap;
    line-height: 1.4;
}

/* ═══ TEAM STATS ═══════════════════════════════════════════ */
.team-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
    margin-bottom: 1.6rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.team-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--blue), var(--green));
}

.team-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: .3rem;
    letter-spacing: -.02em;
}

.team-header-top {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.team-header-text {
    flex: 1;
}
.team-avatar {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    object-fit: contain;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.team-header p {
    color: var(--text-secondary);
    font-size: .88rem;
    margin-bottom: .15rem;
}

.team-highlights {
    display: flex;
    gap: 1.1rem;
    margin: 1.3rem 0;
}

.highlight-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.4rem;
    flex: 1;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.highlight-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 10%; right: 10%;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    opacity: 0;
    transition: var(--transition);
}

.highlight-card:hover::after { opacity: 1; }
.highlight-card:hover { border-color: rgba(99,102,241,.2); }

.highlight-label {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .3rem;
    font-weight: 600;
}

.highlight-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-hover);
    letter-spacing: -.01em;
}

.team-card h3 {
    margin: 1.3rem 0 .8rem;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

/* ═══ HEAD TO HEAD ═════════════════════════════════════════ */
.h2h-section {
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
}

.h2h-section h3 {
    margin-bottom: 0;
    font-weight: 700;
    letter-spacing: -.01em;
}
.h2h-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.h2h-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.8rem;
    box-shadow: var(--shadow-md);
}

.h2h-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--mono);
    margin-bottom: 1rem;
    letter-spacing: -.02em;
}

.vs-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: .85rem;
    font-family: var(--font);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.h2h-summary {
    text-align: center;
    margin-bottom: 1.2rem;
    padding: .8rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.h2h-score {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.1rem;
    margin-top: .5rem;
    font-family: var(--mono);
    font-weight: 700;
}

.h2h-card h4 {
    margin: 1.2rem 0 .7rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.muted {
    color: var(--text-muted);
    font-size: .82rem;
}

/* ═══ LOADING OVERLAY ═════════════════════════════════════ */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(6,6,14,.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(99,102,241,.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s cubic-bezier(.4, .15, .6, .85) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay p {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
}

.loading-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 1.2rem;
    font-weight: 500;
}

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem 2rem;
    font-style: italic;
    font-size: .9rem;
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
}

/* ═══ PLAY BY PLAY ═════════════════════════════════════════ */
.pbp-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: .8rem 1.2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.pbp-nav-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: .55rem 1.3rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: none;
}
.pbp-nav-btn:hover {
    background: var(--primary-soft);
    border-color: rgba(99,102,241,.3);
    color: var(--primary-hover);
    transform: none;
    box-shadow: none;
}

.pbp-match-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
}

.pbp-match-label {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--text);
}

.pbp-selector-row select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .35rem .8rem;
    border-radius: 6px;
    font-family: var(--font);
    font-size: .82rem;
    outline: none;
    cursor: pointer;
}

/* ── Arena: split red / blue ─────────────────────────────── */
.pbp-arena {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

.pbp-alliance {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.pbp-alliance.red-side {
    border-top: 3px solid var(--red);
}
.pbp-alliance.blue-side {
    border-top: 3px solid var(--blue);
}

.pbp-alliance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.3rem;
}

.pbp-alliance.red-side .pbp-alliance-header {
    background: var(--red-bg);
}
.pbp-alliance.blue-side .pbp-alliance-header {
    background: var(--blue-bg);
}

.pbp-alliance-title {
    font-size: .88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.red-side .pbp-alliance-title { color: var(--red); }
.blue-side .pbp-alliance-title { color: var(--blue); }

.pbp-score-group {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.pbp-winner-label {
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    color: var(--green);
    background: rgba(52,211,153,.1);
    border: 1px solid rgba(52,211,153,.25);
    padding: .15rem .5rem;
    border-radius: 4px;
}
.pbp-alliance-score {
    font-size: 1.6rem;
    font-weight: 900;
    font-family: var(--mono);
    letter-spacing: -.03em;
}
.red-side .pbp-alliance-score { color: var(--red); }
.blue-side .pbp-alliance-score { color: var(--blue); }

.pbp-alliance-opr {
    font-size: .76rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

.pbp-alliance-won .pbp-alliance-score {
    color: var(--green) !important;
}
.pbp-alliance-won .pbp-alliance-header {
    background: rgba(34,197,94,.06) !important;
}
.pbp-alliance-won {
    border-top-color: var(--green) !important;
    box-shadow: var(--shadow-md), 0 0 16px rgba(34,197,94,.1);
}

/* ── Team card inside alliance ───────────────────────────── */
.pbp-team-cards {
    display: flex;
    flex-direction: column;
}

.pbp-team {
    padding: 1rem 1.3rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--card);
    transition: background var(--transition);
}
.pbp-team:last-child { border-bottom: none; }
.pbp-team:hover { background: var(--card-hover); }

.pbp-team-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: .5rem;
}

.pbp-team-number {
    font-size: 1.8rem;
    font-weight: 900;
    font-family: var(--mono);
    letter-spacing: -.03em;
    min-width: 80px;
}
.red-side .pbp-team-number { color: var(--red); }
.blue-side .pbp-team-number { color: var(--blue); }

.pbp-team-identity {
    flex: 1;
    min-width: 0;
}

.pbp-team-nickname {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pbp-team-school {
    font-size: .78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pbp-team-location {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

.pbp-team-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: .5rem;
    margin-top: .6rem;
}

.pbp-stat {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: .35rem .6rem;
    text-align: center;
}

.pbp-stat-label {
    font-size: .62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.pbp-stat-value {
    font-size: .88rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
}

.pbp-stat-value.opr-val { color: var(--green); }
.pbp-stat-value.dpr-val { color: var(--red); }

.pbp-team-highscore {
    font-size: .72rem;
    color: var(--primary-hover);
    margin-top: .4rem;
    font-weight: 600;
}

/* ── Footer ──────────────────────────────────────────────── */
.pbp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.2rem;
    padding: .7rem 1.2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.pbp-footer-text {
    font-size: .82rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

.pbp-footer-score { font-weight: 700; color: var(--primary-hover); }

/* PBP Prior Connections */
.pbp-connections {
    margin-top: .6rem;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
}
.pbp-conn-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .7rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--surface-raised, rgba(255,255,255,.03));
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}
.pbp-conn-header:hover {
    background: rgba(255,255,255,.06);
}
.pbp-connections.pbp-conn-expanded .pbp-conn-header {
    border-bottom: 1px solid var(--border-subtle);
}
.pbp-conn-header .conn-svg { width: 1em; height: 1em; }

/* Loading spinner for connections */
.pbp-conn-loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: pbp-conn-spin .8s linear infinite;
    margin-left: 4px;
    vertical-align: middle;
}
@keyframes pbp-conn-spin {
    to { transform: rotate(360deg); }
}

.pbp-conn-chevron {
    width: .85em;
    height: .85em;
    flex-shrink: 0;
    transition: transform .2s;
    transform: rotate(-90deg);
}
.pbp-conn-expanded .pbp-conn-chevron {
    transform: rotate(0deg);
}
.pbp-conn-count {
    font-size: .68rem;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    padding: .05rem .4rem;
    border-radius: 100px;
    line-height: 1.2;
}
.pbp-conn-range-toggle {
    display: flex;
    align-items: center;
    gap: .3rem;
    margin-left: auto;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.pbp-conn-range-toggle input { display: none; }
.pbp-conn-range-toggle .conn-toggle-slider {
    position: relative;
    width: 1.7rem;
    height: .95rem;
    background: var(--border);
    border-radius: 100px;
    transition: background .2s;
    flex-shrink: 0;
}
.pbp-conn-range-toggle .conn-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: .65rem;
    height: .65rem;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.pbp-conn-range-toggle input:checked + .conn-toggle-slider {
    background: var(--primary);
}
.pbp-conn-range-toggle input:checked + .conn-toggle-slider::after {
    transform: translateX(.7rem);
}
.pbp-conn-body {
    display: none;
}
.pbp-conn-expanded .pbp-conn-body {
    display: block;
}
.pbp-conn-empty {
    padding: .5rem .7rem;
    font-size: .76rem;
    color: var(--text-muted);
    font-style: italic;
}
.pbp-conn-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem .7rem;
    font-size: .76rem;
    border-bottom: 1px solid var(--border-subtle);
    border-left: 3px solid transparent;
}
.pbp-conn-item:last-child { border-bottom: none; }
.pbp-conn-red { border-left-color: var(--red); }
.pbp-conn-blue { border-left-color: var(--blue, #3b82f6); }
.pbp-conn-cross { border-left-color: var(--text-muted); }
.pbp-conn-teams {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .82rem;
    white-space: nowrap;
    min-width: 5.5rem;
    flex-shrink: 0;
}
.pbp-conn-highlights {
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
}
.pbp-conn-highlights .conn-svg { width: .8em; height: .8em; }
.pbp-conn-type {
    font-weight: 600;
}
.pbp-conn-stage {
    font-weight: 600;
    font-size: .68rem;
    padding: .05rem .35rem;
    border-radius: 100px;
    background: rgba(100,116,139,.1);
    color: var(--text-muted);
    border: 1px solid rgba(100,116,139,.2);
}
.pbp-conn-winner {
    font-weight: 700;
    font-size: .65rem;
    padding: .05rem .3rem;
    border-radius: 100px;
    background: rgba(234,179,8,.15);
    color: var(--yellow, #eab308);
    border: 1px solid rgba(234,179,8,.3);
    text-transform: uppercase;
}
.pbp-conn-finalist {
    font-weight: 700;
    font-size: .65rem;
    padding: .05rem .3rem;
    border-radius: 100px;
    background: rgba(148,163,184,.15);
    color: var(--text-secondary);
    border: 1px solid rgba(148,163,184,.3);
    text-transform: uppercase;
}
.pbp-conn-sep {
    color: var(--text-muted);
    font-weight: 400;
}
.pbp-conn-more {
    font-size: .68rem;
    color: var(--accent);
    font-style: italic;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    margin-left: 4px;
}
.pbp-conn-more:hover {
    color: var(--accent-hover, #60b0ff);
}
.pbp-conn-extra.hidden {
    display: none;
}

/* ═══ SITE FOOTER ═════════════════════════════════════════ */
/* ═══ SCORE BREAKDOWN ════════════════════════════════════ */
.bd-status {
    text-align: center;
    padding: .5rem;
    font-size: .85rem;
    color: var(--text-muted);
}
.bd-status .bd-available { color: #22c55e; font-weight: 600; }
.bd-status .bd-unavailable { color: var(--text-muted); font-style: italic; }

/* Pulsing dot for "waiting for breakdown" polling indicator */
.bd-poll-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: 6px;
    vertical-align: middle;
    animation: bd-pulse 1.2s ease-in-out infinite;
}
@keyframes bd-pulse {
    0%, 100% { opacity: .3; transform: scale(.8); }
    50%      { opacity: 1;  transform: scale(1.2); }
}

.bd-content {
    display: flex;
    gap: 1rem;
    margin-top: .5rem;
}

.bd-alliance {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.bd-alliance.red-side   { border-color: var(--red-border); }
.bd-alliance.blue-side  { border-color: var(--blue-border); }

.bd-alliance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1rem;
    font-weight: 700;
    font-size: 1rem;
}
.bd-alliance.red-side .bd-alliance-header  { background: var(--red-bg); color: var(--red); }
.bd-alliance.blue-side .bd-alliance-header { background: var(--blue-bg); color: var(--blue); }

.bd-alliance-score-group {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.bd-winner-label {
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    color: var(--green);
    background: rgba(52,211,153,.1);
    border: 1px solid rgba(52,211,153,.25);
    padding: .15rem .5rem;
    border-radius: 4px;
}
.bd-alliance-score {
    font-family: var(--mono);
    font-size: 1.5rem;
}

.bd-section {
    padding: .6rem 1rem;
    border-top: 1px solid var(--border);
}

.bd-section-title {
    font-weight: 700;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--primary);
    margin-bottom: .5rem;
}

/* Robot rows (per-team fields) */
.bd-robots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
    margin-bottom: .5rem;
}

.bd-robot-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .4rem .6rem;
    text-align: center;
}

.bd-robot-num {
    font-weight: 700;
    font-family: var(--mono);
    font-size: .9rem;
    margin-bottom: .2rem;
}

.bd-robot-field {
    display: flex;
    justify-content: space-between;
    font-size: .75rem;
    padding: .15rem 0;
    border-top: 1px solid var(--border);
}

.bd-robot-label { color: var(--text-muted); }
.bd-robot-value { font-weight: 600; }
.bd-robot-value.yes { color: #22c55e; }
.bd-robot-value.no  { color: var(--text-muted); }
.bd-robot-value.deep { color: #a855f7; }
.bd-robot-value.shallow { color: #3b82f6; }
.bd-robot-value.parked { color: #eab308; }

/* Stats grid (alliance-level fields) */
.bd-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .3rem .8rem;
}

.bd-stat-row {
    display: flex;
    justify-content: space-between;
    padding: .2rem 0;
    font-size: .8rem;
    border-bottom: 1px dotted rgba(99,102,241,.1);
}

.bd-stat-label { color: var(--text-muted); }
.bd-stat-value { font-weight: 600; font-family: var(--mono); }

/* Reef grid visualization */
.bd-reef {
    margin: .5rem 0;
}

.bd-reef-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .3rem;
}

.bd-reef-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2px;
}

.bd-reef-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .55rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 0;
}

.bd-reef-cell.filled {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.bd-reef-cell.filled-auto {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

.bd-reef-row-label {
    grid-column: 1 / -1;
    font-size: .65rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: .15rem 0 0;
    text-align: center;
}

/* Bonus badges */
.bd-bonuses {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .4rem;
}

.bd-bonus-badge {
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
}

.bd-bonus-badge.achieved {
    background: rgba(34,197,94,.15);
    border-color: rgba(34,197,94,.4);
    color: #22c55e;
}

/* Foul section */
.bd-fouls {
    display: flex;
    gap: 1rem;
    font-size: .8rem;
}

.bd-foul-item { display: flex; gap: .3rem; align-items: baseline; }
.bd-foul-label { color: var(--text-muted); }
.bd-foul-value { font-weight: 600; font-family: var(--mono); }

/* Match total bar */
.bd-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1rem;
    border-top: 2px solid var(--border);
    font-weight: 700;
}
.bd-total-label { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.bd-total-score { font-family: var(--mono); font-size: 1.3rem; }
.bd-alliance.red-side .bd-total-bar  { color: var(--red); }
.bd-alliance.blue-side .bd-total-bar { color: var(--blue); }

/* Match select indicator for breakdown availability */
#bd-match-select option.has-breakdown {
    color: #22c55e;
}

/* Trough display */
.bd-trough {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
    margin-top: .3rem;
}
.bd-trough-label { color: var(--text-muted); }
.bd-trough-value { font-weight: 600; font-family: var(--mono); }

/* ═══ TEAM COMPARISON ═════════════════════════════════════ */

/* Overlay / Modal */
.compare-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: comp-fade-in .2s ease-out;
}
.compare-overlay.hidden { display: none !important; }

@keyframes comp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.compare-modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 960px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: comp-slide-up .25s ease-out;
    overflow: hidden;
}

@keyframes comp-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1.4rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(99,102,241,.06) 0%, transparent 100%);
}

.compare-modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.compare-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0 .3rem;
    line-height: 1;
    box-shadow: none;
    transition: color .2s;
}
.compare-close-btn:hover {
    color: var(--text);
    background: none;
    box-shadow: none;
}

.compare-body {
    overflow-y: auto;
    padding: 1.25rem;
}

/* Grid layout */
.compare-grid {
    display: grid;
    grid-template-columns: 110px repeat(var(--cols), 1fr);
    gap: 2px;
    font-size: .82rem;
}

/* Corner cell (top-left) */
.comp-corner { visibility: hidden; }

/* Label column */
.comp-label {
    display: flex;
    align-items: center;
    padding: .5rem .6rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface);
    border-radius: var(--radius) 0 0 var(--radius);
}

.comp-label-total {
    font-weight: 700;
    color: var(--primary-hover);
}

/* Team header */
.comp-header {
    text-align: center;
    padding: .7rem .5rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-subtle);
    margin-bottom: .35rem;
}

.comp-header.comp-red {
    border-color: var(--red-border);
    background: var(--red-bg);
}

.comp-header.comp-blue {
    border-color: var(--blue-border);
    background: var(--blue-bg);
}

.comp-team-num {
    font-family: var(--mono);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
}
.comp-red .comp-team-num { color: var(--red); }
.comp-blue .comp-team-num { color: var(--blue); }

.comp-team-name {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: .1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comp-team-record {
    font-family: var(--mono);
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

.comp-team-loc {
    font-size: .65rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

/* Stat cell */
.comp-cell {
    position: relative;
    display: flex;
    align-items: center;
    padding: .45rem .6rem;
    background: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    overflow: hidden;
}

.comp-cell.comp-red { background: var(--red-bg); }
.comp-cell.comp-blue { background: var(--blue-bg); }

.comp-bar-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.comp-bar {
    height: 100%;
    background: var(--primary-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: width .4s ease-out;
}

.comp-red .comp-bar { background: rgba(239, 68, 68, .1); }
.comp-blue .comp-bar { background: rgba(59, 130, 246, .1); }

.comp-val {
    position: relative;
    z-index: 1;
    font-family: var(--mono);
    font-weight: 600;
    font-size: .82rem;
    color: var(--text);
    width: 100%;
    text-align: center;
}

.comp-best .comp-val {
    color: var(--green);
}

.comp-best .comp-bar {
    background: rgba(52, 211, 153, .12);
}

.comp-divider {
    height: 1px;
    background: var(--border);
    margin: .4rem 0;
}

.comp-total { font-weight: 700; }
.comp-total-empty { background: transparent; }

/* ── Rankings table checkbox column ───────────────────────── */
.compare-th,
.compare-td {
    width: 32px;
    text-align: center;
    padding: .4rem !important;
}

.compare-cb {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

/* Show on row hover or when checked */
tr:hover .compare-cb,
.compare-cb:checked {
    opacity: 1;
}

/* ── Floating compare bar ─────────────────────────────────── */
.compare-bar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--card);
    border: 1px solid var(--primary);
    border-radius: 999px;
    padding: .55rem .7rem .55rem 1.3rem;
    box-shadow: var(--shadow-lg), 0 0 30px var(--primary-glow);
    z-index: 9999;
    animation: comp-bar-in .3s ease-out;
    font-size: .85rem;
}

.compare-bar.hidden { display: none !important; }

@keyframes comp-bar-in {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.compare-bar span {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.compare-bar button {
    padding: .4rem 1rem;
    font-size: .8rem;
    border-radius: 999px;
}

.compare-bar-clear {
    background: rgba(255,255,255,.08) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
}
.compare-bar-clear:hover {
    background: rgba(255,255,255,.14) !important;
    color: var(--text) !important;
}

/* ── PBP Compare button ──────────────────────────────────── */
.pbp-compare-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem 1rem;
    font-size: .78rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c7ff7 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 2px 8px var(--primary-glow);
    transition: var(--transition);
}
.pbp-compare-btn:hover {
    box-shadow: 0 4px 16px var(--primary-glow);
    transform: translateY(-1px);
}

.site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: 1.2rem 2rem;
    margin-top: 2rem;
    font-size: .74rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: .02em;
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 0;
}
.footer-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.footer-sep {
    opacity: .35;
}

.footer-version {
    font-family: var(--mono);
    font-size: .68rem;
    background: var(--primary-soft);
    color: var(--primary-hover);
    padding: .15rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.footer-attribution {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    flex-wrap: wrap;
    font-size: .68rem;
    color: var(--text-muted);
    opacity: .85;
}
.status-item {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .68rem;
    font-weight: 500;
    color: var(--text-muted);
}
.status-item a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.status-item a:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}
.status-dot {
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.status-ok {
    background: #22c55e;
    box-shadow: 0 0 4px rgba(34, 197, 94, .5);
}
.status-dot.status-down {
    background: #ef4444;
    box-shadow: 0 0 4px rgba(239, 68, 68, .5);
}
.status-dot.status-checking {
    background: var(--text-muted);
    opacity: .5;
    animation: statusPulse 1.2s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: .3; }
    50% { opacity: .7; }
}

/* ═══ SCROLLBAR ═══════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(99,102,241,.2);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99,102,241,.35);
}

/* ═══ SELECTION ═══════════════════════════════════════════ */
::selection {
    background: rgba(99,102,241,.3);
    color: #fff;
}

/* ═══ RESPONSIVE ═══════════════════════════════════════════ */

/* ── Tablet / small laptop ────────────────────────────────── */
@media (max-width: 768px) {
    header {
        padding: .65rem 1rem;
        gap: .5rem;
    }
    header h1 { font-size: 1rem; }
    .brand-sub { display: none; }
    .brand-icon { width: 22px; height: 22px; }

    main {
        padding: 1.2rem 1rem;
    }

    /* ── Tab bar: compact scrollable pills with fade hints ── */
    .tabs {
        padding: 0 .75rem;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    .tabs::-webkit-scrollbar { display: none; }

    .tab {
        padding: .7rem .85rem;
        font-size: .78rem;
        white-space: nowrap;
        gap: .3rem;
        min-height: 44px;          /* touch target */
    }

    /* ── Active event banner ── */
    .active-event-banner {
        flex-wrap: wrap;
        padding: .65rem 1rem;
        gap: .5rem;
    }
    .aeb-name { white-space: normal; word-break: break-word; }
    .aeb-right { width: 100%; justify-content: flex-end; }
    .aeb-cache-badge { font-size: .65rem; }

    /* ── Alliance ── */
    #alliance-grid { grid-template-columns: 1fr; }
    .team-highlights { flex-direction: column; }
    .alliance-team-row { flex-wrap: wrap; }
    .alliance-header { flex-direction: column; align-items: flex-start; }
    .alliance-header-stats { margin-top: .3rem; }
    .alliance-partners-row { padding-left: .5rem; }
    .alliance-toolbar { flex-wrap: wrap; gap: .6rem; }

    /* ── H2H ── */
    .h2h-header { font-size: 1.15rem; }

    /* ── PBP ── */
    .pbp-arena { grid-template-columns: 1fr; }
    .pbp-topbar { flex-wrap: wrap; justify-content: center; gap: .5rem; }
    .pbp-team-number { font-size: 1.4rem; min-width: 60px; }
    .pbp-team-stats { grid-template-columns: repeat(3, 1fr); }

    /* ── Breakdown ── */
    .bd-content { flex-direction: column; }
    .bd-robots { grid-template-columns: 1fr 1fr 1fr; }
    .bd-stats { grid-template-columns: 1fr; }
    .bd-reef-cell { font-size: .45rem; }

    /* ── Summary ── */
    .summary-stats-row { grid-template-columns: repeat(2, 1fr); }
    .conn-detail-line { flex-wrap: wrap; }
    .conn-detail-event { min-width: 0; }
    .conn-toolbar { flex-direction: column; align-items: stretch; }
    .conn-toolbar-secondary { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .conn-search-input { width: 100%; }
    .conn-filter-bar { flex-wrap: wrap; }
    .conn-sort-bar { flex-wrap: wrap; }
    .conn-filter-btn { min-height: 36px; padding: .4rem .85rem; }
    .conn-sort-btn { min-height: 32px; padding: .35rem .65rem; }

    /* ── Tables: horizontal scroll ── */
    #event-teams, #summary-history-list, .history-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Prevent iOS auto-zoom on focus (16px min) ── */
    input[type=\"text\"],
    select,
    .season-search-wrap input,
    .conn-search-input {
        font-size: 16px !important;
    }

    /* ── Compare modal ── */
    .compare-overlay { padding: .5rem; }
    .compare-modal { max-width: 100%; max-height: 92vh; }
    .compare-body { padding: .75rem; overflow-x: auto; }
    .compare-grid { font-size: .72rem; }
    .comp-label { font-size: .62rem; padding: .35rem .4rem; }
    .comp-team-num { font-size: .95rem; }

    /* ── Compare bar ── */
    .compare-bar {
        left: .75rem;
        right: .75rem;
        transform: none;
        border-radius: var(--radius-lg);
        justify-content: center;
        padding: .55rem .85rem;
    }
    @keyframes comp-bar-in {
        from { opacity: 0; transform: translateY(20px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    /* ── Footer ── */
    .site-footer {
        padding: 1rem 1rem;
        gap: .35rem;
        text-align: center;
    }
    .footer-top {
        gap: .3rem .5rem;
    }

    /* ── Event filters ── */
    .season-filter-row select { min-width: 0; flex: 1; }
    .event-section-card { padding: 1rem 1rem; }

    /* ── Saved events ── */
    .saved-event-meta { gap: .3rem; }
    .saved-event-time { font-size: .62rem; }
    .saved-event-delete { min-width: 32px; min-height: 32px; display: flex; align-items: center; justify-content: center; }
}

/* ── Phone (≤480px) ───────────────────────────────────────── */
@media (max-width: 480px) {
    header {
        padding: .55rem .75rem;
    }
    header h1 { font-size: .92rem; }
    #event-badge {
        font-size: .68rem;
        padding: .2rem .7rem;
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    main {
        padding: .85rem .65rem;
    }

    /* ── Tab bar: icon-prominent compact pills ── */
    .tabs {
        padding: 0 .5rem;
        gap: .15rem;
    }
    .tab {
        padding: .55rem .6rem;
        font-size: .68rem;
        min-height: 44px;
        flex-direction: column;
        gap: .15rem;
    }
    .tab-icon {
        width: 18px;
        height: 18px;
    }

    /* ── Active event banner ── */
    .active-event-banner { padding: .55rem .75rem; }
    .aeb-name { font-size: .82rem; }
    .aeb-meta { font-size: .68rem; }
    .aeb-status-badge { font-size: .58rem; }
    .btn-save-event {
        padding: .35rem .65rem;
        font-size: .72rem;
    }

    /* ── Event section cards ── */
    .event-section-card { padding: .85rem .75rem; }
    .event-section-title { font-size: .88rem; }
    .event-section-desc { font-size: .75rem; }

    /* ── Input / button sizing (16px min prevents iOS zoom) ── */
    input[type="text"],
    select {
        font-size: 16px !important;
        padding: .55rem .85rem;
    }
    button {
        padding: .55rem 1.1rem;
        font-size: .82rem;
    }
    .input-row { gap: .5rem; }
    input[type="text"].input-sm { max-width: 100px; }

    /* ── Season filter dropdowns ── */
    .season-filter-row {
        flex-direction: column;
    }
    .season-filter-row select {
        min-width: 0;
        width: 100%;
    }

    /* ── Rankings table: hide low-priority columns ── */
    .data-table { font-size: .76rem; }
    .data-table th { padding: .5rem .35rem; font-size: .62rem; }
    .data-table td { padding: .45rem .35rem; }
    .data-table .location,
    .data-table .col-location,
    .data-table .stat-dpr,
    .data-table .col-dpr,
    .data-table .team-avatar-cell { display: none; }
    .data-table .team-num { font-size: .82rem; }
    .data-table .rank { text-align: center; min-width: 2rem; }
    .compare-td { padding: .3rem !important; }
    .compare-cb { width: 18px; height: 18px; }

    /* ── Summary stat cards ── */
    .summary-stats-row { grid-template-columns: repeat(2, 1fr); gap: .5rem; }

    /* ── PBP ── */
    .pbp-team { padding: .75rem .85rem; }
    .pbp-team-number { font-size: 1.2rem; }
    .pbp-team-stats { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
    .pbp-nav-btn { padding: .5rem .85rem; font-size: .78rem; min-height: 44px; }
    .pbp-match-label { font-size: .85rem; }

    /* ── Breakdown reef ── */
    .bd-reef-cell { font-size: .4rem; min-width: 0; }
    .bd-robots { gap: .35rem; }
    .bd-robot-card { padding: .5rem; }

    /* ── Alliance cards ── */
    .alliance-toolbar {
        padding: .5rem .65rem;
        gap: .4rem .8rem;
        font-size: .75rem;
    }
    .alliance-card { border-radius: var(--radius); }
    .team-stats-mini { font-size: .7rem; }

    /* ── Playoff bracket ── */
    .bkt-slot { min-width: 140px; }
    .bkt-score { font-size: .85rem; }

    /* ── History stat cards ── */
    .history-stat-card { flex: 1 1 90px; min-width: 80px; padding: .55rem .45rem; }
    .hsc-value { font-size: 1.1rem; }
    .hsc-label { font-size: .65rem; }
    .history-panel { padding: .85rem .75rem; }
    .history-panel-title { font-size: .95rem; }

    /* ── Compare modal ── */
    .compare-overlay { padding: .25rem; }
    .compare-modal { border-radius: var(--radius); }
    .compare-modal-header { padding: .65rem .85rem; }
    .compare-modal-header h2 { font-size: .88rem; }
    .compare-body { padding: .5rem; }
    .compare-grid { gap: 1px; font-size: .65rem; }
    .comp-label { font-size: .55rem; padding: .3rem .35rem; min-width: 0; }
    .comp-header { padding: .45rem .35rem; }
    .comp-team-num { font-size: .85rem; }
    .comp-team-name { font-size: .65rem; }

    /* ── Compare bar ── */
    .compare-bar {
        bottom: .75rem;
        left: .5rem;
        right: .5rem;
        font-size: .78rem;
        padding: .45rem .65rem;
        gap: .5rem;
    }
    .compare-bar button { padding: .35rem .75rem; font-size: .72rem; }

    /* ── Footer ── */
    .site-footer {
        font-size: .68rem;
        padding: .85rem .75rem;
        gap: .25rem;
    }
    .footer-top .footer-sep { display: none; }
    .footer-attribution .footer-sep { display: none; }
    .footer-attribution {
        flex-direction: column;
        gap: .2rem;
    }

    /* ── H2H ── */
    .h2h-header { font-size: 1rem; }
    .conn-range-toggle { font-size: .72rem; }

    /* ── PBP connections ── */
    .pbp-conn-item { flex-wrap: wrap; }

    /* ── Settings menu ── */
    .settings-menu {
        min-width: 200px;
        right: -.5rem;
        max-width: calc(100vw - 1.5rem);
    }

    /* ── Saved events ── */
    .saved-event-item { padding: .5rem .65rem; }
    .saved-event-name { font-size: .78rem; }
    .saved-event-status { font-size: .58rem; }

    /* ── Loading overlay ── */
    .loader { width: 32px; height: 32px; }

    /* ── Rankings: row tap selects for compare ── */
    .data-table tbody tr {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(99,102,241,.15);
    }
}

/* ── Phone Landscape ─────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: .4rem 1rem;
    }
    header h1 { font-size: .88rem; }
    .brand-sub { display: none; }
    .brand-icon { width: 20px; height: 20px; }

    .tabs {
        padding: 0 .5rem;
    }
    .tab {
        padding: .4rem .7rem;
        font-size: .72rem;
        min-height: 36px;
        flex-direction: row;
        gap: .3rem;
    }
    .tab-icon { width: 14px; height: 14px; }

    main {
        padding: .6rem .85rem;
    }

    /* PBP: side-by-side in landscape */
    .pbp-arena {
        grid-template-columns: 1fr 1fr;
        gap: .6rem;
    }
    .pbp-team {
        padding: .5rem .65rem;
    }
    .pbp-team-top {
        gap: .5rem;
        margin-bottom: .25rem;
    }
    .pbp-team-number {
        font-size: 1.1rem;
        min-width: 50px;
    }
    .pbp-team-nickname { font-size: .85rem; }
    .pbp-team-school { font-size: .68rem; }
    .pbp-team-location { font-size: .66rem; }
    .pbp-team-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: .3rem;
    }
    .pbp-stat { padding: .2rem .4rem; }
    .pbp-stat-label { font-size: .55rem; }
    .pbp-stat-value { font-size: .78rem; }
    .pbp-alliance-score { font-size: 1.2rem; }
    .pbp-alliance-header {
        padding: .45rem .8rem;
    }
    .pbp-topbar {
        padding: .5rem .8rem;
        margin-bottom: .75rem;
    }
    .pbp-nav-btn {
        padding: .35rem .8rem;
        font-size: .78rem;
    }
    .pbp-match-label { font-size: .88rem; }

    /* Breakdown in landscape */
    .bd-content { flex-direction: row; }

    /* Alliance grid: 2-col in landscape */
    #alliance-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Active event banner: compact */
    .active-event-banner { padding: .45rem .8rem; }
    .aeb-name { font-size: .8rem; }
    .aeb-meta { font-size: .65rem; }
    .aeb-right { width: auto; }

    /* Event cards compact */
    .event-section-card { padding: .7rem .8rem; margin-bottom: .6rem; }

    /* Compare modal - broader in landscape */
    .compare-modal { max-height: 95vh; }

    /* History panels side-by-side if wide enough */
    .history-panels { grid-template-columns: 1fr 1fr; }
}


/* ═══════════════════════════════════════════════════════════
   EVENT SUMMARY TAB
   ═══════════════════════════════════════════════════════════ */

.summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.summary-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.summary-refresh-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--primary);
    padding: .45rem 1rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.summary-refresh-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}
.summary-refresh-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Demographic stat cards ────────────────────────────────── */
.summary-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1.2rem;
}
.summary-stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: var(--transition);
}
.summary-stat-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}
.summary-stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    font-family: var(--mono);
    color: var(--primary);
    line-height: 1.2;
}
.summary-stat-label {
    font-size: .78rem;
    color: var(--text-secondary);
    margin-top: .25rem;
}
.summary-stat-sub {
    display: block;
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: .15rem;
}

/* ── Summary cards (HoF, History, Top Scorers) ─────────────── */
.summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}
.summary-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 .6rem 0;
}
.summary-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}
.summary-card-header h3 {
    margin: 0;
}
.collapse-icon {
    font-size: .75rem;
    color: var(--text-muted);
    transition: var(--transition);
}
.summary-card-header:hover .collapse-icon {
    color: var(--text);
}
#summary-history-body {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height .35s ease, opacity .25s ease, margin .25s ease;
    opacity: 1;
    margin-top: .6rem;
}
#summary-history-list {
    max-height: 26rem;
    overflow-y: auto;
}
#summary-history-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}
.summary-card-desc {
    font-size: .78rem;
    color: var(--text-muted);
    margin: 0 0 .75rem 0;
}

/* Hall of Fame */
.summary-hof-team {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem 0;
    border-bottom: 1px solid var(--border-subtle);
}
.summary-hof-team:last-child { border-bottom: none; }
.summary-hof-num {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .95rem;
    color: var(--yellow);
    min-width: 3.5rem;
}
.summary-hof-name {
    font-weight: 600;
    color: var(--text);
}
.summary-hof-loc {
    color: var(--text-muted);
    font-size: .78rem;
    margin-left: auto;
}

/* Connection filter bar */
.conn-filter-bar {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    align-items: center;
}
.conn-filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: .3rem .75rem;
    border-radius: 100px;
    font-family: var(--font);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.conn-filter-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}
.conn-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Prior connections — accordion layout */
.conn-toolbar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
}
.conn-search-input {
    flex: 0 0 auto;
    width: 10rem;
    padding: .3rem .55rem;
    font-size: .78rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .2s;
}
.conn-search-input:focus {
    border-color: var(--primary);
}
.conn-search-input::placeholder { color: var(--text-muted); }

/* Range toggle (Past 3 seasons / All time) */
.conn-range-toggle {
    display: flex;
    align-items: center;
    gap: .35rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.conn-range-side {
    font-size: .73rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color .2s;
}
.conn-range-side.active {
    color: var(--primary);
}
.conn-range-toggle input { display: none; }
.conn-toggle-slider {
    position: relative;
    width: 2rem;
    height: 1.1rem;
    background: var(--border);
    border-radius: 100px;
    transition: background .2s;
    flex-shrink: 0;
}
.conn-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: .75rem;
    height: .75rem;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.conn-range-toggle input:checked + .conn-toggle-slider {
    background: var(--primary);
}
.conn-range-toggle input:checked + .conn-toggle-slider::after {
    transform: translateX(.85rem);
}

/* Secondary toolbar — range toggle + sort */
.conn-toolbar-secondary {
    justify-content: space-between;
}
.conn-sort-bar {
    display: flex;
    align-items: center;
    gap: .3rem;
}
.conn-sort-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: .15rem;
}
.conn-sort-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: .2rem .55rem;
    border-radius: 100px;
    font-family: var(--font);
    font-size: .7rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.conn-sort-btn:hover { border-color: var(--primary); color: var(--text); }
.conn-sort-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.conn-filter-sep {
    width: 1px;
    height: 1rem;
    background: var(--border);
    margin: 0 .15rem;
}

/* Winner/Finalist result badges */
.conn-detail-result {
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .35rem;
    border-radius: 100px;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.conn-result-winner {
    background: rgba(234, 179, 8, .15);
    color: var(--yellow, #eab308);
    border: 1px solid rgba(234, 179, 8, .3);
}
.conn-result-finalist {
    background: rgba(148, 163, 184, .15);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, .3);
}

/* Accordion rows */
.conn-row {
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    margin-bottom: .35rem;
    cursor: pointer;
    transition: box-shadow .15s;
}
.conn-row:last-child { margin-bottom: 0; }
.conn-row:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.conn-row-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .7rem;
}
.conn-team {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
}
.conn-vs {
    color: var(--text-muted);
    font-size: .75rem;
}
.conn-chips {
    display: flex;
    gap: .3rem;
    margin-left: auto;
}
.conn-chip {
    font-size: .7rem;
    font-weight: 600;
    padding: .1rem .4rem;
    border-radius: 100px;
    white-space: nowrap;
}
.conn-chip-partner {
    background: rgba(34, 197, 94, .1);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, .2);
}
.conn-chip-opponent {
    background: rgba(239, 68, 68, .1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, .2);
}
.conn-expand-icon {
    font-size: .7rem;
    color: var(--text-muted);
    transition: transform .2s;
    flex-shrink: 0;
}
.conn-row.expanded .conn-expand-icon {
    transform: rotate(90deg);
}

/* Detail panel — hidden by default */
.conn-row-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    border-top: 0 solid transparent;
}
.conn-row.expanded .conn-row-details {
    max-height: 300px;
    border-top: 1px solid var(--border-subtle);
}
.conn-detail-line {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .7rem .3rem 1.2rem;
    font-size: .78rem;
    border-bottom: 1px solid var(--border-subtle);
}
.conn-detail-line:last-child { border-bottom: none; }
.conn-detail-icon { font-size: .75rem; flex-shrink: 0; }
.conn-svg {
    width: .85em;
    height: .85em;
    vertical-align: -0.1em;
    display: inline-block;
    flex-shrink: 0;
}
.conn-detail-event {
    flex: 1;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conn-detail-year {
    font-weight: 600;
    font-size: .72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.conn-detail-stage {
    font-weight: 600;
    font-size: .7rem;
    padding: .1rem .4rem;
    border-radius: 100px;
    white-space: nowrap;
    flex-shrink: 0;
}
.conn-line-partner .conn-detail-stage {
    background: rgba(34, 197, 94, .1);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, .25);
}
.conn-line-opponent .conn-detail-stage {
    background: rgba(239, 68, 68, .1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, .25);
}

/* Top scorers */
.summary-top-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}
.summary-top-row:last-child { border-bottom: none; }
.top-medal {
    font-weight: 800;
    font-size: .8rem;
    color: var(--yellow);
    min-width: 2rem;
    text-align: center;
}
.summary-top-row:nth-child(2) .top-medal { color: var(--text-secondary); }
.summary-top-row:nth-child(3) .top-medal { color: #cd7f32; }
.top-team-num {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .95rem;
    color: var(--text);
    min-width: 3.5rem;
}
.top-team-name {
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
}
.top-opr {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .85rem;
    color: var(--primary);
}
.top-rank {
    font-size: .75rem;
    color: var(--text-muted);
    min-width: 4.5rem;
    text-align: right;
}

/* ── 2026 RP Progress Bars ─────────────────────────────────── */
.bd-rp-progress {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-top: .5rem;
    padding: 0 .2rem;
}
.rp-progress-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.rp-progress-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 6.5rem;
    text-align: right;
}
.rp-progress-track {
    flex: 1;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}
.rp-progress-fill {
    height: 100%;
    background: var(--text-muted);
    border-radius: 5px;
    transition: width 0.4s ease;
}
.rp-progress-fill.rp-bar-achieved {
    background: #22c55e;
}
.rp-progress-text {
    font-family: var(--mono);
    font-size: .72rem;
    color: var(--text-muted);
    min-width: 5rem;
    text-align: left;
}

/* ── Team Spotlight ────────────────────────────────────────── */
.bd-spotlight {
    margin-bottom: .75rem;
}
.spotlight-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    animation: spotlightIn 0.25s ease;
}
@keyframes spotlightIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.spotlight-red   { border-color: rgba(239, 68, 68, .5); }
.spotlight-blue  { border-color: rgba(59, 130, 246, .5); }

.spotlight-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .8rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}
.spotlight-team-info {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
.spotlight-team-num {
    font-family: var(--mono);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}
.spotlight-team-nick {
    font-size: .85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.spotlight-alliance-badge {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 4px;
}
.spotlight-badge-red {
    background: rgba(239, 68, 68, .15);
    color: #ef4444;
}
.spotlight-badge-blue {
    background: rgba(59, 130, 246, .15);
    color: #3b82f6;
}
.spotlight-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 .3rem;
    line-height: 1;
    transition: color .15s;
}
.spotlight-close:hover { color: var(--text); }

.spotlight-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: .4rem;
    padding: .6rem .8rem;
}
.spotlight-stat-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .35rem .2rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    gap: .15rem;
}
.spotlight-stat-val {
    font-family: var(--mono);
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
}
.spotlight-stat-lbl {
    font-size: .6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    text-align: center;
}

/* ── Spotlight section areas ────────────────────────────────── */
.spotlight-section {
    padding: .5rem .8rem;
}
.spotlight-section + .spotlight-section {
    border-top: 1px solid var(--border);
}
.spotlight-section-title {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: .4rem;
}
/* Current match individual data - large featured display */
.spotlight-featured {
    display: flex;
    gap: .6rem;
    align-items: stretch;
    flex-wrap: wrap;
}
.spotlight-feat-cell {
    flex: 1 1 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .5rem .3rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    gap: .2rem;
    min-width: 80px;
}
.spotlight-feat-val {
    font-family: var(--mono);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text);
}
.spotlight-feat-lbl {
    font-size: .55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: center;
}
/* Tower level badges */
.tower-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: 800;
    font-size: .85rem;
}
.tower-none    { background: var(--bg-tertiary); color: var(--text-muted); }
.tower-level1  { background: rgba(34, 197, 94, .15); color: #22c55e; }
.tower-level2  { background: rgba(59, 130, 246, .15); color: #3b82f6; }
.tower-level3  { background: rgba(168, 85, 247, .15); color: #a855f7; }
/* Match result badges */
.result-badge {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    border-radius: 4px;
    text-align: center;
    font-family: var(--mono);
    font-weight: 800;
    font-size: .7rem;
}
.result-W { background: rgba(34, 197, 94, .15); color: #22c55e; }
.result-L { background: rgba(239, 68, 68, .15); color: #ef4444; }
.result-T { background: rgba(234, 179, 8, .15); color: #eab308; }
/* Match history table */
.spotlight-matches-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .72rem;
}
.spotlight-matches-table th {
    font-size: .55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    padding: .25rem .3rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.spotlight-matches-table td {
    padding: .25rem .3rem;
    text-align: center;
    font-family: var(--mono);
    font-size: .7rem;
    color: var(--text-secondary);
}
.spotlight-matches-table tr:not(:last-child) td {
    border-bottom: 1px solid rgba(255,255,255,.04);
}
.spotlight-matches-table tr.current-match td {
    background: rgba(108, 99, 255, .08);
    color: var(--text);
    font-weight: 600;
}
/* Aggregate stat bars */
.spotlight-bar-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .3rem;
}
.spotlight-bar-label {
    font-size: .6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    width: 70px;
    text-align: right;
    flex-shrink: 0;
}
.spotlight-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}
.spotlight-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .3s ease;
}
.spotlight-bar-fill-green  { background: #22c55e; }
.spotlight-bar-fill-blue   { background: #3b82f6; }
.spotlight-bar-fill-purple { background: #a855f7; }
.spotlight-bar-value {
    font-family: var(--mono);
    font-size: .65rem;
    font-weight: 700;
    color: var(--text-secondary);
    width: 36px;
    flex-shrink: 0;
}
.spotlight-loading {
    padding: 1.5rem;
    text-align: center;
    font-size: .8rem;
    color: var(--text-muted);
}

/* Clickable team numbers in robot cards */
.bd-spotlight-trigger {
    cursor: pointer;
    transition: color .15s, text-shadow .15s;
}
.bd-spotlight-trigger:hover {
    color: var(--primary) !important;
    text-shadow: 0 0 6px rgba(108, 99, 255, .3);
}

/* Robot card highlight/dim states */
.bd-robot-card {
    transition: opacity .2s, box-shadow .2s;
}
.bd-robot-card.bd-spotlight-active {
    box-shadow: 0 0 0 2px var(--primary), 0 2px 8px rgba(108, 99, 255, .2);
}
.bd-robot-card.bd-spotlight-dimmed {
    opacity: .35;
}

/* ═══════════════════════════════════════════════════════════
   Region & Event History tab
   ═══════════════════════════════════════════════════════════ */

.history-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 1100px) {
    .history-panels { grid-template-columns: 1fr; }
}

.history-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    min-width: 0;
}

.history-panel-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 2px solid var(--primary);
    padding-bottom: .5rem;
}

/* ── Stat cards row ─────────────────────────────────────── */
.history-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.history-stat-card {
    flex: 1 1 110px;
    min-width: 100px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem .65rem;
    text-align: center;
    transition: var(--transition);
}

.history-stat-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.hsc-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
    word-break: break-word;
}

.hsc-label {
    font-size: .72rem;
    letter-spacing: .02em;
    color: var(--muted);
    margin-top: .2rem;
}

.hsc-sub {
    font-size: .68rem;
    color: var(--muted);
    margin-top: .15rem;
    opacity: .75;
    line-height: 1.3;
}

/* ── Detail sections ────────────────────────────────────── */
.history-detail-section {
    margin-top: 1rem;
}

.history-detail-section h4 {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 .5rem;
}

.detail-note {
    font-weight: 400;
    font-size: .72rem;
    color: var(--muted);
}

/* ── Team chips ─────────────────────────────────────────── */
.history-team-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .6rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.chip-name { font-weight: 400; opacity: .7; }
.chip-years { font-size: .68rem; color: var(--muted); }
.chip-country { font-size: .68rem; color: var(--muted); font-style: italic; }
.chip-count { font-weight: 700; color: var(--primary); }

.hof-chip { border-color: #f59e0b; background: rgba(245, 158, 11, .08); }
.impact-chip { border-color: #8b5cf6; background: rgba(139, 92, 246, .08); }
.visitor-chip { border-color: #06b6d4; background: rgba(6, 182, 212, .08); }

/* More button for chip lists */
.history-chip-more {
    display: inline-block;
    padding: .25rem .65rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--card);
    border: 1px dashed var(--primary);
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, color .15s;
    vertical-align: middle;
}
.history-chip-more:hover { background: var(--primary); color: #fff; }
.history-chip-extra { display: contents; }
.history-chip-extra.hidden { display: none; }

/* ── History table ──────────────────────────────────────── */
.history-table { font-size: .8rem; }
.history-table th { font-size: .72rem; }
.history-table td { padding: .35rem .5rem; }
.history-table .num { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.history-table .year-cell { font-weight: 700; color: var(--primary); }
.history-table .years-cell {
    font-size: .7rem;
    color: var(--muted);
    max-width: 200px;
    white-space: normal;
    line-height: 1.4;
}
.history-table .more-row td {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    font-size: .75rem;
}

/* ── Leaderboards ───────────────────────────────────────── */
.history-leaderboards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.history-leaderboard {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
}

.history-leaderboard h4 {
    font-size: .8rem;
    font-weight: 700;
    margin: 0 0 .5rem;
    color: var(--text);
}

.leaderboard-list {
    margin: 0;
    padding-left: 1.25rem;
    list-style: decimal;
}

.leaderboard-list li {
    font-size: .78rem;
    padding: .15rem 0;
    display: flex;
    align-items: baseline;
    gap: .3rem;
}

.leaderboard-list li::marker {
    color: var(--muted);
    font-weight: 600;
}

.lb-team {
    font-weight: 700;
    color: var(--primary);
    min-width: 2.5rem;
}

.lb-name {
    flex: 1;
    color: var(--muted);
    font-size: .72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-count {
    font-weight: 800;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .05rem .4rem;
    font-size: .72rem;
    min-width: 1.2rem;
    text-align: center;
}

