/* Mobile Hamburger Menu Styles */

/* Hamburger Button - Floating tab design */
.mobile-menu-button {
    display: none;
    position: fixed;
    top: calc(5px + env(safe-area-inset-top, 0)); /* Default for desktop */
    right: 0;
    z-index: 1000;
    width: 19px;  /* Reduced by 40% total from 30px */
    height: 70px;
    background: linear-gradient(180deg, 
        rgba(139, 92, 246, 0.15) 0%, 
        rgba(139, 92, 246, 0.25) 50%,
        rgba(139, 92, 246, 0.4) 100%);
    border: none;
    border-radius: 12px 0 0 12px;
    cursor: pointer;
    padding: 0;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    transition: opacity 0.6s ease; /* Smooth fade */
    font-size: 11px;  /* Back to original size */
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.8px;  /* Further reduced */
    text-transform: uppercase;
    font-weight: 700;  /* Bold */
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* Desktop specific - keep same styling */
@media (min-width: 769px) {
    .mobile-menu-button {
        width: 27px;  /* Reduced by 40% total from 42px */
        height: 80px;
        font-size: 11px; /* Back closer to original */
        /* Keep desktop at top */
        top: calc(30px + env(safe-area-inset-top, 0));
        bottom: auto;
    }
    
    .mobile-menu-button:hover {
        /* No hover effect on desktop - keep it minimal, click-only */
        background: linear-gradient(180deg, 
            rgba(139, 92, 246, 0.15) 0%, 
            rgba(139, 92, 246, 0.25) 50%,
            rgba(139, 92, 246, 0.4) 100%);
    }
}

/* Position stays consistent on all screens */
.mobile-menu-button.game-active {
    /* No position changes needed - uses default position */
}

/* Mobile only - circular button at bottom of page */
@media (max-width: 768px) {
    /* Default: dim the button and keep depth low until user interaction */
    .mobile-menu-button {
        opacity: 0.25;
        z-index: 1; /* push even further behind primary UI on mobile */
        /* Move all button styles to top */
        position: fixed !important;
        top: 35px !important;
        bottom: unset !important;
        right: 0 !important;
    }

    /* Elevate on interaction */
    .mobile-menu-button.foreground {
        opacity: 1;
        z-index: 1001; /* just under the panel (1002) */
    }
    .mobile-menu-button.circle-style {
        top: 35px !important;
        bottom: unset !important;
        right: calc(8px + env(safe-area-inset-right, 0));
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
        border-radius: 50%;
        background: rgba(139, 92, 246, 0.5);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 0.5px solid rgba(139, 92, 246, 0.3);
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        writing-mode: initial !important;
        text-orientation: initial !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        color: white !important;
        line-height: 1 !important;
    }
    
    .mobile-menu-button.circle-style:hover {
        background: rgba(139, 92, 246, 0.7);
    }
    
    .mobile-menu-button.circle-style::before {
        content: "◉";
        display: block;
    }
    
    /* Arrow style */
    .mobile-menu-button.arrow-style {
        top: 35px !important;
        bottom: unset !important;
        right: calc(8px + env(safe-area-inset-right, 0));
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
        border-radius: 50%;
        background: rgba(139, 92, 246, 0.5);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 0.5px solid rgba(139, 92, 246, 0.3);
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        writing-mode: initial !important;
        text-orientation: initial !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        color: white !important;
        line-height: 1 !important;
    }
    
    .mobile-menu-button.arrow-style:hover {
        background: rgba(139, 92, 246, 0.7);
    }
    
    .mobile-menu-button.arrow-style::before {
        content: "◀";
        display: block;
    }
    
    /* Dots style */
    .mobile-menu-button.dots-style {
        top: 35px !important;
        bottom: unset !important;
        right: calc(8px + env(safe-area-inset-right, 0));
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
        border-radius: 50%;
        background: rgba(139, 92, 246, 0.5);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 0.5px solid rgba(139, 92, 246, 0.3);
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        writing-mode: initial !important;
        text-orientation: initial !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        color: white !important;
        line-height: 1 !important;
    }
    
    .mobile-menu-button.dots-style:hover {
        background: rgba(139, 92, 246, 0.7);
    }
    
    .mobile-menu-button.dots-style::before {
        content: "⋮";
        display: block;
    }
    
    /* Classic MENU tab style (from baseline) */
    .mobile-menu-button.classic-style {
        top: 35px !important;
        bottom: unset !important;
        right: 0;
        width: 19px !important;  /* Reduced by 40% total from 30px */
        height: 70px !important;
        min-width: 19px !important;
        min-height: 70px !important;
        max-width: 19px !important;
        max-height: 70px !important;
        background: linear-gradient(180deg, 
            rgba(139, 92, 246, 0.15) 0%, 
            rgba(139, 92, 246, 0.25) 50%,
            rgba(139, 92, 246, 0.4) 100%);
        border: none;
        border-radius: 12px 0 0 12px;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
        font-size: 11px !important;  /* Back to original size */
        color: rgba(255, 255, 255, 0.8) !important;
        letter-spacing: 0.8px;  /* Further reduced to fit narrower button */
        text-transform: uppercase;
        font-weight: 700 !important;  /* Bold */
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        writing-mode: vertical-rl !important;
        text-orientation: mixed !important;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    
    .mobile-menu-button.classic-style:hover {
        background: linear-gradient(180deg, 
            rgba(139, 92, 246, 0.2) 0%, 
            rgba(139, 92, 246, 0.35) 50%,
            rgba(139, 92, 246, 0.5) 100%);
    }
    
    .mobile-menu-button.classic-style::before {
        display: none;
    }

    /* Uniform vertical offset for the mobile menu button */
    #mobileMenuButton,
    #mobileMenuButton.circle-style,
    #mobileMenuButton.arrow-style,
    #mobileMenuButton.dots-style,
    #mobileMenuButton.classic-style {
        top: calc(35px + env(safe-area-inset-top, 0)) !important;  /* Set to 35px */
    }
}

/* Removed: Strong mobile override that was pinning button to bottom
   Now using top positioning at 30px as defined above */

.mobile-menu-button:active {
    /* Simple press feedback */
    opacity: 0.9;
}

.mobile-menu-button.active {
    background: linear-gradient(180deg, 
        rgba(139, 92, 246, 0.3) 0%, 
        rgba(139, 92, 246, 0.4) 50%,
        rgba(139, 92, 246, 0.6) 100%);
}

/* Hide hamburger icon - we'll use text instead */
.hamburger-icon {
    display: none;
}

/* Keep hamburger icon unchanged when active */
.mobile-menu-button.active .hamburger-icon span {
    /* No transformation - stays as hamburger */
}

/* Slide-out Menu Panel */
.mobile-menu-panel {
    position: fixed;
    top: 0;
    right: -100%; /* Slide from right */
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: linear-gradient(180deg, #1a0b2e 0%, #111827 100%);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease-in-out;
    z-index: 1002; /* Higher than hamburger button */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.mobile-menu-panel.active {
    right: 0;
}

/* Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001; /* Above hamburger button but below menu panel */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

/* Menu Header */
.mobile-menu-header {
    background: linear-gradient(135deg, #9f7aea 0%, #6b46c1 100%);
    padding: 1.5rem;
    color: white;
    position: relative;
    flex-shrink: 0;
}

.mobile-menu-header h2 {
    font-size: 1.5rem;
    margin: 0;
    margin-top: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mobile-menu-header p {
    margin: 0.5rem 0 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Close button */
.mobile-menu-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.2));
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 50%;
    color: #fca5a5;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mobile-menu-close:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(220, 38, 38, 0.3));
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.mobile-menu-close:active {
    transform: scale(0.95);
}

/* Menu Content */
.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 100px; /* Add padding at bottom for scrolling space */
}

/* Menu Sections */
.mobile-menu-section {
    padding: 1rem;
    border-bottom: 1px solid rgba(148, 100, 229, 0.2);
}

.mobile-menu-section h3 {
    color: #c084fc;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

/* Menu Items */
.mobile-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: rgba(30, 14, 48, 0.5);
    border: 1px solid rgba(148, 100, 229, 0.2);
    border-radius: 8px;
    color: #e8e3f5;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.mobile-menu-item:active {
    background: rgba(148, 100, 229, 0.3);
    transform: scale(0.98);
}

.mobile-menu-item .icon {
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.mobile-menu-item .label {
    flex: 1;
}

.mobile-menu-item .value {
    color: #a78bfa;
    font-weight: 600;
}

/* Navigation Buttons in Menu */
.mobile-menu-button-primary {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: linear-gradient(135deg, #9f7aea 0%, #6b46c1 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 4px 10px rgba(159, 122, 234, 0.3);
    transition: all 0.2s ease;
}

.mobile-menu-button-secondary {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: rgba(107, 114, 128, 0.3);
    color: #e8e3f5;
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
}

.mobile-menu-button-danger {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
}

/* Player List in Menu */
.mobile-player-list {
    max-height: 200px;
    overflow-y: auto;
}

.mobile-player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: rgba(13, 7, 21, 0.8);
    border-radius: 6px;
    font-size: 0.9rem;
}

.mobile-player-item .score {
    color: #c084fc;
    font-weight: 600;
}

/* Room Info Badge */
.room-info-badge {
    display: inline-block;
    background: rgba(192, 132, 252, 0.2);
    color: #d6bcfa;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(192, 132, 252, 0.3);
}

/* Navigation Pages */
.menu-page {
    display: none;
    min-height: 100%;
}

.menu-page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Back Button in Pages */
.menu-back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 1rem;
    color: #c084fc;
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
}

/* People in Room List */
.friends-in-room-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.friend-in-room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(30, 14, 48, 0.5);
    border: 1px solid rgba(148, 100, 229, 0.2);
    border-radius: 8px;
}

.friend-in-room-item .status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #a78bfa;
}

.friend-in-room-item .score {
    font-weight: 600;
    color: #c084fc;
}

/* Share Section */
.share-room-section {
    text-align: center;
    padding: 2rem 1rem;
}

.share-room-code {
    font-size: 2rem;
    font-weight: 700;
    color: #d6bcfa;
    letter-spacing: 0.2rem;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(148, 100, 229, 0.1);
    border: 2px dashed rgba(148, 100, 229, 0.3);
    border-radius: 10px;
}

.share-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.share-button {
    flex: 1;
    min-width: 100px;
    padding: 0.5rem;
    background: rgba(148, 100, 229, 0.2);
    border: 1px solid rgba(148, 100, 229, 0.3);
    border-radius: 8px;
    color: #c084fc;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Game History */
.history-item {
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: rgba(30, 14, 48, 0.5);
    border: 1px solid rgba(148, 100, 229, 0.2);
    border-radius: 8px;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-item-word {
    font-weight: 600;
    color: #d6bcfa;
}

.history-item-result {
    font-size: 0.8rem;
}

.history-item-result.won {
    color: #10b981;
}

.history-item-result.lost {
    color: #ef4444;
}

.history-item-details {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #a78bfa;
}

/* Game Stats Grid */
.mobile-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mobile-stat-item {
    background: rgba(30, 14, 48, 0.5);
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(148, 100, 229, 0.2);
}

.mobile-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #c084fc;
}

.mobile-stat-label {
    font-size: 0.75rem;
    color: #a78bfa;
    margin-top: 0.25rem;
}

/* Show on mobile AND desktop */
.mobile-menu-button {
    display: flex !important;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    
    /* On game screen, maintain consistent position */
    .mobile-menu-button.game-active {
        /* Maintain top position on game screen */
        position: fixed !important;
        top: 35px !important;
        bottom: unset !important;
        z-index: 1001; /* Above fixed input area */
    }
    
    /* Ensure screens are properly positioned on mobile */
    .screen {
        position: relative;
        z-index: 1;
        width: 100%;
        min-height: 100vh;
    }
    
    .screen.active {
        z-index: 10;
        display: block !important;
    }
    
    /* Hide inactive screens completely */
    .screen:not(.active) {
        display: none !important;
    }
    
    /* Fix game screen UI on mobile */
    #gameScreen {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        position: relative;
    }
    
    /* Ensure container takes full height on mobile */
    .container {
        min-height: 100vh;
        max-height: none;
        border-radius: 0;
        width: 100%;
        padding: 1rem;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
