/* GameRunner.cshtml - Mobile-first responsive styles */

/* MOBILE-FIRST BASE */
.game-runner-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: none;
    box-shadow: none;
    border-radius: 0;
    align-items: stretch;
    justify-content: flex-start;
}

/* Mobile header - always visible, height optimized for mobile */
.game-header-mobile {
    flex: none;
    background: linear-gradient(to right, var(--header-gradient-from), var(--header-gradient-to));
    color: white;
    padding: 8px 12px;
    z-index: 40; /* Higher than stats to prevent overlap */
    position: relative;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-header-mobile .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.game-header-mobile .title-section {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    max-width: calc(100% - 160px); /* Leave more space for bigger stats and exit button */
}

.game-header-mobile .game-title {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1; /* More flexible than fixed max-width */
}

.game-header-mobile .game-badge {
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.game-header-mobile .stats-section {
    display: flex;
    gap: 6px;
    font-size: 12px;
    flex-shrink: 0;
    z-index: 50; /* Ensure visibility over header */
    position: relative;
    overflow: visible;
    max-width: 140px; /* Slightly more space */
}

.game-header-mobile .stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 0;
    flex-shrink: 1; /* Allow shrinking */
    max-width: 65px; /* Slightly bigger individual stat width */
    overflow: hidden;
}

.game-header-mobile .stat-value {
    font-weight: bold;
    font-family: monospace;
    min-width: 2rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.game-header-mobile .stat-item span:first-child {
    font-size: 12px; /* Emoji size */
    line-height: 1;
}

.game-header-mobile .exit-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    min-width: 44px; /* Touch-friendly size */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-header-mobile .exit-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Base game area styles */
.game-area {
    width: 100%;
    background: black;
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Game container - main game content area */
.game-container,
#gameContainer {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    position: relative !important;
    overflow: hidden !important;
    flex: 1 1 auto !important;
    box-sizing: border-box !important;
}

.game-content-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Mobile: Kontener i centrowanie gry */
@media (max-width: 639px) {
    .game-runner-container {
        height: 100vh;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        background: none;
        max-width: 100vw;
    }
    .game-header-mobile {
        border-radius: 0 0 12px 12px;
        margin-bottom: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        height: 56px;
        padding: 8px 12px;
    }
    .game-area {
        flex: 1 1 0%;
        width: 100%;
        min-height: 0;
        height: calc(100vh - 56px); /* header height */
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        border-radius: 0;
        background: #000;
    }
    .game-content-wrapper {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        min-width: 0;
        min-height: 0;
        margin: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Game overlay styles */
.game-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center;
    background: rgba(17, 24, 39, 0.95);
    color: white;
    z-index: 10; /* Lower than mobile header (999) */
    padding: 8px; /* Minimal padding on mobile */
    /* Adjust for header but keep content centered */
    padding-top: max(8px, calc(72px + env(safe-area-inset-top) - 30px));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.game-overlay-content {
    text-align: center;
    width: 100%;
    max-width: none; /* Full width on mobile */
    margin: 0;
    padding: 16px 12px; /* Reduced padding for mobile */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px; /* Smaller radius on mobile */
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Better vertical centering on mobile */
    min-height: 0;
    max-height: calc(100vh - 80px); /* Leave less space for better utilization */
    overflow-y: auto;
}

/* Desktop styles for overlay */
@media (min-width: 640px) {
    .game-overlay {
        padding: 16px;
        padding-top: max(16px, calc(72px + env(safe-area-inset-top) - 30px));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .game-overlay-content {
        max-width: 384px;
        margin: 0 auto;
        padding: 24px;
        border-radius: 16px;
        max-height: calc(100vh - 120px);
    }
}

/* Mobile-specific body behavior during gameplay */
html.game-active,
body.game-active {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
    touch-action: none; /* Better for games, prevents default touch behaviors */
}

/* Ensure game container uses all available space on mobile */
.game-active .game-content-wrapper {
    position: absolute;
    top: 56px; /* Account for fixed mobile header */
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: calc(100% - 56px) !important;
    overflow: hidden;
}

/* Ensure game area also accounts for the header */
.game-active .game-area {
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: calc(100vh - 56px) !important;
    margin: 0 !important;
    z-index: 1 !important;
}

/* Hide potential footers and headers during gameplay on mobile */
.game-active footer,
.game-active .footer,
.game-active [class*="footer"],
.game-active header,
.game-active .header,
.game-active nav,
.game-active .navbar,
.game-active [class*="header"],
.game-active [class*="nav"] {
    display: none !important;
}

/* Exception: Keep the game header visible in mobile game mode */
.game-active .game-header-mobile {
    display: flex !important;
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999 !important;
    background: linear-gradient(to right, var(--header-gradient-from), var(--header-gradient-to)) !important;
    color: white !important;
}

/* Exception: Keep the header content visible inside game header */
.game-active .game-header-mobile .header-content {
    display: flex !important;
}

/* Prevent any margin/padding that could cause scrolling */
.game-active .game-runner-container {
    margin: 0 !important;
    padding: 0 !important;
}

/* Color variations for demo vs competition */
.demo-theme {
    --header-gradient-from: #f97316;
    --header-gradient-to: #dc2626;
    --badge-bg: #ea580c;
}

.competition-theme {
    --header-gradient-from: #10b981;
    --header-gradient-to: #2563eb;
    --badge-bg: #059669;
}

.demo-theme .game-badge,
.competition-theme .game-badge {
    background: var(--badge-bg);
}

/* Desktop strefa gry */
@media (min-width: 640px) {
    /* Hide layout header on desktop too when game is active */
    .game-active header {
        display: none !important;
    }
    
    .game-runner-container {
        box-sizing: border-box;
        max-width: 800px;
        margin: 20px auto;
        padding: 0;
        border-radius: 18px;
        background: rgba(17, 24, 39, 0.95);
        box-shadow: 0 8px 32px rgba(0,0,0,0.3);
        height: auto;
        min-height: 700px;
        display: flex;
        flex-direction: column;
    }
    .game-header-mobile {
        border-radius: 18px 18px 0 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.24);
        height: 64px;
        padding: 16px 18px;
        margin: 0;
    }
    .game-area {
        width: 100%;
        height: 700px;
        min-height: 700px !important;
        border-radius: 0 0 18px 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        background: #000;
        flex: 1;
    }
    .game-content-wrapper {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 700px !important;
        margin: 0;
        background: transparent;
        border-radius: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Large desktop - maintain centering */
@media (min-width: 1024px) {
    .game-runner-container {
        max-width: 900px;
    }

    .game-area {
        height: 750px;
        min-height: 750px !important;
    }
    
    .game-content-wrapper {
        min-height: 750px !important;
    }
}

/* Extra large screens */
@media (min-width: 1280px) {
    .game-runner-container {
        max-width: 1000px;
    }

    .game-area {
        height: 800px;
    }
}
