:root {
    --bg-color: #f3f4f6;
    --board-bg: #e5e7eb;
    --tile-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --accent-color: #3b82f6;
    --danger-color: #ef4444;
    --success-color: #10b981;
    
    --tile-black: #1f2937;
    --tile-red: #dc2626;
    --tile-blue: #2563eb;
    --tile-yellow: #d97706; /* Darkened for visibility on white */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden; /* Prevent body scroll, handle inside containers */
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 1rem;
    gap: 1rem;
}

/* Opponents Area */
#opponents-area {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.opponent {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.opponent.active {
    opacity: 1;
    font-weight: bold;
    color: var(--accent-color);
}

.avatar {
    width: 40px;
    height: 40px;
    background: #d1d5db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.tile-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Board Area */
#board-container {
    flex: 1;
    background: var(--board-bg);
    border-radius: 12px;
    overflow-y: auto;
    padding: 1rem;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

#board {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-content: flex-start;
    min-height: 100%;
}

.tile-group {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.7);
    padding: 12px; /* Increased padding for easier clicking */
    border-radius: 8px;
    min-width: 80px; /* Min width for drop target */
    min-height: 60px;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.tile-group:hover {
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Player Area */
#player-area {
    background: white;
    border-radius: 12px 12px 0 0;
    padding: 1rem;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

#timer {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
    background: #eff6ff;
    padding: 4px 12px;
    border-radius: 20px;
}

#player-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 80px;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 2px dashed #e5e7eb;
}

/* Tiles */
.tile {
    width: 36px;
    height: 50px;
    background: var(--tile-bg);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: grab;
    user-select: none;
    position: relative;
}

.tile:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.tile.selected {
    outline: 2px solid var(--accent-color);
    transform: translateY(-4px);
}

.tile[data-color="black"] { color: var(--tile-black); }
.tile[data-color="red"] { color: var(--tile-red); }
.tile[data-color="blue"] { color: var(--tile-blue); }
.tile[data-color="yellow"] { color: var(--tile-yellow); }
.tile[data-joker="true"] { color: purple; font-size: 1.5rem; }

/* Controls */
#controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}

button {
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}
.btn-primary:hover { background: #2563eb; }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-secondary {
    background: #e5e7eb;
    color: var(--text-primary);
}
.btn-secondary:hover { background: #d1d5db; }

.btn-action {
    background: var(--success-color);
    color: white;
}
.btn-action:hover { background: #059669; }

/* Modal */
.hidden { display: none !important; }

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#modal {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

#modal h2 { margin-bottom: 1rem; }
.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 600px) {
    .tile {
        width: 30px;
        height: 42px;
        font-size: 1rem;
    }
    
    #controls {
        flex-wrap: wrap;
    }
    
    button {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}
