:root {
    --bg-color: #030308;
    --player-color: #00ffff;
    --enemy-chaser: #ff0055;
    --enemy-predictor: #ffaa00;
    --enemy-blocker: #aa00ff;
    --text-color: #ffffff;
    --ui-bg: rgba(3, 3, 8, 0.75);
    --grid-color: rgba(0, 255, 255, 0.03);
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at center, #0a0a1a 0%, #030308 100%);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.mono-text {
    font-family: 'JetBrains Mono', monospace;
}

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

canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

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

/* Subtle scanline effect overlay */
#ui-layer::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.1) 50%,
        rgba(0,0,0,0.1)
    );
    background-size: 100% 4px;
    z-index: 1;
    pointer-events: none;
}

/* Make screens and buttons capture clicks */
.screen, .top-bar, .ai-status, #pause-btn {
    pointer-events: auto;
    z-index: 10;
}

.hidden {
    display: none !important;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ui-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    z-index: 20;
    text-align: center;
}

.glass-panel {
    background: rgba(10, 10, 26, 0.6);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 16px;
    padding: 3rem 4rem;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
}

.glass-panel > * {
    flex-shrink: 0;
}

.glass-panel.border-red {
    border-color: rgba(255, 0, 85, 0.2);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(255, 0, 85, 0.05);
}

.glass-panel.border-cyan {
    border-color: rgba(0, 255, 255, 0.2);
}

/* Typography */
.neon-text {
    font-size: 4.5rem;
    font-weight: 800;
    color: #fff;
    text-shadow:
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--player-color),
        0 0 40px var(--player-color),
        0 0 80px var(--player-color);
    margin-bottom: 0.2rem;
    letter-spacing: 4px;
}

.red-glow {
    text-shadow:
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--enemy-chaser),
        0 0 40px var(--enemy-chaser),
        0 0 80px var(--enemy-chaser);
}

.glow-text {
    text-shadow: 0 0 10px var(--player-color);
    color: var(--player-color);
}

.neon-subtitle {
    font-size: 1.5rem;
    color: #a0d8d8;
    margin-bottom: 1.5rem;
    letter-spacing: 6px;
    text-transform: uppercase;
    font-weight: 500;
}

.desc {
    font-size: 1.1rem;
    color: #ccc;
    max-width: 500px;
    line-height: 1.5;
    margin-bottom: 2rem;
}

/* Controls Info */
.controls-info {
    display: flex;
    gap: 2rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.control-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #bbb;
}

.key {
    background: #222;
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    box-shadow: 0 2px 0 #000;
    border: 1px solid #444;
}

.key.touch {
    font-size: 1.2rem;
    padding: 0.1rem 0.4rem;
}

/* Buttons */
.neon-btn {
    background: transparent;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    padding: 1rem 3rem;
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.glow-cyan {
    border-color: var(--player-color);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3), inset 0 0 10px rgba(0, 255, 255, 0.1);
}

.glow-cyan:hover {
    background: var(--player-color);
    color: #000;
    box-shadow: 0 0 25px var(--player-color), inset 0 0 15px var(--player-color);
}

.glow-red {
    border-color: var(--enemy-chaser);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3), inset 0 0 10px rgba(255, 0, 85, 0.1);
}

.glow-red:hover {
    background: var(--enemy-chaser);
    color: #fff;
    box-shadow: 0 0 25px var(--enemy-chaser), inset 0 0 15px var(--enemy-chaser);
}

.high-score {
    font-size: 1.1rem;
    color: #888;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.top-bar {
    display: flex;
    justify-content: center;
    gap: 3rem;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: #a0d8d8;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.4);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    border: 1px solid rgba(0, 255, 255, 0.2);
    width: fit-content;
    margin: 0 auto;
    backdrop-filter: blur(4px);
}

.score-display span, .time-display span, .multiplier-display span {
    color: #fff;
    font-size: 1.4rem;
    margin-left: 0.5rem;
    text-shadow: 0 0 10px var(--player-color);
}

.ai-status {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 1.1rem;
    color: #fff;
    font-weight: 500;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--enemy-blocker), 0 0 20px var(--enemy-blocker);
    animation: pulse 2s infinite;
}

.icon-btn {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 0.6; }
}

/* Stats Container */
.stats-container {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    width: 100%;
    justify-content: center;
}

.stat-box {
    background: rgba(255, 0, 85, 0.1);
    border: 1px solid rgba(255, 0, 85, 0.3);
    padding: 1rem 2rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 160px;
}

.stat-label {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.8rem;
    color: #fff;
    text-shadow: 0 0 10px var(--enemy-chaser);
    font-weight: bold;
}

.ai-analysis {
    background: rgba(0, 0, 0, 0.5);
    padding: 1.5rem 2rem;
    border-radius: 8px;
    border: 1px solid rgba(170, 0, 255, 0.4);
    margin-bottom: 2.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: inset 0 0 20px rgba(170, 0, 255, 0.1);
    
    flex-shrink: 1 !important;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ai-analysis h3 {
    color: #df99ff;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--enemy-blocker);
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-align: left;
    display: flex;
    align-items: center;
}

#analysis-list {
    list-style: none;
    text-align: left;
    font-size: 1rem;
    line-height: 1.6;
    color: #ddd;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 10px;
}

#analysis-list::-webkit-scrollbar {
    width: 6px;
}
#analysis-list::-webkit-scrollbar-track {
    background: rgba(170, 0, 255, 0.1);
    border-radius: 4px;
}
#analysis-list::-webkit-scrollbar-thumb {
    background: rgba(170, 0, 255, 0.5);
    border-radius: 4px;
}

#analysis-list li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

#analysis-list li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--enemy-blocker);
    font-weight: bold;
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
    40%, 60% { transform: translate3d(5px, 0, 0); }
}

/* Trackpad */
#trackpad {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35%;
    background: rgba(0, 255, 255, 0.05);
    border-top: 2px solid rgba(0, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(0, 255, 255, 0.2);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 5px;
    z-index: 5;
    pointer-events: auto;
    touch-action: none;
}

@media (min-width: 769px) {
    #trackpad {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .neon-text { font-size: 2.8rem; }
    .neon-subtitle { font-size: 1rem; }
    .glass-panel { padding: 2rem 1.5rem; }
    .top-bar { gap: 1rem; padding: 0.6rem 1rem; font-size: 0.9rem; flex-wrap: wrap; }
    .score-display span, .time-display span, .multiplier-display span { font-size: 1.1rem; }
    .icon-btn { top: 1rem; right: 1rem; width: 40px; height: 40px; }
    .controls-info { flex-direction: column; gap: 1rem; align-items: stretch; }
    .stats-container { flex-direction: column; gap: 1rem; }
}
