/* ===== CSS Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
}

/* ===== Unity Canvas Container ===== */
/* Viewport-anchored (fixed + vw/vh) so the box can NEVER measure 0 during the
   fullscreen enter/exit reparent. The engine reads getBoundingClientRect() to size
   the drawing buffer; if that box ever collapses to 0 the default framebuffer becomes
   0x0 (GL_INVALID_FRAMEBUFFER_OPERATION / black / white-ellipse). 100vw/100vh is
   independent of parent layout, so the reparent can't zero it. */
#unity-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    /* Fit the VISIBLE viewport height (dvh), not the large/layout viewport. On mobile the
       layout viewport is taller than what's visible (the browser URL bar), so 100vh pushed
       the bottom of the game off-screen. dvh tracks the currently-visible height; with the
       interactive-widget=resizes-visual meta it also stays keyboard-safe. 100vh = fallback. */
    height: 100vh;
    height: 100dvh;
    background: #0a0a0a;
}

/* #unity-container is the element we put into browser fullscreen (NOT the canvas, to
   avoid Unity's SetFullscreen reparenting the canvas → 0x0 framebuffer). Pin it to the
   full screen while it's the fullscreen element so the canvas (100%) fills it. */
#unity-container:fullscreen,
#unity-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #0a0a0a;
}

#unity-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 1px;
    min-height: 1px;
    display: block;
    cursor: default;
    outline: none;
}

#unity-canvas:focus {
    outline: none;
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease-in-out;
}

#loading-content {
    text-align: center;
    max-width: 400px;
    padding: 20px;
}

#vlands-logo {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    object-fit: contain;
    animation: pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 8px 32px rgba(102, 126, 234, 0.3));
}

#vlands-wordmark {
    display: block;
    width: 240px;
    height: auto;
    margin: 0 auto 40px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.3));
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ===== Loading Bar ===== */
#loading-bar-container {
    margin-top: 20px;
}

#loading-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

#loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

#loading-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* ===== Error/Warning Banner ===== */
#unity-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 38, 38, 0.95);
    color: #ffffff;
    padding: 20px 30px;
    border-radius: 8px;
    max-width: 80%;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    #loading-content {
        max-width: 90%;
        padding: 15px;
    }

    #vlands-logo {
        width: 100px;
        height: 100px;
        margin-bottom: 15px;
    }

    #vlands-wordmark {
        width: 200px;
        margin-bottom: 30px;
    }

    #loading-text {
        font-size: 12px;
    }

    #unity-warning {
        max-width: 90%;
        padding: 15px 20px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #vlands-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 10px;
    }

    #vlands-wordmark {
        width: 160px;
        margin-bottom: 20px;
    }
}

/* ===== Touch/Mobile Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    /* Mobile touch devices */
    #unity-canvas {
        touch-action: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ===== Landscape Mobile ===== */
@media (max-width: 900px) and (orientation: landscape) {
    #loading-content {
        max-width: 60%;
    }

    #vlands-logo {
        width: 80px;
        height: 80px;
    }

    #vlands-wordmark {
        width: 160px;
        margin-bottom: 20px;
    }
}

/* ===== Prevent Selection & Context Menu ===== */
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

canvas {
    -webkit-tap-highlight-color: transparent;
}

/* The fullscreen toggle is now a Unity UI button (vLands.UI.FullscreenButton), not an HTML
   overlay — its styling lives in Unity, so there are no #fs-toggle rules here anymore. */
