/* --- 1. VARIABILE & RESETARE GLOBALĂ --- */
:root {
    --bg-color: #0f0f10;
    --card-bg: rgba(30, 30, 32, 0.7);
    --primary: #538d4e;   /* Verde Wordle */
    --accent: #b59f3b;    /* Galben/Auriu Wordle */
    --error: #ff4d4d;     /* Rosu */
    --text: #ffffff;
    --text-sec: #a0a0a0;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --key-bg: #818384;
}

* { box-sizing: border-box; outline: none; user-select: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    height: 100dvh; /* Fix pentru mobil */
    width: 100vw;
    overflow: hidden; 
    display: flex;
    flex-direction: column;
}

/* --- 2. FUNDAL ANIMAT --- */
.background-animation {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1;
    background: radial-gradient(circle at center, #1a1a1d 0%, #0f0f10 100%);
    pointer-events: none;
}
.cube {
    position: absolute; width: 60px; height: 60px;
    border: 2px solid var(--border);
    background: rgba(255,255,255,0.02);
    animation: float 10s infinite linear;
    border-radius: 12px;
}
.cube:nth-child(1) { top: 20%; left: 10%; animation-duration: 12s; transform: rotate(15deg); }
.cube:nth-child(2) { top: 70%; left: 80%; animation-duration: 15s; width: 40px; height: 40px; }
.cube:nth-child(3) { top: 40%; left: 60%; animation-duration: 9s; width: 80px; height: 80px; opacity: 0.5; }
@keyframes float {
    0% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
    50% { transform: translateY(-20px) rotate(20deg); opacity: 0.8; }
    100% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
}

/* --- 3. NAVBAR --- */
.navbar {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 0 15px; 
    border-bottom: 1px solid var(--border);
    background: rgba(15, 15, 16, 0.95);
    height: 60px;
    flex-shrink: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem; font-weight: 800; letter-spacing: 2px;
    color: white; text-transform: uppercase; text-decoration: none; cursor: pointer;
}

/* Navbar Dreapta */
.nav-right {
    display: flex; align-items: center; gap: 15px;
}

.icon-btn {
    background: transparent; border: none; cursor: pointer;
    position: relative; width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn svg { width: 24px; height: 24px; fill: #ddd; }
.icon-btn:hover svg { fill: white; }

.nav-badge {
    position: absolute; top: 5px; right: 5px;
    background: var(--error); color: white;
    font-size: 0.6rem; font-weight: bold;
    padding: 2px 5px; border-radius: 10px;
    border: 1px solid var(--bg-color);
}

.user-container { position: relative; cursor: pointer; }
.user-icon {
    width: 40px; height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    transition: 0.3s;
}
.user-icon svg { width: 20px; height: 20px; fill: #ffffff; }
.user-container:hover .user-icon { background: var(--primary); border-color: var(--primary); }

/* --- DROPDOWNS (MENIURILE CARE SE DESCHID) --- */
.nav-dropdown, .dropdown-menu {
    position: absolute; top: 55px; right: 0; width: 300px;
    background: #1a1a1d; 
    border: 1px solid var(--border); border-radius: 12px; padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: none; 
    z-index: 2000;
    max-height: 400px; overflow-y: auto;
}

.nav-dropdown::before, .dropdown-menu::before {
    content: ""; position: absolute; top: -10px; right: 10px;
    border-width: 0 10px 10px 10px; border-style: solid;
    border-color: transparent transparent var(--border) transparent;
}

.nav-dropdown.active, .dropdown-menu.active { 
    display: block !important; 
}

.dropdown-list { list-style: none; padding: 0; margin: 0; }
.dropdown-empty { text-align: center; color: #777; padding: 10px; font-size: 0.9rem; }

.menu-item { padding: 10px 15px; color: var(--text-sec); border-radius: 6px; font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.menu-item:hover { background: rgba(255,255,255,0.1); color: white; }
.divider { height: 1px; background: rgba(255,255,255,0.1); margin: 5px 0; }

.nav-btn {
    background: rgba(255,255,255,0.1); color: white; padding: 8px 15px;
    border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
    font-size: 0.85rem; font-weight: bold; transition: 0.3s;
}
.nav-btn:hover { background: var(--primary); border-color: var(--primary); }

.copy-id-btn {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    color: var(--accent); width: 100%; padding: 8px; margin: 5px 0;
    border-radius: 5px; cursor: pointer; font-size: 0.8rem; font-weight: bold;
    display: flex; align-items: center; justify-content: center; gap: 5px;
}
.copy-id-btn:hover { background: rgba(255,255,255,0.1); }

.sidebar-toggle {
    display: none; background: transparent; border: none; color: white;
    font-size: 1.5rem; cursor: pointer; margin-right: 15px;
}

/* --- 4. HERO & MENIU --- */
.hero {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 80vh; text-align: center; z-index: 2; padding: 20px;
}
.hero h1 { font-size: 3rem; margin-bottom: 10px; text-shadow: 0 0 20px rgba(255,255,255,0.3); }
.hero p { font-size: 1.2rem; color: #a0a0a0; max-width: 600px; margin-bottom: 30px; }
.cta-btn {
    padding: 15px 40px; font-size: 1.2rem; background: var(--primary); color: white;
    border: none; border-radius: 30px; cursor: pointer; font-weight: bold;
    box-shadow: 0 0 20px rgba(83, 141, 78, 0.4); transition: 0.3s;
}
.cta-btn:hover { transform: scale(1.05); filter: brightness(1.1); }

.container { 
    flex-grow: 1; display: flex; flex-direction: column; 
    align-items: center; justify-content: flex-start;
    padding: 20px; z-index: 5; overflow-y: auto; width: 100%;
}
.menu-title { font-size: 2.5rem; margin: 20px 0 40px 0; text-transform: uppercase; letter-spacing: 2px; text-align: center; }
.modes-grid { display: flex; gap: 30px; flex-wrap: wrap; justify-content: center; }

.mode-card {
    background: rgba(255, 255, 255, 0.03); backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: 20px;
    padding: 40px; width: 280px; text-align: center; cursor: pointer;
    transition: all 0.3s ease; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.mode-card:hover { transform: translateY(-10px); border-color: var(--primary); box-shadow: 0 20px 40px rgba(83, 141, 78, 0.2); }
.mode-icon { font-size: 4rem; margin-bottom: 20px; }
.mode-card h2 { margin: 10px 0; font-size: 1.5rem; color: white; }
.mode-card p { color: var(--text-sec); font-size: 0.9rem; margin-bottom: 30px; line-height: 1.5; }
.play-btn {
    background: transparent; border: 1px solid var(--primary); color: var(--primary);
    padding: 12px 25px; border-radius: 25px; font-weight: bold; width: 100%;
    cursor: pointer; transition: 0.3s;
}
.mode-card:hover .play-btn { background: var(--primary); color: white; }

.auth-card, .form-box { 
    background: #1a1a1d; border: 1px solid var(--border); padding: 30px; 
    border-radius: 10px; width: 100%; max-width: 400px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); position: relative; margin-bottom: 20px;
}
.input-group, .form-group { margin-bottom: 15px; text-align: left; }
.input-group label, .form-group label { display: block; font-size: 0.9rem; color: var(--text-sec); margin-bottom: 5px; }
.input-group input, .form-group input, #friend-id-input, .settings-section input { 
    width: 100%; padding: 12px; background: #121213; 
    border: 1px solid var(--border); border-radius: 4px; color: white; 
}
.input-group input:focus { border-color: var(--primary); }
.full-btn, .action-btn { width: 100%; padding: 12px; border-radius: 4px; font-weight: bold; cursor: pointer; border: none; margin-bottom: 10px; transition:0.2s; font-size: 1rem; }
.btn-primary, .action-btn { background: var(--primary); color: white; }
.btn-sec, .action-btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--text-sec); }

/* --- 6. LAYOUT JOC --- */
.game-wrapper {
    display: flex; flex-direction: row; flex-grow: 1;
    position: relative; height: calc(100dvh - 60px); overflow: hidden;
}

#party-sidebar {
    width: 280px; background-color: #161618; border-right: 1px solid #333;
    padding: 20px; overflow-y: auto; flex-shrink: 0; display: none; z-index: 1000;
    transition: transform 0.3s ease;
}
.close-sidebar-btn {
    display: none; background: none; border: none; color: #888; font-size: 1.5rem; 
    position: absolute; top: 10px; right: 10px; cursor: pointer;
}

.game-center {
    flex-grow: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: space-between;
    padding: 10px 0; background-color: #121213;
}

/* --- 7. TABLA DE JOC (V2 - FIX ANIMATIE) --- */
.board-container { 
    display: grid; 
    grid-template-rows: repeat(6, 1fr); 
    gap: 5px; 
    margin-bottom: auto; 
    margin-top: 10px; 
    width: 300px; 
    height: 360px; 
}

.board-row { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 5px; 
}

.tile { 
    width: 100%; 
    height: 100%; 
    border: 2px solid #3a3a3c; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    font-size: 2rem; 
    font-weight: bold; 
    background: transparent; 
    color: white;
    user-select: none;
    text-transform: uppercase;
    
    /* ELIMINAT ORICE TRANSITION AICI PENTRU A EVITA CONFLICTE */
    /* transition: transform 0.6s;  <-- ASTA ERA PROBLEMA */
}

/* Animație POP când scrii o literă */
.tile[data-status="filled"] { 
    border-color: #565758; 
    animation: pop 0.1s linear; 
}
@keyframes pop { 50% { transform: scale(1.1); } }

/* --- ANIMAȚIA DE FLIP (ROTIRE 3D) --- */
.flip {
    animation: flip-tile 0.5s ease-in forwards;
}

@keyframes flip-tile {
    0% { 
        transform: rotateX(0deg); 
        border-color: #3a3a3c; /* Începe cu bordură gri */
    }
    50% { 
        transform: rotateX(90deg); /* Aici e "plat"/invizibil */
        border-color: #3a3a3c; 
    }
    100% { 
        transform: rotateX(0deg); /* Revine la normal */
        /* La final culoarea va fi dată de clasa .correct/.present */
    }
}

/* CULORI */
/* Important: border:none !important ca să suprascriem bordura gri */
.correct { background-color: var(--primary) !important; border-color: var(--primary) !important; }
.present { background-color: var(--accent) !important; border-color: var(--accent) !important; }
.absent  { background-color: #3a3a3c !important; border-color: #3a3a3c !important; }

/* Animation shake pentru cuvinte greșite */
.invalid-row { animation: shake 0.4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
/* --- 8. TASTATURA --- */
.keyboard { width: 100%; max-width: 500px; padding: 0 5px; margin-bottom: 5px; }
.key-row { display: flex; justify-content: center; margin-bottom: 6px; gap: 4px; width: 100%; }
.key { 
    flex: 1; height: 58px; 
    border-radius: 4px; border: none; 
    background-color: #818384; color: white; font-weight: bold; 
    font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; 
    user-select: none; -webkit-tap-highlight-color: transparent;
}
.key.large { flex: 1.5; font-size: 0.9rem; }
.key:active { transform: scale(0.95); }

/* --- 9. MODALE & UI DIVERS --- */
.friends-list { display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; }
.friend-item { padding: 10px; background: rgba(255,255,255,0.05); border-radius: 5px; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; border: 1px solid transparent; }

.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 2000; display: none; justify-content: center; align-items: center; 
}
.modal-overlay.active { display: flex; }
.close-modal { position: absolute; top: 15px; right: 20px; font-size: 1.5rem; cursor: pointer; color: #888; }
.badge { background: var(--error); color: white; padding: 2px 6px; border-radius: 10px; font-size: 0.7rem; }
.loader { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; margin: 15px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes bounce { 50% { transform: scale(1.1); } }
.toast { position: fixed; top: 12%; left: 50%; transform: translateX(-50%); background: white; color: black; padding: 10px 20px; border-radius: 5px; font-weight: bold; z-index: 3000; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

/* --- BIFA PREMIUM (STIL GEOMETRIC - CLARITATE MAXIMĂ) --- */
.verified-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; /* Dimensiunea ideală pentru claritate */
    height: 18px;
    margin-right: 4px; 
    vertical-align: middle;
    
    /* Fără fundaluri sau borduri care să strice aspectul */
    background: none;
    border: none;
    box-shadow: none;

    /* Animație subtilă de "respirație" */
    animation: badge-pop 3s infinite ease-in-out;
}

.verified-icon svg {
    width: 100%;
    height: 100%;
    fill: #20d5ec; /* Albastru Cyan deschis */
    /* Eliminăm orice filtru de umbră pentru a scăpa de blur */
    filter: none; 
}

/* Animație elastică simplă */
@keyframes badge-pop {
    0%, 90% { transform: scale(1); }
    95% { transform: scale(1.15); } 
    100% { transform: scale(1); }   
}

/* --- 10. RESPONSIVE --- */
@media (max-width: 650px) {
    .menu-title { font-size: 1.8rem; }
    .mode-card { width: 100%; padding: 20px; }
    .hero h1 { font-size: 2rem; }
    
    .sidebar-toggle { display: block; } 
    #party-sidebar {
        position: absolute; top: 0; left: 0; height: 100%;
        width: 85%; max-width: 300px;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
        border: none;
    }
    #party-sidebar.open { transform: translateX(0); }
    .close-sidebar-btn { display: block; }
    
    .game-center { height: auto; flex-grow: 1; }
    .board-container { width: 100%; max-width: 320px; height: auto; aspect-ratio: 5/6; gap: 3px; }
    .tile { font-size: 1.8rem; border-width: 2px; }
    .keyboard { padding-bottom: 20px; }
    .key { height: 62px; font-size: 1.2rem; }
}