* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Orbitron', sans-serif;
    user-select: none; /* Prevent touch highlighting */
}

body {
    background-color: #050508;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: manipulation;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1280px;
    height: 100vh;
    padding: 10px;
}

.header-ui {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    background: rgba(10, 10, 20, 0.9);
    border: 1px solid #1a1a2e;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.1);
    flex-shrink: 0;
}

.ui-panel {
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    letter-spacing: 1px;
    color: #ccc;
}

.highlight-cyan { color: #00ffff; font-weight: bold; text-shadow: 0 0 10px #00ffff; }
.highlight-green { color: #00ff00; font-weight: bold; text-shadow: 0 0 10px #00ff00; }
.highlight-yellow { color: #ffff00; font-weight: bold; text-shadow: 0 0 10px #ffff00; }
#echo-status .locked { color: #ff3366; text-shadow: 0 0 10px #ff3366; }
#echo-status .unlocked { color: #cc00ff; text-shadow: 0 0 10px #cc00ff; }

.game-area {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 70vh;
    box-shadow: 0 0 40px rgba(0, 200, 255, 0.2);
    border: 2px solid #1a1a2e;
    margin: 10px 0;
    flex-shrink: 1;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #080812;
}

.footer-ui {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    background: rgba(10, 10, 20, 0.9);
    border: 1px solid #1a1a2e;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.1);
    flex-shrink: 0;
    padding: 10px;
}

.instructions-panel {
    text-align: center;
    margin-bottom: 15px;
}

.instructions-panel h3 {
    font-size: 1rem;
    color: #00ffcc;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.instructions-panel p {
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: #ddd;
}

.keys-legend {
    margin-bottom: 5px;
}

.keys-legend span {
    color: #00ffcc;
    font-weight: bold;
}

.mobile-controls {
    display: none;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

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

.d-pad, .action-buttons {
    display: flex;
    gap: 10px;
}

.touch-btn {
    background: rgba(20, 20, 40, 0.8);
    border: 2px solid #0055ff;
    color: #00ffff;
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    font-weight: bold;
    padding: 15px;
    border-radius: 8px;
    outline: none;
    touch-action: none; /* Crucial for touch events */
}

.touch-btn:active {
    background: #0055ff;
    color: #fff;
    box-shadow: 0 0 15px #00ffff;
}

#message-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px #00ffff;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

#pause-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 10, 20, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.3);
    padding: 20px 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
    z-index: 100;
}

#pause-menu h2 {
    font-size: clamp(1.5rem, 5vw, 3rem);
    color: #fff;
    text-shadow: 0 0 20px #00ffff;
    letter-spacing: 5px;
    margin-bottom: 10px;
}

/* Responsive tweaks for wider screens where mobile controls aren't strictly needed, but keep them for touch laptops */
@media (min-width: 768px) {
    .footer-ui {
        flex-direction: row;
        align-items: center;
        padding: 15px 30px;
    }
    .instructions-panel {
        text-align: left;
        margin-bottom: 0;
        max-width: 50%;
    }
}
