/* Games Grid Override */
.projects-list.view-mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 3 Columns */
    gap: 1.5rem;
    padding-bottom: 10rem;
}

.view-mode-grid .project-item {
    aspect-ratio: 1/1;
    /* Square */
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

/* Center content in square */
.view-mode-grid .project-main {
    justify-content: center;
    align-items: center;
    height: 100%;
}

.view-mode-grid .project-title {
    font-size: 2rem;
    text-align: center;
    padding: 0 1rem;
}

/* Game Overlay */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background-color: #000000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Add this class to your loader-percent when active */
.loader-percent {
    display: inline-block;
    transition: color 0.3s ease;
}

.game-loader.active .loader-percent {
    animation: heartbeat 1.5s infinite ease-in-out;
    color: #ffffff;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(0.95);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Add a subtle glow to the message so they know it's working */
.loader-message {
    animation: fadeText 2s infinite;
}

@keyframes fadeText {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.game-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Close Game Button */
.close-game-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.8rem 1.5rem;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    z-index: 10002;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 4px;
    /* Optional: Slight rounding */
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-game-btn:hover {
    background: #fff;
    color: #000;
}

.btn-icon {
    display: none;
    /* Hidden on Desktop */
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background-color: #000;
}

#game-canvas {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 800px;
}

/* Ensure Game Items look clickable */
.game-item {
    cursor: pointer;
    aspect-ratio: 1/1;
    /* Square */
}

.game-item:hover .project-title {
    color: var(--griffin-accent);
}

/* Game Images */
.p-img-studio {
    background-image: url('./assets/studio.png');
    background-color: #111;
}

.p-img-fluffy {
    background-image: url('./assets/fluffy.png');
    background-color: #222;
}

.p-img-feed {
    background-image: url('./assets/feedcat.png');
    background-color: #333;
}

.p-img-road {
    background-image: url('./assets/hitroad.png');
    background-color: #444;
}

/* Remove Hover Effect for Games */
.game-item:hover .p-img {
    transform: none;
}

.game-item .p-img {
    transform: none;
    width: 100%;
    height: 100%;
    transition: none;
    /* Disable transition */
}

/* Force Full Opacity for Game Images */
.game-item .project-image-reveal {
    opacity: 1 !important;
    transform: none !important;
}

.game-item:hover .project-image-reveal {
    opacity: 1 !important;
    transform: none !important;
}

/* Orientation Overlay */
.orientation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    /* Dynamic Viewport Height for Mobile Bars */
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.orientation-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.rotate-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: rotate-phone 2s infinite ease-in-out;
}

@keyframes rotate-phone {

    0%,
    10% {
        transform: rotate(0deg);
    }

    40%,
    60% {
        transform: rotate(90deg);
    }

    90%,
    100% {
        transform: rotate(0deg);
    }
}

/* Mobile Layout Fixes */
@media (max-width: 900px) {
    .projects-list.view-mode-grid {
        grid-template-columns: 1fr;
        /* One below one */
    }

    .view-mode-grid .project-item {
        aspect-ratio: 1/1;
        /* Keep square or adjust if needed */
        margin-bottom: 2rem;
    }

    .close-game-btn {
        top: 1rem;
        right: 1rem;
        padding: 0;
        width: 3rem;
        height: 3rem;
        border-radius: 50% !important;
        /* Circle on mobile */
        font-size: 1.2rem;
        background: rgba(0, 0, 0, 0.5);
        /* Darker bg for contrast */
        border: 1px solid rgba(255, 255, 255, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-text {
        display: none !important;
    }

    .btn-icon {
        display: block !important;
    }

    .canvas-container {
        width: 100%;
        height: 100%;
    }

    #game-canvas {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

/* Loading Spinner */
.game-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    z-index: 10002;
    display: none;
    text-align: center;
}

.loader-percent {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: block;
    line-height: 1;
}

.loader-message {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 1rem;
    min-height: 1.5em;
    /* Prevent layout shift */
    font-weight: 400;
}

.game-loader.active {
    display: block;
}

/* Placeholder Game Images */
.p-img-noobie {
    background-image: url('./assets/noobie.png');
    background-color: #111;
}

.p-img-stray {
    background-image: url('./assets/kitty.png');
    background-color: #111;
}

.p-img-pop {
    background-color: #ff1493;
    background-image: linear-gradient(135deg, #ff1493 0%, #ff69b4 100%);
}

.p-img-rotate {
    background-color: #00fa9a;
    background-image: linear-gradient(135deg, #00fa9a 0%, #3cb371 100%);
}

/* Overlay Iframe Styling */
#game-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    background: transparent;
}

.p-img-happy {
    background-image: url('./assets/happy.png?v=2');
    background-color: #111;
}

#canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Hide on Mobile Utility */
@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
}