/* Wishy Washy - Window Cleaning Game */

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

body {
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000;
    color: white;
    cursor: none;
}

/* Beautiful view background - hidden, webcam is the view now */
#view-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: none; /* Hide - webcam is the background */
    background:
        /* Sun */
        radial-gradient(circle at 80% 20%, rgba(255, 200, 100, 0.8) 0%, transparent 20%),
        /* Sky gradient */
        linear-gradient(180deg,
            #87CEEB 0%,
            #98D8E8 30%,
            #B4E4F0 50%,
            #E8F4F8 70%,
            #90EE90 70.5%,
            #228B22 85%,
            #006400 100%
        );
}

/* Add some clouds */
#view-background::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 200px;
    height: 60px;
    background: white;
    border-radius: 50px;
    box-shadow:
        60px -20px 0 -10px white,
        100px 0 0 -5px white,
        150px -10px 0 -15px white,
        400px 30px 0 0 white,
        450px 10px 0 -10px white,
        500px 25px 0 -5px white,
        700px -20px 0 10px white,
        750px 0 0 -5px white;
    opacity: 0.9;
}

/* Mountains silhouette */
#view-background::after {
    content: '';
    position: absolute;
    bottom: 30%;
    left: 0;
    width: 100%;
    height: 20%;
    background:
        linear-gradient(135deg, transparent 40%, #4a7c59 40%, #4a7c59 42%, transparent 42%),
        linear-gradient(225deg, transparent 45%, #3d6b4f 45%, #3d6b4f 48%, transparent 48%),
        linear-gradient(150deg, transparent 35%, #5a8f6a 35%, #5a8f6a 38%, transparent 38%);
    background-size: 33% 100%;
    background-position: 0 0, 33% 0, 66% 0;
}

/* Webcam - visible as background (EyeToy style) */
#webcam {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transform: scaleX(-1); /* Mirror for natural interaction */
}

/* Dirt canvas overlay */
#dirt-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

/* Sponge pointer */
.pointer {
    position: fixed;
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 500;
}

.pointer-sponge {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #f4d03f, #e9b824);
    border-radius: 15px;
    border: 3px solid #c9a020;
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.3),
        inset 0 -5px 10px rgba(0, 0, 0, 0.2),
        inset 0 5px 10px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.sponge-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(0,0,0,0.2) 2px, transparent 2px),
        radial-gradient(circle at 60% 30%, rgba(0,0,0,0.15) 3px, transparent 3px),
        radial-gradient(circle at 40% 60%, rgba(0,0,0,0.2) 2px, transparent 2px),
        radial-gradient(circle at 80% 70%, rgba(0,0,0,0.15) 3px, transparent 3px),
        radial-gradient(circle at 30% 80%, rgba(0,0,0,0.2) 2px, transparent 2px),
        radial-gradient(circle at 70% 40%, rgba(0,0,0,0.15) 2px, transparent 2px);
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
}

.overlay.hidden {
    display: none;
}

.start-content,
.results-content,
.turn-content {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 500px;
}

.start-content h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    background: linear-gradient(90deg, #3498db, #2ecc71, #f1c40f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    font-size: 1.2rem;
    padding: 15px 40px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5dade2, #3498db);
}

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

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

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    z-index: 500;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
}

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

.hud-center {
    flex-direction: column;
    gap: 10px;
}

.player-display,
.round-display,
.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.75rem;
    opacity: 0.7;
    text-transform: uppercase;
}

#current-player,
#current-round,
#score {
    font-size: 1.5rem;
    font-weight: bold;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

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

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

/* Progress bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    width: 200px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 8px;
    transition: width 0.3s, background 0.3s;
}

.percent-text {
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 60px;
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.status-indicator .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2ecc71;
}

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

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

.status-indicator.mouse .dot {
    background: #9b59b6;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Settings drawer */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 600;
    padding: 20px;
    transform: translateX(0);
    transition: transform 0.3s;
}

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

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

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

.setting-group label {
    display: block;
    margin-bottom: 10px;
    opacity: 0.8;
}

.setting-group input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

/* Hand hint */
.hint {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 30px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 400;
    animation: bounce 1s ease-in-out infinite;
}

.hint.hidden {
    display: none;
}

.hint-icon {
    font-size: 2rem;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-10px); }
}

/* Calibration */
.calibration-content {
    text-align: center;
}

.calibration-corners {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 4px solid white;
    border-radius: 50%;
    opacity: 0.3;
    transition: all 0.3s;
}

.corner.active {
    opacity: 1;
    background: rgba(46, 204, 113, 0.5);
    animation: pulse-corner 1s ease-in-out infinite;
}

.corner.complete {
    opacity: 0.8;
    background: #2ecc71;
}

.corner.top-left { top: 10%; left: 10%; }
.corner.top-right { top: 10%; right: 10%; }
.corner.bottom-left { bottom: 10%; left: 10%; }
.corner.bottom-right { bottom: 10%; right: 10%; }

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

/* Results */
.results-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.leaderboard-row.winner {
    background: linear-gradient(135deg, rgba(241, 196, 15, 0.3), rgba(243, 156, 18, 0.3));
    border: 2px solid #f1c40f;
}

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

.leaderboard-row .name {
    flex: 1;
    text-align: left;
    padding: 0 20px;
}

.leaderboard-row .score {
    font-weight: bold;
    font-size: 1.2rem;
}

/* Turn announcement */
.turn-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.player-name-large {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 20px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

#turn-countdown {
    font-size: 3rem;
    font-weight: bold;
}

/* Clean complete popup */
.clean-complete-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    padding: 30px 60px;
    border-radius: 20px;
    font-size: 2rem;
    font-weight: bold;
    z-index: 800;
    animation: pop-in 0.5s ease-out;
    box-shadow: 0 10px 40px rgba(46, 204, 113, 0.5);
}

@keyframes pop-in {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Winner popup */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 900;
}

.popup.hidden {
    display: none;
}

.winner-content {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    padding: 40px 60px;
    border-radius: 20px;
    text-align: center;
    animation: winner-pop 0.5s ease-out;
}

.winner-name {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 20px 0;
}

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

@keyframes winner-pop {
    0% { transform: scale(0) rotate(-10deg); }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .progress-bar {
        width: 120px;
    }

    .timer-display {
        font-size: 2rem;
    }

    #hud {
        padding: 10px;
    }

    .hud-left,
    .hud-right {
        gap: 10px;
    }

    .pointer {
        width: 80px;
        height: 80px;
    }
}
