@font-face {
	font-family: "Fredoka Match";
	src: url("../fonts/Fredoka-Variable.woff2") format("woff2");
	font-weight: 300 700;
	font-stretch: 75% 125%;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Andika Match";
	src: url("../fonts/Andika-Bold.woff2") format("woff2");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}
/* All rules are confined to the matching game. Shared site styles stay untouched. */
#match-game {
	--match-notice-size: clamp(18px, 2.2vw, 22px);
	--match-notice-leading: 1.35;
	--font-body: "Fredoka Match", sans-serif;
	--match-tile-font: "Fredoka Match", sans-serif;
	font-family: var(--font-body);
	font-weight: 600;
	scroll-margin-top: 56px;
	width: 100%;
	font-size: 16px;
	line-height: 1.3;
}
#match-game .match-controls {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 12px;
	margin-bottom: 12px;
}
#match-game label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
}
#match-game select {
	width: 100%;
	min-width: 0;
	height: 48px;
	font: inherit;
	color: var(--gray);
	border: 1px solid #bbb;
	border-radius: var(--radius);
	background: #fff;
	padding: 8px 10px;
}
#match-game .button {
	font: 600 16px var(--font-body);
	min-height: 48px;
	padding: 10px 18px;
	letter-spacing: 1px;
	margin: 0;
	white-space: nowrap;
	cursor: pointer;
}
#match-game .match-stats {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	align-items: start;
	gap: 8px;
	font-size: 16px;
	line-height: 24px;
}
#match-game #message {
	margin: 8px 0 10px;
	min-height: 2.7em;
	font-size: var(--match-notice-size);
	line-height: var(--match-notice-leading);
}
#match-game #board {
	display: grid;
	grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
	gap: 8px;
}
#match-game .match-tile {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: var(--tile-height, 120px);
	min-width: 0;
	min-height: 44px;
	border: 2px solid #626262;
	border-radius: var(--radius);
	background: #606060;
	color: #fff;
	padding: 6px;
	cursor: pointer;
	touch-action: manipulation;
	box-shadow: var(--shadow);
	font: 600 18px var(--match-tile-font);
	overflow: hidden;
}
#match-game .tile-back {
	display: block;
	width: 96%;
	height: 96%;
	max-width: 132px;
	color: #fff2cc;
	overflow: visible;
	pointer-events: none;
}
#match-game .tile-face {
	display: none;
	width: 100%;
	height: 100%;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 5px;
}
#match-game .tile-picture {
	display: block;
	min-height: 0;
	max-width: 85%;
	width: 72px;
	height: 72px;
	flex: 1;
	color: var(--picture-color, #b9473a);
	overflow: visible;
	pointer-events: none;
}
#match-game .tile-word {
	font: 600 16px/1.15 var(--match-tile-font);
	color: var(--gray-dark);
	text-align: center;
	overflow-wrap: anywhere;
	flex-shrink: 0;
	max-width: 100%;
}
#match-game .words-only .tile-word {
	font-size: var(--advanced-font-size, clamp(16px, 2vw, 23px));
	line-height: 1.2;
	white-space: nowrap;
	overflow-wrap: normal;
	word-break: normal;
}
#match-game .match-tile.revealed,
#match-game .match-tile.matched {
	background: #fff;
	border-color: var(--accent-strong);
}
#match-game .revealed .tile-back,
#match-game .matched .tile-back {
	display: none;
}
#match-game .revealed .tile-face,
#match-game .matched .tile-face {
	display: flex;
}
#match-game .match-tile.matched {
	background: #eaf3e7;
	border-color: #5c8252;
	cursor: default;
}
#match-game .match-tile:focus-visible,
#match-game select:focus-visible {
	outline: 3px solid var(--accent-strong);
	outline-offset: 3px;
}
.match-note {
	font-family: "Fredoka Match", sans-serif;
	font-weight: 600;
	font-size: clamp(18px, 2.2vw, 22px);
	line-height: 1.35;
	margin: 16px 0 0;
}
.match-note:empty {
	display: none;
}
@media (max-width: 460px) {
	#match-game .match-controls {
		gap: 8px;
	}
	#match-game .button {
		padding: 10px 12px;
	}
	#match-game #board {
		gap: 6px;
	}
	#match-game .match-tile {
		padding: 5px;
	}
	#match-game .tile-face {
		gap: 3px;
	}
}

#match-game .moves-stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}
#match-game .match-stats > span:last-child {
	text-align: right;
}
#match-game #give-up {
	min-height: 44px;
	padding: 8px 10px;
	font-size: 16px;
	letter-spacing: 1px;
}
#match-game #give-up:disabled {
	opacity: 0.55;
	cursor: default;
}

/* Colors uses full-color faces with readable, handwriting-style names. */
#match-game .color-tile.revealed,
#match-game .color-tile.matched {
	background: var(--tile-color);
	border-color: #333;
	box-shadow:
		inset 0 0 0 2px #ffffff70,
		var(--shadow);
}
#match-game .color-tile.matched {
	outline: 2px solid #555;
	outline-offset: -5px;
}
#match-game .color-word {
	font-family: "Andika Match", sans-serif;
	font-weight: 700;
	font-feature-settings: "ss01" 0;
	font-synthesis: none;
	font-size: clamp(16px, 2vw, 24px);
	line-height: 1.22;
	color: var(--color-ink);
	overflow-wrap: normal;
	word-break: normal;
	max-width: 100%;
}
@media (max-width: 460px) {
	#match-game .color-word {
		font-size: 16px;
	}
}

/* Larger counters on roomy displays; compact sizes on phones and short windows. */
#match-game .match-stats {
	font-size: var(--match-notice-size);
	line-height: var(--match-notice-leading);
}
#match-game .match-stats strong {
	display: inline-block;
	font-size: clamp(22px, 2.7vw, 28px);
	line-height: 1.2;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}
@media (max-width: 460px), (max-height: 500px) {
	#match-game {
		--match-notice-size: 16px;
		--match-notice-leading: 1.3;
	}
	.match-note {
		font-size: 16px;
		line-height: 1.3;
	}
	#match-game .match-stats strong {
		font-size: 20px;
	}
}

/* Game-only interface typography. Tile words keep their established fonts. */
#match-game button:not(.match-tile),
#match-game select,
#match-game option,
#match-game label,
#match-game .match-stats,
#match-game #message {
	font-family: "Fredoka Match", sans-serif;
}
#match-game .opposite-tile .tile-word {
	white-space: normal;
	overflow-wrap: normal;
	word-break: normal;
}
