﻿:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-green: #4ade80;
    --accent-gold: #facc15;
    --accent-red: #ef4444;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-hover: rgba(56, 189, 248, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

.background-globes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(74, 222, 128, 0.15) 0%, transparent 40%);
    pointer-events: none;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Header & Nav */
.glass-header {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 32px;
}

/* Week Selector */
.week-selector-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.week-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.week-select option {
    background: #0f172a;
    color: var(--text-primary);
}

.view-toggles {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--glass-border);
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: slideUp 0.4s ease-out;
}

.user-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.user-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.user-btn:hover {
    background: var(--accent-blue);
    color: #000;
    transform: translateY(-2px);
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px;
    transition: opacity 0.5s ease;
}

.app-container.hidden {
    opacity: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

h1 {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(to right, var(--text-primary), var(--accent-blue));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Games Grid */
.games-section {
    margin-top: 40px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.game-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.game-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.game-status {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
}

.status-final {
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-green);
}

.teams-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.team-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.team-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.team-option.selected {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-blue);
}

.team-option.winner {
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.1), transparent);
    border-left: 2px solid var(--accent-green);
}

.team-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.team-details {
    display: flex;
    flex-direction: column;
}

.team-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.team-record {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.team-score {
    font-weight: 700;
    font-size: 1.2rem;
}

.check-icon {
    color: var(--accent-green);
    font-weight: bold;
    font-size: 1.2rem;
}

/* Recap Matrix */
.recap-container {
    overflow-x: auto;
    padding: 0;
    /* Let table fill */
}

.recap-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.recap-table th,
.recap-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.recap-table th {
    background: rgba(15, 23, 42, 0.95);
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 600;
    color: var(--text-secondary);
}

.pick-cell {
    font-weight: 500;
}

.pick-cell.correct {
    color: var(--accent-green);
    background: rgba(74, 222, 128, 0.05);
}

.pick-cell.incorrect {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.05);
}

.pick-cell.neutral {
    color: var(--text-secondary);
}

.late-icon {
    margin-left: 6px;
    font-size: 0.9rem;
    cursor: help;
}

.matchup-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mini-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Standings */
.standings-section {
    margin-top: 60px;
}

.standings-list {
    padding: 0;
    overflow: hidden;
}

.standing-row {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.standing-row:last-child {
    border-bottom: none;
}

.user-rank {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-number {
    font-weight: 700;
    color: var(--accent-gold);
    width: 24px;
}

.user-score {
    font-weight: 600;
    color: var(--accent-blue);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.clickable-header {
    cursor: pointer;
    transition: color 0.2s;
}

.clickable-header:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.2s;
}

.clickable-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.week-select optgroup {
    background: #0f172a;
    color: var(--text-secondary);
    font-style: normal;
    font-weight: 600;
}

.tbd-game {
    cursor: not-allowed !important;
    opacity: 0.6;
    filter: grayscale(100%);
    pointer-events: none;
}

@media (max-width: 768px) {

    /* Header Grid Layout */
    .header-content {
        display: grid;
        grid-template-columns: 1fr auto;
        /* Title | User */
        grid-template-areas:
            "title user"
            "selector selector";
        gap: 16px 0;
        align-items: center;
        width: 100%;
        padding: 0 16px;
    }

    /* Flatten header-main to let children participate in Grid */
    .header-main {
        display: contents;
    }

    .header-main h1 {
        grid-area: title;
        font-size: 1.5rem;
        margin: 0;
    }

    .user-profile {
        grid-area: user;
        width: auto;
    }

    .week-selector-container {
        grid-area: selector;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .week-select {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        margin-bottom: 8px;
        /* Avoid iOS zoom */
    }

    .view-toggles {
        width: 100%;
        display: flex;
    }

    .toggle-btn {
        flex: 1;
        padding: 12px;
        justify-content: center;
    }

    /* Games Grid */
    .games-grid {
        grid-template-columns: 1fr;
    }

    .game-card {
        padding: 16px;
        gap: 12px;
    }

    .team-option {
        padding: 16px;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        margin: 10px;
    }

    /* Recap Matrix: Mobile Card View */
    .recap-grid-container {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .recap-header-row {
        display: none;
    }

    .recap-row {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        padding: 12px;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .recap-cell.game-cell {
        grid-column: 1 / -1;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        padding: 8px;
        margin-bottom: 8px;
        display: flex;
        justify-content: center;
        border: none;
        box-shadow: none;
    }

    .recap-cell.status-cell {
        display: none;
    }

    .recap-cell.pick-cell {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 6px;
        text-align: center;
        font-size: 0.9rem;
    }

    .recap-cell.pick-cell::before {
        content: attr(data-label);
        font-size: 0.75rem;
        color: var(--text-secondary);
        text-transform: uppercase;
        font-weight: 600;
        margin-bottom: 2px;
    }

    .recap-cell {
        padding: 0;
    }
}

/* Desktop Recap Grid */
/* Desktop Recap Grid */
@media (min-width: 769px) {
    .recap-grid-container {
        display: table;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    .recap-header-row,
    .recap-row {
        display: table-row;
    }

    .recap-header-row {
        background: rgba(15, 23, 42, 0.95);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .recap-cell {
        display: table-cell;
        padding: 16px;
        vertical-align: middle;
        white-space: nowrap;
        border-bottom: 1px solid var(--glass-border);
    }

    /* Sticky Columns */
    .recap-cell.game-cell {
        position: sticky;
        left: 0;
        background: #0f172a;
        z-index: 5;
        border-right: 1px solid var(--glass-border);
        text-align: left;
        min-width: 150px;
    }

    .recap-header-row .recap-cell.game-cell {
        z-index: 20;
    }

    .recap-cell.status-cell {
        border-right: 1px solid var(--glass-border);
        text-align: left;
        padding-left: 24px;
        position: static;
        background: transparent;
    }

    .recap-cell.header-cell {
        font-weight: 600;
        color: var(--text-secondary);
        background: rgba(15, 23, 42, 0.95);
    }
}

/* Winner & Score Styling */
.team-option.winner-card {
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.15), rgba(74, 222, 128, 0.05));
    border-left: 3px solid var(--accent-green);
}

.winner-badge {
    font-size: 0.7rem;
    background: var(--accent-green);
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 700;
    vertical-align: middle;
}

.team-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-score {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 40px;
    text-align: center;
}


.team-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.winner-badge {
    margin-left: 0;
    /* Reset previous margin */
    white-space: nowrap;
    /* Prevent badge text wrapping */
    flex-shrink: 0;
    /* Keep badge distinct */
}


/* User Switcher Dropdown */
.user-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    min-width: 100px;
}

.user-select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
}

.user-select option {
    background: #0f172a;
    color: var(--text-primary);
    padding: 8px;
}


/* Animations */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-20deg);
    }

    60% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}


.check-icon {
    color: var(--accent-green);
    font-weight: bold;
    font-size: 1.2rem;
    /* animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; */
}

.team-option:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.08);
}

.team-option:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.08);
    transition: transform 0.05s;
}