* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none; /* Prevents text selection during drag */
    -webkit-user-select: none;
}

body {
    background-color: #3b4358;
    color: white;
    overflow: hidden; /* No scrolling */
    touch-action: none; /* Crucial for custom touch drag on mobile */
    height: 100vh;
    width: 100vw;
}

.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* --- Login Screen --- */
#login-screen {
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.8);
    z-index: 100;
}

.modal {
    background: #e8dcc4;
    color: #333;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.modal h1 {
    margin-bottom: 10px;
    color: #5bbd2b;
}

.modal input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
}

.modal button, #logout-btn, #reset-board-btn {
    background: #5bbd2b;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
}

.modal button:active, button:active {
    background: #4a9e22;
}

/* --- Header & Leaderboard --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #2c3242;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

#logout-btn {
    padding: 5px 10px;
    width: auto;
    font-size: 12px;
    background: #d9534f;
}

.score-board {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

.leaderboard-container {
    background: #4a546c;
    padding: 10px;
    margin: 10px;
    border-radius: 10px;
    max-height: 120px;
    overflow-y: auto;
    pointer-events: auto; /* Allow scrolling here if needed */
    touch-action: pan-y;
}

.leaderboard-container h3 {
    font-size: 14px;
    text-align: center;
    margin-bottom: 5px;
    color: #ccc;
}

#leaderboard-list {
    list-style: none;
    font-size: 14px;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* --- Game Board --- */
#game-board {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
}

.shelf {
    background: #d4b58e;
    border: 4px solid #b38b59;
    border-radius: 5px;
    display: flex;
    justify-content: space-evenly;
    align-items: flex-end;
    width: 45%; /* Two shelves per row */
    height: 80px;
    padding: 0 5px;
    box-shadow: inset 0 -10px 15px rgba(0,0,0,0.2);
}

.slot {
    width: 30%;
    height: 90%;
    border-bottom: 3px solid rgba(255,255,255,0.2);
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

/* --- The Blocks / Items --- */
.item {
    width: 40px;
    height: 45px;
    font-size: 30px; /* Size of emojis */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    touch-action: none; /* Required for custom dragging */
    z-index: 10;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.4));
}

.item:active {
    cursor: grabbing;
}

.controls {
    padding: 15px;
    text-align: center;
}

/* Animation for matched items */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.matched .item {
    animation: pop 0.4s ease-out forwards;
}
