body {
    margin: 0;
    overflow: hidden;
    background-color: #2E2E2E;
    color: white;
    font-family: Arial, sans-serif;
    touch-action: none;
}

#container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 14px;
}

#top-player {
    background-color: rgba(0, 0, 0, 0.7);
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    gap: 10px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
}

#bottom-player {
    background-color: rgba(0, 0, 0, 0.7);
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    gap: 10px;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
}

#turn-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: auto;
    z-index: 100;
}

#controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
}

button {
    pointer-events: auto;
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    touch-action: manipulation;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

button:hover {
    background-color: #45a049;
}

button:active {
    transform: scale(0.95);
}

button:disabled {
    background-color: grey;
    cursor: not-allowed;
    opacity: 0.6;
}

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

.modal-content {
    background: linear-gradient(145deg, #252525, #1A1A1A);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 85%;
    max-width: 340px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 20px;
    color: #FFD700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.modal-content p {
    margin: 15px 0 20px;
    font-size: 15px;
    line-height: 1.5;
    color: #E0E0E0;
}

/* Modal Button Styles */
.modal-content button {
    margin: 8px 5px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 8px;
    min-width: 100px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Promotion Modal Buttons */
#promotion-modal .modal-content button {
    width: 70px;
    height: 70px;
    font-size: 16px;
    border-radius: 10px;
    margin: 8px;
}

#promotion-modal .modal-content button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(76, 175, 80, 0.4);
}

/* Draw Offer Modal Buttons */
#draw-offer-modal button#accept-draw {
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: white;
}

#draw-offer-modal button#accept-draw:hover {
    background: linear-gradient(145deg, #45a049, #3d8b40);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

#draw-offer-modal button#decline-draw {
    background: linear-gradient(145deg, #f44336, #da190b);
    color: white;
}

#draw-offer-modal button#decline-draw:hover {
    background: linear-gradient(145deg, #da190b, #c41709);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
}

/* Game End Modal Buttons */
#game-end-modal button#end-rematch {
    background: linear-gradient(145deg, #2196F3, #0b7dda);
    color: white;
}

#game-end-modal button#end-rematch:hover {
    background: linear-gradient(145deg, #0b7dda, #0a6bc4);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.5);
}

#game-end-modal button#end-lobby {
    background: linear-gradient(145deg, #FF9800, #f57c00);
    color: white;
}

#game-end-modal button#end-lobby:hover {
    background: linear-gradient(145deg, #f57c00, #e65100);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

/* Overlay Message */
.overlay-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.95), rgba(20, 20, 20, 0.95));
    padding: 20px 30px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 3s ease-out;
    z-index: 1000;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    min-width: 200px;
    text-align: center;
}

/* Check Bar */
#check-bar {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    z-index: 999;
    display: none;
    box-shadow: 0 4px 16px rgba(255, 0, 0, 0.5);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) scale(1.05);
    }
}

@media (max-width: 600px) {
    #ui-overlay {
        font-size: 12px;
    }

    #top-player,
    #bottom-player {
        padding: 6px;
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }

    #turn-indicator {
        font-size: 12px;
        padding: 6px;
        top: 5px;
        right: 5px;
    }

    #controls {
        padding: 6px;
        gap: 4px;
        bottom: 40px;
    }

    button {
        padding: 5px 10px;
        font-size: 10px;
    }

    .modal-content {
        width: 90%;
        padding: 20px;
        max-width: 300px;
    }

    .modal-content h3 {
        font-size: 18px;
    }

    .modal-content p {
        font-size: 13px;
    }

    .modal-content button {
        padding: 10px 18px;
        font-size: 12px;
        min-width: 80px;
    }

    #promotion-modal .modal-content button {
        width: 60px;
        height: 60px;
        font-size: 14px;
        margin: 5px;
    }

    .overlay-message {
        font-size: 14px;
        padding: 15px 20px;
        min-width: 150px;
    }
}