/* ==========================================
   PIX3L.PRO - UNIFIED GAME PAGE STYLES
   Responsive across all browsers & mobile
   ========================================== */

/* ==========================================
   ROOT LAYOUT - ensure full viewport coverage
   ========================================== */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.game-page {
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

/* ==========================================
   BASE GAME PAGE LAYOUT
   ========================================== */

.game-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    background: var(--bg);
    overflow: hidden;
}

/* ==========================================
   GAME HEADER
   ========================================== */

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-grow: 0;
    z-index: 10;
}

.game-header-left,
.game-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.game-header-center {
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--text);
    letter-spacing: 0.1em;
    text-align: center;
}

.game-header .back-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.game-header .back-link:hover {
    color: var(--accent);
}

.game-header .stat {
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.game-header .stat-value {
    color: var(--accent);
}

/* ==========================================
   GAME STAGE (Main Game Area)
   ========================================== */

.game-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    position: relative;
    overflow: hidden;
}

/* Game Frame - holds the actual game */
.game-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* ==========================================
   ARCADE CABINET FRAME
   ========================================== */

/* Top lights bar */
.lights-bar {
    display: flex;
    gap: 12px;
    padding: 8px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
    flex-grow: 0;
}

.light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: light-blink 1.5s infinite alternate;
}

.light:nth-child(1) { background: var(--accent); animation-delay: 0s; }
.light:nth-child(2) { background: var(--green); animation-delay: 0.5s; }
.light:nth-child(3) { background: var(--blue); animation-delay: 1s; }

@keyframes light-blink {
    0% { opacity: 0.3; }
    100% { opacity: 1; box-shadow: 0 0 8px currentColor; }
}

/* ==========================================
   GAME SCREEN
   ========================================== */

.game-screen {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

/* For iframe games (Flappy Bird, Galaga) */
.game-screen iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #000;
}

/* For canvas games (Space Shooter) */
.game-screen canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Desktop: fixed aspect ratio */
.game-screen.portrait {
    max-width: 420px;
    aspect-ratio: 9 / 16;
}

.game-screen.landscape {
    max-width: 800px;
    aspect-ratio: 4 / 3;
}

.game-screen.square {
    max-width: 600px;
    aspect-ratio: 1 / 1;
}

/* ==========================================
   BOTTOM PANEL
   ========================================== */

.bottom-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    min-width: 120px;
    flex-shrink: 0;
    flex-grow: 0;
}

.panel-label {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--accent);
    letter-spacing: 1px;
}

.panel-brand {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Insert coin hint */
.coin-hint {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--yellow);
    text-align: center;
    flex-shrink: 0;
    flex-grow: 0;
}

/* ==========================================
   GAME OVERLAYS (Space Shooter)
   ========================================== */

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.92);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

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

.overlay-logo {
    text-align: center;
    margin-bottom: 30px;
}

.overlay-title {
    font-family: var(--font-pixel);
    font-size: clamp(1.2rem, 4vw, 2rem);
    color: var(--accent);
    text-shadow: 0 0 20px rgba(255, 0, 77, 0.5);
    letter-spacing: 4px;
    line-height: 1.3;
}

.overlay-title.game-over {
    color: var(--accent);
    animation: shake 0.5s ease-in-out;
}

.overlay-subtitle {
    font-family: var(--font-pixel);
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    color: var(--blue);
    margin-top: 8px;
    letter-spacing: 6px;
}

.overlay-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
    max-width: 300px;
    padding: 0 20px;
}

.overlay-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
}

.overlay-btn:hover {
    border-color: var(--accent);
    color: var(--text);
    background: var(--bg-hover);
}

.overlay-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text);
    animation: pulse-glow 2s infinite;
}

.overlay-btn.primary:hover {
    background: var(--accent-hover);
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 0, 77, 0.2); }
    50% { box-shadow: 0 0 20px rgba(255, 0, 77, 0.5); }
}

.overlay-stats {
    text-align: center;
    margin-top: 8px;
}

.overlay-stats p {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    line-height: 1.6;
}

.overlay-blink {
    margin-top: 20px;
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--yellow);
}

/* Score display */
.final-score {
    text-align: center;
    margin-bottom: 16px;
}

.final-score p {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.final-score .score-number {
    font-size: 1rem;
    color: var(--accent);
    text-shadow: 0 0 15px rgba(255, 0, 77, 0.5);
}

/* ==========================================
   IN-GAME HUD (Space Shooter)
   ========================================== */

.in-game-hud {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s;
}

.in-game-hud.visible {
    opacity: 1;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-item-label {
    font-family: var(--font-pixel);
    font-size: 0.35rem;
    color: var(--text-muted);
}

.hud-item-value {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--green);
}

/* Boss bar */
.boss-bar {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 55%;
    max-width: 350px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.5s;
}

.boss-bar.visible {
    opacity: 1;
}

.boss-bar.hidden {
    display: none;
}

.boss-bar-label {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--accent);
    white-space: nowrap;
}

.boss-health-track {
    flex: 1;
    height: 12px;
    background: var(--bg);
    border: 1px solid var(--accent);
    overflow: hidden;
}

.boss-health-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
    width: 100%;
}

/* Wave announcement */
.wave-announce {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-pixel);
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--yellow);
    text-shadow: 0 0 20px rgba(255, 236, 39, 0.5);
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    text-align: center;
    white-space: nowrap;
}

.wave-announce.show {
    opacity: 1;
    animation: wave-pop 1.5s ease-out forwards;
}

@keyframes wave-pop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ==========================================
   MOBILE CONTROLS
   ========================================== */

.mobile-controls {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: none;
    justify-content: space-between;
    align-items: center;
    z-index: 8;
    pointer-events: all;
    gap: 10px;
}

.mobile-control-btn {
    width: 70px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: var(--text);
    font-size: 1.5rem;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: all 0.15s;
}

.mobile-control-btn:active {
    background: rgba(255, 0, 77, 0.3);
    border-color: var(--accent);
    transform: scale(0.95);
}

.mobile-control-btn.shoot {
    width: 80px;
    height: 80px;
    background: rgba(255, 0, 77, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.mobile-control-btn.shoot:active {
    background: rgba(255, 0, 77, 0.4);
}

/* ==========================================
   GAME FOOTER
   ========================================== */

.game-footer {
    text-align: center;
    padding: 10px;
    border-top: 1px solid var(--border);
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--text-muted);
    flex-shrink: 0;
    flex-grow: 0;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.blink {
    animation: blink 1.5s infinite;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

/* Tablet */
@media (max-width: 1024px) {
    .game-screen.portrait {
        max-width: 380px;
    }
    .game-screen.landscape {
        max-width: 700px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .game-header {
        padding: 8px 12px;
    }

    .game-header-center {
        font-size: 0.55rem;
    }

    .game-header .back-link {
        font-size: 0.7rem;
    }

    .game-header .stat {
        font-size: 0.5rem;
    }

    .game-stage {
        padding: 8px 12px;
    }

    .game-frame {
        width: 100%;
        max-width: 100%;
    }

    /* On mobile, let the game screen fill available flex space */
    .game-screen.portrait,
    .game-screen.landscape,
    .game-screen.square {
        max-width: 100%;
        aspect-ratio: auto;
    }

    .lights-bar {
        padding: 6px 16px;
        gap: 8px;
    }

    .light {
        width: 6px;
        height: 6px;
    }

    .bottom-panel {
        padding: 6px 16px;
    }

    .panel-label,
    .panel-brand {
        font-size: 0.35rem;
    }

    .coin-hint {
        font-size: 0.4rem;
    }

    .mobile-controls {
        display: flex;
    }

    .mobile-control-btn {
        width: 65px;
        height: 65px;
        font-size: 1.3rem;
    }

    .mobile-control-btn.shoot {
        width: 75px;
        height: 75px;
    }

    .in-game-hud {
        top: 6px;
        left: 6px;
        right: 6px;
    }

    .hud-item-label {
        font-size: 0.3rem;
    }

    .hud-item-value {
        font-size: 0.4rem;
    }

    .boss-bar {
        width: 75%;
        bottom: 70px;
    }

    .boss-bar-label {
        font-size: 0.35rem;
    }

    .game-footer {
        padding: 6px;
        font-size: 0.4rem;
    }

    .overlay-title {
        font-size: 1rem;
        letter-spacing: 2px;
    }

    .overlay-subtitle {
        font-size: 0.5rem;
        letter-spacing: 3px;
    }

    .overlay-btn {
        padding: 12px 20px;
        font-size: 0.5rem;
    }

    .overlay-stats p {
        font-size: 0.35rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .game-header {
        padding: 6px 10px;
    }

    .game-header-center {
        font-size: 0.5rem;
    }

    .game-stage {
        padding: 6px;
    }

    .mobile-control-btn {
        width: 55px;
        height: 55px;
        font-size: 1.1rem;
    }

    .mobile-control-btn.shoot {
        width: 65px;
        height: 65px;
    }

    .overlay-title {
        font-size: 0.9rem;
    }

    .overlay-btn {
        padding: 10px 16px;
    }
}

/* Landscape mobile - maximize game area */
@media (max-height: 500px) and (orientation: landscape) {
    .game-header {
        padding: 4px 10px;
    }

    .game-header-center {
        font-size: 0.45rem;
    }

    .game-stage {
        padding: 4px 8px;
    }

    .lights-bar {
        display: none;
    }

    .bottom-panel {
        display: none;
    }

    .coin-hint {
        display: none;
    }

    .mobile-controls {
        bottom: 4px;
        left: 4px;
        right: 4px;
    }

    .mobile-control-btn {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }

    .mobile-control-btn.shoot {
        width: 55px;
        height: 55px;
    }

    .game-footer {
        display: none;
    }
}

/* ==========================================
   TOUCH DEVICE OPTIMIZATIONS
   ========================================== */

@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }

    .overlay-btn:hover {
        border-color: var(--border);
        color: var(--text-secondary);
        background: var(--bg-card);
    }

    .overlay-btn.primary:hover {
        background: var(--accent);
        border-color: var(--accent);
        color: var(--text);
    }
}

/* ==========================================
   SAFARI / iOS FIXES
   ========================================== */

@supports (-webkit-touch-callout: none) {
    html, body {
        height: -webkit-fill-available;
    }

    .game-page {
        min-height: -webkit-fill-available;
    }

    .game-stage {
        min-height: 0;
    }
}

/* Prevent elastic scrolling on iOS */
body.game-page {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

/* Prevent text selection on game elements */
.game-screen,
.mobile-controls,
.overlay-btn {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ==========================================
   REDUCED MOTION
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    .light,
    .blink,
    .overlay-btn.primary,
    .wave-announce {
        animation: none;
    }
}
