/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: 
        linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%),
        radial-gradient(circle at 20% 80%, rgba(120, 200, 80, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(102, 126, 234, 0.2) 0%, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card h2 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: end;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.vs {
    font-weight: bold;
    color: #667eea;
    font-size: 1.2rem;
    padding: 0 8px;
    align-self: center;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #4a5568;
}

input, select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Add player form specific */
#add-player-form .form-group {
    display: flex;
    gap: 12px;
}

#add-player-form input {
    flex: 1;
}

#add-player-form button {
    white-space: nowrap;
}

/* Rankings table */
.rankings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.rankings-table th,
.rankings-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.rankings-table th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
}

.rankings-table tr:hover {
    background: #f7fafc;
}

.position {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
}

.win-percentage {
    font-weight: 600;
}

.win-percentage.high {
    color: #38a169;
}

.win-percentage.medium {
    color: #d69e2e;
}

.win-percentage.low {
    color: #e53e3e;
}

/* Matches list */
.match-item {
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #f7fafc;
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.match-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-players {
    font-weight: 600;
    color: #2d3748;
}

.match-date {
    color: #718096;
    font-size: 0.9rem;
}

.match-score {
    color: #667eea;
    font-weight: 600;
}

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

.edit-match-btn, .delete-match-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.edit-match-btn {
    background: #4299e1;
    color: white;
}

.edit-match-btn:hover {
    background: #3182ce;
}

.delete-match-btn {
    background: #e53e3e;
    color: white;
}

.delete-match-btn:hover {
    background: #c53030;
}

.winner {
    color: #38a169;
    font-weight: bold;
}

/* Messages */
#message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.message {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.message.success {
    background: #38a169;
    color: white;
}

.message.error {
    background: #e53e3e;
    color: white;
}

/* Rankings Table */
.rankings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.rankings-table th {
    background: #4a5568;
    color: white;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rankings-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    color: #2d3748;
}

.rankings-table tr:hover {
    background: #f7fafc;
}

.rankings-table .position {
    font-weight: bold;
    color: #667eea;
    text-align: center;
    width: 60px;
}

.rankings-table .win-percentage {
    font-weight: 600;
    text-align: center;
}

.rankings-table .win-percentage.high {
    color: #38a169;
}

.rankings-table .win-percentage.medium {
    color: #d69e2e;
}

.rankings-table .win-percentage.low {
    color: #e53e3e;
}

/* Highlight statistical columns */
.rankings-table th:nth-child(4), /* Wins column header */
.rankings-table th:nth-child(5), /* Losses column header */
.rankings-table th:nth-child(7), /* Sets Won column header */
.rankings-table th:nth-child(8), /* Sets Lost column header */
.rankings-table th:nth-child(9), /* Games Won column header */
.rankings-table th:nth-child(10), /* Games Lost column header */
.rankings-table td:nth-child(4), /* Wins column data */
.rankings-table td:nth-child(5), /* Losses column data */
.rankings-table td:nth-child(7), /* Sets Won column data */
.rankings-table td:nth-child(8), /* Sets Lost column data */
.rankings-table td:nth-child(9), /* Games Won column data */
.rankings-table td:nth-child(10) { /* Games Lost column data */
    text-align: center;
    font-weight: 600;
}

.rankings-table td:nth-child(4) { /* Wins column - green tint */
    color: #38a169;
}

.rankings-table td:nth-child(5) { /* Losses column - red tint */
    color: #e53e3e;
}

.rankings-table td:nth-child(7) { /* Sets Won column - blue tint */
    color: #3182ce;
}

.rankings-table td:nth-child(8) { /* Sets Lost column - orange tint */
    color: #dd6b20;
}

.rankings-table td:nth-child(9) { /* Games Won column - purple tint */
    color: #805ad5;
}

.rankings-table td:nth-child(10) { /* Games Lost column - gray tint */
    color: #718096;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading states */
.loading {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 20px;
}

.empty-state {
    text-align: center;
    color: #718096;
    padding: 40px 20px;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: #4a5568;
}

/* Demo section */
.demo-section {
    text-align: center;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 2px dashed #cbd5e0;
}

.demo-section p {
    margin-bottom: 20px;
    color: #4a5568;
}

.demo-button {
    margin: 0 8px;
    padding: 10px 20px;
    font-size: 14px;
}

.demo-button.secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.demo-button.secondary:hover {
    background: #cbd5e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Connection status */
.connection-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
}

.connection-status.connected {
    background: #38a169;
    color: white;
}

.connection-status.disconnected {
    background: #e53e3e;
    color: white;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-row .form-group {
        margin-bottom: 16px;
    }
    
    .vs {
        align-self: center;
        margin: 8px 0;
    }
    
    .rankings-table {
        font-size: 14px;
    }
    
    .rankings-table th,
    .rankings-table td {
        padding: 8px 12px;
    }
    
    .match-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}/* Mobil
e UI Improvements */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    /* Header mobile optimization */
    header {
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    /* Card mobile spacing */
    .card {
        padding: 20px;
        margin-bottom: 16px;
        border-radius: 8px;
    }
    
    /* Record Match Form Mobile Layout */
    #record-match-form .form-row {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    #record-match-form .vs {
        text-align: center;
        font-weight: bold;
        font-size: 1.2rem;
        color: #667eea;
        margin: 8px 0;
    }
    
    /* Full-width form elements on mobile */
    .form-group {
        width: 100%;
        margin-bottom: 16px;
    }
    
    .form-group input,
    .form-group select {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        background: white;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    .form-group select {
        background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23666' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 12px;
        padding-right: 40px;
    }
    
    .form-group input:focus,
    .form-group select:focus {
        border-color: #667eea;
        outline: none;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }
    
    /* Full-width buttons on mobile */
    button {
        width: 100%;
        padding: 16px 20px;
        font-size: 16px;
        font-weight: 600;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        min-height: 48px;
    }
    
    button[type="submit"] {
        background: #667eea;
        color: white;
        margin-top: 8px;
    }
    
    button[type="submit"]:hover {
        background: #5a67d8;
    }
    
    button[type="submit"]:active {
        transform: translateY(1px);
    }
    

    
    /* Demo buttons mobile layout */
    .demo-controls {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: 20px;
    }
    
    .demo-controls button {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    /* Message positioning for mobile */
    #message-container {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        z-index: 1000;
    }
    
    .message {
        margin-bottom: 8px;
        padding: 12px 16px;
        border-radius: 6px;
        font-size: 0.9rem;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .container {
        padding: 8px;
    }
    
    .card {
        padding: 16px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .rankings-table {
        font-size: 0.8rem;
    }
    
    .rankings-table th,
    .rankings-table td {
        padding: 6px 2px;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    button:hover {
        transform: none;
    }
    
    button:active {
        transform: scale(0.98);
    }
    
    .card:hover {
        transform: none;
    }
}/* Add P
layer Section - Special Layout */
@media (max-width: 768px) {
    #add-player-form .form-group {
        display: flex;
        gap: 8px;
        align-items: stretch;
    }
    
    #add-player-form input {
        flex: 1;
        width: auto; /* Override the 100% width */
        min-width: 0; /* Allow input to shrink */
    }
    
    #add-player-form button {
        width: auto; /* Override the 100% width */
        flex-shrink: 0;
        padding: 14px 12px;
        font-size: 14px;
        white-space: nowrap;
        max-width: 90px; /* Ensure it fits within the card */
    }
}/* Enhan
ced Background Effects */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 50% 50%, rgba(120, 200, 80, 0.1) 0%, transparent 30%);
    pointer-events: none;
    z-index: -1;
}

/* Subtle animation for background */
@keyframes backgroundShift {
    0%, 100% { 
        background-position: 0% 50%; 
    }
    50% { 
        background-position: 100% 50%; 
    }
}

body {
    background-size: 400% 400%;
    animation: backgroundShift 20s ease infinite;
}

/* Enhanced card shadows for better depth */
.card {
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Improved header with better contrast */
header {
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    border-radius: 1px;
}