/* CSS 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;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #764ba2;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.user-score {
    background: #764ba2;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: bold;
}

/* Navigation */
.nav {
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(118, 75, 162, 0.2);
}

.nav-content {
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
}

.nav-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #667eea;
    transition: all 0.3s ease;
    min-width: 80px;
}

.nav-btn.active {
    background: #667eea;
    color: white;
}

.nav-btn:hover:not(.active) {
    background: rgba(102, 126, 234, 0.1);
}

/* Main Content */
.main {
    padding: 20px 0;
    min-height: calc(100vh - 120px);
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Card Styles */
.card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(118, 75, 162, 0.1);
}

.card h3 {
    color: #764ba2;
    margin-bottom: 16px;
    font-size: 18px;
}

/* Match Card Styles */
.match-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #667eea;
}

.match-info {
    flex: 1;
}

.teams {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.match-time {
    font-size: 12px;
    color: #666;
}

.deadline-warning {
    color: #e74c3c;
    font-weight: bold;
}

.prediction-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
}

.score-input {
    width: 50px;
    height: 40px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
}

.score-input:focus {
    outline: none;
    border-color: #667eea;
}

.vs {
    font-weight: bold;
    color: #764ba2;
}

.locked {
    opacity: 0.6;
    pointer-events: none;
}

.locked-label {
    background: #95a5a6;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* League Table Styles */
.league-table {
    overflow-x: auto;
}

.league-table table {
    width: 100%;
    border-collapse: collapse;
}

.league-table th,
.league-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.league-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #764ba2;
}

.user-row {
    background: rgba(102, 126, 234, 0.1);
    font-weight: bold;
}

.position {
    text-align: center;
    font-weight: bold;
}

/* Button Styles */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

.btn-secondary {
    background: #95a5a6;
}

.btn-secondary:hover {
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #764ba2;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* League Code Styles */
.league-code-display {
    background: #764ba2;
    color: white;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 16px;
}

.league-code {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #e74c3c;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 {
    color: #764ba2;
    margin-bottom: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 8px;
        padding: 16px 0;
    }

    .match-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .prediction-inputs {
        margin-left: 0;
        justify-content: center;
        width: 100%;
    }

    .nav-content {
        padding: 12px 0;
    }

    .nav-btn {
        font-size: 12px;
        padding: 8px 12px;
        min-width: 70px;
    }

    .league-table {
        font-size: 14px;
    }

    .league-table th,
    .league-table td {
        padding: 8px 4px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .logo {
        font-size: 20px;
    }

    .user-score {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* Loading States */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state img {
    width: 80px;
    height: 80px;
    opacity: 0.5;
    margin-bottom: 16px;
}

/* Score Display */
.score-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.score-item {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    display: block;
}

.score-label {
    font-size: 12px;
    opacity: 0.9;
}

/* Status Badge Styles */
.match-status {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.finished {
    background: #4caf50;
    color: white;
}

.status-badge.upcoming {
    background: #ff9800;
    color: white;
}

.status-badge.live {
    background: #f44336;
    color: white;
    animation: pulse 2s infinite;
}

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

/* Match card status styling */
.match-card.finished {
    background: linear-gradient(135deg, #e8f5e8 0%, #f4f9f4 100%);
    border-left: 4px solid #4caf50;
}

.match-card.upcoming {
    background: linear-gradient(135deg, #fff3e0 0%, #faf7f2 100%);
    border-left: 4px solid #ff9800;
}

.match-card.live {
    background: linear-gradient(135deg, #ffebee 0%, #fef7f7 100%);
    border-left: 4px solid #f44336;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.2);
}

/* Point System Styling */
.point-system {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.point-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.point-item .points {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
    font-size: 12px;
}

.point-item .description {
    flex: 1;
    font-size: 14px;
}

/* Badge Styling */
.player-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-leader {
    background: #ffd700;
    color: #333;
}

.badge-accurate {
    background: #4caf50;
    color: white;
}

.badge-optimist {
    background: #2196f3;
    color: white;
}

.badge-wildcard {
    background: #ff9800;
    color: white;
}

.badge-unlucky {
    background: #f44336;
    color: white;
}

/* Achievement Cards */
.achievement-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9ff 0%, #fff 100%);
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid #667eea;
}

.achievement-icon {
    font-size: 24px;
}

.achievement-text {
    flex: 1;
}

.achievement-text .title {
    font-weight: bold;
    color: #333;
}

.achievement-text .description {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.stat-card {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #fff 100%);
    border-radius: 8px;
    border: 1px solid #e1e8f0;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    display: block;
}

.stat-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Player Selection Styling */
.player-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.player-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f9ff 0%, #fff 100%);
    border: 2px solid #e1e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 500;
}

.player-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.player-emoji {
    font-size: 24px;
}

.player-name {
    flex: 1;
    text-align: left;
}

/* Prevent page scroll during score interaction */
.score-input-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #f7fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    user-select: none;
    touch-action: pan-x;
}

/* Better touch feedback */
.score-spinner:active,
.score-spinner.dragging {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
    transform: scale(1.02);
}

.team-name {
    font-weight: 600;
    color: #2d3748;
    text-align: center;
    min-height: 20px;
    font-size: 14px;
}

.score-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    width: 80px;
    height: 120px;
    position: relative;
    touch-action: pan-y;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.score-spinner:active,
.score-spinner.dragging {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.score-spinner.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: #f5f5f5;
}

.spinner-button {
    width: 100%;
    height: 35px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
}

.spinner-button:first-child {
    border-radius: 10px 10px 0 0;
}

.spinner-button:last-child {
    border-radius: 0 0 10px 10px;
}

.spinner-button:hover:not(:disabled) {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.spinner-button:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

.spinner-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}

.score-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: var(--primary-color);
    background: white;
    margin: 4px;
    border-radius: 8px;
    min-height: 60px;
    width: 100%;
    touch-action: pan-y;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    border: 1px solid #e2e8f0;
}

.score-display:active {
    cursor: grabbing;
}

.vs-separator {
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    border: 2px solid #667eea;
    min-width: 50px;
    text-align: center;
}

.match-deadline {
    font-size: 11px;
    color: var(--error-color);
    margin-top: 4px;
    text-align: center;
}

.match-deadline.expired {
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

/* Individual Match Prediction Boxes */
.match-prediction-box {
    background: white;
    border: 2px solid #e3e8ff;
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.match-prediction-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.match-prediction-box.deadline-soon {
    border-color: #ff9800;
    background: linear-gradient(135deg, white 0%, #fff9e6 100%);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.15);
}

.match-prediction-box.deadline-expired {
    border-color: #e74c3c;
    background: linear-gradient(135deg, white 0%, #ffebee 100%);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.15);
    opacity: 0.7;
}

/* Match Header Improvements */
.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e3e8ff;
}

.match-title strong {
    font-size: 18px;
    color: #2d3748;
    display: block;
    margin-bottom: 4px;
}

.match-date {
    font-size: 14px;
    color: #718096;
    font-weight: normal;
}

/* Score Prediction Area */
.score-prediction-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.team-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.team-name {
    font-weight: 600;
    color: #2d3748;
    text-align: center;
    min-height: 20px;
}

/* Touch feedback */
@media (hover: none) {
    .spinner-button:hover {
        transform: none;
    }
    
    .spinner-button:active {
        transform: scale(0.9);
        filter: brightness(0.8);
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .match-prediction-box {
        margin: 12px 0;
        padding: 16px;
    }
    
    .match-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .match-title strong {
        font-size: 16px;
    }
    
    .score-input-container {
        gap: 12px;
        padding: 12px;
    }
    
    .vs-separator {
        font-size: 14px;
        padding: 6px 8px;
        min-width: 40px;
    }
    
    .save-prediction-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .score-spinner {
        width: 70px;
        height: 100px;
    }
    
    .score-display {
        font-size: 32px;
        min-height: 50px;
    }
    
    .spinner-button {
        height: 30px;
        font-size: 18px;
    }
    
    .team-name {
        font-size: 13px;
    }
}