/* ============================================
   CODE INVADERS — Game Modal Styles
   Retro hacker arcade overlay for WK2.0
   ============================================ */

/* ---- Modal overlay ---- */
.game-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.game-modal.hidden { display: none; }

.game-modal__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}

/* ---- Header bar ---- */
.game-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 4px;
}

.game-modal__title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.game-modal__close {
    background: none;
    border: 1px solid #21262d;
    color: #6e7681;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Share Tech Mono', monospace;
    transition: all 0.3s;
    line-height: 1;
}

.game-modal__close:hover {
    color: #ff006e;
    border-color: #ff006e;
    box-shadow: 0 0 10px rgba(255, 0, 110, 0.3);
}

/* ---- Canvas container ---- */
.game-canvas-wrap {
    position: relative;
    border: 2px solid #21262d;
    border-radius: 4px;
    overflow: hidden;
    box-shadow:
        0 0 20px rgba(0, 255, 136, 0.1),
        0 0 60px rgba(0, 255, 136, 0.05),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    background: #050508;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* CRT scanlines overlay */
.game-canvas-wrap::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.04) 2px,
        rgba(0, 0, 0, 0.04) 4px
    );
    pointer-events: none;
    z-index: 2;
}

/* CRT vignette */
.game-canvas-wrap::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at center, transparent 65%, rgba(0,0,0,0.25) 100%);
    pointer-events: none;
    z-index: 3;
}

/* ---- Responsive canvas sizing ---- */
.game-canvas-wrap {
    width: min(280px, calc(100vw - 32px));
    height: min(400px, calc(100vh - 120px));
    aspect-ratio: 7 / 10;
}

@media (min-width: 500px) and (min-height: 600px) {
    .game-canvas-wrap {
        width: min(392px, calc(100vw - 48px));
        height: min(560px, calc(100vh - 140px));
    }
}

@media (min-width: 800px) and (min-height: 750px) {
    .game-canvas-wrap {
        width: min(448px, calc(100vw - 64px));
        height: min(640px, calc(100vh - 160px));
    }
}

/* ---- Modal footer ---- */
.game-modal__footer {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    color: #6e7681;
    text-align: center;
}

.game-modal__footer span {
    color: #b44dff;
}

/* ---- Canvas touch behavior ---- */
#game-canvas {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ---- Standalone page styles (game.html) ---- */
body:not(:has(.game-modal)) .game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(16, 16, 30, 0.9);
    border-bottom: 1px solid #21262d;
}

body:not(:has(.game-modal)) .game-topbar__back {
    color: #00ff88;
    text-decoration: none;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
}

body:not(:has(.game-modal)) .game-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

body:not(:has(.game-modal)) .game-footer {
    text-align: center;
    padding: 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #6e7681;
}

body:not(:has(.game-modal)) .game-footer a {
    color: #00ff88;
    text-decoration: none;
}
