/* ==========================================================
   GAME LAB PAGE — Arcade Zone
   ========================================================== */

#page-gamelab {
    position: relative;
    overflow-x: hidden;
}

/* ── Page Layout ── */
.gamelab-page {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: calc(var(--nav-h) + var(--space-10)) var(--space-8) var(--space-10);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Background Particles Canvas ── */
#gamelab-bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.2;
}

/* ── Header ── */
.gamelab-header {
    text-align: center;
    margin-bottom: var(--space-10);
    position: relative;
    z-index: 1;
}

.gamelab-header__label {
    font-family: var(--font-head);
    font-size: var(--size-xs);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--clr-primary);
    margin-bottom: var(--space-2);
}

.gamelab-header__title {
    font-family: var(--font-head);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    line-height: 1.1;
    color: var(--clr-text);
    margin-bottom: var(--space-3);
}

.gamelab-header__title span {
    background: linear-gradient(135deg, #6366f1, #2563eb, #7b6ff0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gamelab-header__sub {
    font-family: var(--font-body);
    font-size: var(--size-md);
    color: var(--clr-muted);
    max-width: 500px;
    margin: 0 auto;
}

/* ── Game Cards Grid ── */
.gamelab-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
    max-width: 1060px;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* ── Game Card ── */
.gamelab-card {
    position: relative;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(192, 160, 98, 0.08);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
        box-shadow 0.4s cubic-bezier(0.23, 1, 0.32, 1),
        border-color 0.3s;
    box-shadow: 0 2px 12px rgba(192, 160, 98, 0.05),
        0 1px 3px rgba(0, 0, 0, 0.04);
}

.gamelab-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 48px rgba(192, 160, 98, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: rgba(192, 160, 98, 0.2);
}

.gamelab-card__preview {
    position: relative;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gamelab-card__preview-bg {
    position: absolute;
    inset: 0;
    opacity: 0.92;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.gamelab-card:hover .gamelab-card__preview-bg {
    transform: scale(1.08);
}

.gamelab-card__icon {
    position: relative;
    z-index: 2;
    font-size: 4rem;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.35));
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    line-height: 1;
}

.gamelab-card:hover .gamelab-card__icon {
    transform: scale(1.18) translateY(-4px);
}

.gamelab-card__play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 3;
}

.gamelab-card:hover .gamelab-card__play-overlay {
    opacity: 1;
}

.gamelab-card__play-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--grad-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(192, 160, 98, 0.55);
    color: white;
    font-size: 1.3rem;
    pointer-events: none;
    transform: scale(0.7);
    transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.gamelab-card:hover .gamelab-card__play-btn {
    transform: scale(1);
}

.gamelab-card__body {
    padding: 1.1rem 1.3rem 1.3rem;
}

.gamelab-card__title {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--clr-text);
    margin-bottom: 0.35rem;
}

.gamelab-card__desc {
    font-size: 0.82rem;
    color: var(--clr-muted);
    line-height: 1.55;
    margin-bottom: 0.7rem;
}

.gamelab-card__controls {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.gamelab-card__control-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    background: rgba(192, 160, 98, 0.07);
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--clr-primary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* ── Leaderboard badge ── */
.gamelab-card__best {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 4;
    padding: 0.22rem 0.55rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(192, 160, 98, 0.12);
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--clr-primary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

/* ═══════════════════════════════════════════════════════════
   GAME CONTAINER (full-screen overlay for playing)
   ═══════════════════════════════════════════════════════════ */
.gamelab-container {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #f8fafc;
    display: none;
    flex-direction: column;
    align-items: stretch;
}

.gamelab-container.active {
    display: flex;
}

/* HUD bar */
.gamelab-hud {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    background: rgba(10, 10, 26, 0.95);
    border-bottom: 1px solid rgba(192, 160, 98, 0.25);
    z-index: 100;
}

.gamelab-hud__title {
    font-family: var(--font-head);
    font-size: var(--size-md);
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.gamelab-hud__score {
    font-family: var(--font-head);
    font-size: var(--size-lg);
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.gamelab-hud__score-val {
    background: linear-gradient(135deg, #6366f1, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 60px;
    text-align: center;
}

.gamelab-hud__back {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-family: var(--font-head);
    font-size: var(--size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    z-index: 200;
}

.gamelab-hud__back:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.04);
}

/* Game Canvas */
.gamelab-canvas {
    display: block;
    flex: 1;
    width: 100%;
    min-height: 0;
}

/* Game Over overlay */
.gamelab-gameover {
    position: absolute;
    inset: 0;
    top: 56px;
    background: rgba(10, 10, 26, 0.9);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    z-index: 50;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.gamelab-gameover.active {
    display: flex;
}

.gamelab-gameover__title {
    font-family: var(--font-head);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 900;
    background: linear-gradient(135deg, #6366f1, #2563eb, #7b6ff0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gamelab-gameover__score {
    font-family: var(--font-head);
    font-size: var(--size-xl);
    color: rgba(255, 255, 255, 0.88);
    font-weight: 600;
}

.gamelab-gameover__btns {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.gamelab-gameover__btn {
    padding: 0.7rem 1.8rem;
    border-radius: var(--radius-full);
    font-family: var(--font-head);
    font-size: var(--size-sm);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}

.gamelab-gameover__btn:hover {
    transform: translateY(-2px);
}

.gamelab-gameover__btn--play {
    background: var(--grad-primary);
    color: #fff;
    box-shadow: 0 4px 20px rgba(192, 160, 98, 0.4);
}

.gamelab-gameover__btn--play:hover {
    box-shadow: 0 8px 30px rgba(192, 160, 98, 0.6);
}

.gamelab-gameover__btn--quit {
    background: rgba(192, 160, 98, 0.06);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .gamelab-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }

    .gamelab-page {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
}

@media (max-width: 560px) {
    .gamelab-grid {
        grid-template-columns: 1fr;
    }

    .gamelab-card__preview {
        height: 150px;
    }

    .gamelab-hud {
        padding: 0 var(--space-3);
        height: 48px;
    }

    .gamelab-hud__title {
        font-size: var(--size-sm);
    }

    .gamelab-hud__score {
        font-size: var(--size-md);
    }
}