@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    /* Base sizes that will scale with viewport */
    --base-font-size: 10px;
    --base-padding: 15px;
    --base-gap: 15px;
    --base-button-padding: 10px 15px;
    --base-border-width: 4px;
    --base-radius: 10px;

    /* Colors */
    --primary-color: #00ff00;
    --secondary-color: #ffff00;
    --danger-color: #ff0000;
    --dark-bg: #1a1a1a;
    --darker-bg: #111;
    --border-color: #222;
    --text-color: #666;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: var(--darker-bg);
    background-image: 
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.03),
            rgba(255, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 2px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.03),
            rgba(255, 255, 255, 0.03) 1px,
            transparent 1px,
            transparent 2px
        );
    position: relative;
    overflow: hidden;
}

/* Add scanline effect for CRT monitor feel */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 2;
    pointer-events: none;
}

/* Add screen glow effect */
body::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 255, 0, 0.05) 0%,
        rgba(0, 0, 0, 0) 70%
    );
    z-index: 2;
    pointer-events: none;
}

/* Responsive design */
@media (min-width: 768px) {
    :root {
        --base-font-size: 14px;
        --base-padding: 30px;
        --base-gap: 20px;
        --base-button-padding: 15px 25px;
        --base-border-width: 6px;
        --base-radius: 15px;
    }
}

@media (min-width: 1200px) {
    :root {
        --base-font-size: 16px;
        --base-padding: 40px;
        --base-gap: 25px;
        --base-button-padding: 20px 30px;
        --base-border-width: 8px;
        --base-radius: 20px;
    }
}

.game-container {
    text-align: center;
    background-color: var(--dark-bg);
    padding: calc(var(--base-padding) * 1.5);
    border-radius: var(--base-radius);
    box-shadow: 
        0 0 calc(var(--base-padding) * 2) rgba(0, 255, 0, 0.15),
        0 0 calc(var(--base-padding) * 4) rgba(0, 0, 0, 0.7),
        inset 0 0 calc(var(--base-padding) * 2) rgba(0, 0, 0, 0.5);
    border: var(--base-border-width) solid var(--border-color);
    max-width: 90vw;
    position: relative;
    z-index: 1;
}

/* Add monitor bezel effect */
.game-container::before {
    content: "";
    position: absolute;
    top: calc(-1 * var(--base-padding));
    left: calc(-1 * var(--base-padding));
    right: calc(-1 * var(--base-padding));
    bottom: calc(-1 * var(--base-padding));
    background: linear-gradient(145deg, #2a2a2a, #0a0a0a);
    border-radius: calc(var(--base-radius) + 5px);
    z-index: -1;
    box-shadow: 
        inset 0 0 calc(var(--base-padding) * 1.5) rgba(0, 0, 0, 0.8),
        0 0 calc(var(--base-padding) * 1.5) rgba(0, 0, 0, 0.5);
}

.game-header {
    margin-bottom: calc(var(--base-gap) * 1.5);
}

h1 {
    color: var(--primary-color);
    margin: 0 0 calc(var(--base-gap) * 1.5) 0;
    font-family: 'Press Start 2P', cursive;
    font-size: calc(var(--base-font-size) * 2.4);
    text-shadow: 
        3px 3px 0 #008800,
        6px 6px 0 #004400;
    letter-spacing: 2px;
}

.score-container, .high-score-container {
    margin: calc(var(--base-gap) * 0.5) 0;
    font-family: 'Press Start 2P', cursive;
    font-size: calc(var(--base-font-size) * 1.4);
    text-shadow: 2px 2px 0 #008800;
}

.score-container {
    color: var(--primary-color);
}

.high-score-container {
    color: var(--secondary-color);
}

#gameCanvas {
    background-color: #000;
    border: var(--base-border-width) solid #333;
    border-radius: 0;
    box-shadow: 
        0 0 calc(var(--base-padding) * 1.5) rgba(0, 255, 0, 0.2),
        inset 0 0 calc(var(--base-padding) * 2) rgba(0, 0, 0, 0.7);
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.game-area {
    margin-bottom: calc(var(--base-gap) * 1.5);
}

.controls {
    margin-top: calc(var(--base-gap) * 1.5);
}

.instructions {
    margin-bottom: calc(var(--base-gap) * 1.5);
}

.instructions p {
    color: var(--primary-color);
    font-family: 'Press Start 2P', cursive;
    font-size: calc(var(--base-font-size) * 1);
    margin: 0;
    text-shadow: 1px 1px 0 #008800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: var(--base-gap);
    flex-wrap: wrap;
}

button {
    background-color: #008800;
    color: white;
    border: none;
    padding: var(--base-button-padding);
    text-align: center;
    text-decoration: none;
    font-family: 'Press Start 2P', cursive;
    font-size: calc(var(--base-font-size) * 1.2);
    cursor: pointer;
    border-radius: 0;
    transition: 
        background-color 0.2s,
        transform 0.1s;
    box-shadow: 
        0 4px 0 #004400,
        0 6px 8px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    top: 0;
    min-width: 120px;
}

button:hover {
    background-color: #00aa00;
}

button:active {
    transform: translateY(4px);
    box-shadow: 
        0 0 0 #004400,
        0 2px 4px rgba(0, 0, 0, 0.3);
}

#resetButton {
    background-color: #880000;
}

#resetButton:hover {
    background-color: #aa0000;
}

#resetButton:active {
    box-shadow: 
        0 0 0 #440000,
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
    margin-top: calc(var(--base-gap) * 1.5);
    font-family: 'Press Start 2P', cursive;
    font-size: calc(var(--base-font-size) * 0.8);
    color: var(--text-color);
    text-shadow: 1px 1px 0 #333;
    letter-spacing: 1px;
}

/* Add blinking cursor effect to buttons */
button::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.5);
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    .game-container {
        padding: calc(var(--base-padding) * 0.8);
    }

    h1 {
        font-size: calc(var(--base-font-size) * 1.8);
    }

    .score-container, .high-score-container {
        font-size: calc(var(--base-font-size) * 1.1);
    }

    button {
        font-size: calc(var(--base-font-size) * 1);
        padding: 10px 15px;
        min-width: 100px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .game-container {
        padding: calc(var(--base-padding) * 0.6);
    }

    h1 {
        font-size: calc(var(--base-font-size) * 1.5);
    }

    .score-container, .high-score-container {
        font-size: calc(var(--base-font-size) * 0.9);
    }

    button {
        font-size: calc(var(--base-font-size) * 0.9);
        padding: 8px 12px;
        min-width: 90px;
    }

    .instructions p {
        font-size: calc(var(--base-font-size) * 0.8);
    }

    .game-info {
        font-size: calc(var(--base-font-size) * 0.7);
    }
}

/* Mobile controls */
.mobile-controls {
    display: none;
    margin-top: 20px;
    width: 100%;
    max-width: 250px;
    margin-left: auto;
    margin-right: auto;
}

.control-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.control-btn {
    background-color: rgba(0, 136, 0, 0.7);
    color: white;
    border: 2px solid #004400;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 #004400;
    transition: transform 0.1s, background-color 0.2s;
    margin: 0 5px;
    touch-action: manipulation;
}

.control-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #004400;
}

/* Show mobile controls on mobile devices */
@media (max-width: 768px) {
    .mobile-controls {
        display: block;
    }

    #controlInstructions {
        font-size: calc(var(--base-font-size) * 0.8);
    }
}

/* Larger mobile controls for tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}

/* Prevent text selection on buttons */
button, .control-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}