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

body {
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #000;
    color: #fff;
}

/* Webcam video as fullscreen background (EyeToy style) */
#webcam {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror so player sees themselves naturally */
    z-index: 0;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
}

#webcam.no-camera {
    /* Fallback gradient when no camera */
    background: linear-gradient(180deg, #1e90ff 0%, #87ceeb 50%, #b0e0e6 100%);
}

/* Hand tracking overlay - shows detected landmarks during gameplay */
#hand-debug-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 8; /* Above game container (5) so hand skeleton is always visible */
    pointer-events: none;
    transform: scaleX(-1); /* Mirror to match video */
}

/* Three.js canvas as transparent overlay */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5;
    pointer-events: none;
}

#game-container canvas {
    display: block;
    pointer-events: none; /* Let clicks pass through to UI */
}

/* Overlays - must be above everything */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.overlay * {
    pointer-events: auto;
}

.overlay.hidden {
    display: none;
}

/* Calibration overlay - much more transparent so user can see themselves */
#calibration-overlay {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
}

.start-content,
.calibration-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

/* Calibration content box with semi-transparent background for readability */
.calibration-content {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    padding: 30px;
}

.start-content h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.start-content p {
    font-size: 1.2rem;
    opacity: 0.8;
    margin-bottom: 30px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 10;
    pointer-events: auto !important;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    padding: 10px 20px;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mode-toggle {
    margin-top: 20px;
    opacity: 0.7;
}

.mode-toggle label {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Calibration */
.calibration-corners {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.corner.active {
    border-color: #48dbfb;
    box-shadow: 0 0 20px #48dbfb, 0 0 40px #48dbfb;
    animation: pulse 1s ease-in-out infinite;
}

.corner.done {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.3);
}

.top-left { top: 40px; left: 40px; }
.top-right { top: 40px; right: 40px; }
.bottom-left { bottom: 40px; left: 40px; }
.bottom-right { bottom: 40px; right: 40px; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Hand Hint */
.hint {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 25px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
    animation: fadeInUp 0.3s ease;
}

.hint.hidden {
    display: none;
}

.hint-icon {
    font-size: 2rem;
    animation: wave 1s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

#hud > * {
    pointer-events: auto;
}

.hud-left,
.hud-right {
    display: flex;
    gap: 20px;
    align-items: center;
}

.score-display,
.combo-display {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.score-display .label,
.combo-display .label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.7;
    letter-spacing: 1px;
}

#score {
    font-size: 2rem;
    font-weight: 700;
    display: block;
}

#combo {
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    color: #feca57;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.status-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: blink 2s ease-in-out infinite;
}

.status-indicator.warning .dot {
    background: #f39c12;
}

.status-indicator.error .dot {
    background: #e74c3c;
    animation: none;
}

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

/* Settings Drawer */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(10px);
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.drawer.hidden {
    transform: translateX(100%);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.drawer-header h3 {
    font-size: 1.2rem;
}

.drawer-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.setting-group input[type="range"] {
    width: calc(100% - 50px);
    vertical-align: middle;
}

.setting-group span {
    display: inline-block;
    width: 40px;
    text-align: right;
    font-weight: 600;
}

.setting-group select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1rem;
}

.setting-group select option {
    background: #1a1a2e;
}

.setting-group .btn {
    width: 100%;
}

/* Combo Popup */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: #feca57;
    text-shadow: 0 0 20px rgba(254, 202, 87, 0.5);
    z-index: 60;
    pointer-events: none;
    animation: popIn 0.5s ease forwards;
}

.popup.hidden {
    display: none;
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) translateY(-30px);
        opacity: 0;
    }
}

/* Screen Shake */
.shake {
    animation: shake 0.15s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Player Setup Styles */
.setup-content,
.turn-content,
.results-content {
    text-align: center;
    max-width: 450px;
    padding: 40px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
}

.setup-screen.hidden {
    display: none;
}

.player-count-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
}

#player-count-display {
    font-size: 4rem;
    font-weight: 700;
    min-width: 80px;
    color: #48dbfb;
}

.arrow-btn {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.arrow-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.hint-text {
    opacity: 0.6;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Player Name Inputs */
.name-input-group {
    margin: 15px 0;
    text-align: left;
}

.name-input-group label {
    display: block;
    margin-bottom: 5px;
    opacity: 0.8;
}

.name-input-group input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    outline: none;
    transition: border-color 0.2s ease;
}

.name-input-group input:focus {
    border-color: #48dbfb;
}

.name-input-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Turn Announcement */
.player-name-large {
    font-size: 3rem;
    font-weight: 700;
    color: #48dbfb;
    margin: 20px 0;
}

.countdown-text {
    font-size: 1.5rem;
    opacity: 0.8;
}

#turn-countdown {
    font-size: 2rem;
    font-weight: 700;
    color: #feca57;
}

/* Timer Display */
.hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.timer-display {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 25px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

#timer {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: #fff;
}

#timer.warning {
    color: #f39c12;
}

#timer.critical {
    color: #e74c3c;
    animation: pulse-timer 0.5s ease-in-out infinite;
}

@keyframes pulse-timer {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Player Display */
.player-display,
.round-display {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

#current-player {
    font-size: 1.2rem;
    font-weight: 600;
    display: block;
    color: #48dbfb;
}

#current-round {
    font-size: 1.2rem;
    font-weight: 600;
    display: block;
    color: #feca57;
}

/* Streak Display */
.streak-display {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 10px;
    margin-top: 10px;
    text-align: center;
}

#streak {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ff6b6b;
}

#streak.hot {
    color: #ff6600;
    text-shadow: 0 0 10px #ff6600;
    animation: pulse-streak 0.3s ease-in-out infinite;
}

#streak.fire {
    color: #ff3300;
    text-shadow: 0 0 15px #ff3300, 0 0 30px #ff0000;
    animation: pulse-streak 0.2s ease-in-out infinite;
}

#streak.blazing {
    color: #ff0000;
    text-shadow: 0 0 20px #ff0000, 0 0 40px #ff3300, 0 0 60px #ffff00;
    animation: pulse-streak 0.15s ease-in-out infinite, rainbow-glow 1s linear infinite;
}

@keyframes pulse-streak {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes rainbow-glow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.multiplier {
    font-size: 1rem;
    color: #feca57;
    margin-left: 8px;
}

/* Lives Display */
.lives-display {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.lives-display .label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
}

#lives {
    font-size: 1.8rem;
    letter-spacing: 8px;
    transition: transform 0.2s;
}

.life-lost {
    animation: life-lost 0.5s ease;
}

@keyframes life-lost {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

/* Miss indicator */
.miss-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 6rem;
    font-weight: 900;
    color: #ff0000;
    text-shadow: 0 0 30px #ff0000, 0 0 60px #ff0000, 2px 2px 0 #000, -2px -2px 0 #000;
    animation: miss-pop 0.8s ease forwards;
    pointer-events: none;
    z-index: 500;
}

/* Red screen flash on miss */
.screen-flash-red {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 0, 0, 0.3);
    pointer-events: none;
    z-index: 400;
    animation: flash-fade 0.5s ease forwards;
}

@keyframes flash-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Game Over Overlay */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 600;
    animation: fade-in 0.3s ease;
}

.game-over-content {
    text-align: center;
    animation: shake 0.5s ease;
}

.game-over-content h1 {
    font-size: 4rem;
    color: #ff0000;
    text-shadow: 0 0 30px #ff0000, 0 0 60px #ff0000;
    margin-bottom: 10px;
}

.game-over-content p {
    font-size: 2rem;
    color: #fff;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes miss-pop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Fireworks */
.fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 500;
    overflow: hidden;
}

.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: firework-explode 1s ease-out forwards;
}

@keyframes firework-explode {
    0% { transform: scale(0); opacity: 1; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

.firework-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-fly 1.5s ease-out forwards;
}

@keyframes particle-fly {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Winner announcement */
.winner-content {
    text-align: center;
    max-width: 500px;
    padding: 50px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(0, 0, 0, 0.9));
    border-radius: 20px;
    border: 3px solid #ffd700;
}

.winner-content h1 {
    font-size: 3rem;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin-bottom: 20px;
}

.winner-name {
    font-size: 2.5rem;
    color: #fff;
    margin: 20px 0;
}

.winner-score {
    font-size: 1.5rem;
    color: #feca57;
}

.winner-title {
    font-size: 3rem;
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ff6600;
    animation: winner-pulse 0.5s ease infinite alternate;
}

@keyframes winner-pulse {
    from { transform: scale(1); text-shadow: 0 0 20px #ffd700, 0 0 40px #ff6600; }
    to { transform: scale(1.1); text-shadow: 0 0 30px #ffd700, 0 0 60px #ff6600; }
}

.trophy {
    font-size: 4rem;
    margin-top: 20px;
    animation: trophy-bounce 0.5s ease infinite alternate;
}

@keyframes trophy-bounce {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-10px) scale(1.1); }
}

.winner-overlay.fade-out {
    animation: fade-out 1s ease forwards;
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Results / Leaderboard */
#leaderboard {
    margin: 20px 0;
    text-align: left;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border-left: 4px solid #48dbfb;
}

.leaderboard-entry.first {
    border-left-color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
}

.leaderboard-entry.second {
    border-left-color: #c0c0c0;
}

.leaderboard-entry.third {
    border-left-color: #cd7f32;
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: 700;
    min-width: 40px;
}

.leaderboard-name {
    flex: 1;
    font-size: 1.2rem;
    margin-left: 15px;
}

.leaderboard-score {
    font-size: 1.4rem;
    font-weight: 700;
    color: #feca57;
}

/* Responsive */
@media (max-width: 768px) {
    .start-content h1 {
        font-size: 2rem;
    }

    .drawer {
        width: 100%;
    }

    #hud {
        padding: 10px 15px;
    }

    .score-display,
    .combo-display {
        padding: 8px 12px;
    }

    #score {
        font-size: 1.5rem;
    }
}

/* Launcher Button */
#launcher-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.launcher {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ff4444, #cc0000);
    border: 6px solid #ff6666;
    box-shadow:
        0 0 30px rgba(255, 0, 0, 0.5),
        0 0 60px rgba(255, 0, 0, 0.3),
        inset 0 -10px 30px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.launcher:hover {
    transform: scale(1.05);
    box-shadow:
        0 0 40px rgba(255, 0, 0, 0.7),
        0 0 80px rgba(255, 0, 0, 0.4),
        inset 0 -10px 30px rgba(0, 0, 0, 0.3);
}

.launcher.active {
    background: linear-gradient(145deg, #00ff00, #00cc00);
    border-color: #66ff66;
    box-shadow:
        0 0 40px rgba(0, 255, 0, 0.7),
        0 0 80px rgba(0, 255, 0, 0.4),
        inset 0 -10px 30px rgba(0, 0, 0, 0.3);
    animation: pulse-launcher 0.5s ease infinite;
}

@keyframes pulse-launcher {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.launcher.triggering {
    animation: trigger-pulse 0.3s ease;
}

@keyframes trigger-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.launcher-inner {
    text-align: center;
    z-index: 2;
}

.launcher-icon {
    font-size: 3rem;
    margin-bottom: 5px;
}

.launcher-text {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.launcher-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 50% 50%;
    transition: height 0.1s linear;
}

.selected-indicator {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 25px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
    backdrop-filter: blur(5px);
}

.selected-indicator.hidden {
    display: none;
}

#selected-count {
    font-size: 1.5rem;
    color: #ffff00;
    text-shadow: 0 0 10px #ffff00;
}

/* Hide lives display for fireworks mode */
.lives-display {
    display: none !important;
}
