:root {
    --primary: #ffffff;
    --secondary: #FFE66D;
    --bg-color-1: #FF6B6B;
    --bg-color-2: #C06C84;
    --bg-color-3: #6C5B7B;
    --bg-color-4: #355C7D;
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.3);
}

body {
    margin: 0;
    padding: 0;
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    touch-action: none;
    background: linear-gradient(135deg, var(--bg-color-1), var(--bg-color-2), var(--bg-color-3), var(--bg-color-4));
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease, backdrop-filter 0.8s ease;
    backdrop-filter: blur(20px);
}

#preloader.hidden {
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(0px);
}

.loader-hexagon {
    width: 100px;
    height: 100px;
    position: relative;
    animation: floatLayer 3s ease-in-out infinite;
}

.loader-hexagon::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--glass-bg);
    border: 2px solid var(--primary);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation: rotate 4s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.loading-text {
    margin-top: 40px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary);
    text-transform: uppercase;
    animation: pulseText 2s ease-in-out infinite;
}

.loading-bar {
    width: 250px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-top: 25px;
    overflow: hidden;
    position: relative;
}

.loading-progress {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    width: 0%;
    animation: loadingProgress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

@keyframes floatLayer {

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

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

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

    25% {
        transform: rotate(90deg);
    }

    50% {
        transform: rotate(180deg);
    }

    75% {
        transform: rotate(270deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulseText {

    0%,
    100% {
        opacity: 0.7;
        transform: scale(1);
    }

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

@keyframes loadingProgress {
    0% {
        width: 0%;
        transform: translateX(-100%);
    }

    50% {
        width: 100%;
        transform: translateX(0);
    }

    100% {
        width: 100%;
        transform: translateX(100%);
    }
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.2));
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#score-display {
    position: absolute;
    top: 30px;
    width: 100%;
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: scoreAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scoreAppear {
    from {
        transform: translateY(-50px) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.score-popup {
    position: absolute;
    font-size: 1.8rem;
    font-weight: 900;
    pointer-events: none;
    animation: scoreFloat 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

@keyframes scoreFloat {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translateY(-20px) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translateY(-120px) scale(1);
        opacity: 0;
    }
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: auto;
    z-index: 10;
}

.overlay.active {
    display: flex;
    animation: fadeInOverlay 0.5s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }

    to {
        opacity: 1;
        backdrop-filter: blur(12px);
    }
}

.overlay-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem 4rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes popIn {
    from {
        transform: scale(0.8) translateY(30px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

h1 {
    font-size: 4.5rem;
    font-weight: 900;
    margin: 0 0 10px 0;
    color: var(--primary);
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    letter-spacing: 2px;
}

.overlay p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 30px;
}

h2 {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--primary);
    margin: 0 0 20px 0;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#final-score,
#high-score {
    font-size: 1.5rem;
    margin: 5px 0;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 30px;
    border-radius: 50px;
}

button {
    padding: 16px 45px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    background: var(--primary);
    color: var(--bg-color-4);
    border: none;
    cursor: pointer;
    margin-top: 25px;
    border-radius: 50px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(2px) scale(0.95);
}

.controls-hint {
    margin-top: 25px;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
}

#sound-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    pointer-events: auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--primary);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    margin-top: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

#sound-toggle.muted {
    background: rgba(0, 0, 0, 0.3);
    color: #ccc;
    border-color: rgba(255, 255, 255, 0.1);
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.combo-text {
    position: absolute;
    font-size: 3rem;
    font-weight: 900;
    color: var(--secondary);
    text-shadow: 0 4px 15px transparent;
    pointer-events: none;
    animation: comboAppear 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    letter-spacing: 2px;
}

@keyframes comboAppear {
    0% {
        transform: scale(0) rotate(-15deg);
        opacity: 0;
    }

    40% {
        transform: scale(1.3) rotate(5deg);
        opacity: 1;
        text-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    }

    100% {
        transform: scale(1) translateY(-50px) rotate(0deg);
        opacity: 0;
    }
}

@media (max-width: 600px) {
    #score-display {
        text-align: left;
        left: 20px;
        top: 25px;
        width: auto;
        font-size: 1.8rem;
    }

    #sound-toggle {
        top: 20px;
        right: 20px;
        padding: 10px 16px;
        font-size: 0.8rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2.2rem;
    }

    .overlay-content {
        padding: 2rem;
        width: 80%;
    }

    button {
        padding: 12px 30px;
        font-size: 1rem;
    }
}
