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

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #1a5f2a 0%, #2d8f4e 50%, #1a5f2a 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    font-size: 2.2em;
    text-align: center;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1em;
    margin-bottom: 20px;
    text-align: center;
}

.game-info {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.15);
    padding: 15px 30px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

.info-item {
    display: flex;
    gap: 8px;
    color: #fff;
    font-size: 1.1em;
}

.info-item .label {
    color: rgba(255, 255, 255, 0.8);
}

.info-item span:last-child {
    font-weight: bold;
    color: #ffd700;
}

.auto-speak-btn {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.auto-speak-btn:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.2));
    transform: scale(1.05);
}

.auto-speak-btn.off {
    opacity: 0.6;
    border-color: rgba(255, 100, 100, 0.5);
}

.level-select-btn {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.level-select-btn:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.2));
    transform: scale(1.05);
}

.level-select-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, #fff, #f8f8f8);
    padding: 40px;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 101;
    display: none;
    max-width: 600px;
    width: 90%;
    border: 3px solid #009246;
}

.level-select-modal h2 {
    color: #009246;
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.8em;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.level-btn {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #f0f0f0, #e0e0e0);
    border: 2px solid #ccc;
    border-radius: 15px;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.level-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #009246, #007a3a);
    color: #fff;
    border-color: #009246;
    transform: scale(1.1);
}

.level-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #ccc;
}

.level-btn.completed {
    background: linear-gradient(145deg, #90EE90, #7CCD7C);
    border-color: #009246;
}

.level-btn.current {
    background: linear-gradient(145deg, #ffd700, #ffb700);
    border-color: #ff9800;
    animation: pulse 2s infinite;
}

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

.close-modal-btn {
    background: linear-gradient(145deg, #ce2b37, #b02030);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
}

.close-modal-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(206, 43, 55, 0.4);
}

.game-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 800px;
    width: 100%;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.card {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #fff, #f0f0f0);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    padding: 10px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #009246, #fff, #ce2b37);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.card:hover::before {
    opacity: 0.1;
}

.speak-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: linear-gradient(145deg, #009246, #007a3a);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.card:hover .speak-btn {
    opacity: 1;
}

.speak-btn:hover {
    transform: scale(1.2);
    background: linear-gradient(145deg, #007a3a, #006630);
}

.speak-btn:active {
    transform: scale(0.95);
}

.card.selected {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    border: 3px solid #ffd700;
}

.card.matched {
    background: linear-gradient(145deg, #90EE90, #7CCD7C);
    cursor: default;
    animation: matchPulse 0.5s ease;
}

.card.matched .word {
    color: #fff;
}

.card.wrong {
    animation: shake 0.5s ease;
    border: 3px solid #ff4444;
}

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

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

.word {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    text-align: center;
    z-index: 1;
    position: relative;
}

.word.italian {
    color: #009246;
    font-size: 1.5em;
}

.word.chinese {
    color: #ce2b37;
    font-size: 1.6em;
}

.pronunciation {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
    text-align: center;
    z-index: 1;
}

.category {
    font-size: 0.7em;
    color: #999;
    margin-top: 5px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    z-index: 1;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    z-index: 100;
}

.victory-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, #fff, #f8f8f8);
    padding: 40px 50px;
    border-radius: 25px;
    text-align: center;
    display: none;
    z-index: 101;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 3px solid #ffd700;
}

.victory-message h2 {
    color: #009246;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.victory-message p {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1em;
}

.restart-btn {
    background: linear-gradient(145deg, #009246, #007a3a);
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-size: 1.1em;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.restart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 146, 70, 0.4);
}

.restart-btn.secondary {
    background: linear-gradient(145deg, #666, #555);
}

.hint-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
    margin-top: 20px;
    max-width: 800px;
    width: 100%;
    text-align: center;
    border: 2px solid #009246;
}

.hint-panel h3 {
    color: #009246;
    margin-bottom: 10px;
}

.hint-panel p {
    color: #333;
    line-height: 1.6;
    font-size: 1.05em;
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.5em;
    }
    
    .game-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 15px;
    }
    
    .word {
        font-size: 1.1em;
    }
    
    .pronunciation {
        font-size: 0.7em;
    }
    
    .game-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .level-btn {
        font-size: 1.2em;
    }
    
    .level-select-modal {
        padding: 25px;
    }
    
    .level-select-modal h2 {
        font-size: 1.4em;
    }
}
}
