* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #f0f2f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
}

.game-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    gap: 20px;
    align-items: flex-start;
}

/* --- ZIJBALK (LINKS) --- */
.sidebar {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-box {
    background-color: #ffffff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-weight: bold;
    color: #333;
}

/* Inputveld voor naam */
.game-controls input[type="text"] {
    padding: 10px;
    border-radius: 6px;
    border: 2px solid #ccc;
    outline: none;
    font-size: 0.95rem;
    width: 100%;
}

.game-controls input[type="text"]:focus {
    border-color: #2196f3;
}

.game-controls select {
    padding: 10px;
    border-radius: 6px;
    border: 2px solid #2196f3;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    width: 100%;
}

#difficulty-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Status wachtkamer */
.queue-info {
    background-color: #fff8e1;
    border-left: 4px solid #ffb300;
    color: #b78103;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.hidden {
    display: none !important;
}

/* Scorebord */
.scoreboard {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}

.player-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
    flex: 1;
    border: 2px solid transparent;
}

.player-score.active {
    background-color: #e3f2fd;
    border: 2px solid #2196f3;
}

.player-name {
    font-weight: bold;
    font-size: 0.95rem;
    color: #555;
    text-align: center;
    word-break: break-all;
}

.player-score.active .player-name {
    color: #1565c0;
}

.score {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

/* Statistieken */
.game-stats {
    text-align: center;
    font-weight: 600;
    color: #444;
    font-size: 1.05rem;
}

#turn-indicator {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

#current-player {
    color: #2196f3;
    font-weight: bold;
}

/* --- POP-UP NOTIFICATIE OVERLAY --- */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.popup-content h3 {
    margin-bottom: 12px;
    color: #1565c0;
}

.popup-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.popup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.popup-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95rem;
}

#popup-accept-btn {
    background-color: #4caf50;
    color: white;
}

#popup-decline-btn {
    background-color: #f44336;
    color: white;
}

/* --- SPEELVELD (RECHTS) --- */
.main-content {
    flex: 1;
    width: 100%;
}

.memory-grid {
    display: grid;
    gap: 10px;
    perspective: 1000px;
    width: 100%;
}

.memory-grid.grid-10 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    max-width: 700px;
}

.memory-grid.grid-20 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    max-width: 850px;
}

/* --- 3D KAART ANIMATIES --- */
.memory-card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    transform: scale(1);
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
}

.memory-card:active {
    transform: scale(0.97);
    transition: transform 0.1s;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card.matched {
    transform: rotateY(180deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    opacity: 0.6;
    cursor: default;
}

/* HIER ZAT DE FOUT: Hersteld naar één enkele punt */
.card-front, .card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 8px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-front {
    background: #ffffff;
    transform: rotateY(180deg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    box-sizing: border-box;
    border: 2px solid #1a73e8;
    z-index: 2;
}

.card-front img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

.card-back {
    background-color: #1a73e8;
    background-image: linear-gradient(135deg, #1a73e8 25%, #1557b0 100%);
    border: 2px solid #ffffff;
    z-index: 1;
}

/* --- RESPONSIVE OPTIMALISATIE --- */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .sidebar {
        flex: none;
        width: 100%;
        max-width: 600px;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-box {
        flex: 1;
        min-width: 180px;
        padding: 12px;
    }
    
    .memory-grid {
        margin: 0 auto;
    }

    .memory-grid.grid-10 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .memory-grid.grid-20 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .sidebar {
        flex-direction: column;
    }
    .memory-grid.grid-10 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .memory-grid.grid-20 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* --- ONLINE SPELERS LIJST STYLING --- */
.online-users-box {
    color: #333;
}

.online-users-box h4 {
    margin-bottom: 5px;
    font-size: 1rem;
    color: #1565c0;
    border-bottom: 2px solid #e3f2fd;
    padding-bottom: 5px;
}

.online-hint {
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 10px;
    font-style: italic;
}

#online-users-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
    padding: 0;
    margin: 0;
}

#online-users-list li {
    padding: 8px 10px;
    margin-bottom: 5px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.current-user-item {
    background-color: #f5f5f5;
    color: #666;
    cursor: default;
}

.challengeable-user {
    background-color: #e8f5e9;
    color: #2e7d32;
    cursor: pointer;
    border: 1px solid #c8e6c9;
}

.challengeable-user:hover {
    background-color: #c8e6c9;
    transform: translateX(2px);
}

.busy-user {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- UPLOAD KNOP STYLING --- */
.upload-label {
    display: block;
    text-align: center;
    background-color: #f1f3f4;
    color: #3c4043;
    padding: 10px;
    border-radius: 6px;
    border: 2px dashed #9aa0a6;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    margin-top: 5px;
}

.upload-label:hover {
    background-color: #e8eaed;
    border-color: #1a73e8;
    color: #1a73e8;
}

.upload-status-text {
    font-size: 0.75rem;
    color: #5f6368;
    text-align: center;
    display: block;
    margin-top: -5px;
    margin-bottom: 10px;
    font-style: italic;
}