/*
 * Tombola Math — quaderno a quadretti (chiaro) e lavagna (scuro).
 * Penna blu per i testi, penna rossa per i numeri estratti, evidenziatore giallo sul tabellone,
 * numeretti di legno come nella tombola vera.
 */
:root {
	--paper: #fbfcfe;
	--grid: #e3ebf6;
	--grid-strong: #cfdcee;
	--ink: #1b2540;
	--muted: #5a6582;
	--blue: #2347c5;
	--on-blue: #ffffff;
	--blue-soft: #e8edfc;
	--red: #d42a2a;
	--marker: #ffe45c;
	--marker-edge: #f2c400;
	--green: #17875c;
	--green-soft: #e3f5ec;
	--card: #ffffff;
	--line: #d3dceb;
	--wood: #e8c592;
	--wood-dark: #c79a5c;
	--wood-ink: #b3201f;
	--shadow: 0 1px 0 rgba(27, 37, 64, 0.06), 0 6px 18px -8px rgba(27, 37, 64, 0.22);

	--font-display: 'Bricolage Grotesque Variable', 'Avenir Next', system-ui, sans-serif;
	--font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;

	--r-sm: 6px;
	--r-md: 12px;
	--r-lg: 20px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		--paper: #1d2a26;
		--grid: #24332e;
		--grid-strong: #2d3e38;
		--ink: #eef2ea;
		--muted: #a8b6ad;
		--blue: #9db8ff;
		--on-blue: #10182c;
		--blue-soft: #283a4c;
		--red: #ff7b6e;
		--marker: #f2d046;
		--marker-edge: #d9b52a;
		--green: #6fd6a6;
		--green-soft: #21403a;
		--card: #24332e;
		--line: #3a4c45;
		--wood: #d9b27a;
		--wood-dark: #a77d45;
		--wood-ink: #a01b1a;
		--shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 8px 22px -10px rgba(0, 0, 0, 0.6);
		color-scheme: dark;
	}
}
:root[data-theme='dark'] {
	--paper: #1d2a26;
	--grid: #24332e;
	--grid-strong: #2d3e38;
	--ink: #eef2ea;
	--muted: #a8b6ad;
	--blue: #9db8ff;
	--on-blue: #10182c;
	--blue-soft: #283a4c;
	--red: #ff7b6e;
	--marker: #f2d046;
	--marker-edge: #d9b52a;
	--green: #6fd6a6;
	--green-soft: #21403a;
	--card: #24332e;
	--line: #3a4c45;
	--wood: #d9b27a;
	--wood-dark: #a77d45;
	--wood-ink: #a01b1a;
	--shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 8px 22px -10px rgba(0, 0, 0, 0.6);
	color-scheme: dark;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100dvh;
	background-color: var(--paper);
	background-image:
		linear-gradient(var(--grid) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid) 1px, transparent 1px);
	background-size: 24px 24px;
	color: var(--ink);
	font-family: var(--font-body);
	font-size: 1.0625rem;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
	font-family: var(--font-display);
	line-height: 1.1;
	letter-spacing: -0.02em;
	margin: 0;
	text-wrap: balance;
}

p {
	margin: 0;
	text-wrap: pretty;
}

a {
	color: var(--blue);
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

:focus-visible {
	outline: 3px solid var(--blue);
	outline-offset: 2px;
}

.num {
	font-family: var(--font-display);
	font-variant-numeric: tabular-nums;
}

/* Bottoni */
.btn {
	--bg: var(--card);
	--fg: var(--ink);
	--bd: var(--line);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	padding: 0.65em 1.15em;
	border: 1.5px solid var(--bd);
	border-radius: var(--r-md);
	background: var(--bg);
	color: var(--fg);
	font-weight: 700;
	line-height: 1.1;
	text-decoration: none;
	cursor: pointer;
	transition:
		transform 0.08s ease,
		background-color 0.15s ease;
	white-space: nowrap;
}
.btn:hover {
	background: color-mix(in srgb, var(--bg) 88%, var(--ink));
}
.btn:active {
	transform: translateY(1px);
}
.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.btn.primary {
	--bg: var(--blue);
	--fg: var(--on-blue);
	--bd: var(--blue);
}
.btn.red {
	--bg: var(--red);
	--fg: #fff;
	--bd: var(--red);
}
.btn.ghost {
	--bg: transparent;
	--bd: transparent;
}
.btn.small {
	padding: 0.4em 0.75em;
	font-size: 0.9rem;
	border-radius: var(--r-sm);
}

/* Campi */
.field {
	display: grid;
	gap: 0.3rem;
}
.field > span {
	font-weight: 700;
	font-size: 0.92rem;
}
.input {
	width: 100%;
	padding: 0.6em 0.75em;
	border: 1.5px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--card);
}
.input:focus {
	outline: none;
	border-color: var(--blue);
	box-shadow: 0 0 0 3px var(--blue-soft);
}
textarea.input {
	resize: vertical;
	min-height: 5.5em;
	line-height: 1.45;
}

.sheet {
	background: var(--card);
	border: 1.5px solid var(--line);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow);
}

.muted {
	color: var(--muted);
}

.visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.page {
	max-width: 1120px;
	margin: 0 auto;
	padding: 24px 16px 64px;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

@media print {
	body {
		background: #fff !important;
		color: #000;
	}
	.no-print {
		display: none !important;
	}
}
