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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Utility */
.hidden { display: none !important; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

header {
    background: white;
    padding: 40px 30px 30px;
    border-bottom: 1px solid #e9ecef;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 12px;
    font-weight: 700;
    color: #2c3e50;
    text-align: left;
}

.description {
    margin-bottom: 25px;
}

.tagline {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 15px;
}

.disclaimer {
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
    margin: 0;
    padding: 12px 16px;
    background: rgba(108, 117, 125, 0.1);
    border-left: 3px solid #6c757d;
    border-radius: 0 4px 4px 0;
}

.disclaimer strong {
    color: #495057;
    font-style: normal;
}

.search-container {
    max-width: 300px;
}

#searchInput {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    background: white;
    color: #495057;
    transition: border-color 0.2s ease;
}

#searchInput:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

#searchInput::placeholder {
    color: #6c757d;
}

.admin-panel {
    background: #f8f9fa;
    padding: 25px 30px;
    border-bottom: 1px solid #dee2e6;
}

.admin-panel.hidden {
    display: none;
}

.admin-panel h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 600;
}

.add-player-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.add-player-form input,
.add-player-form select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.add-player-form input {
    min-width: 200px;
    flex: 1;
}

.add-player-form select {
    min-width: 180px;
}

.add-player-form input:focus,
.add-player-form select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

#addPlayerBtn {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

#addPlayerBtn:hover {
    background: #0056b3;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}

.save-all-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-all-btn:hover:not(:disabled) {
    background: #218838;
}

.save-all-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.unsaved-indicator {
    color: #ffc107;
    font-size: 16px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.save-status {
    font-size: 14px;
    font-weight: 500;
    min-width: 120px;
}

.save-status.saving {
    color: #007bff;
}

.save-status.success {
    color: #28a745;
}

.save-status.error {
    color: #dc3545;
}

.admin-note {
    margin-top: 10px;
    color: #495057;
    font-size: 13px;
}

.leaderboard {
    background: white;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 80px 1fr 120px;
    background: #495057;
    color: white;
    padding: 16px 30px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #dee2e6;
}

.actions-col.hidden {
    display: none;
}

.leaderboard-header.no-admin {
    grid-template-columns: 80px 1fr;
}

.player-list {
    background: white;
}

.player-item {
    display: grid;
    grid-template-columns: 80px 1fr 120px;
    align-items: center;
    padding: 18px 30px;
    border-bottom: 1px solid #e9ecef;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
    background: white;
}

.player-item.no-admin {
    grid-template-columns: 80px 1fr;
}

.player-item:hover {
    background: #f8f9fa;
}

.player-item.dragging {
    opacity: 0.6;
    background: #e9ecef;
    z-index: 1000;
    cursor: grabbing;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.player-item.drag-over {
    border-top: 2px solid #007bff;
    background: rgba(0, 123, 255, 0.05);
}

.rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rank-input {
    width: 50px;
    height: 35px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    border: 2px solid #007bff;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    outline: none;
    transition: border-color 0.2s ease;
}

.rank-input:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.rank-input:hover {
    border-color: #0056b3;
}

.rank-change {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 12px;
    display: inline-block;
}

.rank-change.positive {
    background: #d4edda;
    color: #155724;
}

.rank-change.negative {
    background: #f8d7da;
    color: #721c24;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-flag {
    width: 32px;
    height: 24px;
    object-fit: cover;
    border: 1px solid #dee2e6;
    border-radius: 2px;
}

.player-name {
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c3e50;
    user-select: none;
    cursor: default;
}

/* Make name selectable only in admin mode */
.admin-mode .player-name {
    user-select: text;
}

.player-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.player-actions.hidden {
    display: none;
}

.player-name-edit,
.player-nationality-edit {
    padding: 4px 8px;
    border: 1px solid #007bff;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: 500;
    outline: none;
    background: white;
    pointer-events: none; /* Disable direct interaction */
    margin-right: 8px;
}

.player-name-edit {
    min-width: 200px;
}

.player-nationality-edit {
    min-width: 150px;
}

/* Only enable edit inputs in admin mode when visible */
.admin-mode .player-name-edit:not(.hidden),
.admin-mode .player-nationality-edit:not(.hidden) {
    pointer-events: auto;
}

.player-name-edit:focus,
.player-nationality-edit:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.edit-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.edit-btn:hover {
    background: #218838;
}

.save-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.save-btn:hover {
    background: #0056b3;
}

.cancel-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.cancel-btn:hover {
    background: #545b62;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.remove-btn:hover {
    background: #c82333;
}

.drag-placeholder {
    height: 4px;
    background: #667eea;
    margin: 0 30px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drag-placeholder.active {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .leaderboard-header,
    .player-item {
        grid-template-columns: 60px 1fr 140px;
        padding: 15px 20px;
    }
    
    .leaderboard-header.no-admin,
    .player-item.no-admin {
        grid-template-columns: 60px 1fr;
    }
    
    .add-player-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .add-player-form input,
    #addPlayerBtn {
        width: 100%;
    }
    
    .player-flag {
        width: 24px;
        height: 18px;
    }
    
    .player-name {
        font-size: 1rem;
    }
    
    .player-name-edit {
        font-size: 1rem;
        min-width: 150px;
    }
    
    .player-actions {
        gap: 4px;
    }
    
    .edit-btn, .save-btn, .cancel-btn, .remove-btn {
        padding: 4px 6px;
        font-size: 11px;
    }
    
    .rank {
        font-size: 1.2rem;
    }
}
