/* ============================================================
   MAIN — ZohnStats
   Layout, structure, and view-level styles.
   All values use design tokens from variables.css.
   All @keyframes live in animations.css.
   ============================================================ */

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

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    min-height: 100vh;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 15% 15%, rgba(124,141,240,0.13) 0%, transparent 65%),
        radial-gradient(ellipse 50% 70% at 85% 85%, rgba(118,75,162,0.10) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}

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

/* ── Header ───────────────────────────────────────────────── */
header {
    background: var(--bg-header);
    backdrop-filter: var(--blur-lg);
    border-bottom: 1px solid var(--border-default);
    box-shadow: var(--shadow-header);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-8);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}
.brand:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

.brand-icon { font-size: 1.75rem; line-height: 1; }

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

.brand-name {
    font-size: var(--text-xl);
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-light) 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 1px;
}

/* Season selector */
.season-select {
    background: var(--bg-interactive);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 700;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast);
    appearance: none;
}
.season-select:hover,
.season-select:focus {
    outline: none;
    border-color: var(--border-accent-hov);
    color: var(--accent);
}
.season-select option { background: var(--bg-surface); }

/* Nav tab base — used by waffle panel and mobile bottom nav */
.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: var(--font-sans);
}
.nav-tab .nav-icon { font-size: 1rem; }
.nav-tab:hover {
    background: var(--bg-interactive);
    color: var(--text-secondary);
    border-color: var(--border-default);
}
.nav-tab.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent-border);
    font-weight: 700;
}

/* ── Sub-nav: persistent horizontal nav bar inside header ──── */
.sub-nav {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.25rem var(--space-8);
    display: flex;
    align-items: center;
    gap: 2px;
    border-top: 1px solid var(--border-subtle, var(--border-default));
    overflow-x: auto;
    scrollbar-width: none;
}
.sub-nav::-webkit-scrollbar { display: none; }

/* Higher specificity beats .nav-tab base — no !important needed */
.sub-nav .nav-tab {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}
.sub-nav .nav-tab:hover {
    background: var(--bg-interactive);
    color: var(--text-secondary);
    border-color: var(--border-default);
}
.sub-nav .nav-tab.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent-border);
    font-weight: 700;
}

/* Theme toggle button in header */
.theme-btn-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.theme-btn-header:hover {
    background: var(--bg-interactive);
    border-color: var(--border-default);
}

/* On desktop hide waffle button (sub-nav + theme btn handle everything) */
@media (min-width: 769px) {
    .waffle-btn { display: none !important; }
}

/* ── Header ticker (fills space between sport switcher and waffle btn) ─ */
.header-ticker {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    height: 100%;
    border-left: 1px solid var(--border-default);
    border-right: 1px solid var(--border-default);
    margin: 0 var(--space-2);
}

/* ── Waffle button ──────────────────────────────────────────── */
.waffle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.waffle-btn:hover {
    background: var(--bg-interactive);
    color: var(--text-secondary);
    border-color: var(--border-default);
}
.waffle-btn--open {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent-border);
}

/* 3×3 dot grid icon */
.waffle-icon {
    width: 17px;
    height: 17px;
    position: relative;
    display: block;
}
.waffle-icon::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 5px; height: 5px;
    background: currentColor;
    border-radius: 1px;
    box-shadow:
        6px 0  0 currentColor, 12px 0  0 currentColor,
        0 6px  0 currentColor, 6px 6px 0 currentColor, 12px 6px 0 currentColor,
        0 12px 0 currentColor, 6px 12px 0 currentColor, 12px 12px 0 currentColor;
}

/* ── Waffle panel ───────────────────────────────────────────── */
.waffle-panel {
    position: sticky;
    top: var(--header-height);
    z-index: calc(var(--z-sticky) - 1);
    background: var(--bg-waffle-panel);
    border-bottom: 1px solid var(--border-default);
    backdrop-filter: var(--blur-lg);
    box-shadow: var(--shadow-waffle-panel);
    animation: waffleSlideDown 0.18s var(--ease-out) both;
}
.waffle-panel[hidden] { display: none; }

@keyframes waffleSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.waffle-panel-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem var(--space-8);
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.waffle-season-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-default);
}
.waffle-season-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


.waffle-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.5rem;
}

/* Waffle tile — overrides base .nav-tab for vertical tile layout */
.waffle-nav-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.875rem 0.5rem;
    min-height: 68px;
    background: var(--bg-interactive);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    white-space: normal;
    text-align: center;
}
.waffle-nav-item .nav-icon { font-size: 1.3rem; }
.waffle-nav-item:hover {
    background: var(--bg-interactive-hov);
    border-color: var(--border-mid);
}
.waffle-nav-item.active {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
    color: var(--accent);
}

/* ── View transition ─────────────────────────────────────── */
.view-enter {
    animation: fadeUp 0.2s var(--ease-out) both;
}

/* ── Main Content Area ────────────────────────────────────── */
main {
    max-width: var(--max-width);
    margin: var(--space-8) auto;
    padding: 0 var(--space-8);
}

/* ── Search Bar ───────────────────────────────────────────── */
.search-container {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--space-4);
    font-size: 1rem;
    pointer-events: none;
}

#searchBox {
    width: 100%;
    padding: 0.875rem 2.75rem;
    font-size: var(--text-md);
    font-family: var(--font-sans);
    background: var(--bg-interactive);
    border: 1.5px solid var(--border-mid);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
#searchBox:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-interactive-hov);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
#searchBox::placeholder { color: var(--text-subtle); }

.search-clear {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem var(--space-2);
    border-radius: var(--radius-xs);
    transition: color var(--transition-fast);
}
.search-clear:hover { color: var(--text-secondary); }

.search-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.875rem;
}

#resultCount {
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Favorites filter button */
.fav-filter-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.2px;
}
.fav-filter-btn:hover {
    background: var(--bg-interactive);
    border-color: rgba(251,113,133,0.4);
    color: #fb7185;
}
.fav-filter-btn.active {
    background: rgba(251,113,133,0.12);
    border-color: rgba(251,113,133,0.4);
    color: #fb7185;
}

/* Heart button on player cards */
.fav-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-subtle);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: color var(--transition-fast), transform var(--transition-fast);
    z-index: 2;
}
.fav-btn:hover { color: #fb7185; transform: scale(1.2); }
.fav-btn--active { color: #fb7185; }

/* Ensure player-card-top is relative so fav-btn can position absolutely */
.player-card-top { position: relative; }

/* View toggle */
.view-toggle { display: flex; gap: 0.25rem; }

.view-toggle-btn {
    padding: 0.35rem 0.65rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: all var(--transition-fast);
}
.view-toggle-btn:hover { color: var(--text-secondary); background: var(--bg-interactive); }
.view-toggle-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
    color: var(--accent);
}

/* View header (non-search views) */
.view-header {
    margin-bottom: var(--space-6);
    padding: 0.6rem var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
}

.breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-interactive);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.breadcrumb-link:hover {
    background: var(--bg-interactive-hov);
    border-color: var(--accent-border);
    color: var(--accent-light);
}

.breadcrumb-sep {
    color: var(--text-subtle);
    font-size: 0.9rem;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 700;
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.breadcrumb-root {
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
}

.breadcrumb-root {
    color: var(--text-muted);
    font-weight: 700;
}

/* ── Player Cards Grid ────────────────────────────────────── */
.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-min-w), 1fr));
    gap: 1.25rem;
}

.player-card {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.35s var(--ease-out) both;
    cursor: pointer;
}

.player-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124,141,240,0.06) 0%, rgba(118,75,162,0.06) 100%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.player-card:hover::before { opacity: 1; }
.player-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-card-hov);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 1;
}

.player-name {
    font-size: var(--text-lg);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    margin-bottom: 0.2rem;
}

.player-id {
    font-size: var(--text-xs);
    color: var(--text-subtle);
    font-weight: 600;
}

.position-badge {
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    color: var(--accent-light);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    position: relative;
    z-index: 1;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    transition: background var(--transition-fast);
}
.detail-row:hover { background: var(--bg-interactive); }

.detail-label {
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
}
.detail-value {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

/* ── Stats Table (player list table view) ─────────────────── */
.table-wrapper {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    overflow: hidden;
    overflow-x: auto;
    box-shadow: var(--shadow-card);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    white-space: nowrap;
}

.stats-table thead tr {
    background: var(--bg-table-head);
    border-bottom: 1px solid var(--border-default);
}

.stats-table th {
    padding: 0.875rem 1.25rem;
    text-align: left;
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: default;
    user-select: none;
}

.stats-table th.sortable { cursor: pointer; }
.stats-table th.sortable:hover { color: var(--text-secondary); }
.stats-table th.sort-active { color: var(--accent); }
.stats-table th.sort-active::after {
    content: attr(data-dir);
    margin-left: 0.25rem;
    font-size: 0.7rem;
}

.stats-table td {
    padding: 0.8rem 1.25rem;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-secondary);
    vertical-align: middle;
}

.stats-table tbody tr {
    transition: background var(--transition-fast);
    cursor: pointer;
}
.stats-table tbody tr:hover { background: rgba(124,141,240,0.06); }
.stats-table tbody tr:last-child td { border-bottom: none; }

.tbl-rank {
    color: var(--text-subtle);
    font-weight: 700;
    font-size: var(--text-xs);
    min-width: 2rem;
}

.tbl-player-name { font-weight: 700; color: var(--text-primary); }
.tbl-player-pos  { font-size: var(--text-xs); color: var(--text-subtle); font-weight: 600; margin-top: 1px; }

.tbl-team-badge {
    display: inline-block;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 0.2rem var(--space-2);
    border-radius: var(--radius-xs);
    letter-spacing: 0.3px;
}

.tbl-stat { font-weight: 700; }
.tbl-pts  { color: var(--color-pts); }
.tbl-reb  { color: var(--color-reb); }
.tbl-ast  { color: var(--color-ast); }
.tbl-pct  { color: var(--color-blk); }

.sort-arrow { opacity: 0.7; font-size: 0.7rem; margin-left: 2px; }

/* ── Leaderboard View ─────────────────────────────────────── */
.leaderboards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-lb-min-w), 1fr));
    gap: 1.25rem;
}

.leaderboard-panel {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    animation: fadeUp 0.35s var(--ease-out) both;
}

.leaderboard-header {
    padding: var(--space-4) 1.25rem;
    border-bottom: 1px solid var(--border-default);
    border-left: 4px solid;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
}

.leaderboard-title {
    font-size: var(--text-sm);
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard-unit {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.leaderboard-header--sortable {
    cursor: pointer;
    user-select: none;
}
.leaderboard-header--sortable:hover { background: rgba(255,255,255,0.04); }
[data-theme="light"] .leaderboard-header--sortable:hover { background: rgba(0,0,0,0.04); }

.leaderboard-sort-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
    flex-shrink: 0;
}

.leaderboard-list { display: flex; flex-direction: column; }

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-default);
    transition: background var(--transition-fast);
    cursor: pointer;
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row:hover { background: var(--bg-interactive); }

.lb-rank {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    flex-shrink: 0;
    background: var(--bg-subtle);
    color: var(--text-muted);
}
.lb-rank-1 { background: rgba(251,191,36,0.18);  color: var(--color-pts); }
.lb-rank-2 { background: rgba(203,213,225,0.10); color: var(--text-secondary); }
.lb-rank-3 { background: rgba(251,146,60,0.14);  color: var(--color-pct); }

.lb-player { flex: 1; min-width: 0; }
.lb-name   { display: block; font-weight: 700; color: var(--text-primary); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-team   { font-size: 0.72rem; color: var(--text-subtle); font-weight: 600; margin-top: 1px; }
.lb-value  { font-size: 1rem; font-weight: 900; flex-shrink: 0; }

/* ── Games Grid ───────────────────────────────────────────── */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-game-min-w), 1fr));
    gap: 1.25rem;
}

.game-card {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
    animation: fadeUp 0.35s var(--ease-out) both;
}
.game-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-card-hov);
}
@keyframes gameCardPulse {
    0%   { box-shadow: 0 0 0 0 var(--accent-border); border-color: var(--accent); }
    60%  { box-shadow: 0 0 0 8px transparent; border-color: var(--accent); }
    100% { box-shadow: none; border-color: var(--border-default); }
}
.game-card--highlight {
    animation: gameCardPulse 1.8s ease-out forwards;
}

/* ── Stat Builder ─────────────────────────────────────────── */
.builder-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

.builder-panel,
.saved-stats-panel {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-card);
}

.builder-panel h2,
.saved-stats-panel h2 { color: var(--text-primary); font-weight: 800; }

.builder-panel input {
    background: var(--bg-interactive);
    border: 1.5px solid var(--border-mid);
    color: var(--text-primary);
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.builder-panel input:focus {
    background: var(--bg-interactive-hov);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
    outline: none;
}
.builder-panel button { transition: all var(--transition-base); }
.builder-panel button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-accent);
}

.examples-panel {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(251,191,36,0.07) 0%, rgba(245,158,11,0.07) 100%);
    backdrop-filter: var(--blur-md);
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(251,191,36,0.14);
}
.examples-panel h3 { color: var(--color-pts); }
.examples-panel > div > div {
    background: var(--bg-table-sub);
    border: 1px solid var(--border-default);
}

/* ── Home / Landing Page ──────────────────────────────────── */
.home-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.home-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.5rem 2.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    text-align: center;
    box-shadow: var(--shadow-card);
}

.home-hero-glow {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 90% 70% at 50% -10%, rgba(124,141,240,0.28) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 15% 110%, rgba(118,75,162,0.18) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 85% 110%, rgba(99,102,241,0.14) 0%, transparent 55%);
    pointer-events: none;
}

.home-hero-content { position: relative; z-index: 1; }

.home-hero-badge {
    display: inline-block;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    color: var(--accent-light);
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 0.35rem 1rem;
    border-radius: var(--radius-full);
    margin-bottom: 1.5rem;
    animation: fadeUp 0.4s var(--ease-out) both;
}

.home-hero-title {
    font-size: clamp(3rem, 8vw, 5.5rem);
    font-weight: 900;
    letter-spacing: -3px;
    line-height: 1;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #eef2f8 0%, var(--accent-light) 45%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeUp 0.45s 0.05s var(--ease-out) both;
}

.home-hero-sub {
    color: var(--text-muted);
    font-size: var(--text-md);
    font-weight: 500;
    max-width: 480px;
    margin: 0 auto 1.5rem;
    line-height: 1.5;
    animation: fadeUp 0.5s 0.1s var(--ease-out) both;
}

/* Animated stats strip inside hero */
.home-stats-strip {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    animation: fadeUp 0.55s 0.18s var(--ease-out) both;
}
.home-stat { text-align: center; }
.home-stat-num {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 900;
    color: var(--accent-light);
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 0.3rem;
    font-variant-numeric: tabular-nums;
}
.home-stat-lbl {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sport entry cards */
.home-sports-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

/* Featured MLB card */
.home-sport-card--featured {
    width: 100%;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 1.25rem;
    padding: 1.75rem 2rem;
    margin-bottom: 1rem;
    border-color: rgba(251,191,36,0.3);
}
.home-sport-card--featured .home-sport-icon { font-size: 3.5rem; flex-shrink: 0; }
.home-sport-card--featured .home-sport-name { font-size: 1.75rem; }
.home-sport-card--featured .home-sport-cta  { margin-top: 0.25rem; }
.home-sport-card--featured .home-sport-desc { max-width: 340px; }

/* ── MLB nav shortcuts ────────────────────────────────────── */
.home-mlb-shortcuts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}
.home-shortcut-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}
.home-shortcut-btn:hover {
    background: var(--bg-interactive-hov);
    border-color: var(--accent-border);
    color: var(--accent-light);
    transform: translateY(-1px);
}
.home-shortcut-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
}
@media (max-width: 600px) {
    .home-mlb-shortcuts { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .home-shortcut-btn { padding: 0.75rem 0.875rem; font-size: var(--text-xs); }
}

/* Dev sports grid (kept for CSS completeness) */
.home-dev-sports { margin-bottom: 1.5rem; }
.home-dev-label  {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}
.home-dev-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
.home-sport-card--dev {
    padding: 1.25rem 1rem 1rem;
    opacity: 0.72;
}
.home-sport-card--dev .home-sport-icon { font-size: 2rem; }
.home-sport-card--dev .home-sport-name { font-size: 1.1rem; }
.home-sport-card--dev:hover { opacity: 1; }
.home-dev-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}

.home-sport-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 2rem 1.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.4s var(--ease-out) both;
    box-shadow: var(--shadow-card);
}

.home-sport-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--transition-base);
}
.home-sport-card--nba::before {
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124,141,240,0.18) 0%, transparent 70%);
}
.home-sport-card--mlb::before {
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(251,191,36,0.15) 0%, transparent 70%);
}
.home-sport-card--nfl::before {
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(100,160,100,0.18) 0%, transparent 70%);
}
.home-sport-card--nhl::before {
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0,120,200,0.18) 0%, transparent 70%);
}

.home-sport-card:not(.home-sport-card--soon):hover {
    transform: translateY(-5px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-card-hov);
}
.home-sport-card:not(.home-sport-card--soon):hover::before { opacity: 1; }

.home-sport-card--soon {
    opacity: 0.38;
    cursor: default;
}

.home-sport-icon { font-size: 2.75rem; line-height: 1; margin-bottom: 0.25rem; }
.home-sport-name {
    font-size: var(--text-xl);
    font-weight: 900;
    color: var(--text-primary);
}
.home-sport-desc {
    font-size: var(--text-xs);
    color: var(--text-subtle);
    font-weight: 500;
    line-height: 1.5;
}
.home-sport-cta {
    margin-top: 0.625rem;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--accent-light);
    transition: color var(--transition-fast), transform var(--transition-fast);
    display: inline-block;
}
.home-sport-card:not(.home-sport-card--soon):hover .home-sport-cta {
    color: var(--accent);
    transform: translateX(3px);
}
.home-sport-badge {
    margin-top: 0.375rem;
    display: inline-block;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    color: var(--text-subtle);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Recently viewed section */
.home-recents { margin-bottom: 1.75rem; }

.home-recents-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.home-recent-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    padding: 0.3rem 0.7rem 0.3rem 0.4rem;
    cursor: pointer;
    font-size: 0.78rem;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.home-recent-chip:hover {
    border-color: var(--border-mid);
    background: var(--bg-interactive);
}

.home-recent-badge {
    font-size: 0.58rem;
    font-weight: 800;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
    letter-spacing: 0.04em;
}
.home-recent-badge--nba { background: rgba(249,115,22,0.18); color: #fb923c; }
.home-recent-badge--mlb { background: rgba(59,130,246,0.18); color: #60a5fa; }

.home-recent-name {
    font-weight: 600;
    color: var(--text-primary);
}
.home-recent-sub {
    color: var(--text-muted);
    font-size: 0.72rem;
}

/* On This Day section (ANN-005) */
.home-on-this-day { margin-bottom: 1.75rem; }

.otd-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.otd-matchup {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.otd-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.otd-team {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.otd-score {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.otd-sep {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 1rem;
}

.otd-perf {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-default);
}

/* Today's games section */
.home-today {
    margin-bottom: 2rem;
}
.home-section-hdr {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}
.home-section-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}
.home-section-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}
.home-today-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.6rem;
}

.home-game-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    padding: 0.65rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    font-size: 0.78rem;
}
.home-game-chip:hover {
    border-color: var(--border-mid);
    background: var(--bg-interactive);
}

.hgc-sport-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.hgc-sport-dot--nba { background: #f97316; }
.hgc-sport-dot--mlb { background: #3b82f6; }

.hgc-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.hgc-team {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 30px;
    text-align: center;
}
.hgc-team--win { color: var(--text-primary); }

.hgc-score {
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 22px;
    text-align: center;
}
.hgc-score--win { color: var(--text-primary); }

.hgc-sep {
    color: var(--text-muted);
    font-weight: 400;
}

.hgc-pill {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Feature strip */
.home-features {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.home-feature-item {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
    animation: fadeUp 0.4s var(--ease-out) both;
}
.home-feature-item:hover {
    border-color: var(--border-mid);
    transform: translateY(-2px);
}

.home-feature-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}
.home-feature-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}
.home-feature-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.45;
}

@media (max-width: 900px) {
    .home-sports-grid { grid-template-columns: repeat(2, 1fr); }
    .home-dev-grid    { grid-template-columns: repeat(2, 1fr); }
    .home-features    { grid-template-columns: repeat(2, 1fr); }
    .home-hero { padding: 3rem 1.75rem 2.5rem; }
    .home-sport-card--featured { flex-direction: column; text-align: center; }
    .home-sport-card--featured .home-sport-desc { max-width: 100%; }
    .home-stats-strip { gap: 1.5rem; }
}

@media (max-width: 600px) {
    .home-hero { padding: 2.25rem 1.25rem 2rem; }
    .home-hero-title { letter-spacing: -2px; }
    .home-hero-sub { font-size: var(--text-base); }
    .home-sports-grid { gap: 0.75rem; }
    .home-sport-card { padding: 1.5rem 0.875rem 1.25rem; }
    .home-sport-icon { font-size: 2.25rem; }
    .home-features { gap: 0.75rem; }
    .home-dev-grid { grid-template-columns: 1fr; }
    .home-sport-card--featured { padding: 1.5rem 1.25rem; gap: 0.75rem; }
}

/* ── Player Detail ────────────────────────────────────────── */
.player-detail-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.player-detail-header {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
}

.back-button {
    background: var(--bg-interactive);
    border: 1px solid var(--border-mid);
    color: var(--text-secondary);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: 1.25rem;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    font-family: var(--font-sans);
}
.back-button:hover {
    background: var(--bg-interactive-hov);
    color: var(--text-primary);
    transform: translateX(-3px);
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-interactive);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), color var(--transition-fast);
    margin-bottom: 1.25rem;
}
.share-btn:hover { border-color: var(--border-mid); color: var(--text-primary); }
.share-btn svg { flex-shrink: 0; }

.player-detail-info {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.player-detail-avatar {
    width: 100px;
    height: 100px;
    background: var(--accent-subtle);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--accent-border);
    flex-shrink: 0;
}

.player-detail-name {
    font-size: var(--text-3xl);
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    letter-spacing: -0.5px;
}

.player-detail-meta {
    color: var(--text-muted);
    font-size: var(--text-base);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.player-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

.stats-card {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
}

.stat-item {
    text-align: center;
    padding: var(--space-4);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 900;
    margin-bottom: 0.4rem;
    line-height: 1;
}

.stat-label {
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.recent-games-list { display: flex; flex-direction: column; gap: 0.75rem; }

.recent-game-item {
    background: var(--bg-subtle);
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
}

.recent-game-date { color: var(--text-subtle); font-size: 0.78rem; margin-bottom: 0.4rem; font-weight: 600; }
.recent-game-matchup { color: var(--text-primary); font-weight: 700; margin-bottom: 0.4rem; display: flex; justify-content: space-between; font-size: 0.9rem; }

.shooting-stats-grid { display: flex; flex-direction: column; gap: 1.25rem; }
.shooting-stat-item { background: var(--bg-subtle); padding: var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--border-default); }
.shooting-stat-header { display: flex; justify-content: space-between; margin-bottom: 0.625rem; font-size: var(--text-sm); }
.shooting-stat-bar { width: 100%; height: 6px; background: var(--bg-interactive); border-radius: var(--radius-xs); overflow: hidden; }
.shooting-stat-fill { height: 100%; border-radius: var(--radius-xs); transition: width 0.5s var(--ease-out); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .header-inner { padding: 0 var(--space-4); gap: var(--space-2); }
    .brand-sub { display: none; }
    .sport-switcher .sport-btn { font-size: var(--text-xs); padding: 0.35rem 0.5rem; }
    .player-detail-grid { grid-template-columns: 1fr; }
    .builder-container  { grid-template-columns: 1fr; }
    .games-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    main { padding: 0 var(--space-4); margin: var(--space-4) auto; }
    .player-detail-info { flex-direction: column; text-align: center; }
    .player-detail-name { font-size: var(--text-2xl); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .leaderboards-grid { grid-template-columns: 1fr; }
    .search-meta { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
    .waffle-nav { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
    .waffle-nav-item { min-height: 58px; padding: 0.65rem 0.35rem; font-size: 0.72rem; }
    .waffle-nav-item .nav-icon { font-size: 1.1rem; }
    .waffle-panel-inner { padding: 0.875rem var(--space-4); }
}

/* ── Mobile Bottom Navigation ─────────────────────────────── */
.mobile-nav { display: none; }
.mobile-nav-label { display: none; }

@media (max-width: 768px) {
    /* On mobile, sub-nav is hidden — waffle button and bottom nav handle navigation */
    .sub-nav { display: none; }
    /* Also hide the sport-btn labels so only icons show */
    .sport-btn { font-size: 0; letter-spacing: 0; }
    .sport-btn::first-letter { font-size: var(--text-base); }

    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: var(--z-nav);
        background: var(--bg-mobile-nav);
        backdrop-filter: var(--blur-lg);
        border-top: 1px solid var(--border-default);
        box-shadow: var(--shadow-mobile-nav);
        padding: 0 0 env(safe-area-inset-bottom, 0);
    }

    .mobile-nav .nav-tab {
        flex: 1;
        min-width: 0;
        flex-direction: column;
        gap: 0.18rem;
        padding: 0.5rem 0.2rem 0.55rem;
        border-radius: 0;
        border: none;
        font-size: 0.52rem;
        letter-spacing: 0.2px;
        text-transform: uppercase;
        font-weight: 700;
        color: var(--text-muted);
        overflow: hidden;
    }
    .mobile-nav .nav-tab.active {
        color: var(--accent-light);
        background: transparent;
    }
    .mobile-nav .nav-tab.active .nav-icon {
        filter: drop-shadow(0 0 4px var(--accent));
    }
    .mobile-nav .nav-icon { font-size: 1.2rem; line-height: 1; }
    .mobile-nav-label { display: block; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: clip; }

    main { padding-bottom: 5rem; }
}

/* ── Global Search Button (header) ───────────────────────────── */

.search-global-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.search-global-btn:hover {
    background: var(--bg-interactive);
    color: var(--text-secondary);
    border-color: var(--border-default);
}

/* ── Global Search Overlay ────────────────────────────────────── */

.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 18, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: var(--z-modal, 900);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: clamp(4rem, 12vh, 8rem);
    animation: fadeIn 0.12s var(--ease-out) both;
}
.search-overlay[hidden] { display: none; }

.search-modal {
    width: min(620px, calc(100vw - 2rem));
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.15s var(--ease-out) both;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.search-modal-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-default);
}
.search-modal-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}
.search-modal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}
.search-modal-input::placeholder { color: var(--text-muted); font-weight: 400; }
.search-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all var(--transition-fast);
}
.search-modal-close:hover { background: var(--bg-interactive); color: var(--text-secondary); }

.search-modal-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.search-modal-results::-webkit-scrollbar { width: 4px; }
.search-modal-results::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.search-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.search-empty strong { color: var(--text-secondary); }

.search-group { padding: 0.25rem 0; }
.search-group + .search-group { border-top: 1px solid var(--border-default); }
.search-group-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast);
}
.search-result-item:hover,
.search-result-item--active { background: var(--bg-interactive); }

.search-result-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}
.search-result-avatar--team {
    background: var(--bg-interactive);
    color: var(--text-primary);
    font-size: 1rem;
    border-radius: var(--radius-sm);
}
.search-result-name {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-right: auto;
}
.search-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.15em 0.5em;
    border-radius: 999px;
    flex-shrink: 0;
}
.search-badge--nba {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}
.search-badge--mlb {
    background: rgba(6, 182, 212, 0.12);
    color: #22d3ee;
}

.search-modal-footer {
    display: flex;
    gap: 1.25rem;
    padding: 0.625rem 1rem;
    border-top: 1px solid var(--border-default);
    font-size: 0.7rem;
    color: var(--text-muted);
}
.search-modal-footer kbd {
    display: inline-block;
    background: var(--bg-interactive);
    border: 1px solid var(--border-mid);
    border-radius: 3px;
    padding: 0.1em 0.35em;
    font-family: var(--font-sans);
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-right: 0.25em;
}

@media (max-width: 768px) {
    .search-global-btn { width: 36px; height: 36px; }
    .search-overlay { padding-top: 1rem; align-items: flex-start; }
    .search-modal { width: 100vw; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
    .search-modal-results { max-height: 60vh; }
}

/* ── Light theme overrides for gradient/glow elements ─────────
   body::before uses raw rgba so we swap it here.
   ─────────────────────────────────────────────────────────── */
[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse 70% 50% at 15% 15%, rgba(91,112,224,0.07) 0%, transparent 65%),
        radial-gradient(ellipse 50% 70% at 85% 85%, rgba(100,80,180,0.05) 0%, transparent 65%);
}

/* Theme toggle button — placed inside waffle panel */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-interactive);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}
.theme-toggle-btn:hover {
    background: var(--bg-interactive-hov);
    color: var(--text-primary);
    border-color: var(--border-mid);
}
.theme-toggle-icon { font-size: 1rem; line-height: 1; }

.waffle-panel-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-default);
    margin-top: 0.25rem;
}

/* Universal section (Arcade — not sport-specific) */
.waffle-universal-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-default);
}
.waffle-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 0.25rem 0.4rem;
}

/* ── Back to top button ──────────────────────────────────────── */
.back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: calc(var(--z-nav) - 1);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-interactive);
    border: 1px solid var(--border-mid);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s, background var(--transition-fast);
}
.back-to-top:hover { background: var(--bg-interactive-hov); color: var(--accent-light); }
.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
@media (max-width: 768px) {
    .back-to-top { bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 0.75rem); right: 0.75rem; }
}

/* ── Accessibility: global focus rings ───────────────────────── */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}
/* Remove outline for mouse users but keep for keyboard */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[tabindex]:focus:not(:focus-visible) {
    outline: none;
}

/* ── Stat Glossary Tooltips ──────────────────────────────────── */
.stat-tip {
    cursor: help;
    border-bottom: 1px dashed var(--border-mid);
    display: inline-block;
    position: relative;
}
.stat-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.45;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    white-space: normal;
    max-width: 220px;
    width: max-content;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    z-index: 800;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.stat-tip:hover::after,
.stat-tip:focus-visible::after {
    opacity: 1;
}

/* ── CSV Export Button ───────────────────────────────────────── */
.lb-export-btn {
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 0.2rem 0.45rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.lb-export-btn:hover {
    background: var(--bg-interactive);
    border-color: var(--border-mid);
    color: var(--accent);
}

/* ── Fantasy Points Badge (leaderboard overlay) ──────────────── */
.lb-fp-badge {
    display: inline-block;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.25);
    color: #10b981;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    margin-left: 0.4rem;
    letter-spacing: 0.2px;
    vertical-align: middle;
}

/* ── Print Layout (ANN-004) ──────────────────────────────────── */
/* Optimised for announcer game-prep sheets and booth reference cards */

@media print {
    /* Hide chrome, nav, interactive elements */
    .app-header,
    .app-nav,
    .mobile-nav,
    #scoreTicker,
    .ticker-container,
    .back-button,
    .share-btn,
    .per36-btn,
    .compare-select,
    #pd-compare-chart-wrap,
    .builder-panel,
    .saved-stats-panel,
    .home-page,
    .arcade-grid,
    .player-notes-card,
    button[onclick*="backToPlayers"],
    button[onclick*="enterSport"],
    .lb-export-btn,
    .career-trend-controls,
    .career-trend-section > .chart-wrap { display: none !important; }

    /* Page setup */
    @page { size: letter portrait; margin: 1.5cm; }

    body {
        background: #fff !important;
        color: #111 !important;
        font-size: 11pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Remove shadows and blur */
    *, *::before, *::after {
        box-shadow: none !important;
        text-shadow: none !important;
        animation: none !important;
        transition: none !important;
    }

    /* Layout: single column */
    .player-detail-container,
    .player-detail-grid { display: block !important; }

    /* Cards */
    .stats-card {
        background: #fff !important;
        border: 1px solid #ccc !important;
        border-radius: 4px !important;
        margin-bottom: 0.6cm !important;
        padding: 0.4cm !important;
        page-break-inside: avoid;
    }

    /* Player hero */
    .player-detail-header {
        background: #f8f9fb !important;
        border-top-color: #555 !important;
        border-radius: 4px !important;
        padding: 0.5cm !important;
        margin-bottom: 0.5cm !important;
    }
    .player-detail-name { color: #111 !important; font-size: 18pt !important; }
    .player-detail-meta,
    .player-hero-pos,
    .bio-label,
    .bio-value { color: #333 !important; }

    /* Stat values */
    .stat-value,
    .career-season { color: #111 !important; }
    .stat-label,
    .stat-rank,
    .career-gp { color: #555 !important; }

    /* Tables */
    .career-table,
    .recent-games-list { font-size: 9pt !important; }
    .career-table thead th { background: #eee !important; color: #111 !important; }

    /* Charts — hide interactive charts except career table */
    .chart-wrap,
    .charts-duo { display: none !important; }

    /* Shooting card — keep bars */
    .shooting-stat-fill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

    /* Force page breaks between hero and stats */
    .player-detail-header { page-break-after: avoid; }
    .stats-card:last-child  { page-break-after: auto; }
}

