:root {
    --primary-color: #6C5CE7;
    --secondary-color: #A29BFE;
    --accent-color: #FF7675;
    --bg-color: #0F0A1A;
    --text-color: #FFFFFF;
    --font-family: 'Inter', system-ui, sans-serif;
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1280px;
    max-height: 720px;
    background: #000;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.4);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000 100%);
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks through to canvas unless on active UI element */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 10, 26, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: all;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.glitch-title {
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-color);
    text-shadow: 2px 2px var(--accent-color), -2px -2px var(--primary-color);
    margin-bottom: 2rem;
    animation: glitch 1s infinite alternate;
}

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

.neon-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--text-color);
    padding: 12px 32px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    margin: 10px;
    box-shadow: 0 0 10px var(--primary-color);
}

.neon-btn:hover {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 20px var(--primary-color), 0 0 40px var(--primary-color);
}

.neon-btn.secondary {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

.neon-btn.secondary:hover {
    background: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-color);
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.score-board {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--secondary-color);
}

.score-label {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

#score-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.boost-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.boost-label {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin-bottom: 5px;
}

.boost-bar-bg {
    width: 150px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

#boost-bar-fill {
    width: 100%;
    height: 100%;
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    transition: width 0.1s linear;
}

.settings-group {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.settings-group label {
    margin-bottom: 5px;
    color: var(--secondary-color);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 200px;
    height: 8px;
    background: #333;
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-color);
}

/* Touch Controls */
#touch-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    pointer-events: auto; /* Enable touch interaction */
    z-index: 5;
}

#dpad {
    width: 150px;
    height: 150px;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.dpad-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
}

.dpad-btn:active, .dpad-btn.active {
    background: rgba(108, 92, 231, 0.5);
}

.dpad-btn.up { top: 0; left: 50px; }
.dpad-btn.down { bottom: 0; left: 50px; }
.dpad-btn.left { top: 50px; left: 0; }
.dpad-btn.right { top: 50px; right: 0; }

.action-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 118, 117, 0.2);
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    color: var(--accent-color);
    cursor: pointer;
    align-self: flex-end;
}

.action-btn:active, .action-btn.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-color);
}

@media (min-width: 768px) {
    #touch-controls {
        display: none !important;
    }
}
