body { padding: 0; margin: 0 }
#unity-container { position: absolute }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
#unity-container.unity-mobile { position: fixed; width: 100%; height: 100% }
#unity-canvas { 
    background: #231F20 !important;
    border: 2px solid white; /* Added white border */
    transition: opacity 0.3s ease;
}
.unity-mobile #unity-canvas { width: 100%; height: 100% }
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
#unity-logo { width: 154px; height: 130px; background: url('../images/unity-logo-dark.png') no-repeat center }
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('../images/progress-bar-empty-dark.png') no-repeat center }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('../images/progress-bar-full-dark.png') no-repeat center }

/* Customized Unity Footer */
#unity-footer { 
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 5px 0;
}

.unity-mobile #unity-footer { 
    display: none 
}

/* Removed unity-logo-title-footer */
#unity-logo-title-footer { 
    display: none;
}

/* Removed the old build title */
#unity-build-title { 
    display: none;
}

/* New game title above the canvas */
.game-title {
    color: white;
    font-family: 'DIN', sans-serif;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    width: 100%;
}

/* Customized fullscreen button */
#unity-fullscreen-button { 
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 15px;
    border: 1px solid white;
    border-radius: 4px;
    font-family: 'DIN', sans-serif;
    font-size: 14px;
    transition: background-color 0.3s ease;
    margin: 0 auto; /* Center the button */
}

#unity-fullscreen-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }

/* Game thumbnail styles */
.game-thumbnails {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
    margin-bottom: 50px;
}

.game-thumbnail {
    width: 500px;
    cursor: pointer;
    transition: transform 0.3s ease;
    text-align: center;
    background-color: #fff;
    display: flex;
    flex-direction: column;
}

.game-thumbnail:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(241, 106, 33, 0.3);
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 2px solid #f16a21;
    border-radius: 8px 8px 0 0; /* Round only the top corners */
}

.thumbnail-title {
    font-family: 'DIN', sans-serif;
    font-size: 20pt;
    color: #000;
    padding: 10px;
    border: 2px solid #f16a21;
    border-top: none; /* Remove top border to connect with image */
    border-radius: 0 0 8px 8px; /* Round only the bottom corners */
    margin-top: -2px; /* Offset to account for image border */
}

/* Improved Modal Animation Styles */
.js-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 1px; /* Start with 1px height to create line effect */
    background-color: #f16a21;
    z-index: 9999;
    overflow: hidden;
    transition: width 0.5s ease, height 0.5s ease 0.5s; /* First expand width, then height */
}

.js-modal.active {
    width: 100%;
    height: 100%;
    transition: width 0.5s ease, height 0.5s ease 0.5s;
}

/* Custom closing animation - only animate height for closing */
.js-modal.closing {
    width: 100%; /* Keep full width */
    height: 1px; /* Collapse to 1px line */
    transition: height 0.5s ease; /* Only animate height when closing */
}

.js-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 50px 20px 20px 20px;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.js-modal.active .js-modal-content {
    opacity: 1;
    transition: opacity 0.5s ease 0.5s;
}

/* Fade out content faster when closing */
.js-modal.closing .js-modal-content {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.js-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10001; /* Ensure it's above other elements */
}

.js-modal-close::before,
.js-modal-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: white;
}

.js-modal-close::before {
    transform: rotate(45deg);
}

.js-modal-close::after {
    transform: rotate(-45deg);
}

/* Hover effect for the close button */
.js-modal-close:hover::before,
.js-modal-close:hover::after {
    background-color: #e0e0e0;
}


/* Unity container in modal - Fixed alignment */
.js-modal .game-container {
    width: 960px; /* Match the canvas width */
    max-width: 90%; /* For mobile responsiveness */
    height: 100%;
    max-height: 80vh; /* Ensure it fits in the viewport */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.js-modal #unity-container {
    width: 960px; /* Match original Unity width */
    max-width: 100%;
    height: auto;
    position: relative; /* Override absolute positioning */
    left: auto;
    top: auto;
    transform: none;
}

.js-modal #unity-canvas {
    width: 960px !important; /* Fixed width */
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/9;
    border: 2px solid white; /* Added white border for the modal view */
    box-sizing: border-box; /* Ensures border is included in width calculation */
}

/* Keyboard instructions */
.keyboard-instructions {
    color: white;
    font-family: 'DIN', sans-serif;
    font-size: 16pt;
    text-align: center;
    margin-top: 20px;
}

/* Ensure modal content is hidden while modal is inactive */
.js-modal:not(.active) .js-modal-content {
    display: none !important;
}

/* Make sure the Unity container is properly reset */
#unity-container {
    position: relative;
    width: 960px;
    max-width: 100%;
}

/* Ensure loading bar displays correctly */
#unity-loading-bar {
    z-index: 10;
}

/* Prevent body scrolling when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .game-thumbnail {
        width: 250px;
    }
    
    .thumbnail-title {
        font-size: 18pt;
    }
    
    .js-modal .game-container {
        max-width: 100%;
    }
    
    .game-title {
        font-size: 22px;
    }
    
    #unity-fullscreen-button {
        font-size: 12px;
        padding: 6px 12px;
    }
}