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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', "Noto Sans SC", sans-serif;
    background: #f9fafb;
    margin: 0;
    text-align: center;
    color: #333;
    line-height: 1.6;
}

main {
    animation: fadeIn 0.5s ease-out;
}

header {
    background: linear-gradient(120deg, #5e72e4, #8660fe);
    color: white;
    padding: 2em 1em;
    border-radius: 0 0 25px 25px;
    box-shadow: 0 4px 20px rgba(94, 114, 228, 0.25);
}

header h1 {
    margin: 0;
    font-weight: 700;
}

header p {
    margin: 0.5em 0 0;
    font-size: 1.1em;
    opacity: 0.9;
}

nav#nav-categorias {
    margin: 1.5em 0 0.5em;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

#nav-modos {
    margin: 0.5em 0 2em;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.tab-button {
    background: #fff;
    color: #555;
    border: 1px solid #ddd;
    padding: 10px 22px;
    border-radius: 50px;
    margin: 0.3em;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background: #f4f4f4;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tab-button.active {
    background: #e53935;
    color: white;
    border-color: #e53935;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3);
    transform: translateY(-2px) scale(1.05);
}

.mode-button {
    background: transparent;
    color: #5e72e4;
    border: 2px solid #5e72e4;
    padding: 8px 18px;
    border-radius: 50px;
    margin: 0.2em;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.mode-button:hover {
    background: #5e72e4;
    color: white;
    transform: translateY(-2px);
}

.mode-button.active {
    background: #2ecc71;
    color: white;
    border-color: #2ecc71;
    box-shadow: 0 2px 10px rgba(46, 204, 113, 0.3);
}

.mode-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    background: transparent;
    color: #999;
    border-color: #ccc;
}

.main-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
    padding: 0 1em;
}

.flashcard-container {
    width: 230px;
    height: 260px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-container.categoria-titulo {
    margin-bottom: 0.5em;
    cursor: default;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05),
        0 5px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.flashcard-container:hover .flashcard {
    transform: translateY(-5px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05),
        0 8px 25px rgba(0, 0, 0, 0.12);
}

.flashcard-container.categoria-titulo:hover .flashcard {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05),
        0 5px 15px rgba(0, 0, 0, 0.08);
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

.flashcard.is-flipped:hover {
    transform: rotateY(180deg) translateY(-5px);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
}

.flashcard-back {
    transform: rotateY(180deg);
}

.flashcard h3 {
    margin: 0.5em 0 0.1em;
    font-size: 2em;
    color: #333;
    font-family: "Noto Sans SC", sans-serif;
}

.flashcard-front p {
    margin: 0.2em 0;
    font-size: 1.1em;
    color: #5e72e4;
    font-weight: 600;
}

.flashcard-front button {
    margin-top: 15px;
    padding: 8px 18px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flashcard-front button:hover {
    background: #27ae60;
    transform: scale(1.05);
}

.flashcard-back img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 0.5em;
}

.flashcard-back p.significado {
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
}

.categoria-titulo .flashcard {
    background-color: #fffbe6;
    border: 1px solid #ffe58f;
}

.quiz-container {
    width: 90%;
    max-width: 600px;
    margin: 20px auto;
    padding: 30px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05),
        0 5px 15px rgba(0, 0, 0, 0.08);
    border-top: 5px solid #5e72e4;
    text-align: left;
    animation: fadeIn 0.5s ease-out;
}

.quiz-score {
    font-size: 1.1em;
    font-weight: 600;
    color: #777;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 25px;
}

.quiz-pergunta {
    font-size: 1.6em;
    color: #333;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 400;
}

.quiz-pergunta span {
    font-weight: 700;
    color: #5e72e4;
}

.quiz-audio-button {
    font-size: 3.5em;
    cursor: pointer;
    background: none;
    border: none;
    display: block;
    margin: 10px auto 20px;
    color: #5e72e4;
    transition: transform 0.2s;
}

.quiz-audio-button:hover {
    transform: scale(1.1);
}

.quiz-opcoes button {
    display: block;
    width: 100%;
    margin: 10px 0;
    font-size: 1.1em;
    text-align: left;
    padding: 15px 20px;
    background: #f9fafb;
    color: #444;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Poppins', "Noto Sans SC", sans-serif;
    font-weight: 600;
    transition: all 0.2s ease;
}

.quiz-opcoes button:hover {
    border-color: #5e72e4;
    background: #f0f2fe;
    color: #5e72e4;
}

.quiz-opcoes button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.quiz-opcoes button.correto {
    background: #eafaf1;
    border-color: #2ecc71;
    color: #27ae60;
}

.quiz-opcoes button.incorreto {
    background: #fbeeee;
    border-color: #e74c3c;
    color: #c0392b;
}

.quiz-feedback {
    font-size: 1.2em;
    font-weight: 600;
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.quiz-feedback.correto {
    color: #27ae60;
    background: #eafaf1;
    border: 1px solid #2ecc71;
}

.quiz-feedback.incorreto {
    color: #c0392b;
    background: #fbeeee;
    border: 1px solid #e74c3c;
}

.memoria-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    width: 90%;
    max-width: 900px;
    margin: 20px auto;
    animation: fadeIn 0.5s ease-out;
}

.memoria-card {
    width: 100%;
    padding-top: 100%;
    position: relative;
    cursor: pointer;
    perspective: 1000px;
}

.memoria-card-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    border-radius: 12px;
}

.memoria-card.is-flipped .memoria-card-inner {
    transform: rotateY(180deg);
}

.memoria-front,
.memoria-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    padding: 5px;
}

.memoria-front {
    background: linear-gradient(135deg, #5e72e4, #8660fe);
    font-size: 2.5em;
    color: white;
}

.memoria-back {
    background: white;
    transform: rotateY(180deg);
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
    font-family: "Noto Sans SC", sans-serif;
}

.memoria-card.is-matched .memoria-card-inner {
    transform: rotateY(180deg) scale(0.95);
    opacity: 0.7;
    border: 4px solid #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.memoria-card.is-matched .memoria-back {
    border-radius: 8px;
}

footer {
    background: #34495e;
    color: white;
    padding: 1.5em;
    font-size: 0.9em;
    margin-top: 30px;
    opacity: 0.8;
}

@media (max-width: 600px) {
    header {
        padding: 1.5em 1em;
        border-radius: 0 0 20px 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    header p {
        font-size: 1em;
    }

    .tab-button,
    .mode-button {
        padding: 8px 15px;
        font-size: 0.9em;
    }

    .flashcard-container {
        width: 150px;
        height: 180px;
    }

    .flashcard h3 {
        font-size: 1.5em;
    }

    .flashcard-front p {
        font-size: 0.9em;
    }

    .flashcard-front button {
        padding: 6px 12px;
        font-size: 0.8em;
    }

    .flashcard-back img {
        width: 60px;
        height: 60px;
    }

    .flashcard-back p.significado {
        font-size: 1.1em;
    }

    .memoria-board {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 10px;
    }

    .memoria-back {
        font-size: 1.1em;
    }

    .quiz-container {
        padding: 20px;
    }

    .quiz-pergunta {
        font-size: 1.3em;
    }

    .quiz-opcoes button {
        padding: 12px 15px;
        font-size: 1em;
    }
}

.dojo-container {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 20px;
    margin: 30px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.flashcard {
    background: white;
    width: 320px;
    min-height: 240px;
    margin: 20px auto;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-bottom: 6px solid #e1e4e8;
    transition: all 0.2s ease;
    padding: 20px;
    position: relative;
}

.flashcard:active {
    transform: translateY(4px);
    border-bottom: 2px solid #e1e4e8;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.hanzi-display {
    font-size: 4.5rem;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 10px;
}

.answer-box {
    margin-top: 15px;
    transition: opacity 0.3s ease;
}

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

.pinyin-display {
    font-size: 1.4rem;
    color: #e74c3c;
    font-weight: 600;
}

.translation-display {
    font-size: 1.1rem;
    color: #7f8c8d;
    margin-top: 5px;
    font-style: italic;
}

.tap-hint {
    position: absolute;
    bottom: 10px;
    font-size: 0.8rem;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Botão */
.btn-action {
    background-color: #2c3e50;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.3);
    transition: background 0.2s;
}

.btn-action:hover {
    background-color: #34495e;
}