/* ========================================================
   Hospital Flow Web — Kontakt.io Brand + Pixel Game Style
   ======================================================== */

:root {
    /* Kontakt Primary Palette */
    --flame: #FF0032;
    --flame-glow: rgba(255, 0, 50, 0.4);
    --light: #F7EDE6;
    --eclipse: #3C2646;
    --eclipse-deep: #2a1a32;

    /* Neutrals */
    --black: #000000;
    --white: #FFFFFF;
    --gray-100: #171717;
    --gray-90: #282828;
    --gray-80: #3D3D3D;
    --gray-70: #565656;
    --gray-60: #6F6F6F;
    --gray-50: #8C8C8C;
    --gray-40: #A4A4A4;
    --gray-30: #BEBEBE;
    --gray-20: #DCDCDC;
    --gray-10: #F3F3F3;

    /* Pixel border size */
    --px: 4px;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Base ─────────────────────────────────────────────── */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Poppins', Arial, Helvetica, sans-serif;
    background: var(--gray-100);
    color: var(--white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;

    /* Subtle scanline effect */
    background-image:
        linear-gradient(160deg, var(--eclipse) 0%, var(--eclipse-deep) 30%, var(--gray-100) 100%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
}

/* Pixel font for headings/accents */
.pixel-text {
    font-family: 'Press Start 2P', monospace;
}

/* ── Loading Overlay ──────────────────────────────────── */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: linear-gradient(160deg, var(--eclipse) 0%, #120a18 60%, var(--black) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-logo {
    width: 140px;
    height: auto;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.loading-pixels {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 1.5rem;
}

.loading-pixels::before,
.loading-pixels::after {
    content: '';
    display: block;
}

.loading-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.75rem;
    letter-spacing: 0.05em;
    color: var(--white);
    margin-bottom: 0.75rem;
    text-shadow:
        0 0 20px var(--flame-glow),
        0 2px 0 var(--eclipse);
}

.loading-subtitle {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--gray-50);
    margin-bottom: 2.5rem;
}

.progress-bar {
    width: 320px;
    height: 8px;
    background: var(--gray-80);
    margin: 0 auto 1rem;
    /* Pixel-art style border */
    border: var(--px) solid var(--gray-70);
    image-rendering: pixelated;
}

#loading-progress {
    height: 100%;
    width: 0%;
    background: var(--flame);
    transition: width 0.3s ease;
    image-rendering: pixelated;
}

#loading-text {
    color: var(--gray-60);
    font-size: 0.8rem;
    font-weight: 400;
    margin-bottom: 2rem;
}

.loading-hint {
    color: var(--gray-60);
    font-size: 0.7rem;
}

.loading-hint kbd {
    font-size: 0.6rem;
    padding: 2px 6px;
}

/* ── Pixel animation for loading ──────────────────────── */
@keyframes pixel-pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ── Header ───────────────────────────────────────────── */
header {
    padding: 0.75rem 2rem;
    border-bottom: var(--px) solid var(--eclipse);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.header-logo {
    height: 20px;
    opacity: 0.75;
}

.header-divider {
    width: 2px;
    height: 18px;
    background: var(--eclipse);
}

.header-title {
    font-size: 0.6rem;
    color: var(--gray-40);
    letter-spacing: 0.08em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-badge {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: var(--flame);
    background: rgba(255, 0, 50, 0.1);
    border: 2px solid rgba(255, 0, 50, 0.25);
    padding: 4px 10px;
    letter-spacing: 0.1em;
}

#fullscreen-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 2px solid var(--gray-80);
    color: var(--gray-50);
    padding: 6px 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s ease;
}

#fullscreen-btn:hover {
    background: var(--flame);
    border-color: var(--flame);
    color: var(--white);
}

#fullscreen-btn svg {
    flex-shrink: 0;
}

/* ── Game Canvas ──────────────────────────────────────── */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 2rem;
}

/* Pixel-art frame around the game */
.game-frame {
    position: relative;
    padding: 6px;
    background: linear-gradient(135deg, var(--flame), var(--eclipse));
    max-width: calc(1536px + 12px);
    width: 100%;
}

.game-frame-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--flame);
    z-index: 2;
}
.game-frame-corner.tl { top: -2px; left: -2px; }
.game-frame-corner.tr { top: -2px; right: -2px; }
.game-frame-corner.bl { bottom: -2px; left: -2px; }
.game-frame-corner.br { bottom: -2px; right: -2px; }

.game-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--black);
    overflow: hidden;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* CRT-like glow on the game frame */
.game-frame::after {
    content: '';
    position: absolute;
    inset: -20px;
    pointer-events: none;
    border-radius: 12px;
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.3),
        0 0 40px rgba(255, 0, 50, 0.08),
        0 0 80px rgba(60, 38, 70, 0.15);
    z-index: -1;
}

/* ── Controls ─────────────────────────────────────────── */
.controls-section {
    padding: 1.25rem 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.controls-section h3 {
    font-size: 0.5rem;
    color: var(--gray-60);
    letter-spacing: 0.2em;
    margin-bottom: 0.75rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(60, 38, 70, 0.2);
    border: 2px solid rgba(60, 38, 70, 0.3);
}

.control-keys {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.5rem;
    padding: 0 6px;
    background: var(--gray-90);
    color: var(--flame);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    letter-spacing: 0.02em;
    border: 2px solid var(--gray-70);
    border-bottom-width: 3px;
}

.control-item span {
    color: var(--gray-50);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ── Footer ───────────────────────────────────────────── */
footer {
    padding: 1rem 2rem;
    border-top: var(--px) solid rgba(60, 38, 70, 0.3);
}

.footer-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.footer-mark {
    height: 16px;
    opacity: 0.3;
}

footer p {
    color: var(--gray-60);
    font-size: 0.7rem;
    font-weight: 300;
}

footer strong {
    color: var(--gray-40);
    font-weight: 500;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    header {
        padding: 0.625rem 1rem;
    }

    .header-title {
        display: none;
    }

    .header-divider {
        display: none;
    }

    .header-badge {
        display: none;
    }

    main {
        padding: 0.75rem;
    }

    .game-frame {
        padding: 4px;
    }

    .game-frame-corner {
        width: 8px;
        height: 8px;
    }

    .controls-section {
        padding: 0.75rem 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr 1fr;
    }

    footer {
        padding: 0.75rem 1rem;
    }
}

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

    .loading-title {
        font-size: 1.25rem;
    }
}

/* ── Fullscreen overrides ─────────────────────────────── */
.game-wrapper:fullscreen,
.game-wrapper:-webkit-full-screen {
    max-width: none;
}

.game-wrapper:fullscreen #canvas,
.game-wrapper:-webkit-full-screen #canvas {
    width: 100vw;
    height: 100vh;
    object-fit: contain;
}
