* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

/* Mobile Wrapper Container */
#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    background-color: #000;
}

/* On desktop, constrain it to mobile dimensions */
@media (min-width: 600px) {
    #app-container {
        width: 400px;
        height: 850px;
        max-height: 100vh;
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
        border-radius: 20px;
        top: 50%;
        transform: translateY(-50%);
    }

    body {
        background-color: #1a1a1a;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

/* The camera feed fills the container but sits behind everything */
#bg-camera {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    /* Optional: Slight dimming to make game elements pop */
    filter: brightness(0.6);
    transform: scaleX(-1);
    /* Mirror the camera */
    border-radius: inherit;
}

/* The game canvas */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: block;
}

/* UI Overlay container over everything */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    /* Let clicks pass through except on active screens */
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* Enable clicks on active screen */
}

/* Glassmorphism for menus */
#start-screen,
#game-over-screen,
#champion-screen {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    margin: auto;
    /* Center it properly */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: auto;
    max-height: 85vh;
    /* Limit height */
    overflow-y: auto;
    /* Enable scroll */
    text-align: center;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Premium Scrollbar */
#game-over-screen::-webkit-scrollbar,
#champion-screen::-webkit-scrollbar {
    width: 8px;
}

#game-over-screen::-webkit-scrollbar-track,
#champion-screen::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

#game-over-screen::-webkit-scrollbar-thumb,
#champion-screen::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #FFD700, #FFA000);
    border-radius: 10px;
}

#champion-screen {
    background: rgba(40, 20, 0, 0.85);
    /* Slightly darker for champion */
    border: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
}

h1 {
    font-size: 28px;
    margin-bottom: 15px;
    color: #ffeb3b;
}

h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #f44336;
}

p {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

button {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    border: none;
    padding: 15px 25px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    width: 100%;
}

button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.error-msg {
    color: #ff5252;
    font-size: 14px;
    margin-top: 15px;
    display: none;
}

/* New Image Styles */
.title-image {
    width: 80%;
    max-width: 300px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(255, 235, 59, 0.5));
    animation: floating 3s ease-in-out infinite;
}

.title-image.small {
    width: 60%;
    margin-bottom: 10px;
}

.prize-text {
    color: #ffd700;
    font-weight: bold;
    font-size: 18px;
    margin: 10px 0;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

@keyframes floating {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.logos-container {
    position: absolute;
    bottom: 60px;
    /* Moved to bottom, above the ticker */
    left: 20px;
    display: flex;
    gap: 15px;
    pointer-events: none;
}

.logo-item {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.4));
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px;
}

.start-logos {
    position: static;
    margin-top: 20px;
    justify-content: center;
}

/* HUD */
#hud-screen {
    justify-content: flex-start;
    padding: 20px;
    align-items: flex-start;
}

.score-board {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.timer-board {
    font-size: 18px;
    font-weight: bold;
    color: #ffeb3b;
    /* Gold/Yellow for the timer */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 15px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.voice-meter-container {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 30px;
    height: 150px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.voice-meter-label {
    position: absolute;
    bottom: -22px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
    white-space: nowrap;
}

.voice-meter-bg {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 13px;
    overflow: hidden;
}

#voice-meter-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    /* Default */
    background: linear-gradient(to top, #4CAF50, #FFEB3B, #F44336);
    transition: height 0.05s ease-out;
}

/* Screenshot & Share UI */
#screenshot-actions {
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 15px;
}

#screenshot-btn {
    background: linear-gradient(135deg, #2196F3, #1565C0);
    margin-bottom: 0;
}

.share-actions {
    display: flex;
    gap: 10px;
}

.share-actions button {
    flex: 1;
    font-size: 16px;
    padding: 10px;
}

#save-screenshot-btn {
    background: linear-gradient(135deg, #009688, #00695C);
}

#share-screenshot-btn {
    background: linear-gradient(135deg, #FF9800, #E65100);
}

/* Scrolling Ticker */
#ticker-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    overflow: hidden;
    z-index: 30;
    display: flex;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.ticker-content {
    display: flex;
    white-space: nowrap;
    animation: ticker-scroll 20s linear infinite;
}

.ticker-content span {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding-right: 0;
}

@keyframes ticker-scroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Champion Screen decoration */
.scroll-decoration {
    position: sticky;
    left: 0;
    width: 100%;
    height: 15px;
    background: linear-gradient(to right, #6d4c41, #8d6e63, #6d4c41);
    border-radius: 10px;
    border: 2px solid #FFD700;
    z-index: 5;
}

.scroll-decoration.top {
    top: -30px;
    margin-bottom: 10px;
}

.scroll-decoration.bottom {
    bottom: -30px;
    margin-top: 10px;
}

.champion-trophy {
    font-size: 60px;
    animation: trophy-bounce 1s ease-in-out infinite alternate;
}

@keyframes trophy-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }
}

.champion-title {
    font-size: 28px;
    color: #FFD700 !important;
    margin: 10px 0;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.champion-coin-display {
    margin: 15px auto;
    width: 100px;
    height: 100px;
}

.champion-coin-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid #FFD700;
    object-fit: cover;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.champion-score {
    font-size: 22px;
    font-weight: bold;
    color: #FFE082;
    margin-bottom: 15px;
}

#champion-screenshot-actions {
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 12px;
}

#champion-screenshot-btn {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: #000;
}