@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700;900&display=swap');

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

:root {
    --candy-pink: #FF6B9D;
    --candy-purple: #A55EEA;
    --candy-blue: #45AAF2;
    --candy-green: #26de81;
    --candy-yellow: #F8B500;
    --candy-orange: #FF9F43;
    --candy-red: #FC5C65;
    --candy-mint: #20BF6B;
    --bg-cream: #FFF9E6;
    --bg-pink: #FFE4EC;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-pop: 0 15px 40px rgba(255, 107, 157, 0.3);
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.candy-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #FFF9E6 0%, #FFE4EC 50%, #E8F5FF 100%);
    z-index: -2;
}

.candy-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(255, 107, 157, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(165, 94, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(69, 170, 242, 0.05) 0%, transparent 70%);
}

.cloud {
    position: absolute;
    background: white;
    border-radius: 50px;
    opacity: 0.8;
    animation: float-cloud 20s ease-in-out infinite;
}

.cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
}

.cloud-1 {
    width: 120px;
    height: 40px;
    top: 8%;
    left: -150px;
    animation-delay: 0s;
}

.cloud-1::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 20px;
}

.cloud-1::after {
    width: 35px;
    height: 35px;
    top: -15px;
    left: 55px;
}

.cloud-2 {
    width: 100px;
    height: 35px;
    top: 15%;
    left: -150px;
    animation-delay: -7s;
    animation-duration: 25s;
}

.cloud-2::before {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 15px;
}

.cloud-2::after {
    width: 30px;
    height: 30px;
    top: -12px;
    left: 45px;
}

.cloud-3 {
    width: 80px;
    height: 30px;
    top: 5%;
    left: -150px;
    animation-delay: -14s;
    animation-duration: 22s;
}

.cloud-3::before {
    width: 35px;
    height: 35px;
    top: -18px;
    left: 10px;
}

.cloud-3::after {
    width: 25px;
    height: 25px;
    top: -10px;
    left: 35px;
}

@keyframes float-cloud {
    0% { transform: translateX(0); }
    50% { transform: translateX(calc(100vw + 300px)); }
    100% { transform: translateX(calc(100vw + 300px)); }
}

.star {
    position: absolute;
    font-size: 20px;
    opacity: 0.6;
    animation: twinkle 3s ease-in-out infinite;
    z-index: -1;
}

.star-1 { top: 10%; left: 10%; animation-delay: 0s; }
.star-2 { top: 20%; left: 85%; animation-delay: 0.5s; font-size: 24px; }
.star-3 { top: 60%; left: 5%; animation-delay: 1s; }
.star-4 { top: 70%; left: 90%; animation-delay: 1.5s; font-size: 16px; }
.star-5 { top: 40%; left: 70%; animation-delay: 2s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

.game-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.candy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow-pop);
    margin-bottom: 20px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 14px;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.game-title {
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, #FF6B9D 0%, #A55EEA 50%, #45AAF2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 2px;
}

.sound-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B9D 0%, #FC5C65 100%);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

.sound-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.5);
}

.candy-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.stat-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: white;
    border-radius: 50px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
    min-width: 120px;
}

.stat-bubble:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-pop);
}

.stat-bubble.error-bubble {
    background: linear-gradient(135deg, #FFF5F5 0%, #FFE4E4 100%);
}

.stat-bubble.timer-bubble {
    background: linear-gradient(135deg, #E8F5FF 0%, #D4ECFF 100%);
}

.bubble-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FF6B9D 0%, #A55EEA 100%);
    border-radius: 50%;
    color: white;
}

.stat-bubble.error-bubble .bubble-icon {
    background: linear-gradient(135deg, #FC5C65 0%, #EB3349 100%);
}

.stat-bubble.timer-bubble .bubble-icon {
    background: linear-gradient(135deg, #45AAF2 0%, #2D98DA 100%);
}

.bubble-content {
    text-align: left;
}

.bubble-value {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.bubble-label {
    font-size: 12px;
    color: #888;
}

.loading-candy {
    text-align: center;
    padding: 60px;
}

.candy-loader {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.candy {
    font-size: 48px;
    animation: bounce-candy 1s ease-in-out infinite;
}

.candy-1 { animation-delay: 0s; }
.candy-2 { animation-delay: 0.2s; }
.candy-3 { animation-delay: 0.4s; }

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

.loading-candy p {
    color: #888;
    font-size: 16px;
}

.candy-board {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    padding: 20px;
}

.candy-card {
    width: 120px;
    height: 90px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.candy-card.eliminated {
    pointer-events: none;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.candy-card.eliminated .card-content {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.candy-card.selected {
    transform: scale(1.1);
    z-index: 10;
}

.candy-card.selected .card-content {
    box-shadow: 
        0 0 0 4px white,
        0 0 0 8px #FFD700,
        0 15px 35px rgba(255, 215, 0, 0.5);
    animation: selected-pulse 0.8s ease-in-out infinite;
}

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

.candy-card.wrong {
    animation: shake-card 0.5s ease-in-out;
}

@keyframes shake-card {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(8px); }
}

.card-content {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.15),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card-content::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, transparent 100%);
    border-radius: 15px 15px 50% 50%;
    pointer-events: none;
}

.card-text {
    font-size: 16px;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    text-align: center;
    word-break: break-word;
    z-index: 1;
}

.candy-card:hover:not(.eliminated):not(.selected) {
    transform: translateY(-8px) scale(1.05);
}

.candy-card:hover:not(.eliminated):not(.selected) .card-content {
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.2),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.candy-card.eliminated {
    animation: explode-card 0.5s ease-out forwards;
}

@keyframes explode-card {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.empty-candy {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 30px;
    box-shadow: var(--shadow-soft);
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

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

.empty-candy p {
    color: #666;
    font-size: 18px;
    margin-bottom: 10px;
}

.btn-candy {
    padding: 14px 32px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    font-family: inherit;
}

.btn-primary-candy {
    background: linear-gradient(135deg, #26de81 0%, #20BF6B 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(38, 222, 129, 0.4);
}

.btn-primary-candy:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(38, 222, 129, 0.5);
}

.btn-secondary-candy {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    margin-left: 12px;
}

.btn-secondary-candy:hover {
    background: #667eea;
    color: white;
}

.modal-candy {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-candy.active {
    display: flex;
}

.mistakes-modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding-bottom: 24px;
}

#mistakes-content {
    padding: 20px 25px;
}

.mistakes-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px 20px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mistakes-modal-title {
    margin: 0;
    color: white;
    font-size: 20px;
    font-weight: 600;
}

.modal-close-candy {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-candy:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.result-content {
    position: relative;
    background: white;
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.result-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(135deg, #FF6B9D 0%, #A55EEA 50%, #45AAF2 100%);
    border-radius: 30px 30px 50% 50% / 30px 30px 0 0;
}

@keyframes pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.result-decoration {
    position: relative;
    font-size: 32px;
    margin-bottom: 10px;
}

.result-decoration.top {
    margin-top: -10px;
}

.result-decoration.bottom {
    margin-top: 20px;
    margin-bottom: -10px;
}

.result-decoration span {
    display: inline-block;
    animation: bounce-deco 0.6s ease-in-out infinite;
}

.result-decoration span:nth-child(2) {
    animation-delay: 0.2s;
}

.result-decoration span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce-deco {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.result-title {
    position: relative;
    font-size: 32px;
    font-weight: 900;
    color: white;
    margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.result-score-wrapper {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: var(--shadow-soft);
}

.result-score {
    font-size: 56px;
    font-weight: 900;
    background: linear-gradient(135deg, #FF6B9D 0%, #A55EEA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: score-pop 0.5s ease-out;
}

@keyframes score-pop {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.result-score-label {
    color: #888;
    font-size: 14px;
    margin-top: 5px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
}

.result-stat-item {
    text-align: center;
}

.result-stat-icon {
    font-size: 28px;
    margin-bottom: 5px;
}

.result-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.result-stat-label {
    font-size: 12px;
    color: #888;
}

.result-message {
    padding: 15px;
    border-radius: 15px;
    margin: 15px 0;
    font-size: 18px;
    font-weight: 600;
}

.result-message.perfect {
    background: linear-gradient(135deg, #FFE4EC 0%, #FFF5F5 100%);
    color: #E91E63;
}

.result-message.great {
    background: linear-gradient(135deg, #E8F5FF 0%, #D4ECFF 100%);
    color: #2196F3;
}

.result-message.good {
    background: linear-gradient(135deg, #FFF9E6 0%, #FFF3D4 100%);
    color: #FF9800;
}

.result-message.try-again {
    background: linear-gradient(135deg, #F5F5F5 0%, #EEEEEE 100%);
    color: #666;
}

.result-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 25px;
}

.flash-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    pointer-events: none;
    opacity: 0;
    z-index: 999;
}

.flash-effect.active {
    animation: flash 0.3s ease-out;
}

@keyframes flash {
    0% { opacity: 0; }
    50% { opacity: 0.8; }
    100% { opacity: 0; }
}

.rainbow-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    z-index: 998;
    background: 
        linear-gradient(45deg, 
            transparent 20%, 
            rgba(255, 0, 0, 0.3) 25%, 
            rgba(255, 165, 0, 0.3) 30%,
            rgba(255, 255, 0, 0.3) 35%,
            rgba(0, 255, 0, 0.3) 40%,
            rgba(0, 0, 255, 0.3) 45%,
            rgba(128, 0, 128, 0.3) 50%,
            transparent 55%);
    background-size: 200% 200%;
    animation: rainbow 0.8s ease-out;
}

.rainbow-effect.active {
    animation: rainbow 0.8s ease-out;
}

@keyframes rainbow {
    0% { opacity: 0; background-position: 0% 50%; }
    50% { opacity: 1; background-position: 100% 50%; }
    100% { opacity: 0; background-position: 100% 50%; }
}

.particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 997;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
}

.particle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

.game-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 32px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.game-toast.toast-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 10px 30px rgba(56, 239, 125, 0.4);
}

.game-toast.toast-error {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    box-shadow: 0 10px 30px rgba(244, 92, 67, 0.4);
}

.toast-icon {
    font-size: 20px;
    animation: bounce 0.5s ease infinite;
}

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

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .candy-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .game-title {
        font-size: 22px;
    }
    
    .candy-stats {
        gap: 10px;
    }
    
    .stat-bubble {
        min-width: 100px;
        padding: 10px 15px;
    }
    
    .bubble-value {
        font-size: 16px;
    }
    
    .candy-card {
        width: 100px;
        height: 75px;
    }
    
    .card-text {
        font-size: 14px;
    }
    
    .result-content {
        padding: 30px 20px;
    }
    
    .result-score {
        font-size: 42px;
    }
    
    .result-stats {
        gap: 20px;
    }
    
    .result-buttons {
        flex-direction: column;
    }
    
    .btn-secondary-candy {
        margin-left: 0;
        margin-top: 10px;
    }

    .mistakes-modal-content {
        padding-bottom: 20px;
    }
    
    .mistakes-modal-header {
        padding: 16px 20px;
    }
    
    #mistakes-content {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .candy-card {
        width: 80px;
        height: 60px;
    }
    
    .card-text {
        font-size: 12px;
    }
    
    .game-wrapper {
        padding: 10px;
    }

    .mistakes-modal-content {
        padding-bottom: 20px;
    }
    
    .mistakes-modal-header {
        padding: 16px 20px;
    }
    
    #mistakes-content {
        padding: 16px 20px;
    }
}
