/* Base Reset & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f7f9fc;
    color: #1e293b;
    position: relative;
}

/* Custom Cursor for tracking right hand */
#custom-cursor {
    position: absolute;
    width: 80px;
    height: 80px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: transform 0.05s ease-out;
}

/* Hidden elements */
.hidden-video {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Screen Layouts */
.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    transition: opacity 0.5s ease-in-out;
    background-color: #f7f9fc;
}

/* Home Screen specific */
#home-screen {
    background: url('assets/background.jpg') no-repeat center center;
    background-size: cover;
    z-index: 10;
}

.home-logo-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 500px;
    padding-top: 40px;
}

.home-logo {
    width: 100%;
    height: auto;
    max-height: 40vh;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
}

.home-start-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 50px;
    z-index: 2;
}

.btn-start-img {
    width: 220px;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.btn-start-img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.2));
}

.guide-text {
    margin-top: 20px;
    font-size: 0.95rem;
    color: #475569;
    text-align: center;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.85);
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

/* Glass Panels & Modals */
.overlay-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(241, 245, 249, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 20px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
    border-radius: 24px;
    padding: 32px;
    max-width: 440px;
    width: 100%;
    text-align: center;
}

.glass-card h2 {
    font-weight: 800;
    font-size: 1.75rem;
    margin-bottom: 12px;
    color: #0f172a;
}

.glass-card p {
    color: #475569;
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 24px;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alert Overlay (No Hands) */
.alert-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    width: 90%;
    max-width: 360px;
    pointer-events: none;
}

.alert-card {
    background: rgba(254, 242, 242, 0.95);
    border: 2px solid #ef4444;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.15);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    animation: bounceAlert 0.4s ease-out;
}

.alert-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.alert-card h3 {
    color: #991b1b;
    font-size: 1.2rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.alert-card p {
    color: #7f1d1d;
    font-size: 0.9rem;
    line-height: 1.4;
}

@keyframes bounceAlert {
    0% { transform: scale(0.9); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* Game Screen Elements */
#game-screen {
    background: url('assets/background.jpg') no-repeat center center;
    background-size: cover;
    position: relative;
}

/* Top Left Mini Logo */
.game-logo-top-left {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.mini-logo {
    height: 144px; /* Enlarged 3x (was 48px) */
    width: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
}

/* Top Right Webcam Box */
.game-webcam-preview {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 420px; /* Enlarged 3x (was 140px) */
    height: 315px; /* Enlarged 3x (was 105px) */
    border-radius: 20px;
    overflow: hidden;
    border: 4px solid white;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.15);
    z-index: 100;
    background-color: #cbd5e1;
    transition: width 0.3s, height 0.3s;
}

#game-webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror camera output */
}

#skeleton-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1); /* Mirror canvas output too */
    pointer-events: none;
}

.preview-label {
    position: absolute;
    bottom: 6px;
    left: 0;
    right: 0;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    color: #3b82f6;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Arena & Virtual Hands */
.arena {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding-top: 80px;
}

.opponent-hand-container {
    flex: 1;
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
    padding-bottom: 250px;
}

.hand-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.base-bawah {
    position: absolute;
    width: 480px; /* Enlarged 2x */
    height: auto;
    bottom: -5vh; /* Lowered to center hand wrapper */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.1));
}

.base-atas {
    position: absolute;
    width: 240px; /* Enlarged 2x */
    height: auto;
    bottom: 10vh; /* Lowered default position */
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    transform-origin: bottom center;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.1));
    will-change: transform, bottom;
}

.swing-auto {
    animation: swingAuto 0.5s ease-in-out;
}

@keyframes swingAuto {
    0% { bottom: 10vh; }
    50% { bottom: 30vh; }
    100% { bottom: 10vh; }
}

.opponent-choice-img {
    position: absolute;
    width: 320px; /* Enlarged 2x */
    height: auto;
    bottom: 2vh; /* Lowered showdown choice */
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    animation: popShowdown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.15));
}

@keyframes popShowdown {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* HUD elements */
.game-hud {
    position: absolute;
    bottom: 30px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 10;
}

#countdown-text {
    position: absolute;
    bottom: 180px;
    font-size: 6rem;
    font-weight: 800;
    color: #3b82f6;
    text-shadow: 0 4px 12px rgba(59, 130, 246, 0.15), 0 0 1px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 20;
}

.countdown-bounce {
    animation: scaleBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.gesture-pill {
    position: relative;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
    color: #475569;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 250px;
    text-align: center;
    overflow: hidden; /* Hide progress bar corners */
    z-index: 10;
}

#gesture-text {
    position: relative;
    z-index: 2; /* Display above the progress bar */
}

#gesture-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(16, 185, 129, 0.25); /* Transparent green fill */
    border-right: 2px solid #10b981;
    z-index: 1;
    transition: none;
}

#gesture-progress.showdown {
    width: 100% !important;
    background: rgba(239, 68, 68, 0.35) !important; /* Transparent red fill */
    border-right: none;
}

.scoreboard {
    display: flex;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    border-radius: 20px;
    padding: 12px 32px;
    gap: 40px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.1em;
    margin-bottom: 2px;
}

.score-val {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
}

/* Result Overlay */
.result-overlay {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.btn-playagain-img {
    display: none !important;
}

.result-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0;
    padding: 0;
    max-width: 440px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popUpCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popUpCard {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.result-banner-img {
    width: 260px;
    height: auto;
    object-fit: contain;
    margin-bottom: 20px;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.05));
}

.tie-banner {
    font-size: 3rem;
    font-weight: 800;
    color: #64748b;
    margin-bottom: 20px;
    letter-spacing: 0.05em;
    text-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.result-detail-text {
    font-size: 1.25rem;
    color: #0f172a;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.95), 0 0 10px rgba(255, 255, 255, 0.95);
}

.btn-playagain-img {
    width: 180px;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.btn-playagain-img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
}

/* Mobile Responsiveness Rules */
@media (max-width: 640px) {
    .game-webcam-preview {
        width: 240px; /* Enlarged on mobile */
        height: 180px;
        top: 15px;
        right: 15px;
        border-width: 2px;
    }

    .game-logo-top-left {
        top: 15px;
        left: 15px;
    }

    .mini-logo {
        height: 90px; /* Enlarged on mobile */
    }

    .base-bawah {
        width: 280px; /* Enlarged on mobile */
        bottom: -5vh;
    }

    .base-atas {
        width: 140px; /* Enlarged on mobile */
        bottom: 10vh;
    }

    .opponent-choice-img {
        width: 180px; /* Enlarged on mobile */
        bottom: 2vh;
    }

    #countdown-text {
        bottom: 140px;
        font-size: 4.5rem;
    }

    .opponent-hand-container {
        padding-bottom: 150px;
    }

    .btn-start-img {
        width: 180px;
    }

    .home-logo {
        max-height: 35vh;
    }

    .guide-text {
        font-size: 0.85rem;
        padding: 10px 16px;
    }
}
