/* Reset i estils base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    font-size: 1.2rem;
    color: #666;
}

/* Secció d'entrada */
.input-section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
    display: flex;
    gap: 20px;
    align-items: end;
    flex-wrap: wrap;
    justify-content: center;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.input-group input {
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1.1rem;
    width: 150px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Botons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-help {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.btn-help:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    color: #333;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(168, 237, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
    margin-left: 10px;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

/* Contenidor de la graella */
.grid-container {
    display: none; /* Ocult inicialment */
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
}

.grid-container.visible {
    display: flex; /* Mostrar quan té la classe 'visible' */
}

.grid {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-x: auto;
}

/* Taula de multiplicació */
.multiplication-table {
    border-collapse: collapse;
    margin: 0 auto;
    font-size: 1.1rem;
}

.multiplication-table td {
    border: 2px solid #e1e5e9;
    padding: 15px;
    text-align: center;
    min-width: 80px;
    min-height: 60px;
    position: relative;
}

.header-cell {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.multiplication-cell {
    background: #f8f9fa;
    cursor: text;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    font-weight: 600;
}

.multiplication-cell:hover {
    background: #e9ecef;
    transform: scale(1.05);
}

.multiplication-cell:focus {
    outline: 3px solid #667eea;
    background: white;
}

.multiplication-cell.correct {
    background: linear-gradient(135deg, #56ab2f, #a8e6cf);
    color: white;
    animation: correctPulse 0.6s ease;
}

.multiplication-cell.incorrect {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    color: white;
    animation: incorrectShake 0.6s ease;
}

.multiplication-cell.help-filled {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    animation: helpFill 0.8s ease;
}

.multiplication-cell.solution-filled {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

/* Animacions */
@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

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

/* Secció de resultats */
.result-section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    min-width: 300px;
}

.result-calculation h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.result-calculation p {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.verification {
    padding: 15px;
    border-radius: 8px;
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    font-weight: 600;
    text-align: center;
}

/* Instruccions d'ajuda */
.help-instructions {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin: 20px 0;
    border-left: 5px solid #667eea;
}

.help-instructions h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.help-instructions ol {
    margin-left: 20px;
    margin-bottom: 20px;
}

.help-instructions li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.step-info {
    margin-top: 20px;
}

.step {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.success {
    background: linear-gradient(135deg, #56ab2f, #a8e6cf);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .input-section {
        flex-direction: column;
        align-items: center;
    }
    
    .input-group input {
        width: 200px;
    }
    
    .grid-container {
        flex-direction: column;
        align-items: center;
    }
    
    .multiplication-table td {
        padding: 10px;
        min-width: 60px;
        min-height: 50px;
        font-size: 1rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .multiplication-table td {
        padding: 8px;
        min-width: 50px;
        min-height: 40px;
        font-size: 0.9rem;
    }
    
    .header-cell {
        font-size: 1rem;
    }
}

/* Footer */
.footer {
    background: transparent;
    padding: 20px;
    text-align: center;
    margin-top: 40px;
}

.footer p {
    margin: 0;
    color: #333;
    font-size: 0.9rem;
    font-weight: 500;
}

.footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #764ba2;
    text-decoration: underline;
}