@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #6C55BC 0%, #9575CD 50%, #BA68C8 100%);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

html, body {
    width: 100%;
    height: 100%;
    min-height: 100svh;
    min-width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 60%, rgba(255,255,255,0.05) 0%, transparent 50%);
    animation: floatingBubbles 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes floatingBubbles {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

.game-container {
    width: min(400px, 95vw);
    height: min(700px, 95vh);
    position: relative;
    background: linear-gradient(180deg, 
        rgba(255,248,220,0.95) 0%, 
        rgba(255,240,245,0.9) 30%,
        rgba(240,248,255,0.95) 70%,
        rgba(255,248,220,0.95) 100%);
    border-radius: 25px;
    box-shadow: 
        0 25px 50px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.2),
        inset 0 1px 0 rgba(255,255,255,0.4);
    overflow: hidden;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255,255,255,0.2);
}

.game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.top-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}

.score-panel, .tokens-panel {
    background: rgba(108, 85, 188, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(108, 85, 188, 0.3);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 8px 32px rgba(108, 85, 188, 0.3); }
    50% { box-shadow: 0 8px 32px rgba(108, 85, 188, 0.6), 0 0 20px rgba(108, 85, 188, 0.4); }
}

.tea-emoji {
    font-size: 18px;
    animation: steamFloat 2s ease-in-out infinite;
}

@keyframes steamFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

.high-score {
    position: absolute;
    top: 80px;
    right: 20px;
    color: #FFD700;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    background: rgba(0,0,0,0.2);
    padding: 6px 12px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

.start-screen, .game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    pointer-events: auto;
    border-radius: 25px;
}

.game-end {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    pointer-events: auto;
    display: none;
    backdrop-filter: blur(10px);

    width: 400px;      
    min-width: 50%;     
    max-width: 80%;  
}

#gameOver .btn {
    margin: 10px 0 0 0;
    width: 75%;
    max-width: 250px;
}

.brand-title {
    font-family: 'Fredoka', cursive;
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: 700;
    background: linear-gradient(45deg, #6C55BC, #9C27B0, #E91E63);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    animation: brandPulse 3s ease-in-out infinite;
    text-shadow: 0 0 30px rgba(108, 85, 188, 0.3);
}

@keyframes brandPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.subtitle {
    font-family: 'Fredoka', cursive;
    font-size: 1.2rem;
    color: #6C55BC;
    margin-bottom: 30px;
    font-weight: 500;
    opacity: 0.8;
}

.game-title {
    font-family: 'Fredoka', cursive;
    font-size: clamp(2rem, 6vw, 2.5rem);
    color: #6C55BC;
    margin-bottom: 20px;
    font-weight: 600;
}

.description {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.6;
    max-width: 300px;
}

.btn {
    background: linear-gradient(45deg, #6C55BC, #9C27B0);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 8px 25px rgba(108, 85, 188, 0.4);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(108, 85, 188, 0.6);
}

.btn:active {
    transform: translateY(0px) scale(0.98);
}

.controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #666;
    font-size: 12px;
    text-align: center;
    opacity: 0.7;
}

.mobile-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 40px;
    pointer-events: auto;
}

.mobile-btn {
    width: 60px;
    height: 60px;
    background: rgba(108, 85, 188, 0.8);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 25px rgba(108, 85, 188, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.mobile-btn:active {
    transform: scale(0.9);
    background: rgba(108, 85, 188, 1);
}

.stats {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    font-size: 14px;
    color: #666;
}

.new-record {
    color: #FFD700;
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0;
    display: none;
    animation: recordBounce 2s ease-in-out infinite;
}

@keyframes recordBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.floating-tea {
    position: absolute;
    font-size: 3rem;
    animation: floatTea 4s ease-in-out infinite;
    opacity: 0.6;
    pointer-events: none;
}

@keyframes floatTea {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(5deg); }
    50% { transform: translateY(-10px) rotate(0deg); }
    75% { transform: translateY(-20px) rotate(-5deg); }
}

/* Mobile responsive */
@media (max-width: 650px) {
    html, body {
        width: 100%;
        min-width: 100vw;
        min-height: 100svh;
        /* Забезпечуємо, що не буде прокрутки */
        overflow: hidden;
    }
    .game-container {
        width: 100%;
        height: 100%;
        min-width: 100vw;
        min-height: 100svh;
        max-width: 100vw;
        max-height: 100svh;
        border-radius: 0 !important;
        border-width: 0 !important;
    }
    /* Якщо є внутрішні елементи з absolute, переконайся, що вони не мають right/bottom > 0 */
    .high-score {
        right: 4vw;
    }
    .top-hud {
        left: 2vw;
        right: 2vw;
    }
}

@media (max-width: 480px) {
    .mobile-controls {
        display: flex;
    }
    .controls {
        display: none;
    }
    .top-hud {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        top: 10px;
        left: 8px;
        right: 8px;
    }
    .score-panel, .tokens-panel {
        text-align: center;
        font-size: 13px;
        padding: 8px 8px;
        border-radius: 16px;
        gap: 6px;
    }
    .high-score {
        top: 60px;
        right: 10px;
        font-size: 10px;
        border-radius: 10px;
    }
    .brand-title, .game-title {
        font-size: clamp(1.2rem, 9vw, 1.7rem);
    }
    .subtitle {
        font-size: 1rem;
        margin-bottom: 18px;
    }
    .description {
        font-size: 13px;
        max-width: 95vw;
        margin-bottom: 18px;
    }
    .game-end {
        width: 98vw;
        padding: 8px 2px;
        min-width: unset;
        border-radius: 10px;
    }
    .btn {
        font-size: 14px;
        padding: 12px 18px;
        border-radius: 22px;
    }
    .stats {
        font-size: 12px;
        margin: 14px 0;
    }
    .floating-tea {
        font-size: 2.1rem;
    }
    .start-screen, .game-over {
        border-radius: 10px;
    }
    .logo-container {
        margin-bottom: 8px;
    }
    .teafi-logo {
        max-width: 140px;
        max-height: 60px;
        margin-bottom: 5px;
    }
}

.particle {
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        box-shadow: 0 8px 25px rgba(108, 85, 188, 0.4);
    }
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
}

.teafi-logo {
    max-width: 240px;
    max-height: 120px;
    margin-bottom: 10px;
    filter: drop-shadow(0 3px 15px rgba(108, 85, 188, 0.2));
}