:root {
    --bg-color: #04070b;
    --sidebar-bg: rgba(13, 17, 23, 0.9);
    --card-bg: rgba(22, 27, 34, 0.7);
    --accent-primary: #00ff87;
    /* FPL Green */
    --accent-secondary: #37003c;
    /* FPL Purple */
    --accent-gradient: linear-gradient(135deg, #00ff87 0%, #02ef7e 50%, #05f0ff 100%);
    --text-main: #f0f6fc;
    --text-muted: #8b949e;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 12px 30px -5px rgba(0, 0, 0, 0.5);
    --btn-bg: rgba(255, 255, 255, 0.05);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    min-width: 320px;
    /* Standard mobile minimum */
}

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    height: 100%;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--accent-primary);
    margin-top: 0.25rem;
    font-style: italic;
    opacity: 0.8;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

input[type="text"],
select {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
}

select option {
    color: #000;
    /* Ensures unselected options are visible on light backgrounds */
    background: #fff;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--accent-gradient);
    color: #000;
    padding: 1rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 15px rgba(0, 255, 135, 0.2);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 135, 0.4);
    filter: brightness(1.1);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

#btn-fetch {
    margin-top: 0.5rem;
}

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

.playback-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.btn-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-circle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.btn-circle:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(1.1);
}

.btn-circle:hover:not(:disabled) svg {
    transform: scale(1.1);
}

.btn-circle:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Range Input Styling */
input[type="range"] {
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 135, 0.5);
}

/* Status Panel */
.status-panel {
    margin: 0 0 0.5rem 0;
}

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

.progress-container {
    margin-bottom: 0.75rem;
}

.progress-label {
    font-size: 0.7rem;
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.progress-bar-bg {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.footer {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.donation-box {
    margin-top: auto;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.donation-box p {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.4;
    font-weight: 400;
}

.donation-box img {
    height: 60px;
    transition: transform 0.2s ease;
}

.donation-box img:hover {
    transform: scale(1.05);
}

/* Main Content Area */
.chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    position: relative;
    background: radial-gradient(circle at 50% -20%, rgba(99, 102, 241, 0.15), transparent 60%);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.league-info h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.league-info p {
    font-size: 1.1rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.chart-container {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* D3 Styles */
.bar {
    /* Transitions handled by D3 */
}

.bar-label {
    font-weight: 600;
    font-size: 14px;
    fill: white;
}

.bar-points {
    font-weight: 800;
    font-size: 14px;
    fill: #ffffff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.axis-label {
    fill: var(--text-muted);
    font-size: 12px;
}

.grid-line {
    stroke: rgba(255, 255, 255, 0.05);
}

/* GW Slider at bottom */
.gw-slider-container {
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
}

#gw-range {
    flex: 1;
}

#gw-range::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    background: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 255, 135, 0.6);
}

/* Chip Badges */
.chip-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 3px;
    text-transform: uppercase;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chip-TC {
    background: #ffd700;
    color: #000;
}

.chip-WC {
    background: #00ff87;
    color: #000;
    padding-left: 4px;
    padding-right: 4px;
    letter-spacing: -0.04em;
}

.chip-FH {
    background: #37003c;
    color: #fff;
}

.chip-BB {
    background: #05f0ff;
    color: #000;
}

/* Firework Burst Effect */
@keyframes firework-burst {
    0% {
        transform: scale(0);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

.firework-particle {
    pointer-events: none;
    transform-origin: center;
    transform-box: fill-box;
    animation: firework-burst ease-out forwards;
}

.chip-active-text {
    font-size: 13px;
    font-weight: 900;
    fill: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Rank Arrows */
.rank-arrow {
    font-size: 10px;
    font-weight: 900;
}

.rank-up {
    fill: #00ff87;
}

.rank-down {
    fill: #f43f5e;
}

.rank-same {
    fill: #94a3b8;
}

/* Transfer Hits */
.hit-label {
    font-size: 12px;
    font-weight: 800;
    fill: #f43f5e;
    text-shadow: 0 0 5px rgba(244, 63, 94, 0.4);
}

.main-controls {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

/* Sidebar Specific (Desktop) */
.sidebar .main-controls {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 1rem;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
}

.sidebar .main-controls .control-group,
.sidebar .main-controls .race-controls {
    width: 100%;
    min-width: 0;
    flex: none;
}

.sidebar .main-controls .race-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar .view-limit-group {
    max-width: none;
}

/* Chart Area Specific (Mobile) */
.chart-area .main-controls {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
}

/* Mobile Responsive Adjustments */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 100;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.action-btn {
    display: flex;
    width: 56px;
    height: 56px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-main);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    position: relative;
    z-index: 100;
}

.action-btn::after {
    content: "🔗 Link Copied";
    position: absolute;
    top: 65px;
    right: 0;
    background: var(--accent-primary);
    color: #000;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 255, 135, 0.3);
    transform: translateY(-10px);
}

.action-btn.success::after {
    opacity: 1;
    transform: translateY(0);
}

.action-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

.action-btn.success {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 40;
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .app-container {
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100dvh;
        z-index: 50;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
        background: rgba(13, 17, 23, 0.95);
    }

    .sidebar .logo {
        padding-left: 3.5rem;
        /* Space for fixed toggle button */
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar.active+.sidebar-overlay {
        display: block;
    }

    .chart-area {
        flex: 1;
        padding: 0.5rem;
        padding-top: 4.5rem;
        /* Increased to clear fixed toggle button */
        display: flex;
        flex-direction: column;
        overflow: hidden;
        gap: 0.25rem;
    }

    .chart-header {
        margin-bottom: 1rem;
        padding-left: 3.5rem;
        /* Space for fixed toggle button */
    }

    .league-info h2 {
        font-size: 1.5rem;
    }

    .league-info p {
        font-size: 0.9rem;
    }

    .chart-container {
        flex: 1;
        min-height: 0;
        height: auto;
    }

    .main-controls {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        margin-top: 0.5rem;
        border-radius: 16px;
    }

    .view-limit-group {
        flex: 1;
        flex-direction: column !important;
        align-items: flex-start;
        gap: 0.5rem;
        padding-right: 0.5rem;
        border-right: 1px solid var(--border-color);
    }

    .view-limit-group label {
        font-size: 0.65rem;
    }

    .view-limit-group select {
        width: 100%;
        padding: 0.4rem;
        font-size: 0.85rem;
    }

    .main-controls .race-controls {
        flex: 1;
        display: flex;
        flex-direction: column-reverse;
        gap: 1.25rem;
        align-items: center;
    }

    .playback-buttons {
        gap: 0.5rem;
        margin-bottom: 0;
    }

    .race-controls .control-group {
        width: 100%;
        gap: 0.5rem;
    }

    .race-controls .control-group label {
        font-size: 0.65rem;
        text-align: center;
    }

    .gw-slider-container {
        margin-top: 0.5rem;
        padding: 0.5rem 0.75rem;
        gap: 0.75rem;
        font-size: 0.8rem;
    }

    /* Smaller indicators for mobile */
    .chip-badge {
        font-size: 8px;
        padding: 1px 4px;
        margin-left: 2px;
    }

    .chip-active-text {
        font-size: 11px;
    }

    .rank-arrow {
        font-size: 8px;
    }

    .bar-points {
        font-size: 12px;
    }

    .bar-label {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    }

    .hit-label {
        font-size: 10px;
    }
}