:root {
    --bg-dark: #0f172a;
    --accent-primary: #3b82f6;
    --accent-secondary: #6366f1;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --blocked: #475569;
    --text-muted: #64748b;

    /* Grid layout configurations */
    --first-col-width: 220px;
    --date-col-width: 50px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100dvh;
    min-height: 100vh;
}

.glass-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 0% 0%, rgba(59,130,246,0.1) 0%, transparent 50%),
                radial-gradient(circle at 100% 100%, rgba(99,102,241,0.1) 0%, transparent 50%);
    z-index: -1;
}

.app-container {
    height: 100dvh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover { color: var(--text-primary); }

.title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.title-group h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(59,130,246,0.2);
    color: var(--accent-primary);
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid rgba(59,130,246,0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.season-pill {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(10px);
}

.season-pill select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.blur-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.controls-bar {
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.input-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-wrap label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrap input {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
}

.control-divider {
    width: 1px;
    height: 2.5rem;
    background: var(--glass-border);
}

/* Custom Checkbox */
.check-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    user-select: none;
}

.check-container input { display: none; }

.checkmark {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--glass-border);
    border-radius: 0.4rem;
    transition: all 0.2s;
    position: relative;
}

.check-container input:checked ~ .checkmark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.check-container input:checked ~ .checkmark::after {
    content: '';
    position: absolute;
    left: 6px; top: 2px;
    width: 4px; height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Grid Container */
.grid-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.grid-wrapper {
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.planning-grid {
    display: grid;
    position: relative;
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
}

/* Cell Styles */
.grid-header-cell {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    padding: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
    text-align: center;
    position: sticky;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 45px;
    transition: all 0.2s ease;
}

.grid-header-cell.highlight {
    background: rgba(59, 130, 246, 0.35);
    box-shadow: inset 0 -2px 0 var(--accent-primary);
}

.grid-header-day {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.grid-header-label {
    font-size: 0.85rem;
    font-weight: 600;
}

/* .blocked-reason-vertical removed */

.grid-header-cell.blocked {
    background: rgba(71, 85, 105, 0.8);
    justify-content: flex-start;
    padding-top: 0.75rem;
}

.blocked-column-overlay {
    position: relative;
    pointer-events: none;
    clip-path: inset(0);
    z-index: 10;
    /* Diagonal Stripe Pattern */
    background: repeating-linear-gradient(
        45deg,
        rgba(15, 23, 42, 0.4),
        rgba(15, 23, 42, 0.4) 10px,
        rgba(15, 23, 42, 0.5) 10px,
        rgba(15, 23, 42, 0.5) 20px
    );
    background-size: 200% 200%;
    animation: stripeScroll 20s linear infinite;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes stripeScroll {
    from { background-position: 0 0; }
    to { background-position: 100% 100%; }
}



.grid-player-cell {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    border-right: 2px solid var(--glass-border);
    position: sticky;
    left: 0;
    z-index: 15;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.grid-player-cell.highlight {
    background: rgba(59, 130, 246, 0.35);
    color: #ffffff;
    box-shadow: inset -3px 0 0 var(--accent-primary);
}

.team-header-row {
    grid-column: 1 / -1;
    background: linear-gradient(90deg, rgba(59,130,246,0.15) 0%, transparent 100%);
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    left: 0;
    z-index: 10;
    display: flex;
    align-items: center;
}

.team-label-sticky {
    position: sticky;
    left: 1.5rem;
    white-space: nowrap;
}

.grid-cell {
    width: 50px;
    height: 50px;
    border-bottom: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.grid-cell:hover:not(.blocked) {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1.05);
    z-index: 5;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.available { color: var(--success); background: rgba(16, 185, 129, 0.1); }
.not-available { color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.maybe { color: var(--warning); background: rgba(245, 158, 11, 0.1); }
.blocked { background: var(--blocked); color: #fff; cursor: not-allowed; opacity: 0.5; }

.grid-cell.highlight {
    background: rgba(59, 130, 246, 0.08);
}
.grid-cell.highlight.available {
    background: rgba(16, 185, 129, 0.2);
}
.grid-cell.highlight.not-available {
    background: rgba(239, 68, 68, 0.2);
}
.grid-cell.highlight.maybe {
    background: rgba(245, 158, 11, 0.2);
}

/* Dashboard Buttons */
.primary-btn {
    background: var(--accent-primary);
    color: #fff;
    padding: 0.75rem 1.75rem;
    border: none;
    border-radius: 0.875rem;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn.glow {
    box-shadow: 0 0 20px rgba(59,130,246,0.2);
}

.primary-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(59,130,246,0.4);
}

.secondary-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.6rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.6rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ghost-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.info-pill {
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.2);
    color: var(--accent-primary);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Legend Styles */
.legend-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: default;
    user-select: none;
}

.legend-badge {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid var(--glass-border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.legend-badge.available {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.legend-badge.not-available {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.legend-badge.maybe {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
}

.legend-item:hover .legend-badge {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
}

.legend-toggle-btn {
    display: none;
}

.controls-collapsible {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    width: 100%;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 450px;
    padding: 2.5rem;
    z-index: 1001;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.form-group input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    padding: 0.875rem;
    font-family: inherit;
    outline: none;
    margin-bottom: 1.5rem;
}

.hidden { display: none !important; }

.animate-pop {
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Auto Save Indicator */
.save-indicator {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.25rem;
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.save-indicator.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.save-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 12px var(--warning);
}

.save-dot.success {
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    z-index: 100;
    gap: 1.5rem;
    color: var(--text-primary);
    animation: fadeIn 0.4s ease-out forwards;
}

.loader-spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 3px solid rgba(59, 130, 246, 0.15);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulse 2s ease-in-out infinite;
    letter-spacing: 0.05em;
}

.no-players-message {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.no-players-message h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.no-players-message p {
    color: var(--text-secondary);
    margin: 0;
}

.no-players-message a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.no-players-message a:hover {
    color: var(--accent-secondary);
}

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

@keyframes pulse {
    0%, 100% { opacity: 0.7; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

/* Mobile Responsiveness Viewport Adjustments */
@media (max-width: 768px) {
    :root {
        --first-col-width: 120px;
        --date-col-width: 44px;
    }

    .app-container {
        padding: 0.5rem;
        gap: 1rem;
    }

    .app-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding-bottom: 0.25rem;
    }

    .header-left {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
    }

    .back-link {
        font-size: 0.8rem;
        gap: 0.25rem;
    }

    .title-group h1 {
        font-size: 1.15rem;
    }

    .season-pill {
        padding: 0.35rem 0.6rem;
        gap: 0.4rem;
        font-size: 0.8rem;
    }

    .season-pill select {
        font-size: 0.8rem;
    }

    .season-pill svg {
        width: 14px;
        height: 14px;
    }

    .controls-bar {
        padding: 0.5rem 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .legend-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-family: inherit;
        font-size: 0.8rem;
        font-weight: 600;
        cursor: pointer;
        padding: 0.4rem 0.2rem;
        user-select: none;
        outline: none;
        transition: color 0.2s ease;
    }

    .legend-toggle-btn:active {
        color: var(--text-primary);
    }

    .toggle-btn-left {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .chevron-icon {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        color: var(--text-muted);
    }

    .controls-bar.expanded .chevron-icon {
        transform: rotate(180deg);
    }

    .controls-collapsible {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--glass-border);
        animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    .controls-bar.expanded .controls-collapsible {
        display: flex;
    }

    .control-divider {
        display: none;
    }

    /* Grid Cell Adjustments for narrower dimensions */
    .grid-cell {
        width: var(--date-col-width);
    }
    
    .grid-player-cell {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 0.25rem;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .info-pill {
        font-size: 0.75rem;
        padding: 0.5rem;
        width: 100%;
        justify-content: center;
    }
}

/* Landscape Tip */
.landscape-tip {
    display: none;
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent-primary);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    color: var(--text-primary);
    z-index: 2000;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    width: 90%;
    max-width: 450px;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tip-text { flex: 1; line-height: 1.4; }

.tip-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideUp {
    from { transform: translate(-50%, 100px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Landscape Phone Adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .landscape-tip {
        display: flex;
    }

    :root {
        --first-col-width: 120px;
        --date-col-width: 44px;
    }

    .app-container {
        padding: 0.25rem;
    }

    .app-header, .controls-bar {
        display: none !important;
    }

    .grid-cell {
        width: var(--date-col-width);
    }
    
    .grid-player-cell {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 0.25rem;
    }
}

/* Read Mode Overrides */
/* Save indicator remains visible for public edits */

