/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Lucida Grande', 'Calibri', 'Helvetica', 'Arial', sans-serif;
    background: #171717;
}

body.template {
    margin: 0;
    border: 0;
    background: #171717;
}

/* Unity container - fullscreen responsive */
#unity-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #171717;
    pointer-events: auto; /* Changed from none to auto for input field compatibility */
}

#unity-container.unity-desktop {
    width: 100%;
    height: 100%;
}

#unity-container.unity-mobile {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Canvas styling */
#unity-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #171717;
    touch-action: manipulation; /* Changed from auto to manipulation for better input compatibility */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events: auto;
    cursor: default;
    outline: none;
}

/* Loading screen */
#loading-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
}

#loading-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

#unity-loading-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 300px;
    width: 80%;
}

#unity-logo {
    width: 300px;
    height: 240px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#unity-progress-bar-empty {
    width: 100%;
    height: 18px;
    margin: 10px 20px;
    background: rgba(40, 40, 40, 0.5);
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

#unity-progress-bar-full {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 8px;
    transition: width 0.3s ease;
    position: relative;
}

#unity-progress-bar-full::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.unity-progress-text {
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-top: 15px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Footer controls */
#unity-footer {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    pointer-events: none;
}

#unity-footer > div {
    pointer-events: auto;
}

#unity-webgl-logo {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: bold;
    width: 204px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    transition: opacity 0.3s ease;
}

#unity-webgl-logo:hover {
    color: rgba(255, 255, 255, 1);
}

#unity-build-title {
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    flex-grow: 1;
    text-align: center;
    margin: 0 20px;
}

#unity-fullscreen-button {
    width: 38px;
    height: 38px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease, transform 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
}

#unity-fullscreen-button svg {
    width: 24px;
    height: 24px;
    transition: color 0.3s ease;
}

#unity-fullscreen-button:hover {
    opacity: 1;
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 1);
}

#unity-fullscreen-button:active {
    transform: scale(0.95);
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    #unity-footer {
        bottom: 10px;
        left: 10px;
        right: 10px;
        height: 30px;
    }
    
    #unity-webgl-logo {
        width: 150px;
        height: 28px;
    }
    
    #unity-build-title {
        font-size: 14px;
        margin: 0 10px;
    }
    
    #unity-fullscreen-button {
        width: 30px;
        height: 30px;
    }
    
    #unity-fullscreen-button svg {
        width: 18px;
        height: 18px;
    }
    
    #unity-loading-bar {
        max-width: 250px;
        width: 90%;
    }
    
    #unity-logo {
        width: 240px;
        height: 192px;
        margin-bottom: 20px;
    }
    
    .unity-progress-text {
        font-size: 14px;
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {
    #unity-footer {
        bottom: 5px;
        height: 25px;
    }
    
    #unity-webgl-logo {
        width: 120px;
        height: 22px;
    }
    
    #unity-build-title {
        font-size: 12px;
    }
    
    #unity-fullscreen-button {
        width: 25px;
        height: 25px;
    }
    
    #unity-fullscreen-button svg {
        width: 16px;
        height: 16px;
    }
    
    #unity-logo {
        width: 200px;
        height: 160px;
        margin-bottom: 15px;
    }
    
    .unity-progress-text {
        font-size: 12px;
        margin-top: 10px;
    }
}

/* Fullscreen styles */
#unity-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
}

#unity-container:-moz-full-screen {
    width: 100vw;
    height: 100vh;
}

#unity-container:fullscreen {
    width: 100vw;
    height: 100vh;
}

/* Hide scrollbars but keep functionality */
body::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Prevent context menu on right click */
#unity-canvas {
    -webkit-context-menu: none;
    -moz-context-menu: none;
    context-menu: none;
}

/* Prevent text selection */
#unity-container {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Performance optimizations - removed pixelated rendering */
#unity-canvas {
    image-rendering: auto;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    transform: translateZ(0);
}

/* Prevent zoom on double tap (iOS) - Allow touch manipulation for Unity input */
#unity-container {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Loading animation for better UX */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#unity-container {
    animation: fadeIn 0.5s ease-in;
}

/* Hide footer during loading */
#loading-cover:not([style*="display: none"]) ~ #unity-footer {
    display: none;
}

/* Input field compatibility fixes */
input[type="text"], 
input[type="password"],
input[type="email"],
input[type="number"],
textarea, 
.unity-input-field,
/* Unity creates input elements with these classes */
input[class*="unity"],
input[data-unity*="input"] {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    z-index: 1001 !important;
    position: relative !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-family: Arial, sans-serif !important;
    color: #333 !important;
}

/* Ensure Unity input overlays work */
div[style*="position: absolute"]:has(input),
div[class*="input"]:has(input) {
    pointer-events: auto !important;
    z-index: 1001 !important;
}

/* Ensure mobile input fields are accessible */
@media (max-width: 768px) {
    input[type="text"], 
    input[type="password"],
    input[type="email"],
    input[type="number"],
    textarea, 
    .unity-input-field,
    input[class*="unity"],
    input[data-unity*="input"] {
        font-size: 16px !important; /* Prevent zoom on iOS */
        -webkit-appearance: none !important;
        border-radius: 4px !important;
        min-height: 44px !important; /* Better touch target size */
        line-height: 1.4 !important;
    }
    
    /* Ensure Unity input containers are touchable on mobile */
    div[style*="position: absolute"]:has(input),
    div[class*="input"]:has(input) {
        min-height: 44px !important;
    }
}
