/* Multiplication Table Speed & Accuracy Trainer — colourful, mobile-first styles, scoped to .mt-trainer */

.mt-trainer {
	--mt-bg: #fff7ed;
	--mt-card: #ffffff;
	--mt-text: #1e1b4b;
	--mt-muted: #6b7280;
	--mt-border: #ede9fe;
	--mt-grid: #f1effa;
	--mt-accent: #7c3aed;
	--mt-accent-2: #ec4899;
	--mt-accent-ink: #ffffff;
	--mt-accent-soft: #f3e8ff;
	--mt-good: #15803d;
	--mt-good-soft: #dcfce7;
	--mt-bad: #c0262d;
	--mt-bad-soft: #fee2e2;
	--mt-radius: 18px;

	/* Rainbow row colours for the multiplication table */
	--mt-r1: #fee2e2;
	--mt-r1-ink: #b91c1c;
	--mt-r2: #ffedd5;
	--mt-r2-ink: #c2410c;
	--mt-r3: #fef9c3;
	--mt-r3-ink: #a16207;
	--mt-r4: #dcfce7;
	--mt-r4-ink: #15803d;
	--mt-r5: #dbeafe;
	--mt-r5-ink: #1d4ed8;

	box-sizing: border-box;
	max-width: 760px;
	margin: 0 auto;
	padding: 12px;
	background:
		radial-gradient(circle at 0% 0%, #fde68a55 0, transparent 40%),
		radial-gradient(circle at 100% 30%, #c4b5fd55 0, transparent 45%),
		radial-gradient(circle at 0% 100%, #f9a8d455 0, transparent 40%),
		var(--mt-bg);
	color: var(--mt-text);
	border-radius: var(--mt-radius);
	font-family: "Nunito", "Trebuchet MS", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 16px;
	line-height: 1.5;
}

.mt-trainer *,
.mt-trainer *::before,
.mt-trainer *::after {
	box-sizing: inherit;
}

.mt-trainer [hidden] {
	display: none !important;
}

/* Banner */
.mt-banner {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	margin-bottom: 12px;
	border-radius: var(--mt-radius);
	background: linear-gradient(110deg, #7c3aed 0%, #ec4899 50%, #f97316 100%);
	color: #fff;
	box-shadow: 0 6px 18px -8px #7c3aed99;
}

.mt-banner-icon {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: #ffffff33;
	font-size: 1.8rem;
	font-weight: 900;
	line-height: 1;
}

.mt-banner-title {
	font-size: 1.1rem;
	font-weight: 800;
	line-height: 1.25;
}

/* Cards */
.mt-card {
	background: var(--mt-card);
	border: 2px solid var(--mt-border);
	border-radius: var(--mt-radius);
	padding: 16px;
	margin-bottom: 12px;
	box-shadow: 0 4px 14px -10px #4c1d9566;
}

.mt-heading {
	margin: 0 0 12px;
	font-size: 1.15rem;
	font-weight: 800;
	color: var(--mt-accent);
}

/* Table card with selector */
.mt-table-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 12px;
	margin-bottom: 10px;
}

.mt-table-head .mt-heading {
	margin: 0;
}

.mt-select-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mt-label {
	font-weight: 800;
	color: var(--mt-text);
	margin: 0;
}

.mt-select {
	min-width: 84px;
	padding: 8px 12px;
	font-size: 1.15rem;
	font-weight: 800;
	border: 2px solid var(--mt-accent);
	border-radius: 12px;
	background: var(--mt-accent-soft);
	color: var(--mt-accent);
	cursor: pointer;
}

.mt-select:disabled {
	cursor: not-allowed;
	opacity: 0.75;
}

.mt-select:focus,
.mt-answer:focus,
.mt-btn:focus-visible,
.mt-size input:focus-visible + span {
	outline: 3px solid var(--mt-accent-2);
	outline-offset: 2px;
}

/* Multiplication table: 5 rows × 2 columns */
.mt-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 6px;
	margin: -6px 0;
	table-layout: fixed;
	font-variant-numeric: tabular-nums;
}

.mt-table td {
	padding: 8px 10px;
	border: 0;
	border-radius: 10px;
	font-size: 1.05rem;
	white-space: nowrap;
	text-align: center;
}

.mt-table tr:nth-child(1) td { background: var(--mt-r1); color: var(--mt-r1-ink); }
.mt-table tr:nth-child(2) td { background: var(--mt-r2); color: var(--mt-r2-ink); }
.mt-table tr:nth-child(3) td { background: var(--mt-r3); color: var(--mt-r3-ink); }
.mt-table tr:nth-child(4) td { background: var(--mt-r4); color: var(--mt-r4-ink); }
.mt-table tr:nth-child(5) td { background: var(--mt-r5); color: var(--mt-r5-ink); }

.mt-expr {
	font-weight: 600;
}

.mt-res {
	font-weight: 900;
}

/* Compact table while practising so the question stays on screen */
.mt-trainer[data-mode="practice"] .mt-table td {
	padding: 4px 8px;
	font-size: 0.98rem;
}

.mt-trainer[data-mode="practice"] .mt-table-card {
	padding-top: 12px;
	padding-bottom: 12px;
}

/* Session size */
.mt-sizes {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	margin-bottom: 8px;
}

.mt-size {
	cursor: pointer;
}

.mt-size input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.mt-size span {
	display: block;
	text-align: center;
	padding: 12px 8px;
	border: 2px solid transparent;
	border-radius: 14px;
	font-weight: 800;
	transition: transform 0.1s, box-shadow 0.15s;
}

.mt-size:nth-child(1) span { background: #e0f2fe; color: #0369a1; }
.mt-size:nth-child(2) span { background: #dcfce7; color: #15803d; }
.mt-size:nth-child(3) span { background: #fef3c7; color: #b45309; }
.mt-size:nth-child(4) span { background: #fce7f3; color: #be185d; }

.mt-size input:checked + span {
	border-color: currentColor;
	box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px currentColor;
	transform: scale(1.03);
}

.mt-selected-summary {
	margin: 10px 0 12px;
	color: var(--mt-muted);
	font-size: 0.95rem;
}

/* Buttons */
.mt-btn {
	display: inline-block;
	min-height: 48px;
	padding: 12px 20px;
	font-size: 1.05rem;
	font-weight: 800;
	font-family: inherit;
	border-radius: 14px;
	border: 2px solid transparent;
	cursor: pointer;
	line-height: 1.2;
	transition: filter 0.15s, transform 0.05s;
}

.mt-btn:active {
	transform: translateY(1px);
}

.mt-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.mt-btn-primary {
	background: linear-gradient(110deg, #7c3aed, #ec4899);
	color: var(--mt-accent-ink);
	box-shadow: 0 6px 14px -8px #7c3aedaa;
}

.mt-btn-primary:hover:not(:disabled) {
	filter: brightness(1.08);
}

.mt-btn-secondary {
	background: var(--mt-card);
	color: var(--mt-accent);
	border-color: var(--mt-accent);
}

.mt-btn-secondary:hover {
	background: var(--mt-accent-soft);
}

.mt-btn-quit {
	display: block;
	width: 100%;
	margin-top: 10px;
	min-height: 40px;
	padding: 8px 16px;
	font-size: 0.95rem;
	background: transparent;
	color: var(--mt-bad);
	border-color: #fca5a5;
}

.mt-btn-quit:hover {
	background: var(--mt-bad-soft);
}

.mt-start {
	width: 100%;
}

/* Practice */
.mt-question-card {
	background: linear-gradient(180deg, #faf5ff 0%, #ffffff 60%);
}

.mt-progress-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-weight: 800;
	margin-bottom: 6px;
}

.mt-timer {
	font-variant-numeric: tabular-nums;
	color: #fff;
	background: #0ea5e9;
	padding: 2px 10px;
	border-radius: 999px;
	font-weight: 800;
	font-size: 0.95rem;
}

.mt-progress {
	height: 10px;
	background: var(--mt-grid);
	border-radius: 999px;
	overflow: hidden;
	margin-bottom: 16px;
}

.mt-progress-bar {
	height: 100%;
	width: 0;
	background: linear-gradient(90deg, #f97316, #ec4899, #7c3aed);
	border-radius: 999px;
	transition: width 0.3s ease;
}

.mt-question-form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.mt-question {
	font-size: 2rem;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	margin: 0;
	color: var(--mt-text);
}

.mt-answer {
	width: 9ch;
	min-width: 120px;
	padding: 10px 12px;
	font-size: 1.8rem;
	font-weight: 800;
	font-family: inherit;
	text-align: center;
	border: 3px solid #c4b5fd;
	border-radius: 14px;
	background: var(--mt-card);
	color: var(--mt-text);
	font-variant-numeric: tabular-nums;
}

.mt-answer.is-correct {
	border-color: var(--mt-good);
	background: var(--mt-good-soft);
}

.mt-answer.is-incorrect {
	border-color: var(--mt-bad);
	background: var(--mt-bad-soft);
}

.mt-submit {
	flex: 1 1 100%;
}

.mt-feedback {
	min-height: 1.5em;
	margin: 14px 0 0;
	padding: 0;
	font-size: 1.1rem;
	font-weight: 800;
	text-align: center;
	border-radius: 14px;
}

.mt-feedback.is-correct,
.mt-feedback.is-incorrect,
.mt-feedback.is-hint {
	padding: 10px 12px;
}

.mt-feedback.is-correct {
	background: var(--mt-good-soft);
	color: var(--mt-good);
}

.mt-feedback.is-correct::before {
	content: "🎉 ";
}

.mt-feedback.is-incorrect {
	background: var(--mt-bad-soft);
	color: var(--mt-bad);
}

.mt-feedback.is-hint {
	color: #92400e;
	background: #fef3c7;
}

.mt-time-note {
	font-weight: 600;
	opacity: 0.85;
}

.mt-next {
	display: block;
	width: 100%;
	margin-top: 12px;
}

.mt-chart-wrap {
	position: relative;
	height: 240px;
}

/* Report */
.mt-ended-early {
	margin: 0 0 10px;
	padding: 10px 14px;
	background: #fef3c7;
	color: #92400e;
	border-radius: 12px;
	font-weight: 700;
}

.mt-encourage {
	margin: 0 0 14px;
	padding: 12px 14px;
	background: linear-gradient(110deg, #f3e8ff, #fce7f3);
	color: var(--mt-text);
	border-radius: 12px;
	font-weight: 700;
}

.mt-stat-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	margin: 0;
}

.mt-stat-grid .mt-stat:first-child:not(:only-child) {
	grid-column: 1 / -1;
}

.mt-compare .mt-stat:first-child:not(:only-child) {
	grid-column: auto;
}

.mt-stat {
	padding: 10px 12px;
	border-radius: 14px;
	background: #f5f3ff;
	color: #5b21b6;
}

.mt-stats .mt-stat:nth-child(1) { background: linear-gradient(110deg, #7c3aed, #ec4899); color: #fff; }
.mt-stats .mt-stat:nth-child(2) { background: #e0f2fe; color: #0369a1; }
.mt-stats .mt-stat:nth-child(3) { background: #dcfce7; color: #15803d; }
.mt-stats .mt-stat:nth-child(4) { background: #fee2e2; color: #b91c1c; }
.mt-stats .mt-stat:nth-child(5) { background: #fef3c7; color: #b45309; }
.mt-stats .mt-stat:nth-child(6) { background: #ede9fe; color: #6d28d9; }
.mt-stats .mt-stat:nth-child(7) { background: #fce7f3; color: #be185d; }

.mt-compare .mt-stat:nth-child(1) { background: #ffedd5; color: #c2410c; }
.mt-compare .mt-stat:nth-child(2) { background: #dbeafe; color: #1d4ed8; }

.mt-stat dt {
	font-size: 0.8rem;
	font-weight: 700;
	opacity: 0.85;
	margin: 0;
}

.mt-stat dd {
	margin: 2px 0 0;
	font-size: 1.3rem;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
}

.mt-improvement-msg {
	margin: 12px 0 0;
	font-weight: 800;
}

.mt-improvement-msg.is-correct {
	color: var(--mt-good);
}

.mt-improvement-msg.is-incorrect {
	color: var(--mt-bad);
}

.mt-muted {
	color: var(--mt-muted);
	margin: 0;
}

.mt-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Tablet and up */
@media (min-width: 600px) {
	.mt-trainer {
		padding: 20px;
	}

	.mt-card {
		padding: 20px;
	}

	.mt-banner-title {
		font-size: 1.3rem;
	}

	.mt-question {
		font-size: 2.6rem;
	}

	.mt-submit {
		flex: 0 0 auto;
	}

	.mt-sizes {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.mt-stat-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.mt-compare {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.mt-actions {
		flex-direction: row;
	}

	.mt-actions .mt-btn {
		flex: 1;
	}

	.mt-chart-wrap {
		height: 300px;
	}
}

/* ---------- Paid unlock (v1.2) ---------- */

.mt-trainer.is-locked .mt-table,
.mt-trainer.is-locked .mt-setup {
	display: none;
}

.mt-paywall {
	text-align: center;
	background: linear-gradient(160deg, #ffffff 0%, var(--mt-accent-soft) 100%);
	border-color: #ddd6fe;
}

.mt-paywall-badge {
	display: inline-grid;
	place-items: center;
	width: 56px;
	height: 56px;
	margin: 4px auto 6px;
	border-radius: 50%;
	background: linear-gradient(135deg, #fde68a, #f9a8d4);
	font-size: 1.6rem;
}

.mt-paywall-text {
	margin: 0 0 14px;
	font-weight: 600;
}

.mt-pay-form {
	display: grid;
	gap: 6px;
	max-width: 380px;
	margin: 0 auto;
	text-align: left;
}

.mt-pay-form .mt-btn {
	width: 100%;
	margin-top: 8px;
}

.mt-input {
	width: 100%;
	padding: 10px 12px;
	border: 2px solid var(--mt-border);
	border-radius: 12px;
	background: #fff;
	color: var(--mt-text);
	font: inherit;
}

.mt-input:focus {
	outline: 3px solid var(--mt-accent-2);
	outline-offset: 1px;
	border-color: var(--mt-accent);
}

.mt-small {
	font-size: 0.85rem;
	margin: 2px 0 0;
}

.mt-pay-status {
	min-height: 1.5em;
	margin: 12px auto 0;
	max-width: 420px;
	font-weight: 700;
}

.mt-pay-status:empty {
	margin: 0;
}

.mt-pay-status.is-success {
	color: var(--mt-good);
}

.mt-pay-status.is-error {
	color: var(--mt-bad);
}

.mt-paywall-foot {
	margin: 14px 0 0;
	font-size: 0.9rem;
}

.mt-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--mt-accent);
	font: inherit;
	font-weight: 700;
	text-decoration: underline;
	cursor: pointer;
}
