/* Boogie's Arcade Games CSS */

.arcade-hero {
    padding-top: 8rem;
    padding-bottom: 2rem;
    text-align: center;
    position: relative;
}

.arcade-title-group {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.arcade-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    background: rgba(243, 156, 18, 0.15);
    border: 1px solid rgba(243, 156, 18, 0.4);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.arcade-subtitle {
    max-width: 650px;
    margin: 0 auto 2rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
}

/* Search and Filters */
.arcade-controls-container {
    max-width: 860px;
    margin: 0 auto 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.search-box-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0.6;
    pointer-events: none;
}

.game-search-input {
    width: 100%;
    padding: 1rem 1.2rem 1rem 3.2rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 1.05rem;
    outline: none;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.game-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

.category-filter-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
}

.cat-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    opacity: 0.8;
}

.cat-btn:hover {
    border-color: var(--primary);
    opacity: 1;
    transform: translateY(-2px);
}

.cat-btn.active {
    background: var(--primary);
    color: #121418;
    font-weight: 700;
    opacity: 1;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.4);
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 5rem;
}

.game-card {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-8px);
    border-color: rgba(243, 156, 18, 0.5);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(243, 156, 18, 0.15);
}

/* Card Visual Header */
.game-card-visual {
    height: 190px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(20, 24, 45, 0.9) 0%, rgba(12, 14, 25, 0.95) 100%);
    overflow: hidden;
    border-bottom: 1px solid var(--glass-border);
}

.game-card-visual .pattern-bg {
    position: absolute;
    inset: 0;
    opacity: 0.15;
    background-size: 20px 20px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
}

.game-icon-large {
    font-size: 4.5rem;
    z-index: 2;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
    transition: transform 0.4s ease;
}

.game-card:hover .game-icon-large {
    transform: scale(1.15) rotate(4deg);
}

/* Featured / Hot Tags */
.status-pill {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 3;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.status-hot {
    background: linear-gradient(135deg, #e74c3c, #f39c12);
    color: #fff;
}

.status-new {
    background: linear-gradient(135deg, #1abc9c, #3498db);
    color: #fff;
}

.status-classic {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: #fff;
}

/* Card Body */
.game-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.game-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.meta-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-device {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
}

.game-card-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.6rem;
}

.game-card-desc {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.68);
    line-height: 1.55;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.game-card-actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.btn-play-game {
    flex: 1;
    padding: 0.75rem 1.2rem;
    border-radius: 50px;
    background: var(--primary);
    color: #121418;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.35);
}

.btn-play-game:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(243, 156, 18, 0.5);
    background: #f5ab35;
}

.btn-external-link {
    padding: 0.75rem 0.9rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-external-link:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ========================================================= */
/* Modern Modal Dialog (<dialog>) */
/* ========================================================= */
dialog:modal {
    overscroll-behavior: contain;
}

dialog::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: rgba(4, 5, 12, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#gameModal {
    margin: auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    background: #0d0f17;
    color: var(--text);
    width: min(94vw, 1020px);
    max-height: 94vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(243, 156, 18, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#gameModal:not([open]) {
    display: none;
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.4rem;
    background: rgba(18, 21, 33, 0.95);
    border-bottom: 1px solid var(--glass-border);
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.modal-game-icon {
    font-size: 1.8rem;
}

.modal-game-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.modal-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    transition: var(--transition);
}

.modal-action-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-close-modal {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.4);
    color: #ff6b6b;
}

.btn-close-modal:hover {
    background: rgba(231, 76, 60, 0.35);
    color: #fff;
}

/* Modal Game Container */
.modal-game-body {
    position: relative;
    flex-grow: 1;
    min-height: 520px;
    max-height: calc(94vh - 70px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #090a10;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Loading Spinner */
.game-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: #0d0f17;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.game-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(243, 156, 18, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Iframe Game Player */
.game-iframe {
    width: 100%;
    height: 640px;
    max-height: calc(90vh - 70px);
    border: none;
    display: block;
}

/* Built-in Game Arena */
.game-arena {
    width: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin-bottom: 1rem;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.score-badge {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.score-badge strong {
    color: var(--primary);
    font-size: 1.15rem;
    margin-left: 0.3rem;
}

.hud-btn {
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: #fff;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.hud-btn:hover {
    background: var(--primary);
    color: #000;
}

/* Canvas Styles */
.game-canvas {
    background: #121422;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    height: auto;
}

/* Mobile D-Pad Virtual Controls */
.mobile-dpad {
    display: none;
    grid-template-areas: 
        ".    up    ."
        "left .     right"
        ".    down  .";
    gap: 8px;
    margin-top: 1rem;
    width: 180px;
    height: 180px;
}

.dpad-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--glass-border);
    color: #fff;
    border-radius: 12px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.dpad-btn:active {
    background: var(--primary);
    color: #000;
}

.dpad-up { grid-area: up; }
.dpad-down { grid-area: down; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }

@media (max-width: 768px) {
    .mobile-dpad {
        display: grid;
    }
}

/* 2048 Board Styles */
.game-2048-container {
    width: 340px;
    max-width: 100%;
    background: #1b1e2c;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.grid-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    aspect-ratio: 1;
}

.cell-2048 {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: #fff;
    transition: transform 0.1s ease;
}

.cell-2 { background: #eee4da; color: #776e65; }
.cell-4 { background: #ede0c8; color: #776e65; }
.cell-8 { background: #f2b179; color: #f9f6f2; }
.cell-16 { background: #f59563; color: #f9f6f2; }
.cell-32 { background: #f67c5f; color: #f9f6f2; }
.cell-64 { background: #f65e3b; color: #f9f6f2; }
.cell-128 { background: #edcf72; color: #f9f6f2; font-size: 1.25rem; box-shadow: 0 0 10px #edcf72; }
.cell-256 { background: #edcc61; color: #f9f6f2; font-size: 1.25rem; box-shadow: 0 0 15px #edcc61; }
.cell-512 { background: #edc850; color: #f9f6f2; font-size: 1.25rem; box-shadow: 0 0 20px #edc850; }
.cell-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.05rem; box-shadow: 0 0 25px #edc53f; }
.cell-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.05rem; box-shadow: 0 0 30px #edc22e; }

/* Memory Game Grid */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 360px;
    max-width: 100%;
}

.memory-card {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    perspective: 1000px;
    transition: transform 0.2s, background-color 0.2s;
    user-select: none;
}

.memory-card:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.memory-card.flipped {
    background: rgba(243, 156, 18, 0.2);
    border-color: var(--primary);
}

.memory-card.matched {
    background: rgba(46, 204, 113, 0.2);
    border-color: #2ecc71;
    cursor: default;
}

/* Tic Tac Toe Grid */
.tictactoe-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 320px;
    max-width: 100%;
}

.tictactoe-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
}

.tictactoe-cell:hover:not(.taken) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
}

.tictactoe-cell.x {
    color: #e74c3c;
}

.tictactoe-cell.o {
    color: #3498db;
}

/* Minesweeper Grid */
.minesweeper-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    overflow-x: auto;
}

.minesweeper-grid {
    display: grid;
    gap: 2px;
    background: #111;
    padding: 6px;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
}

.mine-cell {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
}

.mine-cell.revealed {
    background: rgba(255, 255, 255, 0.04);
    cursor: default;
}

.mine-cell.exploded {
    background: #e74c3c;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .arcade-hero {
        padding-top: 6.5rem;
    }
    .games-grid {
        grid-template-columns: 1fr;
    }
    #gameModal {
        width: 98vw;
        max-height: 98vh;
        border-radius: 16px;
    }
    .modal-game-body {
        min-height: 440px;
    }
    .game-iframe {
        height: 520px;
    }
}
