/* ==========================================================================
   1. RESET E CONFIGURAÇÕES GLOBAIS
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 15px 25px;
}

/* ==========================================================================
   2. HEADER E PAINEL DE INFORMAÇÕES DO JOGO (Alinhamento Lado a Lado)
   ========================================================================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 3px solid #4A90E2;
}

.game-header h1 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #4A90E2;
    font-size: 1.8rem;
    margin-bottom: 0;
}

.app-logo {
    width: 45px;
    height: 45px;
    object-fit: contain;
}

.game-info {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    flex-wrap: wrap;
}

.info-item {
    background: #f8f9fa;
    padding: 6px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-item .label {
    color: #666;
    font-size: 0.9em;
}

.info-item .value {
    color: #4A90E2;
    font-weight: bold;
    font-size: 1.1em;
}

/* ==========================================================================
   3. SEÇÃO DA PALAVRA E SLOTS DE PROGRESSO
   ========================================================================== */
.word-section {
    text-align: center;
    margin-bottom: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
}

.word-display h2 {
    color: #495057;
    font-size: 1.1em;
    margin-bottom: 4px;
}

.target-word {
    color: #2b6cb0;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 12px;
}

.progress-display {
    margin-top: 10px;
}

.progress-display h3 {
    color: #495057;
    font-size: 1rem;
    margin-bottom: 8px;
}

.progress-letters {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.letter-slot {
    display: inline-block;
    width: 50px;
    height: 65px;
    border: 3px solid #4A90E2;
    border-radius: 10px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    font-weight: bold;
    color: #4A90E2;
    transition: all 0.3s ease;
}

.letter-slot.empty {
    color: transparent;
    background-color: rgba(74, 144, 226, 0.03);
    border-style: dashed;
}

.letter-slot.filled {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border-color: #4CAF50;
    animation: fillAnimation 0.4s ease;
}

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

.attempts-info {
    margin-top: 8px;
    color: #666;
    font-size: 1rem;
}

.attempts-info span {
    font-weight: bold;
    color: #4A90E2;
}

/* ==========================================================================
   4. TECLADO VISUAL CUSTOMIZADO (LIBRAS)
   ========================================================================== */
.keyboard-section {
    margin-bottom: 15px;
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 15px;
}

.keyboard-header h3 {
    margin: 0;
    text-align: center;
    color: #495057;
    font-size: 1.2em;
}

.toggle-letters {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.toggle-letters input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4A90E2;
}

.toggle-letters label {
    cursor: pointer;
    font-size: 0.95em;
    color: #495057;
    user-select: none;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.keyboard-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.key {
    position: relative;
    width: 80px;
    height: 80px;
    background: white;
    border: 3px solid #dee2e6;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.key:hover {
    border-color: #4A90E2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.3);
}

.key:active {
    transform: translateY(0);
}

.key.focused {
    border-color: #4A90E2;
    box-shadow: 0 0 0 4px #2b6cb0;
    background: #f0f7ff;
}

.key.correct {
    animation: correctAnimation 0.6s ease;
}

@keyframes correctAnimation {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-10px); }
    75% { transform: translateY(-5px); }
}

.key.wrong {
    animation: wrongAnimation 0.6s ease;
}

@keyframes wrongAnimation {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.key.wrong::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 3px solid #E74C3C;
    border-radius: 10px;
    animation: wrongBorderFade 0.6s ease;
}

@keyframes wrongBorderFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.key img {
    width: 100%;
    height: 50px;
    object-fit: contain;
    margin-bottom: 2px;
}

.letter-label {
    font-size: 0.75em;
    color: #666;
    font-weight: bold;
}

.hide-letters .letter-label {
    display: none;
}

.zoom-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(74, 144, 226, 0.9);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.key:hover .zoom-btn {
    opacity: 1;
}

.zoom-btn:hover {
    background: rgba(74, 144, 226, 1);
    transform: scale(1.1);
}

/* ==========================================================================
   5. BOTÕES DE AÇÃO E FEEDBACKS
   ========================================================================== */
.actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
}

.btn i {
    margin-right: 8px;
}

.feedback.toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translate(-50%, -20px);
    z-index: 2000;
    min-width: 280px;
    max-width: 90%;
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.feedback.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.feedback.toast.success {
    background-color: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

.feedback.toast.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
}

.redirect-msg {
    margin-top: 25px;
    font-size: 1rem;
    color: #718096;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.redirect-msg i {
    color: #4A90E2;
}

/* ==========================================================================
   6. INTERFACES MODAIS (ESTRUTURA BASE E ANIMAÇÕES)
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    text-align: center;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2em;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #E74C3C;
}

/* ==========================================================================
   7. MODAIS ESPECÍFICOS (ZOOM E CELEBRAÇÃO)
   ========================================================================== */
#zoomImage {
    max-width: 400px;
    max-height: 400px;
    object-fit: contain;
}

.modal-letter {
    font-size: 2em;
    font-weight: bold;
    color: #4A90E2;
    margin-top: 15px;
}

.celebration {
    animation: celebration 0.5s ease;
}

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

.celebration h2 {
    color: #4CAF50;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.celebration p {
    font-size: 1.3em;
    margin: 10px 0;
    color: #495057;
}

.celebration strong {
    color: #4A90E2;
}

/* ==========================================================================
   8. MODAL DE INFORMAÇÕES INSTITUCIONAIS
   ========================================================================== */
.info-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.4);
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(74, 144, 226, 0.6);
}

.info-content {
    max-width: 650px !important;
    padding: 30px !important;
    border-radius: 12px !important;
    text-align: left !important;
}

.info-header {
    border-bottom: 2px solid #edf2f7;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.info-header h2 {
    color: #4A90E2;
    font-size: 1.6rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-header .subtitle {
    color: #718096;
    font-size: 0.9rem;
    margin: 4px 0 0 0;
}

.info-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.info-column {
    display: flex;
    flex-direction: column;
}

.info-group {
    margin-bottom: 15px;
}

.info-group h3 {
    font-size: 0.95rem;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-group p {
    font-size: 0.95rem;
    color: #2d3748;
    margin: 0;
    line-height: 1.4;
}

.info-group .names {
    color: #4A90E2;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
}

.info-group .campus {
    color: #718096;
    font-size: 0.85rem;
    font-weight: bold;
}

.badge {
    display: inline-block;
    background-color: #e2e8f0;
    color: #4a5568;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 6px;
}

.modal-divider {
    border: 0;
    border-top: 1px solid #edf2f7;
    margin: 15px 0;
}

.info-footer h3 {
    font-size: 0.95rem;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-footer p {
    font-size: 0.9rem;
    color: #4a5568;
    text-align: justify;
    margin: 0;
    line-height: 1.5;
}

.linkedin-link {
    color: #4A90E2;
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.linkedin-link:hover {
    color: #2b6cb0;
    text-decoration: underline;
}

/* ==========================================================================
   9. INTERFACE DE GAME OVER E ESTATÍSTICAS (Grid Alinhado em 3 Colunas)
   ========================================================================== */
.game-over {
    max-width: 650px;
    padding: 35px 25px;
}

.game-over h2 {
    color: #4CAF50;
    font-size: 2.3em;
    margin-bottom: 20px;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 25px 0;
}

.stat-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px 10px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat-item i {
    font-size: 2.2em;
    margin-bottom: 10px;
}

.stat-label {
    color: #666;
    font-size: 0.85em;
    font-weight: 600;
    margin: 5px 0;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    margin-top: 2px;
}

/* Cores customizadas por card */
.stat-item:nth-child(1) i,
.stat-item:nth-child(1) .stat-value {
    color: #f39c12;
}

.stat-item:nth-child(2) i,
.stat-item:nth-child(2) .stat-value {
    color: #2ecc71;
}

.stat-item:nth-child(3) i,
.stat-item:nth-child(3) .stat-value {
    color: #3498db;
}

.congratulations-msg {
    font-size: 1.2em;
    color: #495057;
    margin: 20px 0;
    font-style: italic;
    font-weight: 500;
}

/* ==========================================================================
   10. REGRAS DE MEDIA (RESPONSIVIDADE INTELIGENTE)
   ========================================================================== */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .game-header h1 {
        font-size: 1.6em;
        justify-content: center;
    }

    .game-info {
        justify-content: center;
        width: 100%;
        gap: 10px;
    }

    .target-word {
        font-size: 2em;
        letter-spacing: 5px;
    }

    .letter-slot {
        width: 50px;
        height: 70px;
        font-size: 1.5em;
    }

    .key {
        width: 70px;
        height: 70px;
    }

    .key img {
        height: 45px;
    }

    .keyboard-row {
        gap: 5px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1em;
    }

    #zoomImage {
        max-width: 250px;
        max-height: 250px;
    }
    
    .keyboard-header {
        justify-content: center;
        text-align: center;
    }
    
    .keyboard-header h3 {
        width: 100%;
    }
    
    .toggle-letters {
        font-size: 0.9em;
    }

    .info-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3em;
        top: 15px;
        right: 15px;
    }

    .info-content {
        max-width: 95% !important;
    }

    .info-grid-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .final-stats {
        grid-template-columns: 1fr; /* Volta para 1 coluna empilhada em celulares */
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.4em;
    }

    .target-word {
        font-size: 1.5em;
    }

    .key {
        width: 54px;
        height: 54px;
        padding: 2px;
    }

    .key img {
        height: 32px;
    }

    .letter-label {
        font-size: 0.65em;
    }

    .zoom-btn {
        width: 18px;
        height: 18px;
        font-size: 0.65em;
    }
}