:root {
    --bg-color: #0f172a;
    --primary: #3b82f6;
    --accent: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-primary: #f8fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through if needed, except for panels */
}

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

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    pointer-events: auto;
}

/* Screens */
.screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 40px;
    text-align: center;
    min-width: 400px;
    transition: opacity 0.3s ease;
}

.title-text {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.title-text.danger {
    color: var(--danger);
}

.instructions {
    margin: 30px 0;
    text-align: left;
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 8px;
}

.gesture-info {
    margin: 10px 0;
    font-size: 1.1rem;
}

.highlight {
    color: var(--primary);
    font-weight: bold;
}

.primary-button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
    margin-top: 20px;
}

.primary-button:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

.error-text {
    color: var(--danger);
    margin-top: 15px;
}

#loading-msg {
    margin-top: 15px;
    color: var(--primary);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-bottom {
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.score-container, .status-container {
    padding: 15px 25px;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    gap: 15px;
    align-items: center;
}

.label {
    color: #888;
    font-size: 1rem;
    letter-spacing: 1px;
}

#score {
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

#gesture-status {
    color: var(--accent);
    text-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
    min-width: 120px;
    text-align: left;
}

.health-container {
    padding: 15px;
    width: 300px;
}

.health-bar-bg {
    width: 100%;
    height: 15px;
    background: rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

.health-bar-fill {
    width: 100%;
    height: 100%;
    background: var(--danger);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    transition: width 0.3s ease;
}

#floating-msg {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--success);
    text-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
    pointer-events: none;
    z-index: 20;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translate(-50%, 0px); }
    50% { transform: translate(-50%, -10px); }
    100% { transform: translate(-50%, 0px); }
}

#debug-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 15px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #0f0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .screen {
        min-width: 90%;
        padding: 20px;
    }
    .title-text {
        font-size: 2rem;
    }
    .hud-top {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    .hud-bottom {
        align-items: center;
    }
    .score-container, .status-container {
        padding: 10px 15px;
        font-size: 1.2rem;
        width: auto;
    }
    .health-container {
        padding: 10px;
        width: 200px;
    }
    .instructions {
        font-size: 0.9rem;
    }
    .primary-button {
        padding: 12px 24px;
        font-size: 1rem;
    }
    #floating-msg {
        font-size: 1.2rem;
        padding: 10px 20px;
        width: 90%;
        text-align: center;
    }
}
