:root {
    --bg-color: #050510;
    --primary: #a200ff;
    --secondary: #00ff9d;
    --accents: #ff0055;
    --glass: rgba(255, 255, 255, 0.05);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    font-family: var(--font-main);
    overflow: hidden;
    color: white;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 600px;
    background: black;
    overflow: hidden;
}

/* DOM Background System */
#bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* Behind canvas */
    pointer-events: none;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
    /* Above background */
}

/* Background Card Styles */
.bg-card {
    position: absolute;
    border-radius: 10px;
    overflow: hidden;
    background: #1a1a2e;
    /* Fallback color */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    background-size: cover;
    background-position: center;
    /* Performance optimizations */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.bg-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    display: block;
    /* GPU acceleration */
    transform: translateZ(0);
}

.bg-card .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    font-size: 14px;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.bg-card .icons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    opacity: 0.8;
}


/* UI Overlay */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    z-index: 20;
}

#score-hud {
    position: absolute;
    top: 10%;
    font-size: 4rem;
    font-weight: 900;
    text-shadow: 0 0 20px var(--primary);
    background: linear-gradient(180deg, #fff, #ccc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    z-index: 10;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

h1 {
    font-size: 3rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

/* Glitch Effect */
.glitch {
    position: relative;
    color: white;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 var(--accents);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 var(--secondary);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(10px, 9999px, 30px, 0);
    }

    20% {
        clip: rect(80px, 9999px, 100px, 0);
    }

    40% {
        clip: rect(30px, 9999px, 50px, 0);
    }

    60% {
        clip: rect(60px, 9999px, 80px, 0);
    }

    80% {
        clip: rect(20px, 9999px, 40px, 0);
    }

    100% {
        clip: rect(50px, 9999px, 70px, 0);
    }
}

.stats-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px 40px;
    border-radius: 20px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.stats-card p {
    font-size: 1.5rem;
    margin: 5px 0;
    font-weight: 700;
}

#restart-btn {
    background: var(--secondary);
    color: black;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 0 20px var(--secondary);
    transition: transform 0.1s, box-shadow 0.1s;
}

#restart-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px var(--secondary);
}

/* CRT Effects */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;
    z-index: 50;
    opacity: 0.6;
}

.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 50%, black 150%);
    pointer-events: none;
    z-index: 51;
}

/* Character Select - Visual Cards */
.ui-label {
    font-size: 1.2rem;
    color: var(--secondary);
    margin-bottom: 15px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px var(--secondary);
}

.skin-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.skin-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    width: 100px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    /* Ensure clickable */
}

.skin-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.5);
}

.skin-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(162, 0, 255, 0.5);
    background: rgba(162, 0, 255, 0.1);
}

.emoji-preview {
    font-size: 40px;
    margin-bottom: 10px;
}

.img-preview {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.3);
    /* Visibility check for transparent pngs */
    border-radius: 5px;
}

.skin-card span {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ccc;
    text-transform: uppercase;
}

.skin-card.active span {
    color: white;
}