:root {
    --primary: #D946EF;
    --secondary: #F0ABFC;
    --accent: #FAE8FF;
    --background: #1A0520;
    --danger: #ef4444;
    --success: #22c55e;
    --glass: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--background);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--accent);
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas if needed, but screens will override */
}

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

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.title {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 0.5rem;
    text-align: center;
    text-transform: uppercase;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--secondary);
    margin-bottom: 3rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.8;
}

.glow-text {
    color: #fff;
    text-shadow:
        0 0 5px var(--primary),
        0 0 10px var(--primary),
        0 0 20px var(--primary),
        0 0 40px var(--primary);
    animation: pulse-glow 2s infinite alternate;
}

.text-danger {
    text-shadow:
        0 0 5px var(--danger),
        0 0 10px var(--danger),
        0 0 20px var(--danger);
}

@keyframes pulse-glow {
    from { text-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary); }
    to { text-shadow: 0 0 20px var(--primary), 0 0 30px var(--primary), 0 0 40px var(--primary); }
}

.btn {
    background: var(--glass);
    border: 1px solid var(--primary);
    color: #fff;
    padding: 1rem 3rem;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s ease;
    box-shadow: 0 0 15px rgba(217, 70, 239, 0.3);
}

.btn:hover {
    background: var(--primary);
    box-shadow: 0 0 30px var(--primary);
    transform: scale(1.05);
}

.btn:active {
    transform: scale(0.95);
}

.controls-hint {
    margin-top: 2rem;
    font-size: 0.9rem;
    opacity: 0.6;
    text-align: center;
    line-height: 1.6;
}

.controls-hint span {
    color: var(--secondary);
    font-weight: bold;
    border: 1px solid var(--secondary);
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 4px;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
}

.hud-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.7rem;
    color: var(--secondary);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

#score-value, #coins-value {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px var(--primary);
}

.speed-box {
    width: 150px;
}

#speed-bar {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-top: 5px;
    overflow: hidden;
}

#speed-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    box-shadow: 0 0 10px var(--primary);
    transition: width 0.2s linear;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--glass);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.stat #final-score, .stat #high-score {
    font-size: 2.5rem;
    font-weight: bold;
    margin-top: 0.5rem;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
    .title { font-size: 2.5rem; }
    .subtitle { font-size: 0.9rem; }
    .btn { padding: 0.8rem 2rem; font-size: 1.2rem; }
    #hud { padding: 1rem; }
    .hud-item { padding: 0.4rem 0.8rem; }
    .stat { padding: 1rem; }
    .stat #final-score, .stat #high-score { font-size: 2rem; }
}
