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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #121220;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

.container {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    background: #131d35;
    border-radius: 0;
    padding: 15px;
    box-shadow: none;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #2a2a4a;
}

header h1 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 5px;
}

header p {
    color: #a0a0c0;
    font-size: 0.9rem;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    width: 100%;
    text-align: center;
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.week-selector label {
    color: #fff;
    font-size: 0.9rem;
}

.week-selector select {
    padding: 5px 10px;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    background: #16213e;
    color: #fff;
    cursor: pointer;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.submit-btn, .clear-btn {
    padding: 4px 8px;
    margin: 0 auto;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    display: inline-block;
    white-space: nowrap;
}

.submit-btn {
    background: #e94560;
    color: white;
}

.submit-btn:not(:disabled):hover {
    background: #c73650;
}

.submit-btn:disabled {
    background: #4a4a6a;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Mobile-first unified row-based lineup comparison */
.lineup-comparison {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    align-items: center;
}

/* Headers row - uses same position-row structure */
.headers-row .lineup-container {
    background: transparent;
    border-radius: 8px;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}


.lineup-comparison.mobile-initial .optimal-lineup {
    display: none;
}

.lineup-comparison.expanded .optimal-lineup {
    display: block;
}

/* Position row layout - each row contains user slot, label, and optimal slot */
.position-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    justify-content: center;
}

/* Position rows container */
.position-rows {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* User position slot - always visible, always same size */
.position-row .user-slot {
    flex: 0 0 350px;
    max-width: 350px;
    width: 350px;
}

/* Position label - standalone element, ALWAYS visible to the right of user slot */
.position-row .position-label {
    background: #319FE8;
    color: white;
    padding: 8px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    width: 45px;
    text-align: center;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transform: scaleX(1);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
}

/* Header position label (Pos) - different color, placed after general rule */
.position-row.headers-row .position-label {
    background: #7b68ee;
    padding: 0px;
    margin: 0px;
    min-height: 20px;
    height: 30px;
    font-size: 0.55rem;
}


/* Optimal position slot - hidden initially, slides from behind label */
.position-row .optimal-slot {
    flex: 0 0 350px;
    max-width: 350px;
    width: 350px;
    transform: translateX(-53px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 1;
}

.lineup-comparison.mobile-initial .position-row .optimal-slot {
    display: none;
}

.lineup-comparison.expanded .position-row .optimal-slot {
    display: block;
    transform: translateX(0);
    opacity: 1;
}

.lineup-header {
    text-align: center;
    margin: 0;
    padding: 4px 8px;
    border-bottom: none;
    position: relative;
}

.lineup-header h3 {
    color: #fff;
    font-size: 0.9rem;
    margin: 0 0 2px 0;
    font-weight: 600;
}

.lineup-score {
    color: #ffd700;
    font-weight: bold;
    font-size: 0.85rem;
}

/* Sleeper-style optimal lineup player cards */
.optimal-lineup .position-slot {
    background: transparent;
    border-radius: 8px;
    padding: 0;
    min-height: 50px;
    transition: all 0.3s ease;
    box-shadow: none;
}

.optimal-lineup .position-slot:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    background: transparent;
}

.optimal-lineup .position-slot.filled {
    background: transparent;
    border-color: #4CAF50;
    box-shadow: none;
}

/* Ensure optimal slot content is properly aligned when filled */
.optimal-slot.filled {
    display: flex;
    align-items: center;
}

.optimal-slot.filled .player-info {
    display: flex;
    flex-direction: column;
}

/* Optimal player row - points left, name right on same line */
.optimal-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.optimal-player-row .player-points-display {
    color: #4CAF50;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: left;
}

.optimal-player-row .player-name {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.optimal-slot .player-team {
    color: #4CAF50;
    font-size: 0.75rem;
    text-align: right;
    margin-top: 4px;
    width: 100%;
}

.optimal-lineup .position-label {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    width: 45px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.optimal-lineup .player-details {
    color: #fff;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.optimal-lineup .player-name-team {
    justify-content: flex-end;
}

.optimal-lineup .player-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
}

.optimal-lineup .player-team {
    color: #4CAF50;
    font-size: 0.75rem;
    font-weight: 500;
}

.optimal-lineup .player-points {
    color: #4CAF50;
    font-size: 0.9rem;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Optimal lineup specific player-info layout */
.optimal-lineup .player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px;
}

.optimal-lineup.filled .player-info,
.optimal-slot.filled .player-info {
    justify-content: space-between;
}

.optimal-lineup .player-points-display,
.optimal-slot .player-points-display {
    color: #4CAF50;
    font-size: 0.9rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    text-align: left;
}

.optimal-lineup .player-details,
.optimal-slot .player-details {
    color: #fff;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    flex-shrink: 0;
    text-align: right;
    margin-left: auto;
}

.optimal-lineup {
    border-left: none;
    background: transparent;
}

.user-lineup {
    border-left: none;
    background: transparent;
}

/* Enhanced highlight for different/same players in optimal lineup */
/* .different-player {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.15) 0%, rgba(233, 69, 96, 0.08) 100%) !important;
    border: 1px solid rgba(233, 69, 96, 0.4) !important;
    box-shadow: 0 2px 12px rgba(233, 69, 96, 0.2) !important;
}

.same-player {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2) 0%, rgba(76, 175, 80, 0.1) 100%) !important;
    border: 1px solid rgba(76, 175, 80, 0.5) !important;
    box-shadow: 0 2px 12px rgba(76, 175, 80, 0.25) !important;
}

.same-player .position-label {
    background: linear-gradient(135deg, #76FF03 0%, #64DD17 100%) !important;
    color: #1a1a1a !important;
    font-weight: 800;
}

.different-player .position-label {
    background: linear-gradient(135deg, #FF5722 0%, #D32F2F 100%) !important;
    animation: pulse 2s infinite;
} */

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 2px 8px rgba(233, 69, 96, 0.4);
    }
}

/* Comparison summary styles */
.total-comparison {
    background: transparent;
    padding: 8px 0;
    margin-top: 12px;
}

.comparison-summary {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.score-item {
    text-align: center;
    min-width: 80px;
}

.score-label {
    display: block;
    color: #a0a0c0;
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.score-value {
    display: block;
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
}

.score-value.positive {
    color: #4CAF50;
}

.score-value.negative {
    color: #e94560;
}

/* Ensure proper hiding of optimal lineup elements */
.hidden {
    display: none !important;
}

/* Player stats styling */
.player-stats {
    font-size: 0.75rem;
    color: #d5dbc8;
    margin-top: 4px;
    line-height: 1.2;
    width: 100%;
}

.optimal-slot .player-stats {
    text-align: right;
}

/* Player info layout styling */
.player-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name-team {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
}

.player-name {
    font-weight: bold;
    color: #fff;
    font-size: 0.9rem;
}

.player-team {
    color: #45e6a7;
    font-size: 0.75rem;
    text-align: left;
    margin-top: 4px;
}

.player-points-display {
    font-weight: bold;
    color: #45e6a7;
    font-size: 0.85rem;
    margin-left: 8px;
    white-space: nowrap;
}

.user-slot .player-header-row .player-points-display {
    margin-left: auto;
    text-align: right;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        padding: 10px;
        margin: 0;
    }

    /* Keep position rows centered */
    .position-row {
        justify-content: space-around;
        width: 100%;
        gap: 4px; /* Small gap for better spacing */
        margin-bottom: 5px;
    }

    /* Allow slots to expand on mobile, remove borders, but maintain centering */
    .position-row .user-slot,
    .position-row .optimal-slot {
        flex: 0 1 auto;
        max-width: 45%;
        width: auto;
        min-width: 40%;
        border: none;
        box-shadow: none;
        padding: 0;
        margin: 0 2px; /* Add small margin for equal spacing */
    }

    .position-slot {
        border: none;
        background: transparent;
        padding: 0;
    }

    .position-row .position-label {
        width: 40px;
        font-size: 0.6rem;
        flex-shrink: 0;
    }

    .comparison-summary {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    /* Mobile-specific player layout */
    .position-slot .player-info {
        display: flex;
        flex-direction: column;
    }

    .position-slot .player-details {
        width: 100%;
    }

    .position-slot .player-header-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .position-slot .player-name-team {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex: 1;
    }

    .position-slot .player-name {
        font-size: 0.85rem;
    }

    .position-slot .player-points-display {
        font-size: 0.8rem;
        margin-left: auto;
    }

    .position-slot .player-team {
        font-size: 0.7rem;
        display: block;
        width: 100%;
        margin-top: 4px;
    }

    .player-stats {
        font-size: 0.7rem;
        width: 100%;
        margin-top: 4px;
        word-wrap: break-word;
        line-height: 1.3;
        text-align: left;
    }

    /* For optimal lineup on mobile - points left of name */
    .optimal-slot .player-info {
        display: flex;
        flex-direction: column;
    }

    .optimal-slot .player-points-display {
        display: inline-block;
        margin-right: 8px;
        font-weight: bold;
    }

    .optimal-slot .player-details {
        width: 100%;
    }

    /* Make player-points-display flush left */
    .optimal-slot .player-details .player-points-display {
        float: left;
        margin-left: 0;
        padding-left: 0;
    }

    .optimal-slot .player-name {
        display: inline;
    }

    .optimal-slot .player-team {
        display: block;
        margin-top: 4px;
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    /* Maintain centering on small screens */
    .position-row {
        justify-content: space-around;
    }

    .position-row .user-slot,
    .position-row .optimal-slot {
        flex: 0 1 auto;
        max-width: 42%;
        width: auto;
        min-width: 38%;
        padding: 0;
        border: none;
        margin: 0 1px; /* Add small margin for equal spacing on very small screens */
    }

    .position-row .position-label {
        width: 35px;
        font-size: 0.55rem;
        padding: 4px 2px;
    }
}

.clear-btn {
    background: #533483;
    color: white;
}

.clear-btn:hover {
    background: #432a6a;
}

.lineup-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.position-slot {
    background: transparent;
    border-radius: 6px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 45px;
}

.position-slot:not(.searching) {
    display: flex;
    align-items: center;
}

.position-slot.searching {
    display: block;
    cursor: default;
}

.position-slot.searching .player-info,
.position-slot.searching .player-points {
    display: none;
}

.position-slot:hover {
    background: transparent;
    border-color: #3a3a6a;
}

.position-slot.filled {
    background: transparent;
    border-color: #e94560;
}

.position-label {
    background: #e94560;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    width: 45px;
    text-align: center;
}

.position-slot.filled .position-label {
    background: #48bb78;
}

.player-info {
    flex: 1;
    display: flex;
    align-items: center;
}

.empty-slot {
    color: #6a6a8a;
    font-size: 1.2rem;
    font-weight: 300;
}

.player-details {
    color: #fff;
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.player-points {
    color: #ffd700;
    font-size: 0.9rem;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}

.player-points.hidden {
    color: #4a4a6a;
}

.player-points.revealed {
    animation: revealPoints 0.5s ease;
}

@keyframes revealPoints {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.total-score {
    text-align: center;
    padding: 20px;
    background: #e94560;
    border-radius: 8px;
    color: white;
    margin-top: 20px;
}

.total-score.hidden {
    display: none;
}

.total-score h2 {
    font-size: 1.3rem;
}

#totalScore {
    font-size: 2rem;
    font-weight: 700;
}

/* Inline Search Styles */
.inline-search {
    margin-top: 8px;
    animation: slideDown 0.2s ease;
}

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

.search-input-container {
    position: relative;
    width: 100%;
}

.inline-player-search {
    width: 100%;
    padding: 8px 12px 8px 35px;
    border: 2px solid #2a2a4a;
    border-radius: 6px;
    background: #0f3460;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.inline-player-search:focus {
    border-color: #e94560;
}

.inline-player-search::placeholder {
    color: #6a6a8a;
}

.inline-player-search:disabled {
    background: #1a4570;
    color: #ffd700;
    cursor: default;
}

.search-input-container::before {
    content: '🔍';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #6a6a8a;
    pointer-events: none;
}

.inline-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #0f3460;
    border: 2px solid #2a2a4a;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.inline-dropdown.active {
    display: block;
}

.inline-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    color: white;
    font-size: 0.9rem;
    border-bottom: 1px solid #1a2540;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inline-dropdown-item:hover,
.inline-dropdown-item.selected {
    background: #1a4570;
}

.inline-dropdown-item:last-child {
    border-bottom: none;
}

.inline-player-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.inline-player-option-name {
    font-weight: 600;
}

.inline-player-option-year {
    color: #a0a0c0;
    font-size: 0.85rem;
}

.year-select .inline-player-option-year {
    color: #e94560;
    font-weight: 600;
}



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

/* Optimal Comparison Styles */
.optimal-comparison {
    background: #0f3460;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    color: white;
}

.optimal-comparison h3 {
    margin: 0 0 15px 0;
    color: #ffd700;
    text-align: center;
    font-size: 1.1rem;
}

.comparison-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.comparison-stats.above-optimal {
    border-left: 4px solid #48bb78;
}

.comparison-stats.below-optimal {
    border-left: 4px solid #e94560;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #1a4570;
    border-radius: 6px;
}

.stat .label {
    color: #a0a0c0;
    font-size: 0.85rem;
}

.stat .value {
    font-weight: 700;
    font-size: 0.9rem;
}

.stat .value.positive {
    color: #48bb78;
}

.stat .value.negative {
    color: #e94560;
}

.improvement-suggestions {
    border-top: 1px solid #2a2a4a;
    padding-top: 15px;
}

.improvement-suggestions h4 {
    margin: 0 0 10px 0;
    color: #ffd700;
    font-size: 0.9rem;
}

.suggestion {
    padding: 8px 12px;
    background: #16213e;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.3;
}

.suggestion:last-child {
    margin-bottom: 0;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #16213e;
    margin: 5% auto;
    padding: 0;
    border: 2px solid #2a2a4a;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #2a2a4a;
    background: #0f3460;
    border-radius: 10px 10px 0 0;
}

.modal-header h2 {
    color: #ffd700;
    margin: 0;
    font-size: 1.4rem;
}

.close {
    color: #a0a0c0;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 20px;
}

.close:hover {
    color: #e94560;
}

.modal-body {
    padding: 20px;
    color: white;
}

.modal-body h3 {
    color: #e94560;
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    margin: 10px 0;
    line-height: 1.5;
    color: #d0d0e0;
}

.modal-body ul {
    margin: 10px 0;
    padding-left: 20px;
}

.modal-body li {
    margin: 8px 0;
    line-height: 1.5;
    color: #d0d0e0;
}

.modal-body .scoring-type {
    background: #1a4570;
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
}

.modal-body .scoring-type h4 {
    color: #ffd700;
    margin: 0 0 8px 0;
    font-size: 0.95rem;
}

.modal-body .scoring-type p {
    margin: 4px 0;
    font-size: 0.9rem;
}

/* Additional responsive adjustments for very small screens */
@media (max-width: 480px) {
    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        padding: 8px;
    }

    header h1 {
        font-size: 1.3rem;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .comparison-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .optimal-comparison {
        padding: 15px;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .week-selector {
        justify-content: center;
    }

    .action-buttons {
        justify-content: center;
    }
}