/* ========================================
   MAIN MENU - Responsive Height-Based Scaling
   Last Updated: 2025-12-21
   
   Logo + 3 buttons fill EXACTLY 80% of viewport height
   Height is the PRIMARY constraint - width follows
   ======================================== */

#main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a0a2e 0%, #2d1b3d 50%, #1a0a2e 100%);
    z-index: 15000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Background image */
#main-menu::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../SPRITES/icons/mm_background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.8;
}

#main-menu.hidden {
    display: none;
}

/* ============================================================
   CONTAINER - EXACTLY 80vh tall, width determined by contents
   ============================================================ */
.menu-container {
    /* HEIGHT IS THE ONLY CONSTRAINT - exactly 80% of viewport */
    height: 80vh;
    
    /* Width is NOT set - determined by children's widths */
    /* But we cap it so it doesn't get too wide on ultrawide screens */
    max-width: 90vw;
    
    /* Flex column distributes the 80vh among children */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
}

/* ============================================================
   LOGO - Gets ~40% of the container's 80vh height
   ============================================================ */
.menu-logo {
    /* Flex basis allocates height proportionally */
    /* Logo gets 4 parts out of 9 total (4 + 1.67*3 for buttons) ≈ 44% */
    flex: 4;
    min-height: 0; /* Required for flex shrinking to work */
    
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.menu-logo img {
    /* Image fills its container's HEIGHT, width follows aspect ratio */
    height: 100%;
    width: auto;
    max-width: 90vw; /* Never exceed viewport width */
    object-fit: contain;
    display: block;
}

/* ============================================================
   BUTTONS SECTION - Gets ~56% of the container's 80vh height
   ============================================================ */
.menu-buttons {
    /* Buttons section gets 5 parts out of 9 total ≈ 56% */
    flex: 5;
    min-height: 0; /* Required for flex shrinking to work */
    
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0;
}

/* ============================================================
   EACH BUTTON - Gets equal share of buttons section
   ============================================================ */
.menu-btn-image {
    /* Each button gets 1/3 of the buttons section */
    flex: 1;
    min-height: 0; /* Required for flex shrinking */
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    filter: drop-shadow(0 8px 15px rgba(0,0,0,0.5));
}

.menu-btn-image img {
    /* Image fills its container's HEIGHT, width follows aspect ratio */
    height: 100%;
    width: auto;
    max-width: 90vw; /* Never exceed viewport width */
    object-fit: contain;
    display: block;
    transition: all 0.15s ease;
}

.menu-btn-image:hover {
    filter: drop-shadow(0 10px 20px rgba(153, 102, 255, 0.7));
}

.menu-btn-image:active img {
    transform: scale(0.95);
    filter: brightness(1.3);
}

/* ===== How to Play Screen ===== */
#how-to-play {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 16000;
    padding: 30px;
}

#how-to-play.visible {
    display: flex;
}

.how-to-play-panel {
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    background: linear-gradient(145deg, #1a0a2e 0%, #2d1b4e 50%, #1a0a2e 100%);
    border: 3px solid #8b5cf6;
    border-radius: 20px;
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.how-to-play-title {
    font-size: 36px;
    font-weight: 900;
    color: #fbbf24;
    text-align: center;
    padding: 25px 30px 15px;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
    flex-shrink: 0;
}

.how-to-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 30px 15px;
}

.how-to-section {
    margin-bottom: 20px;
}

.how-to-section h3 {
    font-size: 22px;
    color: #ff88bb;
    margin-bottom: 10px;
    font-weight: bold;
}

.how-to-section p {
    font-size: 16px;
    color: #ddd;
    line-height: 1.6;
    margin-bottom: 8px;
}

.how-to-close-btn {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: bold;
    background: linear-gradient(180deg, #8866aa, #6644aa);
    color: white;
    border: none;
    border-radius: 0 0 18px 18px;
    cursor: pointer;
    box-shadow: 0 5px 0 #4a2d6b;
    flex-shrink: 0;
    margin: 0;
}

.how-to-close-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 7px 0 #4a2d6b;
}

.how-to-close-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #4a2d6b;
}

/* ========================================
   VERSION DISPLAY
   ======================================== */
.menu-version {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 700;
    color: rgba(200, 170, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 10px rgba(153, 102, 255, 0.5);
    letter-spacing: 2px;
    z-index: 15002;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(153, 102, 255, 0.4);
}

/* ============================================================
   HOW TO PLAY MODAL - Higher z-index for main menu context
   Must use !important to override modals.css which loads after
   ============================================================ */
#howtoplay-modal.visible {
    z-index: 20000 !important;
    display: flex !important;
}