/* ════════════════════════════════════════════════════════════════
   MARCH MADNESS BRACKET ANALYZER — Dark Sports Broadcast Theme
   ════════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Core palette */
    --bg-deep:      #060a12;
    --bg-base:      #0a0e17;
    --bg-surface:   #131a2b;
    --bg-elevated:  #1a2340;
    --bg-hover:     #1e2a4a;
    --border:       #1e293b;
    --border-light: #2a3654;

    /* Text */
    --text-primary:   #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    /* Accent */
    --accent:       #3b82f6;
    --accent-light: #60a5fa;
    --accent-dark:  #2563eb;
    --accent-glow:  rgba(59, 130, 246, 0.25);

    /* Status */
    --green:     #22c55e;
    --green-bg:  rgba(34, 197, 94, 0.12);
    --yellow:    #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --red:       #ef4444;
    --red-bg:    rgba(239, 68, 68, 0.12);
    --orange:    #f97316;

    /* Sizing */
    --header-h: 64px;
    --tab-h:    52px;
    --radius:   8px;
    --radius-lg: 12px;
    --radius-sm: 4px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Typography ─── */
h1, h2, h3, h4 { font-weight: 600; color: var(--text-primary); }
h2 { font-size: 1.15rem; }

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ════════════════════ HEADER ════════════════════ */
.app-header {
    height: var(--header-h);
    background: linear-gradient(180deg, #0f1524 0%, var(--bg-surface) 100%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { flex-shrink: 0; }
.logo-text {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}
.logo-text .accent { color: var(--accent-light); }

.year-badge {
    background: var(--accent);
    color: white;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.last-refresh {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.refresh-label { margin-right: 4px; }

/* ════════════════════ BUTTONS ════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
    color: white;
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.1); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }

.btn-glow {
    box-shadow: var(--shadow-glow);
}
.btn-glow:hover:not(:disabled) {
    box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(59,130,246,0.1);
}

.btn-large { padding: 12px 32px; font-size: 1rem; }

.btn-icon { width: 16px; height: 16px; flex-shrink: 0; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ════════════════════ TAB NAVIGATION ════════════════════ */
.tab-nav {
    display: flex;
    gap: 0;
    background: var(--bg-deep);
    border-bottom: 2px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: var(--header-h);
    z-index: 99;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}
.tab-btn svg { opacity: 0.5; transition: opacity 0.2s; }
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn:hover svg { opacity: 0.7; }

.tab-btn.active {
    color: var(--accent-light);
}
.tab-btn.active svg { opacity: 1; }
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ════════════════════ TAB CONTENT ════════════════════ */
.tab-content {
    padding: 24px;
    max-width: 1800px;
    margin: 0 auto;
}

/* ════════════════════ LOADING ════════════════════ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 18, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    gap: 16px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ════════════════════ STATS BAR ════════════════════ */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-light);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ════════════════════ CONTROLS ════════════════════ */
.controls-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
    transition: border-color 0.2s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100%;
}
.search-box input::placeholder { color: var(--text-muted); }

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

select, .form-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}
select:focus, .form-input:focus { border-color: var(--accent); box-shadow: var(--shadow-glow); }
select option { background: var(--bg-surface); }

/* ════════════════════ CARDS ════════════════════ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
}

.badge {
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ════════════════════ DATA TABLE ════════════════════ */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 2;
    user-select: none;
}

.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--accent-light); }
.data-table th.sort-active { color: var(--accent-light); }
.sort-arrow { font-size: 0.65rem; margin-left: 2px; }

.data-table tbody tr {
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    transition: background 0.15s;
}
.data-table tbody tr:nth-child(even) { background: rgba(19, 26, 43, 0.5); }
.data-table tbody tr:hover { background: var(--bg-hover); }

.clickable-row { cursor: pointer; }

.data-table td {
    padding: 10px 14px;
    white-space: nowrap;
}

.data-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

.rank-cell {
    color: var(--text-muted);
    font-weight: 600;
    width: 50px;
}

.team-name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

/* Seed pips */
.seed-pip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--bg-hover);
    color: var(--text-secondary);
    flex-shrink: 0;
}
.seed-pip.large { width: auto; padding: 2px 12px; border-radius: 20px; font-size: 0.8rem; }

.seed-1, .seed-2 { background: rgba(34, 197, 94, 0.2); color: var(--green); }
.seed-3, .seed-4 { background: rgba(59, 130, 246, 0.2); color: var(--accent-light); }
.seed-5, .seed-6, .seed-7, .seed-8 { background: rgba(234, 179, 8, 0.2); color: var(--yellow); }
.seed-9, .seed-10, .seed-11, .seed-12 { background: rgba(249, 115, 22, 0.2); color: var(--orange); }
.seed-13, .seed-14, .seed-15, .seed-16 { background: rgba(239, 68, 68, 0.2); color: var(--red); }

.region-badge {
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.positive { color: var(--green); }
.negative { color: var(--red); }

/* Probability badges */
.prob-badge {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}
.prob-high { background: var(--green-bg); color: var(--green); }
.prob-mid { background: var(--yellow-bg); color: var(--yellow); }
.prob-low { background: var(--red-bg); color: var(--red); }

/* ════════════════════ CHARTS ════════════════════ */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-card { flex: 1; }

.chart-container {
    padding: 20px;
    position: relative;
    height: 350px;
}
.chart-container canvas { width: 100% !important; height: 100% !important; }

.radar-container { height: 300px; }

/* ════════════════════ MODAL ════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 18, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.team-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}
.team-detail-header h2 { font-size: 1.5rem; margin-bottom: 8px; }
.team-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.team-adjEM { text-align: center; }
.big-number { font-size: 2.2rem; font-weight: 800; }
.big-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.team-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.team-stat {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}
.team-stat-value { font-size: 1.2rem; font-weight: 700; color: var(--accent-light); }
.team-stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }

/* ════════════════════ BRACKET BUILDER ════════════════════ */
.bracket-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.controls-left { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.controls-right { display: flex; gap: 10px; align-items: center; }

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.control-group label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.slider {
    -webkit-appearance: none;
    width: 140px;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    outline: none;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
}
.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-light);
    min-width: 60px;
}
.slider-value.computed { color: var(--text-secondary); }

.bracket-name-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.85rem;
    outline: none;
    width: 180px;
}
.bracket-name-input:focus { border-color: var(--accent); }

.bracket-actions { display: flex; gap: 8px; align-items: center; }

/* Sim Status */
.sim-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.sim-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse 2s ease-in-out infinite;
}
.sim-status-sep { color: var(--border-light); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Live Score Badges */
.badge-live { background: #ef4444; color: #fff; animation: pulse 1.5s infinite; }
.badge-final { background: var(--surface-3); color: var(--text-muted); }
.badge-pre { background: var(--surface-3); color: var(--text-muted); }

/* Live Game Card States */
.game-live { border: 1px solid rgba(239,68,68,0.4); box-shadow: 0 0 12px rgba(239,68,68,0.1); }
.game-final { opacity: 0.85; }
.game-pre { }

/* Bracket Viewport — scrollable container */
.bracket-viewport {
    overflow: auto;
    padding: 10px 0;
}

/* Bracket Grid — 4 regions + center */
.bracket-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0 20px;
    min-width: 1200px;
}

.region-top-left    { grid-column: 1; grid-row: 1; }
.region-top-right   { grid-column: 3; grid-row: 1; direction: rtl; }
.region-top-right .matchup { direction: ltr; }
.region-bottom-left { grid-column: 1; grid-row: 2; }
.region-bottom-right{ grid-column: 3; grid-row: 2; direction: rtl; }
.region-bottom-right .matchup { direction: ltr; }
.bracket-center     { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Region layout */
.bracket-region {
    display: flex;
    gap: 4px;
    position: relative;
    padding-top: 28px;
}

.region-label {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

/* Rounds */
.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    min-width: 130px;
    gap: 4px;
}

/* Matchup */
.matchup {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin: 2px 0;
}
.matchup:hover { border-color: var(--border-light); }
.matchup.user-pick { }
/* Clear team button — inline next to team name */
.clear-team-btn { color:#ef4444;cursor:pointer;font-size:1rem;padding:0 3px;line-height:1;font-weight:700;margin-left:auto; }
.clear-team-btn:hover { color:#ff0000;transform:scale(1.3); }

/* Locked matchup (completed game) */
.matchup.locked-game { border-color: var(--green); border-width: 1px; }
.matchup.locked-game .matchup-team { cursor: default; }
.matchup.locked-game .matchup-team:hover { background: inherit; }
.final-score { font-size:0.6rem; color:var(--green); font-weight:700; margin-left:auto; font-variant-numeric:tabular-nums; }

/* Correct/wrong pick indicators on loaded brackets */
.matchup.pick-correct { border-color: #22c55e; border-width: 2px; }
.matchup.pick-correct::after { content: '✓'; position: absolute; top: 2px; right: 4px; color: #22c55e; font-size: 0.7rem; font-weight: 700; }
.matchup.pick-wrong { border-color: #ef4444; border-width: 2px; }
.matchup.pick-wrong::after { content: '✗'; position: absolute; top: 2px; right: 4px; color: #ef4444; font-size: 0.7rem; font-weight: 700; }
.matchup.pick-wrong .matchup-team.winner .team-label { text-decoration: none; }
.matchup.pick-wrong .matchup-team:not(.winner) .team-label { opacity: 0.5; }

/* Analysis recommendation cards */
.card.rec-strong { border-left: 4px solid #22c55e; }
.card.rec-bet { border-left: 4px solid #f59e0b; }
.card.rec-lean { border-left: 4px solid #6366f1; }

.matchup-team {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border);
}
.matchup-team:last-child { border-bottom: none; }
.matchup-team:hover { background: var(--bg-hover); }

.matchup-team.winner {
    background: rgba(59, 130, 246, 0.12);
    font-weight: 700;
}

.matchup-team.agrees { background: var(--green-bg); border-left: 2px solid var(--green); }
.matchup-team.disagrees { background: var(--red-bg); border-left: 2px solid var(--red); }
.matchup-team.close-call { background: var(--yellow-bg); border-left: 2px solid var(--yellow); }

.team-seed {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.team-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.win-prob {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-light);
    background: rgba(59,130,246,0.15);
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Final Four & Championship */
.final-four-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
}

.final-four {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 200px;
}

.final-matchup { width: 200px; }

.championship-matchup {
    width: 220px;
    border: 2px solid var(--accent) !important;
    box-shadow: var(--shadow-glow);
}

.champ-label {
    text-align: center;
    padding: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-light);
    background: rgba(59,130,246,0.08);
}

.champion-display {
    text-align: center;
    padding: 16px;
}
.champion-display svg { margin-bottom: 6px; }
.champion-name { font-size: 1.2rem; font-weight: 800; color: #f59e0b; }
.champion-seed { font-size: 0.75rem; color: var(--text-muted); }

/* Load bracket modal */
.saved-brackets-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.saved-bracket-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s;
}
.saved-bracket-item:hover { border-color: var(--accent); }
.bracket-item-name { font-weight: 600; }
.bracket-item-date { color: var(--text-muted); font-size: 0.85rem; }

/* ════════════════════ POOL OPTIMIZER ════════════════════ */
.pool-config {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.config-card .card-header { background: var(--bg-surface); }

.config-form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.form-textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
}
.form-textarea:focus { border-color: var(--accent); }
.form-textarea::placeholder { color: var(--text-muted); }

.form-input.small { width: 70px; }

.custom-scoring {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.custom-score-input { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.custom-score-input label { font-size: 0.65rem; }

.parse-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--green);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.success { background: var(--green); }

.optimizer-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

/* EV Table Styling */
.ev-legend {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
}
.legend-item { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.legend-dot.high-ev { background: var(--green); }
.legend-dot.med-ev { background: var(--yellow); }
.legend-dot.low-ev { background: var(--red); }

.ev-badge {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.8rem;
}
.ev-high { background: var(--green-bg); color: var(--green); }
.ev-mid { background: var(--yellow-bg); color: var(--yellow); }
.ev-low { background: var(--red-bg); color: var(--red); }

.ev-row-high { border-left: 3px solid var(--green); }
.ev-row-mid { border-left: 3px solid var(--yellow); }
.ev-row-low { border-left: 3px solid var(--red); }

.rec-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.rec-badge.strong-pick { background: var(--green-bg); color: var(--green); }
.rec-badge.lean-pick { background: rgba(34,197,94,0.06); color: #4ade80; }
.rec-badge.neutral { background: var(--yellow-bg); color: var(--yellow); }
.rec-badge.avoid { background: var(--red-bg); color: var(--red); }
.rec-badge.strong-avoid { background: rgba(239,68,68,0.2); color: #f87171; }

/* Scenario Cards */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    padding: 20px;
}

.scenario-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.scenario-card.best-scenario {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.scenario-name {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.scenario-ev { margin-bottom: 16px; }
.scenario-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-light);
}
.scenario-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
}

.scenario-stats {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}
.scenario-stat-value { font-size: 1rem; font-weight: 700; color: var(--text-primary); display: block; }
.scenario-stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }

.scenario-tag {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
}

/* ════════════════════ EMPTY STATES ════════════════════ */
.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
    gap: 12px;
}
.empty-state-large h3 { color: var(--text-secondary); font-size: 1.2rem; }
.empty-state-large p { color: var(--text-muted); max-width: 480px; line-height: 1.6; }

/* ════════════════════ TOASTS ════════════════════ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    min-width: 280px;
}
.toast.success { background: var(--green); color: white; }
.toast.error { background: var(--red); color: white; }
.toast.info { background: var(--accent); color: white; }

/* ════════════════════ TRANSITIONS ════════════════════ */
[x-transition\:enter] { transition: opacity 0.2s ease, transform 0.2s ease; }
.fade-in { animation: fadeIn 0.2s ease; }
.fade-out { animation: fadeOut 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ════════════════════ RESPONSIVE ════════════════════ */
@media (max-width: 1200px) {
    .charts-row { grid-template-columns: 1fr; }
    .pool-config { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .app-header { padding: 0 12px; }
    .tab-content { padding: 16px; }
    .tab-btn { padding: 12px 16px; font-size: 0.8rem; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .bracket-controls { flex-direction: column; align-items: stretch; }
    .controls-left { flex-direction: column; }
}
/* ════════════════════ MOBILE OVERRIDES (added 2026-05-26) ════════════════════ */

/* Phones (< 600px) */
@media (max-width: 600px) {
    /* Header — stack tightly */
    .app-header { padding: 8px 12px; }
    .logo-text { font-size: 1.1rem; }
    .last-refresh { display: none; }

    /* Tab navigation — make it horizontally scrollable on phones */
    nav.tabs, .tabs-nav, .tab-nav, [x-data] nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .tab-btn {
        padding: 10px 12px !important;
        font-size: 0.78rem !important;
        min-height: 44px;  /* Apple touch target minimum */
        flex-shrink: 0;
    }
    .tab-btn svg { width: 14px !important; height: 14px !important; }

    /* Tab content — less padding on mobile */
    .tab-content { padding: 12px 10px !important; }

    /* Buttons — bigger tap targets */
    .btn, button.btn-ghost, button.btn-primary {
        min-height: 44px;
        padding-left: 14px;
        padding-right: 14px;
    }

    /* Headings — smaller on mobile */
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }

    /* === MOBILE: Stats grids — force 2 columns regardless of inline styles === */
    main > div[style*="grid-template-columns:repeat(4,1fr)"],
    main > div[style*="grid-template-columns:repeat(auto-fit,minmax(100px,1fr))"],
    main > div[style*="grid-template-columns:repeat(auto-fit,minmax(120px,1fr))"],
    main > div[style*="grid-template-columns:repeat(auto-fit,minmax(130px,1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Pick cards — let them fill full width on phones */
    main > div > div[style*="grid-template-columns:repeat(auto-fill,minmax(240px,320px))"],
    main > div > div[style*="grid-template-columns:repeat(auto-fill,minmax(240px,1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Pick history table — shrink fixed columns proportionally */
    main div[style*="55px 1fr 50px 50px 45px 55px 55px"] {
        grid-template-columns: 45px 1fr 38px 35px 38px 42px 42px !important;
        font-size: 0.65rem !important;
        padding: 4px 6px !important;
    }
    main div[style*="60px 1fr 55px 45px 50px 65px"] {
        grid-template-columns: 50px 1fr 42px 35px 40px 48px !important;
        font-size: 0.7rem !important;
        padding: 4px 6px !important;
    }

    /* Modals — full-width on phones */
    .modal-overlay .card { max-width: 95% !important; padding: 14px !important; }

    /* Cards — less padding */
    .card { padding: 12px !important; }

    /* Hide some less-critical columns/elements on tight screens */
    .mobile-hide { display: none !important; }

    /* Make form inputs/selects bigger for thumb taps */
    select, input, textarea {
        min-height: 40px;
        font-size: 16px !important; /* Prevent iOS zoom on focus */
    }

    /* Optimal picks card — tighter padding */
    main > div > div[style*="background:linear-gradient"] {
        padding: 8px 12px !important;
    }
}

/* Small phones (< 400px) */
@media (max-width: 400px) {
    .stats-bar, main > div[style*="grid-template-columns:repeat"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    .tab-btn { padding: 8px 10px !important; font-size: 0.72rem !important; }
    .card { padding: 10px !important; }
}

/* Tablets (601-900px) */
@media (min-width: 601px) and (max-width: 900px) {
    /* Pick cards: 2 columns on tablets, max-width relaxed */
    main > div > div[style*="grid-template-columns:repeat(auto-fill,minmax(240px,320px))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    /* Stats grid: 3 cols on tablets */
    main > div[style*="grid-template-columns:repeat(auto-fit,minmax(100px,1fr))"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Touch-friendly globally */
@media (hover: none) and (pointer: coarse) {
    /* No hover effects on touch — they get "stuck" */
    .tab-btn:hover, .btn:hover { transform: none; }
    /* Bigger interactive elements */
    button, .tab-btn, a.tab-btn { min-height: 44px; }
}

/* Prevent horizontal scroll from any wide element */
html, body { overflow-x: hidden; }
body { -webkit-text-size-adjust: 100%; }

/* ════════════════════ MOBILE V2 — Specific fixes for scrunched content ════════════════════ */

@media (max-width: 600px) {

    /* === Pick card body: bump up font sizes and give boxes breathing room === */
    /* Targets the 3-box row (RL / ML / Win Prob) inside picks */
    div[style*="display:flex;gap:6px;margin-top:6px"] {
        flex-wrap: wrap;
        gap: 4px !important;
    }
    /* Make the 3 boxes flow as 3-up on tablets but 3-up here too, just bigger text */
    div[style*="display:flex;gap:6px;margin-top:6px"] > div {
        min-width: calc(33% - 4px);
        padding: 6px 4px !important;
    }
    /* Boost the small labels and values that are hard to read */
    div[style*="font-size:0.55rem"] { font-size: 0.65rem !important; }
    div[style*="font-size:0.6rem"]  { font-size: 0.7rem !important; }
    div[style*="font-size:0.65rem"] { font-size: 0.72rem !important; }
    div[style*="font-size:0.68rem"] { font-size: 0.75rem !important; }
    div[style*="font-size:0.7rem"]  { font-size: 0.78rem !important; }
    div[style*="font-size:0.72rem"] { font-size: 0.8rem !important; }
    div[style*="font-size:0.75rem"] { font-size: 0.82rem !important; }
    /* The big "team name + spread" line — keep readable */
    span[style*="font-size:1.05rem"] { font-size: 1rem !important; }
    /* The bet value inside each box — bump these too */
    div[style*="font-size:0.9rem"]  { font-size: 0.95rem !important; }

    /* === Pick card padding — more breathing room === */
    div[style*="border-radius:var(--radius-lg);padding:10px 12px"] {
        padding: 12px 14px !important;
    }

    /* === Stats grid: 2-column layout with bigger numbers === */
    div[style*="grid-template-columns:repeat(auto-fit,minmax(100px,1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    /* Stats grid cards: bump padding and number size */
    div[style*="grid-template-columns:repeat(auto-fit,minmax(100px,1fr))"] .card,
    div[style*="grid-template-columns:repeat(auto-fit,minmax(100px,1fr))"] > div {
        padding: 14px 10px !important;
    }
    div[style*="font-size:1.3rem;font-weight:700"] { font-size: 1.4rem !important; }
    div[style*="font-size:1.5rem;font-weight:700"] { font-size: 1.5rem !important; }

    /* === Pick history table: more usable === */
    /* Less aggressive shrinking — keep readable */
    main div[style*="55px 1fr 50px 50px 45px 55px 55px"] {
        grid-template-columns: 50px 1fr 42px 38px 42px 42px 42px !important;
        font-size: 0.72rem !important;
        padding: 8px 8px !important;
        gap: 4px !important;
    }
    main div[style*="60px 1fr 55px 45px 50px 65px"] {
        grid-template-columns: 50px 1fr 45px 38px 42px 50px !important;
        font-size: 0.75rem !important;
        padding: 8px 8px !important;
    }
    /* Header row of pick history */
    main div[style*="text-transform:uppercase"][style*="font-size:0.6rem"] {
        font-size: 0.65rem !important;
        padding: 6px 8px !important;
    }

    /* === "Today's Optimal Plays" header — better spacing === */
    h2[style*="font-size:1.1rem"] { font-size: 1.15rem !important; }

    /* === Optimal plays banner (the brown gradient header) === */
    div[style*="background:linear-gradient(135deg,#78350f"] {
        flex-direction: column !important;
        gap: 6px !important;
        text-align: center;
    }
    div[style*="background:linear-gradient(135deg,#78350f"] > div { width: 100%; }
    div[style*="background:linear-gradient(135deg,#78350f"] > div:last-child {
        justify-content: center !important;
    }

    /* === Matchup text inside cards: full readability === */
    div[x-text*="matchup"], div[x-text*="bet.matchup"] {
        font-size: 0.82rem !important;
        margin-top: 2px !important;
    }

    /* === Tier badge (LOCK/STRONG) === */
    span[style*="font-size:0.6rem;font-weight:700;padding:2px 6px"] {
        font-size: 0.68rem !important;
        padding: 3px 8px !important;
    }
}

/* === Tablets — pick cards 2-up instead of cramped 3-up === */
@media (min-width: 601px) and (max-width: 900px) {
    div[style*="grid-template-columns:repeat(auto-fill,minmax(240px,320px))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
