/* Dynamic viewport height for mobile compatibility */
.min-h-screen-dynamic {
    min-height: 100dvh; /* Dynamic viewport height */
    min-height: 100vh; /* Fallback for older browsers */
    min-height: calc(var(--vh, 1vh) * 100); /* JS-calculated height fallback */
}

/* Ensure body fills viewport exactly with no overflow */
body {
    height: 100vh;
    overflow: hidden;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
}

#lobby-container {
    height: 100vh; /* Exact viewport height */
    padding: 1rem; /* Reduced padding */
    box-sizing: border-box; /* Include padding in height calculation */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent container overflow */
}

/* Lobby info scaling */
#lobby-info {
    font-size: clamp(0.75rem, 2vw, 1rem);
}

#lobby-number {
    font-size: clamp(0.875rem, 2.5vw, 1.25rem);
}

#exit-lobby-button {
    font-size: clamp(0.625rem, 1.5vw, 0.875rem);
    padding: clamp(0.25rem, 1vw, 0.5rem) clamp(0.5rem, 1.5vw, 1rem);
}

#settings-button {
    font-size: clamp(0.625rem, 1.5vw, 0.875rem);
    padding: clamp(0.25rem, 1vw, 0.5rem);
}

#settings-button i {
    font-size: clamp(0.625rem, 1.5vw, 0.875rem);
}

/* Modern lobby enhancements */
.player-frame {
    display: flex;
    flex-direction: column;
    font-size: 4vh; /* font scales with viewport height */
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    height: 100%;
    padding: 10px;
    position: relative;
    overflow: hidden; /* Ensure overlay stays inside */
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Ensure minimum height for mobile */
    min-height: 80px;
    /* Allow frames to scale higher - remove restrictive max-height */
    max-height: none;
}

.player-frame:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.settings-button,
.remove-player-button {
    position: absolute;
    z-index: 10; /* Ensure above overlay squares */
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-button:hover,
.remove-player-button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.remove-player-button {
    top: 4px;
    left: 4px;
}

.settings-button {
    top: 4px;
    right: 4px;
}

/* Enhanced page dots */
.dot {
    height: 16px;
    width: 16px;
    background-color: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: inline-block;
    margin: 0 4px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.dot:hover {
    background-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.2);
}

.dot.filled {
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

/* Enhanced overlay effects */
.player-frame-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: 1fr 1fr;
    grid-template-columns: 1fr 1fr;
    z-index: 2;
    pointer-events: none; /* Only overlay squares get pointer events */
    border-radius: 16px;
    overflow: hidden;
}

.player-frame-overlay .overlay-square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    font-weight: bold;
    color: rgba(255, 255, 255, 0);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: 2px;
    border-radius: 8px;
    pointer-events: auto;
    z-index: 3;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Remove backdrop blur to prevent text blurriness */
}

.player-frame-overlay .overlay-square:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
    transform: scale(0.98);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Enhanced dice display */
#dice-display {
    left: 80%;
    top: 80%;
    position: fixed;
    transform: translate(-50%, -50%) rotate(840deg);
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3em;
    font-weight: bold;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    transition: all 0.3s ease;
}

/* Professional gradient backgrounds for key elements */
.bg-clip-text {
    -webkit-background-clip: text;
    background-clip: text;
}

/* Enhanced modal styles */
.modal-content {
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Mobile-specific adjustments for lobby */
@media screen and (max-width: 768px) and (max-height: 700px) {
    /* Adjust for mobile browsers with visible UI */
    .min-h-screen-dynamic {
        min-height: 100svh; /* Small viewport height - excludes browser UI */
    }
    
    #lobby-container {
        min-height: 100svh;
        padding: 1rem;
        gap: 1rem;
    }
    
    /* Reduce spacing and sizing on cramped mobile screens */
    #left-panel {
        margin-bottom: 1rem;
    }
    
    #player-grid {
        gap: 0.75rem;
        /* Use available viewport height more efficiently */
        max-height: calc(100svh - 200px); /* Reserve space for controls */
        overflow-y: auto; /* Allow internal scrolling */
    }
    
    .player-frame {
        font-size: 3.5vh; /* Slightly smaller font on mobile */
        min-height: 80px; /* Smaller minimum height for mobile */
        max-height: 300px; /* Increased max height for mobile - allow better scaling */
    }
    
    #bottom-controls {
        margin-top: 1rem;
        padding-bottom: 1rem;
    }
    
    /* Make buttons more compact */
    #bottom-controls .flex.gap-4 {
        gap: 0.75rem;
    }
    
    #bottom-controls button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* Additional constraint for player grid on all screen sizes */
#player-grid {
    max-height: calc(100vh - 240px); /* Ensure grid doesn't overflow viewport */
    overflow-y: auto; /* Allow internal scrolling when needed */
}

/* Landscape mobile orientation adjustments */
@media screen and (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    #lobby-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    #player-grid {
        gap: 0.5rem;
    }
    
    #bottom-controls {
        margin-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    /* Make the layout more horizontal-friendly */
    .flex.flex-col.md\\:flex-row {
        flex-direction: row;
    }
    
    #left-panel {
        width: auto;
        min-width: 120px;
    }
}

/* Additional mobile enhancements for lobby */
@media (hover: none) and (pointer: coarse) {
    /* Enhance touch targets for mobile */
    .player-frame button,
    #settings-button,
    #exit-lobby-button,
    .overlay-square {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Make player frame interactions more touch-friendly */
    .player-frame-overlay .overlay-square {
        min-height: 60px; /* Larger touch targets for game interactions */
    }
    
    /* Improve modal touch interactions */
    .modal-content button {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}