@font-face {
    font-family: 'Pixeboy';
    src: url('assets/Pixeboy.ttf') format('truetype');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Pixeboy', sans-serif;
    background: linear-gradient(135deg, #ebad74, #da935d, #ebad74, #da935d);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

#title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

#game-title {
    font-family: 'Pixeboy', sans-serif;
    font-size: 72px;
    color: #fff;
    text-align: center;
    text-shadow: 
        4px 4px 0px #d2691e,
        8px 8px 0px rgba(0, 0, 0, 0.3);
    letter-spacing: 4px;
    animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

#game-subtitle {
    font-family: 'Pixeboy', sans-serif;
    font-size: 20px;
    color: #fff;
    text-align: center;
    text-shadow: 
        2px 2px 0px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
    margin-top: -5px;
}

#game-container {
    position: relative;
    width: 640px;
    height: 480px;
    border: 6px solid #fff;
    border-radius: 20px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.4), 
        0 0 0 3px #ff6b6b, 
        0 0 20px rgba(255, 107, 107, 0.5);
    overflow: hidden;
    background: #000;
}

#webcam {
    display: none;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 640px;
    height: 480px;
    display: block;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#ui-overlay.hidden {
    display: none;
}

#score-display {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 180px;
    height: 60px;
    background-image: url('assets/Score.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Pixeboy', sans-serif;
    font-size: 40px;
    font-weight: bold;
    color: #da935d;
    padding-left: 72px;
    padding-bottom: 3.6px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    line-height: 1;
}

#time-display {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 180px;
    height: 60px;
    background-image: url('assets/Time.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Pixeboy', sans-serif;
    font-size: 40px;
    font-weight: bold;
    color: #da935d;
    padding-left: 72px;
    padding-bottom: 3.6px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    line-height: 1;
}

#phase-display {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Pixeboy', sans-serif;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    text-shadow: 
        2px 2px 0px #000,
        -1px -1px 0px #000,
        1px -1px 0px #000,
        -1px 1px 0px #000;
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#start-screen.hidden {
    display: none;
}

#logo-image {
    width: auto;
    height: auto;
    max-width: 540px;
    max-height: 300px;
    object-fit: contain;
    margin-bottom: 40px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
}

#start-button-container {
    position: relative;
    width: 320px;
    height: 90px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

#start-button-container:hover {
    transform: scale(1.05);
}

#start-button-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 2;
}

#start-button-hover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 1;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.1s linear;
}

#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#game-over-screen.hidden {
    display: none;
}

#game-over-image {
    width: auto;
    height: auto;
    max-width: 450px;
    max-height: 200px;
    object-fit: contain;
    margin-bottom: 20px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    animation: gameOverPulse 1s ease-in-out;
}

@keyframes gameOverPulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#final-score {
    font-family: 'Pixeboy', sans-serif;
    font-size: 60px;
    color: #d2691e;
    margin-bottom: 25px;
    text-align: center;
    text-shadow: 
        2px 2px 0px rgba(0, 0, 0, 0.3);
    animation: scoreCount 0.5s ease-out;
}

@keyframes scoreCount {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#replay-button-container {
    position: relative;
    width: 320px;
    height: 90px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

#replay-button-container:hover {
    transform: scale(1.05);
}

#replay-button-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 2;
}

#replay-button-hover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 1;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.1s linear;
}

#warning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    pointer-events: none;
}

#warning-overlay.hidden {
    display: none;
}

#warning-image {
    width: auto;
    height: auto;
    max-width: 500px;
    max-height: 300px;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    animation: warningShake 0.5s ease-in-out;
}

@keyframes warningShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ebad74 0%, #da935d 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#loading-screen.hidden {
    display: none;
}

#loading-screen h2 {
    font-family: 'Pixeboy', sans-serif;
    font-size: 40px;
    color: white;
    margin-bottom: 20px;
    text-align: center;
    padding: 0 20px;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#loading-screen p {
    font-family: 'Pixeboy', sans-serif;
    font-size: 40px;
    color: #ddd;
    text-align: center;
}