:root {
    --primary-color: #00ff00;
    --secondary-color: #ff0080;
    --accent-color: #ffff00;
    --background-dark: #000011;
    --background-space: #000022;
    --text-color: #00ff00;
    --text-secondary: #00cc88;
    --danger-color: #ff0040;
    --warning-color: #ffaa00;
    --success-color: #00ff88;
    --border-radius: 4px;
    --neon-glow: 0 0 10px currentColor;
    --pixel-size: 2px;
}

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

body {
    font-family: 'Orbitron', monospace;
    background: radial-gradient(circle at center, var(--background-space), var(--background-dark));
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

/* Animated starfield background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(1px 1px at 20px 30px, white, transparent),
        radial-gradient(1px 1px at 40px 70px, white, transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(1px 1px at 130px 80px, white, transparent),
        radial-gradient(1px 1px at 160px 30px, white, transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: stars 20s linear infinite;
    opacity: 0.5;
    z-index: -1;
}

@keyframes stars {
    from { transform: translateY(0px); }
    to { transform: translateY(-100px); }
}

#game-container {
    background: linear-gradient(145deg, rgba(0, 20, 40, 0.9), rgba(0, 10, 20, 0.95));
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 
        0 0 30px rgba(0, 255, 0, 0.3),
        inset 0 0 20px rgba(0, 255, 0, 0.05);
    max-width: 900px;
    width: 100%;
    position: relative;
}

#game-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(0, 255, 0, 0.3);
    padding-bottom: 15px;
}

#game-header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: var(--neon-glow);
    margin-bottom: 15px;
    letter-spacing: 3px;
    position: relative;
    animation: neon-pulse 2s ease-in-out infinite alternate;
}

@keyframes neon-pulse {
    0% { 
        text-shadow: 
            0 0 5px var(--primary-color),
            0 0 10px var(--primary-color),
            0 0 15px var(--primary-color);
    }
    100% { 
        text-shadow: 
            0 0 10px var(--primary-color),
            0 0 20px var(--primary-color),
            0 0 30px var(--primary-color),
            0 0 40px var(--primary-color);
    }
}

#game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    justify-content: center;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.info-item:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.2);
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 8px currentColor;
    font-family: 'Courier New', monospace;
}

#game-board {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 20px 0;
    background: linear-gradient(180deg, 
        rgba(0, 0, 50, 0.3) 0%, 
        rgba(0, 0, 20, 0.8) 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 
        inset 0 0 30px rgba(0, 255, 0, 0.1),
        0 0 20px rgba(0, 255, 0, 0.2);
}

#game-canvas {
    display: block;
    background: transparent;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    max-width: 100%;
    height: auto;
}

#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.overlay-message {
    background: linear-gradient(145deg, rgba(0, 20, 40, 0.95), rgba(0, 10, 20, 0.98));
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    box-shadow: 
        0 0 30px rgba(0, 255, 0, 0.4),
        inset 0 0 20px rgba(0, 255, 0, 0.1);
    pointer-events: all;
    animation: overlay-appear 0.5s ease-out;
}

@keyframes overlay-appear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.overlay-message h2 {
    font-size: 2rem;
    color: var(--primary-color);
    text-shadow: var(--neon-glow);
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.overlay-message p {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

#game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.control-btn, .action-btn {
    padding: 12px 20px;
    font-family: inherit;
    font-weight: bold;
    font-size: 1rem;
    background: linear-gradient(145deg, rgba(0, 255, 0, 0.2), rgba(0, 200, 0, 0.3));
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.control-btn::before, .action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.control-btn:hover::before, .action-btn:hover::before {
    left: 100%;
}

.control-btn:hover, .action-btn:hover {
    background: linear-gradient(145deg, rgba(0, 255, 0, 0.3), rgba(0, 255, 0, 0.4));
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.5),
        inset 0 0 10px rgba(0, 255, 0, 0.2);
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: linear-gradient(145deg, rgba(255, 0, 128, 0.2), rgba(200, 0, 100, 0.3));
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.action-btn.secondary:hover {
    background: linear-gradient(145deg, rgba(255, 0, 128, 0.3), rgba(255, 0, 128, 0.4));
    box-shadow: 
        0 0 20px rgba(255, 0, 128, 0.5),
        inset 0 0 10px rgba(255, 0, 128, 0.2);
}

.control-btn:active, .action-btn:active {
    transform: translateY(0);
}

.control-btn:disabled, .action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#instructions {
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(0, 255, 0, 0.2);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-top: 20px;
}

#instructions h3 {
    color: var(--accent-color);
    margin-bottom: 15px;
    text-shadow: 0 0 10px currentColor;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius);
    border: 1px solid rgba(0, 255, 0, 0.2);
}

.key {
    background: var(--primary-color);
    color: var(--background-dark);
    padding: 4px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

.desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.game-tips h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-tips p {
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.points {
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0 0 5px currentColor;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(145deg, rgba(0, 20, 40, 0.95), rgba(0, 10, 20, 0.98));
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 
        0 0 30px rgba(0, 255, 0, 0.4),
        inset 0 0 20px rgba(0, 255, 0, 0.1);
    animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.scoreboard-content {
    max-width: 600px;
}

.modal h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-shadow: var(--neon-glow);
    font-size: 1.8rem;
    letter-spacing: 2px;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

/* Form Styles */
form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-top: 20px;
}

label {
    color: var(--text-color);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type="text"] {
    padding: 12px 15px;
    font-family: inherit;
    font-size: 1.1rem;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    color: var(--primary-color);
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 250px;
    max-width: 100%;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 
        0 0 15px rgba(0, 255, 0, 0.3),
        inset 0 0 10px rgba(0, 255, 0, 0.1);
    background: rgba(0, 0, 0, 0.7);
}

input[type="text"]::placeholder {
    color: rgba(0, 255, 0, 0.5);
    text-transform: none;
    letter-spacing: normal;
}

/* Scoreboard Styles */
#scoreboard-display {
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 20px 0;
    border: 1px solid rgba(0, 255, 0, 0.3);
    max-height: 400px;
    overflow-y: auto;
}

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
}

.scoreboard-table th,
.scoreboard-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 255, 0, 0.2);
}

.scoreboard-table th {
    background: rgba(0, 255, 0, 0.1);
    color: var(--accent-color);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 5px currentColor;
}

.scoreboard-table td {
    color: var(--text-color);
    font-family: 'Courier New', monospace;
}

.scoreboard-table tr:hover {
    background: rgba(0, 255, 0, 0.05);
}

.scoreboard-table tr:first-child td {
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0 0 10px currentColor;
}

/* Credits */
#credits {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: rgba(0, 255, 0, 0.6);
    text-align: center;
    letter-spacing: 1px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    #game-header h1 {
        font-size: 2rem;
    }
    
    #game-info {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .info-item {
        padding: 6px 10px;
    }
    
    .info-value {
        font-size: 1.2rem;
    }
    
    #game-canvas {
        width: 100%;
        max-width: 400px;
    }
    
    .control-btn, .action-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .instruction-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .modal-content {
        padding: 20px;
        width: 95%;
    }
    
    input[type="text"] {
        width: 200px;
    }
    
    .overlay-message {
        padding: 20px;
    }
    
    .overlay-message h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    #game-header h1 {
        font-size: 1.5rem;
    }
    
    .info-value {
        font-size: 1rem;
    }
    
    .control-btn, .action-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    #instructions {
        padding: 15px;
    }
    
    .game-tips p {
        font-size: 0.8rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    body::before {
        animation: none;
    }
    
    #game-header h1 {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #00ff00;
        --text-color: #ffffff;
        --background-dark: #000000;
    }
}
