/* Server Saver Shield - Enhanced Styles */
:root {
    --bg-dark: #020503;
    --bg-panel: #050d06;
    --bg-primary: #020503;
    --bg-secondary: #050d06;
    --neon-purple: #10b981;
    --neon-purple-light: #34d399;
    --neon-purple-dark: #047857;
    --neon-blue: #3b82f6;
    --neon-cyan: #06b6d4;
    --neon-green: #10b981;
    --neon-red: #ef4444;
    --neon-orange: #f59e0b;
    --neon-pink: #ec4899;
    --text-primary: #f5f5f5;
    --text-secondary: #a7f3d0;
    --text-muted: #047857;
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* ===== CRITICAL TEMPLATE FALLBACK STYLES ===== */
/* These ensure the game works even if styles.css fails to load */

.TEMPLATE-4weird-game-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding-top: 70px;
}

.TEMPLATE-4weird-starfield,
#TEMPLATE-4weird-starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.TEMPLATE-4weird-nav-placeholder,
.TEMPLATE-4weird-footer-placeholder {
    display: block;
}

/* Credits section - hide by default, show properly when styles load */
.TEMPLATE-4weird-credits-section, .TEMPLATE-4weird-bio-section, .TEMPLATE-4weird-more-games { display: block; }

/* Ensure game wrapper allows page scrolling and centers the container */
.game-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    overflow: visible;
    z-index: 10;
    padding: 20px 0;
}

.game-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 auto;
}

/* Start screen positioning */
#startScreen {
    position: absolute;
    inset: 0;
    z-index: 500;
}

/* Wave announcement overlay */
.wave-announcement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1d1530;
    padding: 30px 60px;
    border-radius: 20px;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    text-align: center;
    z-index: 8000;
    animation: waveAnnounce 2s ease-out forwards;
    pointer-events: none;
}

@keyframes waveAnnounce {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    40% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Tutorial Tooltip Styles */
.tutorial-tooltip {
    background: #0a0a0f;
    border: 2px solid var(--neon-purple);
    border-radius: 12px;
    padding: 20px;
    max-width: 300px;
    box-shadow: 0 10px 40px #1d1530;
    animation: tooltipFadeIn 0.3s ease;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #1d1530;
    padding-bottom: 10px;
}

.tutorial-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--neon-purple);
}

.tutorial-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.tutorial-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tutorial-content {
    color: #e5e7eb;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 15px;
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-progress {
    color: #ffffff;
    font-size: 0.85rem;
}

.tutorial-next {
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-purple-dark));
    border: none;
    color: white;
    padding: 8px 20px;
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tutorial-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px #1d1530;
}

.tutorial-highlight {
    box-shadow: 0 0 0 4px #1d1530;
    animation: highlightPulse 2s infinite;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 0 4px #1d1530; }
    50% { box-shadow: 0 0 0 8px #1d1530; }
}

/* Kill Counter Display */
.kill-counter {
    position: absolute;
    top: 100px;
    right: 20px;
    background: #0a0a0f;
    border: 1px solid #3d2605;
    border-radius: 8px;
    padding: 10px 15px;
    font-family: 'Orbitron', sans-serif;
}

.kill-counter-label {
    font-size: 0.75rem;
    color: #ffffff;
    text-transform: uppercase;
}

.kill-counter-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f59e0b;
}

/* Screen flash overlay */
.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9998;
    background: rgba(255, 0, 0, 0);
    transition: background 0.1s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-y: auto;
    touch-action: auto;
    user-select: none;
    -webkit-user-select: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #0a0a0f;
    border-bottom: 1px solid #1d1530;
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
}

.logo span { font-size: 1.2rem; }

.game-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px #0e2d35;
}

.back-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-purple-dark));
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: 0.3s ease;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px #1d1530;
}

/* Game Wrapper - background added to fallback definition above */
.game-wrapper {
    background: radial-gradient(ellipse at center, #051a08 0%, var(--bg-primary) 70%);
}

#gameCanvas {
    background: linear-gradient(180deg, #020503 0%, #051207 50%, #020803 100%);
    border: 3px solid var(--neon-purple);
    border-radius: 12px;
    /* Always show full canvas - page scrolls to reveal content below */
    min-width: 400px !important;
    min-height: 300px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    box-shadow: 0 0 45px rgba(16, 185, 129, 0.25);
    cursor: crosshair;
    max-width: 100%;
    /* No max-height - let the canvas be its natural size */
}

/* HUD */
.hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 100;
}

.hud-section {
    display: flex;
    gap: 15px;
    align-items: center;
}

.hud-section.center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.stat-box {
    background: #0a0a0f;
    border: 1px solid #1d1530;
    border-radius: 10px;
    padding: 8px 16px;
    text-align: center;
    min-width: 80px;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
}

.score-box .stat-value { color: var(--neon-orange); text-shadow: 0 0 10px #3d2605; }
.wave-box .stat-value { color: var(--neon-cyan); text-shadow: 0 0 10px #0e2d35; }

.server-health {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0a0a0f;
    padding: 8px 16px;
    border-radius: 25px;
    border: 2px solid var(--neon-green);
    box-shadow: 0 0 20px #0d2d20;
}

.server-icon { font-size: 1.5rem; }

.health-bar {
    width: 150px;
    height: 12px;
    background: #000000;
    border-radius: 6px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-red), var(--neon-orange), var(--neon-green));
    border-radius: 6px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px #0d2d20;
}

.health-text {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--neon-green);
    min-width: 45px;
}

.powerup-indicator {
    display: flex;
    gap: 5px;
}

.powerup-icon {
    font-size: 1.5rem;
    animation: pulse 1s ease-in-out infinite;
}

/* Screens */
.screen-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* flex-start (not center) so overflow is always scrollable from the top.
       justify-content:center splits overflow above AND below, making the top
       unreachable since browsers can't scroll to negative positions. */
    justify-content: flex-start;
    background: #0a0a0f;
    backdrop-filter: blur(10px);
    z-index: 500;
    text-align: center;
    padding: 1.5rem 2rem;
    border-radius: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.screen-overlay.hidden { 
    display: none;
    opacity: 0;
    visibility: hidden;
}

/* Start screen styling */
#startScreen {
    display: flex;
    opacity: 1;
    visibility: visible;
    padding: 1.25rem;
}

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

#startScreen .logo-big {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    margin-bottom: 0.25rem;
}

#startScreen .tagline {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

#startScreen .story {
    padding: 10px 15px;
    margin-bottom: 0.5rem;
    max-width: 420px;
}

#startScreen .story p {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

#startScreen .enemies-preview {
    gap: 10px;
    margin-bottom: 0.5rem;
}

#startScreen .enemy-type {
    padding: 6px 12px;
}

#startScreen .enemy-type span {
    font-size: 1.4rem;
}

#startScreen .enemy-type small {
    font-size: 0.65rem;
}

#startScreen .btn {
    padding: 8px 20px;
    font-size: 0.85rem;
    margin: 4px;
}

#startScreen .controls-hint {
    margin-top: 0.5rem;
    gap: 8px;
}

#startScreen .controls-hint span {
    font-size: 0.75rem;
    padding: 4px 8px;
}

.logo-big {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px #1d1530;
}

.logo-big.glitch {
    animation: glitch 2s infinite;
    color: var(--neon-red);
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(2px, -2px); }
    60% { transform: translate(-2px, -2px); }
    80% { transform: translate(2px, 2px); }
}

.tagline {
    font-size: 1.1rem;
    color: var(--neon-cyan);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.story {
    background: linear-gradient(135deg, #3d0f0f, #3d2605);
    border: 1px solid #3d0f0f;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 1.5rem;
    max-width: 450px;
}

.story p { margin-bottom: 10px; font-size: 0.95rem; color: #ffffff; }
.story p:last-child { margin-bottom: 0; }
.story strong { color: var(--neon-red); }

.enemies-preview {
    display: flex;
    gap: 20px;
    margin-bottom: 1.5rem;
}

.enemy-type {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px;
    background: #1d1530;
    border-radius: 12px;
    border: 1px solid #1d1530;
    transition: 0.3s ease;
}

.enemy-type:hover {
    transform: translateY(-5px);
    border-color: var(--neon-purple);
}

.enemy-type span { font-size: 2rem; }
.enemy-type small { font-size: 0.7rem; color: #e5e7eb; text-transform: uppercase; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 35px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: 0.3s ease;
    margin: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-start {
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
    color: white;
    box-shadow: 0 4px 20px #0e2d35;
}

.btn-start:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px #0e2d35;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--neon-purple);
}

.btn-secondary:hover {
    background: #1d1530;
    box-shadow: 0 0 20px #1d1530;
}

.controls-hint {
    display: flex;
    gap: 20px;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: #e5e7eb;
    flex-wrap: wrap;
    justify-content: center;
}

.controls-hint span {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #1d1530;
    padding: 8px 12px;
    border-radius: 20px;
}

/* Final Stats */
.final-stats {
    background: #1d1530;
    border: 1px solid #1d1530;
    border-radius: 12px;
    padding: 20px 30px;
    margin-bottom: 1.5rem;
    min-width: 250px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #1d1530;
}

.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: #ffffff; font-size: 0.9rem; }
.stat-row .highlight {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--neon-orange);
}

/* Footer */
.footer-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 12px;
    background: #0a0a0f;
    border-top: 1px solid #1d1530;
    font-size: 0.75rem;
    color: #e5e7eb;
}

.footer-bar a { color: var(--neon-purple-light); text-decoration: none; }

/* Game Info Panel */
.game-info-panel {
    background: #0a0a0f;
    border-top: 2px solid #1d1530;
    padding: 40px 20px;
    margin-top: 20px;
}

.game-info-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.info-section {
    background: #1d1530;
    border: 1px solid #1d1530;
    border-radius: 16px;
    padding: 25px;
}

.info-section h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--neon-cyan);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-section p {
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1.6;
}

.controls-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.controls-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    color: #ffffff;
    font-size: 0.9rem;
    border-bottom: 1px solid #1d1530;
}

.controls-list li:last-child {
    border-bottom: none;
}

.key {
    background: #1d1530;
    color: var(--neon-purple-light);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.high-score-display {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--neon-orange);
    text-shadow: 0 0 20px #3d2605;
    margin: 10px 0;
}

.high-score-label {
    font-size: 0.8rem;
    color: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* Responsive */
@media (max-width: 768px) {
    .header { padding: 10px 15px; }
    .game-title { font-size: 0.85rem; }
    .back-btn { padding: 6px 12px; font-size: 0.75rem; }
    .hud { top: 10px; left: 10px; right: 10px; }
    .stat-box { padding: 6px 12px; min-width: 60px; }
    .stat-value { font-size: 1rem; }
    .health-bar { width: 100px; height: 10px; }
    .enemies-preview { gap: 10px; flex-wrap: wrap; justify-content: center; }
    .enemy-type { padding: 10px; }
    .enemy-type span { font-size: 1.5rem; }
    .controls-hint { flex-direction: column; gap: 8px; }
    .controls-hint span { font-size: 0.7rem; padding: 6px 10px; }
    .footer-bar { flex-wrap: wrap; gap: 15px; font-size: 0.7rem; }

    /* Mobile screen overlay fixes */
    .screen-overlay {
        padding: 1rem 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .logo-big {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }

    .story {
        padding: 15px;
        margin-bottom: 1rem;
        max-width: 100%;
    }

    .story p {
        font-size: 0.85rem;
    }

    .btn {
        padding: 12px 25px;
        font-size: 0.9rem;
    }

    .final-stats {
        padding: 15px;
        min-width: auto;
        width: 100%;
        max-width: 300px;
    }

    .stat-row {
        padding: 8px 0;
    }

    .stat-row .highlight {
        font-size: 1rem;
    }

    /* Mobile: Natural canvas size, page scrolls */
    #gameCanvas {
        width: 100%;
        max-width: 100%;
        border-width: 2px;
        border-radius: 8px;
    }

    .game-wrapper {
        padding: 5px;
        align-items: flex-start;
        padding-top: 10px;
    }

    /* Mobile HUD adjustments for vertical layout */
    .hud {
        top: 5px;
        left: 5px;
        right: 5px;
    }

    .stat-box {
        padding: 4px 8px;
        min-width: 50px;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .health-bar {
        width: 80px;
        height: 8px;
    }
}

@media (max-width: 480px) {
    .hud-section.center { position: static; transform: none; order: -1; width: 100%; justify-content: center; margin-bottom: 10px; }
    .hud { flex-wrap: wrap; justify-content: center; }
    .health-bar { width: 120px; }

    /* Smaller mobile adjustments */
    .logo-big {
        font-size: 1.2rem;
    }

    .tagline {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .enemies-preview {
        gap: 8px;
    }

    .enemy-type {
        padding: 8px;
    }

    .enemy-type span {
        font-size: 1.2rem;
    }

    .enemy-type small {
        font-size: 0.6rem;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.85rem;
        margin: 4px;
    }

    /* Stack buttons on very small screens */
    .screen-overlay > div[style*="display: flex"] {
        flex-direction: column !important;
        width: 100%;
    }

    .screen-overlay > div[style*="display: flex"] button {
        max-width: 100% !important;
        width: 100%;
    }

    /* Mobile info panel adjustments */
    .game-info-panel {
        padding: 20px 15px;
    }

    .game-info-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .info-section {
        padding: 20px;
    }

    .info-section h3 {
        font-size: 1.1rem;
    }

    .high-score-display {
        font-size: 2rem;
    }
}

/* Mobile Virtual Touch Controls */
.mobile-touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 50;
}

@media (max-width: 900px), (pointer: coarse) {
    .mobile-touch-controls {
        display: flex;
    }
}

.virtual-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.6);
    padding: 8px;
    border-radius: 20px;
    border: 1px solid rgba(0, 242, 254, 0.3);
    backdrop-filter: blur(8px);
}

.dpad-mid {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dpad-center {
    width: 38px;
    height: 38px;
    background: rgba(0, 242, 254, 0.1);
    border-radius: 50%;
}

.dpad-btn {
    width: 44px;
    height: 44px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(0, 242, 254, 0.4);
    color: var(--neon-cyan);
    font-size: 1.2rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background 0.1s, transform 0.1s;
}

.dpad-btn:active {
    background: var(--neon-cyan);
    color: #000;
    transform: scale(0.92);
}

.virtual-actions {
    pointer-events: auto;
}

.touch-fire-btn {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: 3px solid #ffffff;
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 800;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: transform 0.1s, box-shadow 0.2s;
}

.touch-fire-btn:active, .touch-fire-btn.active {
    transform: scale(0.92);
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.7);
}
