/* Multiplication Table Specific Styles */
:root {
    --times-bg: #f6f8fc;
    --times-panel: #ffffff;
    --times-text: #10213a;
    --times-muted: #58708d;
    --times-line: #d6e0eb;
    --times-accent: #0f766e;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--times-bg);
    color: var(--times-text);
}

.multiplication-container {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.multiplication-panel {
    background: var(--times-panel);
    border: 1px solid var(--times-line);
    border-radius: 8px;
    box-shadow: 0 14px 36px rgba(16, 33, 58, 0.08);
    margin-bottom: 16px;
    padding: 20px;
}

.title-panel {
    text-align: left;
}

.title-panel .back-link {
    color: var(--times-accent);
    font-weight: 800;
    text-decoration: none;
}

.title-panel p {
    margin: 0;
}

.page-title {
    color: var(--times-text);
    font-size: clamp(2rem, 6vw, 4rem);
    line-height: 1;
    letter-spacing: 0;
    margin: 8px 0 10px;
}

.page-description {
    color: var(--times-muted);
    font-size: 1.08rem;
}

/* Controls Container */
.controls-container {
    align-items: end;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(180px, 260px) 1fr;
}

.size-selector {
    display: grid;
    gap: 8px;
}

.size-selector label {
    color: var(--times-text);
    font-weight: 800;
}

.size-selector input[type="number"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 2px solid var(--times-line);
    border-radius: 8px;
    text-align: center;
    background-color: white;
    color: var(--times-text);
}

.size-selector input[type="number"]:focus {
    border-color: var(--times-accent);
    outline: none;
}

.size-info {
    color: var(--times-muted);
    font-size: 0.9em;
}

.table-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Main Table Container */
.table-container-wrapper {
    overflow: hidden;
}

.table-scroll-container {
    overflow-x: auto;
    padding: 10px;
}

/* Table Styles */
.multiplication-table {
    border-collapse: collapse;
    margin: 0 auto;
    min-width: max-content;
}

.multiplication-table td {
    width: 45px;
    height: 45px;
    text-align: center;
    border: 1px solid #e0e0e0;
    padding: 0;
    position: relative;
    transition: all 0.3s ease;
}

.multiplication-table .header {
    background-color: #f0f7ff;
    font-weight: bold;
    color: var(--times-text);
    min-width: 45px;
    position: sticky;
    left: 0;
    z-index: 1;
}

.multiplication-table .header:first-child {
    background-color: #e3f2fd;
    z-index: 2;
}

/* Input Styles */
.multiplication-table input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 16px;
    outline: none;
    background: transparent;
    font-family: monospace;
    color: var(--times-text);
    padding: 0;
}

.multiplication-table input:focus {
    background-color: #fff9c4;
}

/* Cell States - Add to existing cell state styles */
.error-cell {
    background-color: #f8d7da !important;
}

.error-cell input {
    color: #721c24;
    font-weight: bold;
}

.empty-cell {
    background-color: #ffffff !important;
}

/* Cell States */
.correct-cell {
    background-color: #d4edda !important;
    pointer-events: none;
}

.correct-cell input {
    color: #155724;
    font-weight: bold;
}

.current-cell {
    background-color: #fff9c4 !important;
}

/* Animation for wrong answers */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
    20%, 40%, 60%, 80% { transform: translateX(3px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Stats Container */
.stats-container {
    display: block;
}

.score-display h3 {
    color: var(--times-text);
    margin: 0 0 14px;
}

.score-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat {
    background-color: #f8fafc;
    border: 1px solid var(--times-line);
    padding: 14px;
    border-radius: 8px;
    text-align: center;
}

.stat.correct {
    border-left: 4px solid #28a745;
}

.stat.total {
    border-left: 4px solid #007bff;
}

.stat.accuracy {
    border-left: 4px solid #ffc107;
}

.stat.attempts {
    border-left: 4px solid #17a2b8;
}

.stat-label {
    display: block;
    font-size: 0.9em;
    color: var(--times-muted);
    margin-bottom: 5px;
    font-weight: 800;
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--times-text);
}

/* Progress Bar */
.progress-container {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background-color: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 6px;
}

.progress-text {
    text-align: center;
    color: var(--times-text);
    font-size: 0.95em;
    min-height: 24px;
}

/* Instructions */
.instructions-container {
    margin-bottom: 0;
}

.instructions h4 {
    color: var(--times-text);
    margin-bottom: 10px;
}

.instructions ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.instructions li {
    padding: 8px 0;
    color: var(--times-muted);
    border-bottom: 1px solid var(--times-line);
}

.instructions li:last-child {
    border-bottom: none;
}

.instructions li strong {
    color: var(--times-text);
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls-container {
        grid-template-columns: 1fr;
    }

    .multiplication-table td {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .multiplication-table input {
        font-size: 14px;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-controls .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .score-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .multiplication-table td {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    .multiplication-table input {
        font-size: 12px;
    }
    
    .size-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .size-selector input[type="number"] {
        width: 100%;
    }
    
    .score-stats {
        grid-template-columns: 1fr;
    }
}
