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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #FFE5EC 0%, #E8D5FF 50%, #D5E5FF 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

#game-container {
    width: 100%;
    max-width: 520px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

#hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.2);
}

#score-section {
    display: flex;
    gap: 20px;
}

#score-display, #high-score-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#score-label, #high-score-label {
    font-size: 10px;
    font-weight: 700;
    color: #A78BFA;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#score-value {
    font-size: 28px;
    font-weight: 900;
    color: #6D28D9;
    text-shadow: 0 2px 10px rgba(109, 40, 217, 0.3);
    transition: transform 0.2s;
}

#score-value.pulse {
    transform: scale(1.1);
}

#high-score-value {
    font-size: 18px;
    font-weight: 700;
    color: #9575E8;
}

#game-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#moves-display {
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    padding: 8px 14px;
    border-radius: 25px;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

#moves-display.low {
    animation: shake 0.5s infinite;
    background: linear-gradient(135deg, #FF4444, #FF6666);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

#moves-icon {
    font-size: 16px;
}

#moves-value {
    font-size: 20px;
    font-weight: 900;
}

#moves-label {
    font-size: 10px;
    opacity: 0.9;
}

#combo-display {
    background: linear-gradient(135deg, #FFE66D, #FFF09A);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 900;
    font-size: 18px;
    color: #B8860B;
    box-shadow: 0 4px 15px rgba(255, 230, 109, 0.5);
    animation: pulse-glow 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from { transform: scale(1); box-shadow: 0 4px 15px rgba(255, 230, 109, 0.5); }
    to { transform: scale(1.05); box-shadow: 0 4px 25px rgba(255, 230, 109, 0.8); }
}

#combo-display.hidden {
    display: none;
}

#canvas {
    border-radius: 15px;
    background: rgba(255,255,255,0.3);
    box-shadow: 0 8px 32px rgba(167, 139, 250, 0.3);
    cursor: pointer;
}

#controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    align-items: center;
}

.control-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 15px;
    background: rgba(255,255,255,0.6);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.control-btn:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.9);
}

.control-btn:active {
    transform: translateY(0);
}

#difficulty-selector {
    display: flex;
    gap: 5px;
    background: rgba(255,255,255,0.4);
    padding: 5px;
    border-radius: 15px;
}

.diff-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
}

.diff-btn.active {
    background: rgba(255,255,255,0.8);
    opacity: 1;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.diff-btn:hover {
    opacity: 0.8;
}

#message-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 100;
}

.floating-message {
    font-size: 32px;
    font-weight: 900;
    color: white;
    text-shadow: 0 3px 10px rgba(0,0,0,0.3), 0 0 30px rgba(255,255,255,0.5);
    animation: float-up 1.5s ease-out forwards;
    position: absolute;
    white-space: nowrap;
    left: 50%;
    transform: translateX(-50%);
}

.floating-message.awesome {
    font-size: 40px;
    color: #FFE66D;
    text-shadow: 0 3px 10px rgba(0,0,0,0.3), 0 0 40px rgba(255, 230, 109, 0.8);
}

.floating-message.legendary {
    font-size: 48px;
    background: linear-gradient(90deg, #FF6B6B, #FFE66D, #95E1A3, #4ECDC4, #A78BFA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: float-up 2s ease-out forwards, rainbow 1s linear infinite;
}

@keyframes float-up {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.5); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.2); }
    40% { transform: translateX(-50%) translateY(-10px) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.8); }
}

@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: linear-gradient(135deg, #fff 0%, #F8F0FF 100%);
    padding: 30px 40px;
    border-radius: 25px;
    text-align: center;
    max-width: 90%;
    width: 340px;
    box-shadow: 0 20px 60px rgba(167, 139, 250, 0.4);
    animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.overlay-content h2 {
    font-size: 32px;
    font-weight: 900;
    color: #6D28D9;
    margin-bottom: 15px;
}

.pause-message {
    color: #9575E8;
    margin-bottom: 20px;
    font-size: 16px;
}

.overlay-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 15px;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
    background: linear-gradient(135deg, #A78BFA, #7C3AED);
    color: white;
    box-shadow: 0 4px 15px rgba(167, 139, 250, 0.4);
}

.overlay-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.6);
}

.overlay-btn.secondary {
    background: rgba(167, 139, 250, 0.2);
    color: #7C3AED;
    box-shadow: none;
}

#final-score-display {
    margin: 20px 0;
}

#final-score-label {
    display: block;
    font-size: 14px;
    color: #9575E8;
    margin-bottom: 5px;
}

#final-score-value {
    font-size: 56px;
    font-weight: 900;
    color: #6D28D9;
    text-shadow: 0 4px 20px rgba(109, 40, 217, 0.3);
}

#high-score-status {
    font-size: 16px;
    font-weight: 700;
    color: #FFB800;
    margin-bottom: 15px;
}

#stats-summary {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 15px;
    background: rgba(167, 139, 250, 0.1);
    border-radius: 15px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 11px;
    color: #9575E8;
    margin-bottom: 3px;
}

.stat span:last-child {
    font-size: 20px;
    font-weight: 900;
    color: #6D28D9;
}

.diff-change-text {
    font-size: 13px;
    color: #9575E8;
    margin-top: 15px;
}

#confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

#confetti-container.active::before {
    content: '🎉✨🍓💫🎊';
    position: absolute;
    font-size: 30px;
    animation: confetti-fall 2s ease-out forwards;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes confetti-fall {
    to {
        transform: translateX(-50%) translateY(100px) rotate(360deg);
        opacity: 0;
    }
}

footer {
    padding: 15px;
    text-align: center;
    color: #9575E8;
    font-size: 13px;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

footer a {
    color: #7C3AED;
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 400px) {
    #hud {
        flex-direction: column;
        gap: 10px;
    }
    
    #score-section {
        width: 100%;
        justify-content: space-between;
    }
    
    #game-info {
        width: 100%;
        justify-content: center;
    }
    
    .overlay-content {
        padding: 25px;
        width: 95%;
    }
    
    #final-score-value {
        font-size: 44px;
    }
}