/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== SETUP PAGE ===== */
.setup-container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    text-align: center;
}

.setup-container h1 {
    font-size: 2rem;
    margin-bottom: 24px;
    color: #fff;
}

.errors p {
    color: #e94560;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.mode-selector {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.mode-option {
    flex: 1;
    cursor: pointer;
}

.mode-option input {
    display: none;
}

.mode-option span {
    display: block;
    padding: 12px 20px;
    border-radius: 8px;
    background: #16213e;
    border: 2px solid #0f3460;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
}

.mode-option input:checked + span {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.terrain {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.terrain-side {
    flex: 1;
    background: #16213e;
    border-radius: 12px;
    padding: 16px;
}

.terrain-side h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 12px;
}

.terrain-side input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #0f3460;
    border-radius: 8px;
    background: #0f3460;
    color: #fff;
    font-size: 1rem;
    margin-bottom: 8px;
}

.terrain-side input[type="text"]::placeholder {
    color: #666;
}

.serveur-choice {
    text-align: left;
    margin-bottom: 12px;
}

.serveur-choice label {
    font-size: 0.85rem;
    color: #aaa;
    cursor: pointer;
}

.serveur-choice input[type="radio"] {
    margin-right: 4px;
    accent-color: #e94560;
}

.joueur-double {
    border-top: 1px solid #0f3460;
    padding-top: 12px;
    margin-top: 4px;
}

.position-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.setup-hint {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 16px;
    font-style: italic;
}

.btn-start {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #e94560;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-start:active {
    transform: scale(0.97);
}

/* ===== MATCH PAGE ===== */
.match-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    gap: 16px;
}

.scoreboard {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.team {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.team-players {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 50px;
    justify-content: center;
}

.player {
    font-size: 1rem;
    color: #aaa;
    transition: all 0.2s;
}

.player.serving {
    font-weight: 700;
    color: #fff;
    position: relative;
    padding-left: 16px;
}

.player.serving::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e94560;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.5; transform: translateY(-50%) scale(0.8); }
}

.score {
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.separator {
    font-size: 3rem;
    font-weight: 300;
    color: #444;
    padding: 0 4px;
}

.btn-point {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: #0f3460;
    color: #fff;
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-point:active {
    background: #e94560;
    transform: scale(0.95);
}

.match-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

.btn-undo, .btn-fin {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-undo {
    background: #16213e;
    color: #aaa;
    border: 1px solid #0f3460;
}

.btn-undo:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-undo:not(:disabled):active {
    transform: scale(0.95);
}

.btn-fin {
    background: #e94560;
    color: #fff;
}

.btn-fin:active {
    transform: scale(0.95);
}

.serve-indicator {
    font-size: 0.9rem;
    color: #888;
    margin-top: 8px;
}

.serve-indicator strong {
    color: #e94560;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: #16213e;
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    max-width: 300px;
    width: 90%;
}

.modal p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.modal-score {
    font-size: 2rem;
    font-weight: 900;
    color: #e94560;
    margin-bottom: 24px !important;
}

.modal-btns {
    display: flex;
    gap: 12px;
}

.btn-confirm, .btn-cancel {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-confirm {
    background: #e94560;
    color: #fff;
}

.btn-cancel {
    background: #0f3460;
    color: #aaa;
}

/* ===== LANDSCAPE ADAPTATIONS ===== */
@media (orientation: landscape) {
    .match-container {
        flex-direction: column;
        padding: 8px 24px;
        gap: 8px;
    }

    .score {
        font-size: 5rem;
    }

    .btn-point {
        padding: 12px;
        font-size: 1.5rem;
    }

    .team-players {
        flex-direction: row;
        gap: 12px;
    }
}

/* ===== SMALL SCREENS ===== */
@media (max-height: 600px) {
    .score {
        font-size: 3rem;
    }

    .btn-point {
        padding: 10px;
        font-size: 1.4rem;
    }

    .match-actions {
        margin-top: 4px;
    }
}
