/* ============================================
   Măzgălici Phase Management
   ============================================ */
.phase-container .phase-area {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.phase-container[data-phase="playing"] #v-playing,
.phase-container[data-phase="round_results"] #v-round_results {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-stiu {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    font-size: 1.4rem;
    padding: 1rem 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
}

.btn-stiu:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 40px rgba(245, 158, 11, 0.4);
}

/* Round Cards in Lobby */
.round-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.round-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.round-card.selected {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.round-card .round-val {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.round-card .round-label {
    font-size: 0.7rem;
    opacity: 0.6;
    letter-spacing: 1px;
}

/* Scoreboard */
.scoreboard-container {
    padding: 1.5rem;
}

.scoreboard-title {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scoreboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scoreboard-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
    font-size: 0.9rem;
}

.scoreboard-item.me {
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.scoreboard-item .rank {
    width: 25px;
    font-weight: 800;
    opacity: 0.5;
}

.scoreboard-item .name {
    flex: 1;
    font-weight: 600;
}

.scoreboard-item .score {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    color: var(--primary);
}

/* Round Results */
.spy-highlight {
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05) !important;
}

/* Timer Pillar */
.round-counter-pill {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2rem;
    padding: 0.5rem 1.25rem;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 1px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.guess-highlight {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 1.5rem 0;
}

/* Card Flip Fixes */
.card-front, .card-back {
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
}

.role-card-flip {
    transform-style: preserve-3d;
}

/* Modal centering and refinement */
#stiu-phase-overlay {
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

/* Stilurile globale din style.css se ocupa acum de modal-content */

.round-results-modal {
    animation: modalShake 0.25s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes modalScaleIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.player-status-item {
    transition: transform 0.2s ease;
}

.player-status-item:hover {
    transform: translateX(5px);
}

.game-container {
    width: 100%;
    
    
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-layout-mazgalici {
    display: flex;
    flex-direction: row;
    gap: 2.5rem;
    width: 100%;
    max-width: 1200px; /* Reduced from 1400 to keep it focused */
    margin: 0 auto;
    justify-content: center;
    align-items: flex-start;
}

.game-sidebar-left {
    flex: 0 0 240px; /* Exact size for card and button column */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.game-content-main {
    display: grid;
    grid-template-areas: 
        "canvas stiu"
        "canvas role"
        "scores scores"
        "instr instr";
    grid-template-columns: 1fr 320px;
    grid-auto-rows: min-content;
    gap: 2rem;
    width: 100%;
}

.af-card-canvas { grid-area: canvas; width: 100%; }
.af-card-stiu { grid-area: stiu; width: 100%; max-width: 300px; justify-self: center; }
.af-card-role { grid-area: role; width: 100%; max-width: 300px; justify-self: center; }
.af-card-scores { grid-area: scores; }
.af-card-instr { grid-area: instr; }

.role-reveal-container {
    width: 100%;
    max-width: 260px;
    height: 350px;
    margin: 0 auto;
}

@media (max-width: 600px) {
    .role-reveal-container {
        height: 80px !important;
        max-width: 100% !important;
    }
    .role-card-flip {
        font-size: 0.9rem;
    }
    .role-card-flip i { font-size: 1.2rem; margin-bottom: 2px; }
    .role-word { font-size: 1.1rem !important; }
}

#stiu-button-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 2rem;
}

/* Ensure Scoreboard fills its space */
.scoreboard-container {
    width: 100%;
    margin: 0 !important;
}

.grid-scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.mazgalici-instructions {
    width: 100%;
    margin-top: auto;
}

/* Instructions Grid */
.instructions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.instr-col h4 {
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.2);
    padding-bottom: 0.5rem;
}

.instr-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instr-col li {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
    line-height: 1.4;
}

/* Scoreboard Grid */
.grid-scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.timer-pill-large {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-main);
    text-shadow: 0 0 20px rgba(255,255,255,0.1);
}

/* Responsive */
@media (max-width: 1100px) {
    .instructions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .game-layout-mazgalici {
        flex-direction: column;
        align-items: center;
    }
    
    .game-sidebar-left {
        flex: none;
        width: 100%;
        position: static;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .timer-pill-large {
        font-size: 1.5rem;
    }

    .game-container {
        
    }

    .game-title-header {
        display: none !important;
    }

    .status-bar {
        margin-bottom: 6px !important;
        padding: 5px 10px !important;
        min-height: auto !important;
    }

    .game-content-main {
        grid-template-areas: 
            "canvas"
            "stiu"
            "role"
            "scores"
            "instr";
        grid-template-columns: 1fr;
        width: 100%;
        gap: 6px; /* Very small distance as requested */
    }

    /* Remove bottom margins to respect the grid gap */
    .game-content-main .glass-card,
    .game-content-main .mb-4,
    .game-content-main .canvas-container {
        margin-bottom: 0 !important;
        margin-top: 0 !important;
    }

    .af-card-stiu, .af-card-role {
        max-width: 100%;
        width: 100%;
        margin-bottom: 0 !important;
    }

    .mobile-action-grid {
        display: flex !important;
        gap: 6px !important;
        width: 100% !important;
        margin-top: 5px !important;
        height: 80px !important;
    }

    .mobile-action-grid > div {
        flex: 1 !important;
        min-width: 0 !important;
        height: 80px !important;
        padding: 5px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .d-none-mobile { display: none !important; }

    .btn-stiu {
        font-size: 1.1rem !important;
        padding: 5px !important;
        height: 70px !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: var(--primary) !important;
        color: white !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 15px var(--primary-glow) !important;
    }
}

@media (max-width: 600px) {
    .round-cards-grid {
        grid-template-columns: 1fr;
    }
    .grid-scoreboard {
        grid-template-columns: 1fr;
    }
}

/* Responsive button text fix */
@media (max-width: 400px) {
    #stiu-phase-overlay .btn {
        font-size: 0.85rem;
        padding: 0.8rem 0.5rem;
        white-space: normal !important;
        line-height: 1.2;
        min-height: 50px;
    }
}

.game-theme-mazgalici {
    --primary: #f43f5e;
    --primary-rgb: 244, 63, 94;
    --secondary: #fda4af;
    --accent: #e11d48;
    --bg-dark: #0f172a;
}

/* Canvas Styles */
.canvas-viewer-container {
    width: 100%;
    max-width: 350px;
    aspect-ratio: 3 / 4; /* Portrait */
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    background: #fff;
    margin: 0 auto;
    position: relative;
}

@media (max-width: 600px) {
    .canvas-viewer-container {
        aspect-ratio: 1 / 1 !important;
        max-width: 100% !important;
    }
}
.drawing-modal-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.drawing-canvas-wrapper {
    width: 100%;
    background: #fff;
    border-radius: 1rem;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    position: relative;
}

.drawing-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0.75rem;
    border: 1px solid rgba(255,255,255,0.1);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
}

