* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    background-color: #000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #fff;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Unity Container */
.unity-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    transition: opacity 0.3s ease;
}

.unity-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: 20px;
    max-width: 90%;
}

.loading-content h1 {
    font-size: clamp(1.5rem, 5vw, 3rem);
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.loading-bar-container {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 15px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d4ff, #0099ff);
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.loading-text {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
}

/* Orientation Notice */
.orientation-notice {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.3s ease;
}

.orientation-notice.hidden {
    opacity: 0;
    pointer-events: none;
}

.orientation-content {
    text-align: center;
    padding: 20px;
}

.phone-icon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.rotate-icon {
    font-size: 40px;
    margin-top: 20px;
    animation: rotate 2s linear infinite;
}

.orientation-content h2 {
    font-size: clamp(1.2rem, 4vw, 2rem);
    margin-bottom: 15px;
}

.orientation-content p {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    color: rgba(255, 255, 255, 0.8);
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Fullscreen Button */
.fullscreen-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.fullscreen-btn.visible {
    display: flex;
}

.fullscreen-btn:hover,
.fullscreen-btn:active {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.fullscreen-btn svg {
    pointer-events: none;
}

/* Error Message */
.error-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    transition: opacity 0.3s ease;
}

.error-message.hidden {
    opacity: 0;
    pointer-events: none;
}

.error-content {
    text-align: center;
    padding: 30px;
    max-width: 90%;
    background: rgba(255, 0, 0, 0.1);
    border: 2px solid rgba(255, 0, 0, 0.3);
    border-radius: 10px;
}

.error-content h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 15px;
    color: #ff4444;
}

.error-content p {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}

.error-content button {
    padding: 12px 30px;
    font-size: 1rem;
    background: #ff4444;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    transition: background 0.3s ease;
}

.error-content button:hover,
.error-content button:active {
    background: #ff6666;
}

/* Landscape Mode Optimizations */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .loading-content h1 {
        font-size: clamp(1.2rem, 4vh, 2rem);
        margin-bottom: 15px;
    }

    .loading-bar-container {
        max-width: 300px;
        height: 6px;
    }

    .loading-text {
        font-size: clamp(0.8rem, 2.5vh, 1rem);
    }

    .fullscreen-btn {
        width: 40px;
        height: 40px;
        bottom: 10px;
        right: 10px;
    }

    .orientation-content h2 {
        font-size: clamp(1rem, 3vh, 1.5rem);
    }

    .orientation-content p {
        font-size: clamp(0.8rem, 2.5vh, 1rem);
    }

    .phone-icon {
        font-size: 40px;
        margin-bottom: 10px;
    }

    .rotate-icon {
        font-size: 30px;
        margin-top: 10px;
    }
}

/* Portrait Mode on Mobile - Show warning */
@media screen and (orientation: portrait) and (max-width: 767px) {
    .unity-container {
        opacity: 0.3 !important;
    }
}

/* Tablet and Desktop */
@media screen and (min-width: 768px) {
    .orientation-notice {
        display: none !important;
    }

    .unity-container {
        opacity: 1 !important;
    }
}

/* Safe area insets for notch devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* Prevent pull-to-refresh on mobile browsers */
body {
    overscroll-behavior-y: contain;
}

/* Hide scrollbars */
::-webkit-scrollbar {
    display: none;
}
