/* --- CORE RESET & VARS --- */
:root {
    --gold: #FFD700;
    --glass-bg: rgba(13, 15, 26, 0.85);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --success: #00ffaa;
    --danger: #ff4444;
}

body {
    margin: 0; overflow: hidden; background-color: #0d0f1a;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main); user-select: none; touch-action: none;
}

canvas { display: block; position: absolute; top: 0; left: 0; z-index: 0; }

/* --- GLASSMORPHISM --- */
.glass-bar, .glass-panel, .glass-chip {
    background: var(--glass-bg);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}
.glass-panel { border-radius: 20px; padding: 25px; box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5); }

/* --- HEADER & FOOTER (High Z-Index to stay clickable) --- */
.header {
    position: absolute; top: 0; left: 0; width: 100%; height: 60px;
    display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
    box-sizing: border-box; 
    z-index: 2100; /* ABOVE THE OVERLAY */
    transition: opacity 0.5s;
}

.footer {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 10px 20px;
    box-sizing: border-box; 
    z-index: 2100; /* ABOVE THE OVERLAY */
    font-size: 11px; text-align: center; color: var(--text-muted);
    transition: opacity 0.5s; display: flex; justify-content: center;
}

.header a { 
    color: var(--text-main); text-decoration: none; font-weight: 600; 
    text-transform: uppercase; font-size: 12px; letter-spacing: 1px;
    display: flex; align-items: center; gap: 8px;
}
.header-center { 
    font-weight: 800; color: var(--gold); letter-spacing: 2px; text-transform: uppercase; 
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3); font-size: 14px;
}
.github-btn { 
    border: 1px solid var(--glass-border); padding: 6px 14px; 
    border-radius: 20px; transition: 0.3s; background: rgba(255,255,255,0.05);
}
.github-btn:hover { background: rgba(255,255,255,0.2); transform: translateY(-2px); }

.footer-inner {
    display: flex; justify-content: space-between; width: 100%; max-width: 1000px;
    align-items: center; background: var(--glass-bg); backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border); padding: 8px 20px; border-radius: 30px;
}
.legal-links a { color: var(--gold); text-decoration: none; border-bottom: 1px dotted var(--gold); }

/* Hide header/footer in immersive mode */
body.immersive .header, body.immersive .footer { opacity: 0; pointer-events: none; }

/* --- OVERLAYS --- */
.overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(13, 15, 26, 0.85);
    z-index: 2000; 
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s; padding: 20px; box-sizing: border-box;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.overlay-inner { 
    text-align: center; width: 100%; max-width: 480px; 
    /* Scrollable Box Fix */
    max-height: 80vh; overflow-y: auto;
    display: flex; flex-direction: column; align-items: center; position: relative;
    scrollbar-width: thin; scrollbar-color: #444 transparent;
}
/* Scrollbar Styling */
.overlay-inner::-webkit-scrollbar { width: 6px; }
.overlay-inner::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
.overlay-inner::-webkit-scrollbar-track { background: transparent; }

/* Tutorial Styles */
.intro-text p { font-size: 15px; line-height: 1.4; margin-bottom: 10px; }
.steps-list {
    text-align: left; list-style: none; padding: 15px; margin: 15px 0;
    background: rgba(255,255,255,0.03); border-radius: 10px; width: 100%;
    box-sizing: border-box; border: 1px solid rgba(255,255,255,0.05);
}
.steps-list li { margin-bottom: 8px; font-size: 13px; color: #ccc; display: flex; align-items: start; gap: 8px;}

.tutorial-row { display: flex; gap: 15px; margin: 15px 0; justify-content: center; flex-wrap: wrap; }
.gesture-demo {
    width: 100px; height: 100px; border-radius: 15px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.3);
}
.hand-icon {
    width: 35px; height: 35px; border-radius: 50%; background: var(--gold);
    margin-bottom: 8px; animation-duration: 2s; animation-iteration-count: infinite;
}
@keyframes expand-anim {
    0% { transform: scale(0.5); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 20px var(--gold); }
    100% { transform: scale(0.5); opacity: 0.5; }
}
@keyframes pinch-anim {
    0% { transform: scale(1.2); }
    50% { transform: scale(0.4); background: var(--danger); }
    100% { transform: scale(1.2); }
}
.demo-expand .hand-icon { animation-name: expand-anim; }
.demo-pinch .hand-icon { animation-name: pinch-anim; }

.btn-start {
    background: linear-gradient(135deg, var(--gold), #ffaa00); color: #000; 
    border: none; padding: 12px 30px; border-radius: 30px; 
    font-weight: 800; font-size: 14px; cursor: pointer;
    text-transform: uppercase; transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 5px; width: 100%; max-width: 300px;
}
.btn-start:hover { transform: scale(1.02); box-shadow: 0 0 25px rgba(255, 215, 0, 0.4); }

/* Calibration */
#cal-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; opacity: 0.8; }
.scan-frame {
    width: 180px; height: 180px; border: 2px dashed #555; border-radius: 20px;
    display: flex; align-items: center; justify-content: center; margin: 15px auto;
    transition: 0.3s; z-index: 10;
}
.scan-frame.scanning { border-color: var(--success); box-shadow: 0 0 30px rgba(0,255,170,0.3); }
.progress-bar { width: 100%; height: 6px; background: #222; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress-fill { width: 0%; height: 100%; background: var(--success); transition: width 0.1s; }

/* Main UI */
.main-ui {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 50; opacity: 0; transition: opacity 1s;
}
.main-ui.visible { opacity: 1; }
.top-bar {
    position: absolute; top: 80px; left: 20px; right: 20px;
    display: flex; justify-content: space-between; padding: 10px; border-radius: 10px;
    pointer-events: auto; max-width: 600px; margin: 0 auto;
}
.panels {
    position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 8px; pointer-events: auto; padding: 12px; 
    flex-wrap: wrap; justify-content: center; width: 90%; max-width: 600px;
}
.shape-btn {
    background: transparent; border: 1px solid rgba(255,255,255,0.1); color: #ccc;
    padding: 8px 16px; border-radius: 25px; cursor: pointer; 
    text-transform: uppercase; font-size: 10px; font-weight: 700; transition: 0.3s;
}
.shape-btn.active { background: var(--gold); color: black; border-color: var(--gold); box-shadow: 0 0 15px rgba(255,215,0,0.4); }

/* Mario */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
.mario-btn { border-color: #e60012 !important; color: #e60012 !important; }
.mario-btn:hover, .mario-btn.active { background: #e60012 !important; color: white !important; box-shadow: 0 0 20px #e60012; }
#mario-ui { font-family: 'Press Start 2P', cursive; pointer-events: none; }
#mario-ui.visible { opacity: 1; pointer-events: auto; }
.mario-hud {
    position: absolute; top: 20px; left: 0; width: 100%; display: flex; justify-content: space-around;
    color: white; text-shadow: 2px 2px #000; font-size: 14px;
}
#mario-gameover {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 3000; color: white;
}
#mario-gameover.hidden { display: none; }
select, input[type=color] { background: rgba(0,0,0,0.5); border: 1px solid #444; color: white; padding: 5px; border-radius: 5px; }
video { display: none; }
.btn-text { background: none; border: none; color: #aaa; margin-top: 20px; cursor: pointer; text-decoration: underline; font-family: inherit; }
