@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@500;700;900&display=swap');

:root {
    --neon-blue: #00f0ff;
    --neon-pink: #ff0055;
    --neon-green: #39ff14;
    --neon-yellow: #ffea00;
    --neon-red: #ff3131;
    --neon-purple: #b026ff;
    --bg-dark: #06060c;
    --glass-bg: rgba(10, 10, 20, 0.85);
    --border-glow: 0 0 10px rgba(0, 240, 255, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: 'Share Tech Mono', monospace;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* CRT Screen Effect Wrapper */
.crt-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Scanlines overlay */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 10;
    pointer-events: none;
}

/* CRT Screen Flicker */
.flicker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(18, 16, 16, 0.05);
    opacity: 0.15;
    z-index: 11;
    pointer-events: none;
    animation: crt-flicker 0.15s infinite;
}

@keyframes crt-flicker {
    0% { opacity: 0.15; }
    50% { opacity: 0.18; }
    100% { opacity: 0.14; }
}

/* Vignette shadow */
.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.9);
    z-index: 12;
    pointer-events: none;
}

/* Webcam element (hidden from direct view, processed in JS) */
#webcam {
    position: absolute;
    left: 0;
    top: 0;
    width: 320px;
    height: 240px;
    opacity: 0.001;
    pointer-events: none;
    z-index: -1000;
}

/* Game Canvas */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* Neon Text Utilities */
.neon-blue {
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue), 0 0 10px var(--neon-blue);
}

.neon-pink {
    color: var(--neon-pink);
    text-shadow: 0 0 5px var(--neon-pink), 0 0 10px var(--neon-pink);
}

.neon-green {
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green);
}

.neon-yellow {
    color: var(--neon-yellow);
    text-shadow: 0 0 5px var(--neon-yellow), 0 0 10px var(--neon-yellow);
}

.neon-red {
    color: var(--neon-red);
    text-shadow: 0 0 5px var(--neon-red), 0 0 10px var(--neon-red);
}

/* HUD Overlay Container */
.hud-container {
    position: absolute;
    top: 20px;
    left: 5%;
    width: 90%;
    height: 70px;
    z-index: 5;
    background: var(--glass-bg);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 8px;
    padding: 5px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--border-glow);
    backdrop-filter: blur(5px);
    transition: opacity 0.5s ease;
}

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

.hud-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.hud-label {
    font-size: 14px;
    color: #888;
    margin-right: 8px;
    letter-spacing: 1px;
}

.hud-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 18px;
}

.hud-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 16px;
    letter-spacing: 2px;
}

.hud-stats {
    font-size: 12px;
    color: #ccc;
    margin-top: 2px;
}

.hud-spacer {
    margin: 0 10px;
    color: #444;
}

.fever-container {
    display: flex;
    align-items: center;
}

.fever-bar-outer {
    width: 120px;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 0, 85, 0.3);
    border-radius: 6px;
    overflow: hidden;
    margin-right: 10px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.fever-bar-inner {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-yellow));
    box-shadow: 0 0 8px var(--neon-pink);
    transition: width 0.1s ease;
}

.fever-text {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 13px;
    animation: pulse 0.8s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* Game Screens Overlay */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.75);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(4px);
}

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

.screen-content {
    background: var(--glass-bg);
    border: 2px solid var(--neon-blue);
    border-radius: 12px;
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.25);
    width: 90%;
    max-width: 580px;
    padding: 35px;
    text-align: center;
    animation: scale-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scale-up {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.game-logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 3px;
    margin-bottom: 5px;
}

.game-subtitle {
    font-size: 15px;
    color: #aaa;
    letter-spacing: 2px;
    margin-bottom: 25px;
}

.guide-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
}

.guide-panel h3 {
    color: var(--neon-yellow);
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
    letter-spacing: 1px;
}

.guide-panel ul {
    list-style-type: none;
}

.guide-panel li {
    font-size: 13px;
    color: #ddd;
    margin-bottom: 8px;
    line-height: 1.5;
    position: relative;
    padding-left: 15px;
}

.guide-panel li::before {
    content: "▶";
    position: absolute;
    left: 0;
    color: var(--neon-blue);
    font-size: 10px;
    top: 2px;
}

.mode-select {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

/* Retro UI Button Styles */
.btn-retro {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #888;
    padding: 10px 18px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-retro:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
}

.btn-retro.active {
    color: var(--neon-pink);
    border-color: var(--neon-pink);
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.25);
    background: rgba(255, 0, 85, 0.05);
}

.btn-retro-primary {
    width: 100%;
    background: linear-gradient(135deg, #00d2ff 0%, #0066ff 100%);
    border: none;
    color: white;
    padding: 15px 0;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 2px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 102, 255, 0.4);
    transition: all 0.2s ease;
}

.btn-retro-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 102, 255, 0.6);
    filter: brightness(1.1);
}

.btn-retro-primary:active {
    transform: translateY(1px);
}

#btnRestart {
    background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-purple) 100%);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

#btnRestart:hover {
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
}

/* Calibration screen status */
.calibration-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

.status-indicator {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    width: 250px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.status-indicator.inactive {
    background: rgba(255, 255, 255, 0.03);
    color: #666;
}

.status-indicator.active {
    background: rgba(57, 255, 20, 0.08);
    color: var(--neon-green);
    border-color: var(--neon-green);
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.2);
}

/* Loading spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 240, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--neon-blue);
    margin: 20px auto;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.note {
    font-size: 11px;
    color: #666;
    margin-top: 10px;
}

/* Stats panel in GameOver */
.stats-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 25px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 15px;
}

.stat-row:not(:last-child) {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stat-row span:last-child {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
}

/* Floating Camera Preview Container (Bottom Right) */
#webcamPreviewContainer {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 160px;
    height: 120px;
    background: #000;
    border: 1px solid var(--neon-blue);
    border-radius: 6px;
    box-shadow: var(--border-glow);
    z-index: 15;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.22s ease;
    pointer-events: none; /* Make click-through */
}

#webcamPreviewContainer.fade {
    opacity: 0.15;
}

#trackingCanvas {
    width: 100%;
    height: 100px;
    background: #05050a;
    display: block;
    transform: scaleX(-1); /* Mirror camera stream */
}

.preview-label {
    height: 20px;
    background: rgba(0, 240, 255, 0.15);
    color: var(--neon-blue);
    font-size: 9px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    letter-spacing: 1px;
    border-top: 1px solid rgba(0, 240, 255, 0.3);
}

/* CRT curves/fades at screen borders */
.crt-wrapper::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: radial-gradient(circle, rgba(0,0,0,0) 0%, rgba(0,0,0,0.1) 70%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
    z-index: 13;
}
