.game-tile {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    border-radius: 0.75rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.game-tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.2s ease-out;
}

.game-tile:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2),
                0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

.game-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.game-tile:hover img {
    transform: scale(1.05);
}

.game-tile .overlay {
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    padding: 2rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
    transform: translateY(0);
    transition: transform 0.3s ease;
}

/* Modal animations */
.modal-backdrop {
    opacity: 0;
    backdrop-filter: blur(4px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.show {
    opacity: 1;
}

.modal-content {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content.show {
    opacity: 1;
    transform: scale(1);
}

/* Navbar transitions */
#mainNav {
    transition: transform 0.3s ease-out;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 50;
    background-color: rgb(17, 24, 39);
}

#mainNav.hide {
    transform: translateY(-100%);
}

#gameNav {
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;
    opacity: 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 45;
    background-color: rgb(17, 24, 39);
}

#gameNav.show {
    transform: translateY(0);
    opacity: 1;
}

/* Game container */
.game-container {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-out;
    overflow: hidden;
}

.game-container.show {
    opacity: 1;
    visibility: visible;
}

.game-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.game-tile:hover .overlay {
    transform: translateY(-5px);
}

/* Footer styles */
footer {
    margin-top: auto;
}

.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.overflow-x-auto::-webkit-scrollbar {
    height: 6px;
}

.overflow-x-auto::-webkit-scrollbar-track {
    background: transparent;
}

.overflow-x-auto::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Add/update these styles */
body.game-active {
    overflow: hidden;
}

/* Add this to handle the fixed navbar spacing */
body {
    padding-top: 88px;
}

/* Add padding to main content */
main.container {
    padding-top: 2rem; /* 32px in Tailwind's spacing */
}

.game-icons {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
    display: flex;
    gap: 0.25rem;
}

.game-icon-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.75);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    border-radius: 9999px;
    padding: 0.25rem;
    padding-left: 0.35rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 28px;
    height: 28px;
    overflow: hidden;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Add a specific Safari-only fix using @supports */
@supports (-webkit-hyphens:none) {
    .game-icon-pill {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
        -webkit-transform-style: preserve-3d;
        transform-style: preserve-3d;
    }
}

.game-icon-wrapper {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.game-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.pill-text {
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Hover animations */
.game-icon-pill:hover {
    width: auto;
    padding: 0.25rem 0.5rem 0.25rem 0.35rem;
}

.game-icon-pill:hover .pill-text {
    opacity: 1;
    transform: translateX(0);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgb(156, 163, 175)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

select:hover {
    background-color: rgb(31, 41, 55);
}

.last-played {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
}

/* If there are game icons, position the timestamp below them */
.game-icons + .last-played {
    top: 3rem;
}

/* Badge container styles */
.carousel .relative {
    position: relative;
    z-index: 1;
}

/* Badge styles with higher z-index and solid background */
#modalPlayerCount, #modalOriginalBadge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 50; /* Even higher z-index */
    pointer-events: none;
    isolation: isolate; /* Create new stacking context */
}

#modalPlayerCount > div, #modalOriginalBadge > div {
    background: rgba(0, 0, 0, 0.85); /* More solid background */
    -webkit-backdrop-filter: blur(8px); /* Stronger blur */
    backdrop-filter: blur(8px);
}

/* Carousel and images */
.carousel {
    position: relative;
    overflow: hidden;
}

#carouselImages {
    position: relative;
    width: 100%;
    height: 12rem;
    z-index: 1;
}

#carouselImages img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Carousel indicators */
#carouselIndicators {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    z-index: 45;
}

/* Close button styles */
.modal-content .close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 50; /* Match the badges z-index */
    pointer-events: all; /* Ensure it's clickable */
}

.unavailable-warning {
    background-color: #ff4444;
    color: white;
    padding: 1rem;
    margin: -1rem -1rem 1rem -1rem;
    text-align: center;
    font-weight: bold;
    border-radius: 0.5rem 0.5rem 0 0;
}

/* Loading Skeleton Animation */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

/* Fade In Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 0.5rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Gradient Fade for Scrollable Sections */
.scroll-fade {
    position: relative;
}

.scroll-fade::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 50px;
    background: linear-gradient(to right, transparent, rgb(17, 24, 39));
    pointer-events: none;
}

/* Play Button Enhancement */
#playButton {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

#playButton::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 50%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.4s ease;
}

#playButton:active::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Search Box Enhancement */
#searchBox {
    transition: all 0.3s ease;
}

#searchBox:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

/* Back to Library Button Animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

#backToLibrary {
    transition: all 0.3s ease;
}

#backToLibrary:hover {
    animation: pulse 2s infinite;
}