/* ======================================================
   MATH-MASTER.CSS
   Enhanced for 50 Levels & Accessibility
====================================================== */

/* --- Setup Grid Fixes --- */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

#level-select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    font-weight: bold;
}

/* --- The Math Arena --- */
.math-arena {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
}

.question-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.math-text {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-shadow: 1px 1px 0px var(--border);
}

.btn-icon {
    background: var(--bg-nav);
    border: 1px solid var(--border);
    font-size: 1.5rem;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.1);
    background: var(--primary);
    color: white;
}

#math-answer {
    width: 100%;
    max-width: 250px;
    font-size: 2.5rem;
    text-align: center;
    padding: 10px;
    border: 3px solid var(--border);
    border-radius: 12px;
    background: var(--bg-page);
    color: var(--text-main);
    font-family: 'Courier New', Courier, monospace;
}

#math-answer:focus {
    border-color: var(--primary);
    outline: none;
}

/* --- Stats Bar --- */
.stats-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px dashed var(--border);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* --- Results Table --- */
.table-container {
    margin-top: 25px;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    font-size: 0.9rem;
}

#results-table th {
    background: var(--bg-nav);
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

#results-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.status-correct { color: #16a34a; font-weight: bold; }
.status-wrong { color: #dc2626; font-weight: bold; }
.status-skipped { color: #64748b; font-style: italic; }

/* --- Dark Mode Adaptation --- */
@media (prefers-color-scheme: dark) {
    #math-answer {
        background: #0f172a;
        border-color: #1e293b;
    }
    .btn-icon {
        background: #1e293b;
    }
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .math-text { font-size: 2.2rem; }
    #math-answer { font-size: 1.8rem; }
}

/* Styling for the Exit link in Arena */
.tool-card .btn-link {
    font-weight: 600;
    text-decoration: none;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}

.tool-card .btn-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}