/* --- RESET E BASICS --- */
* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
    outline: none; 
    border: none; 
}

body { 
    margin: 0; 
    background: #1a472a; 
    color: white; 
    font-family: 'Arial Black', sans-serif; 
    overflow: hidden; 
    width: 100vw; 
    height: 100vh; 
}

.hidden { display: none !important; }

/* --- SCHERMATE PRINCIPALI (START/END) --- */
#startScreen, #endScreen { 
    position: fixed; 
    inset: 0; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: radial-gradient(circle, #2d5a3f 0%, #1a472a 100%); 
    z-index: 2000; 
}

#endScreen { background: rgba(0,0,0,0.95); z-index: 5000; }

.main-box { 
    background: rgba(0,0,0,0.9); 
    padding: 40px; 
    border-radius: 40px; 
    text-align: center; 
    width: 92%; 
    max-width: 440px; 
    display: flex; 
    flex-direction: column; 
    gap: 30px; 
    border: 4px solid #f1c40f; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

/* --- ELEMENTI UI --- */
.logo-title { color: #f1c40f; font-size: 38px; margin: 0; }
.end-title { font-size: 45px; margin: 0; text-transform: uppercase; }
.win-text { color: #f1c40f; text-shadow: 0 0 20px #f1c40f; }
.lose-text { color: #e74c3c; text-shadow: 0 0 20px #e74c3c; }

.btn-yellow { background: #f1c40f; color: #000; padding: 18px; border-radius: 18px; font-weight: 900; cursor: pointer; box-shadow: 0 6px 0 #b7950b; text-transform: uppercase; }
.btn-white { background: #fff; color: #1a472a; padding: 18px; border-radius: 18px; font-weight: 900; box-shadow: 0 6px 0 #ccc; text-transform: uppercase; cursor: pointer; }
input { background: rgba(255,255,255,0.1); border: 2px solid #f1c40f !important; padding: 18px; border-radius: 15px; color: white; text-align: center; font-size: 18px; width: 100%; }

.peer-display { background: rgba(255,255,255,0.1); padding: 10px; border-radius: 10px; font-family: monospace; font-size: 20px; color: #f1c40f; }
.menu-section { display: flex; flex-direction: column; gap: 15px; }

/* --- TAVOLO DA GIOCO --- */
#gameArea { 
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    align-items: center; 
    padding: 20px 0; 
}

#turnIndicator { font-size: 14px; font-weight: 900; letter-spacing: 1px; }

.gold-badge { 
    background: #f1c40f; color: #000; padding: 6px 12px; border-radius: 8px; 
    font-weight: 900; font-size: 11px; position: absolute; left: 15px; top: -25px; z-index: 50; 
}

.game-row { position: relative; width: 100%; display: flex; justify-content: center; }

.hand { display: flex; justify-content: center; width: 100%; min-height: 120px; }
.card { 
    width: 80px; height: 115px; border-radius: 12px; border: 3px solid #fff; 
    margin: 0 -22px; display: flex; align-items: center; justify-content: center; 
    font-size: 32px; font-weight: 900; color: white; position: relative; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); transition: transform 0.2s;
}
.card:active { transform: translateY(-20px); }

.card::before, .card::after { content: attr(data-val); position: absolute; font-size: 12px; }
.card::before { top: 5px; left: 7px; } 
.card::after { bottom: 5px; right: 7px; transform: rotate(180deg); }

/* COLORI CARTE */
.red { background: #d63031; } 
.blue { background: #0984e3; } 
.green { background: #27ae60; } 
.yellow { background: #f1c40f; color: #000 !important; }
.wild, .wild4 { background: #2d3436; border-color: #f1c40f; }

#centerArea { display: flex; gap: 30px; align-items: center; margin: 15px 0; }
/* RETRO CARTA CON TESTO SPEZZATO */
.card-back-classic { 
    width: 85px; 
    height: 120px; 
    background: #000; 
    border: 4px solid #fff; 
    border-radius: 15px; 
    color: #f1c40f; 
    display: flex; 
    flex-direction: column; /* Forza la disposizione verticale */
    align-items: center; 
    justify-content: center; 
    font-weight: 900; 
    text-align: center; 
    font-size: 15px; /* Leggermente più grande per leggibilità */
    line-height: 1.2; 
    gap: 5px; /* Crea spazio tra MASTER e UNO */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* --- ALERT E BOTTONI --- */
#toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 11000; }
.toast { 
    background: #f1c40f; color: #000; padding: 12px 20px; border-radius: 50px; 
    font-weight: 900; border: 3px solid #fff; margin-bottom: 8px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); animation: slideIn 0.3s forwards;
}

#masterUnoBtn { 
    background: #e74c3c; color: #fff; padding: 15px 30px; border-radius: 50px; 
    font-weight: 900; position: fixed; bottom: 160px; right: 20px; 
    border: 3px solid #fff; animation: pulse 1s infinite; z-index: 1000; 
}

/* --- SELETTORE COLORE (QUADRATO 2x2) --- */
#colorPicker { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.9); 
    display: flex; align-items: center; justify-content: center; z-index: 10000; 
}

.picker-box { 
    background: #000; padding: 30px; border-radius: 30px; 
    border: 4px solid #f1c40f; text-align: center; 
}

.picker-box h3 { color: #f1c40f; margin: 0 0 20px 0; text-transform: uppercase; }

/* Forza la griglia 2x2 */
.pick-grid { 
    display: grid !important; 
    grid-template-columns: repeat(2, 100px) !important; 
    grid-template-rows: repeat(2, 100px) !important; 
    gap: 15px !important; 
}

.pick { 
    width: 100px !important; 
    height: 100px !important; 
    border-radius: 20px; 
    border: 5px solid #fff; 
    cursor: pointer; 
}

.pick.red { background: #d63031; } 
.pick.blue { background: #0984e3; } 
.pick.green { background: #27ae60; } 
.pick.yellow { background: #f1c40f; }

/* --- ANIMAZIONI --- */
@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
