/* ===== VARIABLES Y RESET ===== */
:root {
    --primary: #764ba2;
    --secondary: #667eea;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --light: #f5f7fa;
    --dark: #333;
    --shadow: 0 10px 40px rgba(0,0,0,0.2);
    --radius: 15px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: var(--gradient);
    min-height: 100vh;
    color: var(--dark);
}

/* ===== HEADER Y NAVEGACIÓN ===== */
header {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary);
}

.logo span { color: var(--secondary); }

nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

nav a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    transition: color 0.3s;
}

nav a:hover { color: var(--primary); }

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

/* ===== TÍTULO DE PÁGINA ===== */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.page-title {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.page-title p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* ===== SISTEMA DE PESTAÑAS ===== */
.tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.8rem 1.5rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.tab-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    border-color: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s;
}

.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== CONTENEDOR GENÉRICO DE JUEGO ===== */
.game-container {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.game-header h2 {
    color: var(--primary);
    font-size: 1.8rem;
}

.game-controls {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.game-controls select,
.game-controls button,
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: 2px solid var(--primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.game-controls select {
    background: white;
    color: var(--primary);
}

.game-controls button,
.btn {
    background: var(--gradient);
    color: white;
    border: none;
    font-weight: bold;
}

.game-controls button:hover,
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.4);
}

/* ===== ESTADÍSTICAS ===== */
.stats {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat { text-align: center; }

.stat-label {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary);
}

/* ===== ROMPECABEZAS ===== */
.puzzle-game {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}

.puzzle-board {
    display: grid;
    gap: 2px;
    background: #333;
    padding: 4px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.puzzle-piece {
    background-size: cover;
    background-position: center;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 4px;
}

.puzzle-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(118, 75, 162, 0.6);
    z-index: 10;
}

.puzzle-piece.dragging { opacity: 0.5; cursor: grabbing; }
.puzzle-piece.drag-over { background-color: rgba(118, 75, 162, 0.3); border: 2px dashed var(--primary); }
.puzzle-piece.correct { box-shadow: 0 0 10px #4CAF50 inset; }

.reference-image { text-align: center; }

.reference-image img {
    max-width: 250px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    border: 4px solid var(--primary);
}

.reference-image p {
    margin-top: 0.5rem;
    color: #666;
    font-style: italic;
}

/* ===== ADIVINA EL PINTOR (QUIZ) ===== */
.quiz-area {
    text-align: center;
}

.quiz-image {
    max-width: 400px;
    width: 100%;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    margin-bottom: 1.5rem;
    border: 4px solid var(--primary);
}

.quiz-question {
    font-size: 1.3rem;
    color: var(--dark);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    max-width: 700px;
    margin: 0 auto;
}

.quiz-option {
    padding: 1rem;
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
}

.quiz-option:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
}

.quiz-option.correct {
    background: #4CAF50 !important;
    color: white !important;
    border-color: #4CAF50 !important;
    animation: pulse 0.5s;
}

.quiz-option.wrong {
    background: #f44336 !important;
    color: white !important;
    border-color: #f44336 !important;
    animation: shake 0.5s;
}

.quiz-feedback {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.1rem;
    display: none;
}

.quiz-feedback.show { display: block; }
.quiz-feedback.success { background: #d4edda; color: #155724; }
.quiz-feedback.error { background: #f8d7da; color: #721c24; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ===== DIBUJO LIBRE (CANVAS) ===== */
.canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.canvas-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    border-radius: 12px;
    width: 100%;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-group label {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.color-picker {
    width: 50px;
    height: 40px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

.size-slider {
    width: 120px;
    accent-color: var(--primary);
}

#drawCanvas {
    border: 3px solid var(--primary);
    border-radius: 10px;
    background: white;
    cursor: crosshair;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    max-width: 100%;
    touch-action: none;
}

/* ===== COLOREA ONLINE (SVG) ===== */
.coloring-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    border-radius: 12px;
    max-width: 600px;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected {
    border-color: var(--dark);
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(0,0,0,0.4);
}

.coloring-svg {
    max-width: 500px;
    width: 100%;
    border: 3px solid var(--primary);
    border-radius: 10px;
    background: white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.coloring-svg path,
.coloring-svg circle,
.coloring-svg rect,
.coloring-svg polygon {
    cursor: pointer;
    stroke: #333;
    stroke-width: 2;
    transition: fill 0.2s;
}

.coloring-svg path:hover,
.coloring-svg circle:hover,
.coloring-svg rect:hover,
.coloring-svg polygon:hover {
    opacity: 0.8;
}

/* ===== MODAL DE VICTORIA ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    animation: bounceIn 0.5s;
}

.modal-content h2 {
    color: var(--primary);
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: #555;
}

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== FOOTER ===== */
footer {
    background: rgba(0,0,0,0.3);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    nav ul {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    }

    nav ul.active { display: flex; }
    .menu-toggle { display: block; }
    .page-title h1 { font-size: 2rem; }
    .game-header { flex-direction: column; align-items: stretch; }
    .tab-btn { font-size: 0.9rem; padding: 0.6rem 1rem; }
}