/* ============================================
   CRS INVADERS PRO - STYLE SHEET
   Cardiac-Medical Theme
   Colors: #c94f52, #f8c5be, #a2272c
   ============================================ */

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

:root {
    /* Primary Palette */
    --primary: #c94f52;
    --primary-light: #f8c5be;
    --primary-dark: #a2272c;

    /* Extended Palette */
    --bg-dark: #1a0a0a;
    --bg-darker: #0d0505;
    --text-light: #fff5f5;
    --text-muted: #d4a5a5;
    --accent-glow: rgba(201, 79, 82, 0.6);
    --danger: #ff3333;
    --success: #4ade80;

    /* Fonts */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-darker);
    font-family: var(--font-body);
    color: var(--text-light);

    /* Disable mobile browser gestures */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* Game Container - Centers on desktop */
#game-container {
    width: 100%;
    height: 100%;
    max-width: 450px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-dark);
    overflow: hidden;

    /* 9:16 Aspect Ratio */
    aspect-ratio: 9 / 16;
}

@media (min-height: 800px) and (min-width: 500px) {
    #game-container {
        height: 100vh;
        width: auto;
        border-left: 2px solid var(--primary-dark);
        border-right: 2px solid var(--primary-dark);
        box-shadow:
            0 0 60px var(--accent-glow),
            inset 0 0 100px rgba(162, 39, 44, 0.1);
    }
}

/* Canvas */
#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

/* ============================================
   OVERLAYS
   ============================================ */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 5, 5, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
    max-width: 90%;
}

/* Game Title */
.game-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 10vw, 3.5rem);
    font-weight: 900;
    color: var(--primary);
    text-shadow:
        0 0 20px var(--accent-glow),
        0 0 40px var(--accent-glow),
        0 0 60px var(--accent-glow);
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {

    0%,
    100% {
        text-shadow:
            0 0 20px var(--accent-glow),
            0 0 40px var(--accent-glow),
            0 0 60px var(--accent-glow);
    }

    50% {
        text-shadow:
            0 0 30px var(--accent-glow),
            0 0 60px var(--accent-glow),
            0 0 100px var(--accent-glow);
    }
}

.subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    color: var(--text-muted);
    font-weight: 300;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

/* Pulse Line Animation */
.pulse-line {
    width: 80%;
    height: 3px;
    margin: 0 auto 2rem;
    background: linear-gradient(90deg,
            transparent,
            var(--primary-dark),
            var(--primary),
            var(--primary-light),
            var(--primary),
            var(--primary-dark),
            transparent);
    background-size: 200% 100%;
    animation: pulseLine 2s linear infinite;
    border-radius: 2px;
    box-shadow: 0 0 10px var(--primary);
}

@keyframes pulseLine {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Glow Button */
.glow-btn {
    font-family: var(--font-display);
    font-size: clamp(1rem, 4vw, 1.3rem);
    font-weight: 700;
    color: var(--text-light);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border: 2px solid var(--primary);
    padding: 1rem 2.5rem;
    border-radius: 50px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow:
        0 0 20px rgba(201, 79, 82, 0.4),
        inset 0 0 20px rgba(248, 197, 190, 0.1);
}

.glow-btn:hover,
.glow-btn:active {
    transform: scale(1.05);
    box-shadow:
        0 0 40px rgba(201, 79, 82, 0.6),
        inset 0 0 30px rgba(248, 197, 190, 0.2);
}

.glow-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent,
            rgba(248, 197, 190, 0.3),
            transparent);
    transform: rotate(45deg);
    animation: btnShine 3s ease-in-out infinite;
}

@keyframes btnShine {

    0%,
    100% {
        transform: translateX(-100%) rotate(45deg);
    }

    50% {
        transform: translateX(100%) rotate(45deg);
    }
}

.glow-btn span {
    position: relative;
    z-index: 1;
}

.instructions {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Game Over Screen */
.game-over-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    color: var(--danger);
    text-shadow: 0 0 30px rgba(255, 51, 51, 0.5);
    margin-bottom: 1rem;
    animation: gameOverPulse 1s ease-in-out infinite;
}

@keyframes gameOverPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.final-score {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--primary-light);
    font-weight: 700;
}

/* Level Complete */
.level-complete-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 7vw, 2rem);
    color: var(--success);
    text-shadow: 0 0 30px rgba(74, 222, 128, 0.5);
    margin-bottom: 1rem;
}

.level-name {
    color: var(--primary-light);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* Science Modal */
.modal-content {
    background: linear-gradient(180deg, rgba(26, 10, 10, 0.95), rgba(13, 5, 5, 0.98));
    border: 2px solid var(--primary-dark);
    border-radius: 20px;
    padding: 2rem;
    max-width: 350px;
    box-shadow: 0 0 50px var(--accent-glow);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: heartbeat 1s ease-in-out infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.1);
    }

    35% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.1);
    }

    55% {
        transform: scale(1);
    }
}

.modal-content h2 {
    font-family: var(--font-display);
    color: var(--primary-light);
    margin-bottom: 1rem;
}

.science-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.science-text strong {
    color: var(--primary-light);
}

/* ============================================
   SCREEN SHAKE ANIMATION
   ============================================ */
@keyframes screenShake {

    0%,
    100% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-8px, -5px);
    }

    20% {
        transform: translate(8px, 5px);
    }

    30% {
        transform: translate(-6px, 4px);
    }

    40% {
        transform: translate(6px, -4px);
    }

    50% {
        transform: translate(-5px, 5px);
    }

    60% {
        transform: translate(5px, -3px);
    }

    70% {
        transform: translate(-3px, 3px);
    }

    80% {
        transform: translate(3px, -3px);
    }

    90% {
        transform: translate(-2px, 2px);
    }
}

#game-container.shake {
    animation: screenShake 0.4s ease-in-out;
}

/* CRS Critical Warning Overlay */
#game-container.critical::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border: 4px solid var(--danger);
    animation: criticalPulse 0.5s ease-in-out infinite;
    z-index: 50;
}

@keyframes criticalPulse {

    0%,
    100% {
        border-color: rgba(255, 51, 51, 0.8);
    }

    50% {
        border-color: rgba(255, 51, 51, 0.3);
    }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-height: 600px) {
    .overlay-content {
        padding: 1rem;
    }

    .game-title {
        margin-bottom: 0.3rem;
    }

    .subtitle {
        margin-bottom: 1rem;
    }

    .pulse-line {
        margin-bottom: 1rem;
    }
}