/* ============================================
   RESETEO BÁSICO
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   BODY / FONDO GENERAL
   ============================================ */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* ============================================
   PANTALLA DE LOGIN
   ============================================ */
.login-screen {
    text-align: center;
    padding: 40px 20px;
}

.login-title {
    font-size: 2.4rem;
    color: #4a5568;
    margin-bottom: 20px;
}

.login-form {
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Panel pequeño para profesor en login */
.teacher-login {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
    text-align: left;
    font-size: 0.95rem;
}

/* ============================================
   INPUTS / BOTONES
   ============================================ */
.input-field {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    width: 100%;
}

.input-field:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

textarea.input-field {
    resize: vertical;
    min-height: 120px;
}

/* Botones generales */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-block;
}

/* Estilos de color de botones */
.btn-primary {
    background: #4299e1;
    color: #ffffff;
}
.btn-primary:hover {
    background: #3182ce;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(66, 153, 225, 0.3);
}

.btn-success {
    background: #48bb78;
    color: #ffffff;
}
.btn-success:hover {
    background: #38a169;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(72, 187, 120, 0.3);
}

.btn-danger {
    background: #f56565;
    color: #ffffff;
}
.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(245, 101, 101, 0.3);
}

.btn-warning {
    background: #ed8936;
    color: #ffffff;
}
.btn-warning:hover {
    background: #dd6b20;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(237, 137, 54, 0.3);
}

/* ============================================
   HEADER / ESTADO CONEXIÓN
   ============================================ */
.header {
    text-align: center;
    margin-bottom: 20px;
}

.game-title {
    font-size: 2rem;
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 10px;
}

.connection-status {
    background: #f7fafc;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: inline-block;
}

.status-online {
    color: #48bb78;
    font-weight: bold;
}

.status-offline {
    color: #f56565;
    font-weight: bold;
}

/* ============================================
   PANEL DEL PROFESOR
   ============================================ */
.teacher-panel {
    background: #fff5f5;
    border: 2px solid #fc8181;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.teacher-panel h3 {
    color: #c53030;
    margin-bottom: 15px;
    text-align: center;
}

.teacher-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 15px;
}

/* Caja de tema */
.theme-box {
    margin-top: 10px;
    background: #fffaf0;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #f6e05e;
}

.theme-box h4 {
    margin-bottom: 10px;
    color: #975a16;
}

/* ============================================
   INDICADOR DE TURNO
   ============================================ */
.current-turn {
    background: linear-gradient(135deg, #4299e1, #667eea);
    color: #ffffff;
    padding: 16px 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    text-align: center;
}

.current-turn-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 4px;
}

.current-turn-player {
    font-size: 1.6rem;
    font-weight: bold;
}

/* Indicador de "Tu turno" */
.your-turn-indicator {
    background: #48bb78;
    color: #ffffff;
    padding: 12px 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

/* ============================================
   SCOREBOARD
   ============================================ */
.scoreboard {
    background: #f7fafc;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    max-height: 260px;
    overflow-y: auto;
}

.scoreboard-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2d3748;
    text-align: center;
    margin-bottom: 12px;
}

.player-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: #ffffff;
    border-radius: 8px;
    border-left: 4px solid #cbd5e0;
    font-size: 0.9rem;
}

.player-score.active {
    border-left-color: #4299e1;
    background: #ebf8ff;
    font-weight: 600;
}

.player-score.you {
    border-left-color: #48bb78;
    background: #f0fff4;
}

/* ============================================
   ESTADÍSTICAS DEL JUEGO
   ============================================ */
.game-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 10px;
    background: #edf2f7;
    border-radius: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-item {
    text-align: center;
    min-width: 90px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2d3748;
}

.stat-label {
    font-size: 0.8rem;
    color: #718096;
}

/* ============================================
   TABLERO DE MEMORIA
   ============================================ */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.memory-card {
    aspect-ratio: 1;
    background: #4299e1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.memory-card:hover:not(.disabled):not(.matched) {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(66, 153, 225, 0.4);
}

.memory-card.flipped {
    background: #ffffff;
    border: 3px solid #4299e1;
}

.memory-card.matched {
    background: #48bb78;
    border: 3px solid #38a169;
    animation: matchPulse 0.6s ease;
}

.memory-card.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.card-back {
    color: #ffffff;
    font-size: 1.8rem;
}

.card-front {
    display: none;
    font-size: 2rem;
}

.memory-card.flipped .card-back {
    display: none;
}

.memory-card.flipped .card-front {
    display: block;
}

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

/* ============================================
   PREGUNTAS / PANELES
   ============================================ */
.question-section {
    background: #f7fafc;
    padding: 18px 15px;
    border-radius: 15px;
    margin-top: 10px;
    border: 2px solid #e2e8f0;
}

.question-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 10px;
    text-align: center;
}

.current-question {
    font-size: 1rem;
    color: #4a5568;
    text-align: center;
    padding: 16px;
    background: #ffffff;
    border-radius: 10px;
    border-left: 4px solid #48bb78;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   PANTALLA FINAL
   ============================================ */
.game-complete {
    text-align: center;
    padding: 25px 20px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: #ffffff;
    border-radius: 15px;
    margin-top: 20px;
}

.celebration {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.winner-announcement {
    font-size: 1.5rem;
    margin-bottom: 15px;
    font-weight: bold;
}

.final-scores {
    background: rgba(255,255,255,0.18);
    padding: 15px;
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.final-score-item {
    padding: 8px 10px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.35);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.final-score-item.winner {
    background: rgba(255,255,255,0.55);
    font-size: 1.05rem;
    font-weight: bold;
}

/* ============================================
   UTILIDADES
   ============================================ */
.hidden {
    display: none !important;
}

/* Scrollbar suave en listas largas */
.scoreboard::-webkit-scrollbar,
.final-scores::-webkit-scrollbar {
    width: 6px;
}
.scoreboard::-webkit-scrollbar-thumb,
.final-scores::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .memory-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 20px;
    }

    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .login-title,
    .game-title {
        font-size: 1.8rem;
    }

    .scoreboard {
        max-height: 220px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .game-container {
        padding: 15px;
        border-radius: 15px;
    }

    .memory-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .login-title,
    .game-title {
        font-size: 1.5rem;
    }

    .teacher-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        text-align: center;
    }
}
