/**
 * First-party game interfaces integrated into SNM Games Core.
 * Layouts are fluid, touch-safe and usable from 320px to wide desktop screens.
 */

.snmg-word-grid-layout {
	align-items: start;
	display: grid;
	gap: clamp(18px, 3vw, 32px);
	grid-template-columns: minmax(0, 1fr) minmax(250px, .48fr);
	margin: auto;
	max-width: 980px;
}

.snmg-word-grid {
	display: grid;
	gap: 3px;
	margin: auto;
	max-width: 620px;
	width: 100%;
}

.snmg-word-grid__blank,
.snmg-word-grid__cell {
	aspect-ratio: 1;
	min-width: 0;
}

.snmg-word-grid__blank {
	display: block;
}

.snmg-word-grid__cell {
	background: var(--snmg-surface);
	border: 1px solid color-mix(in srgb, var(--game-accent) 22%, var(--snmg-line));
	border-radius: 7px;
	display: block;
	position: relative;
}

.snmg-word-grid__cell:focus-within {
	border-color: var(--game-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--game-accent) 16%, transparent);
	z-index: 2;
}

.snmg-word-grid__cell small {
	color: var(--snmg-muted);
	font-size: clamp(7px, 1vw, 10px);
	font-weight: 850;
	left: 3px;
	line-height: 1;
	pointer-events: none;
	position: absolute;
	top: 3px;
}

.snmg-word-grid__cell input {
	background: transparent;
	border: 0;
	color: var(--snmg-ink);
	font-size: clamp(16px, 3.2vw, 30px);
	font-weight: 900;
	height: 100%;
	min-height: 0;
	outline: 0;
	padding: 4px;
	text-align: center;
	text-transform: uppercase;
	width: 100%;
}

.snmg-word-grid-clues {
	background: var(--snmg-soft);
	border: 1px solid var(--snmg-line);
	border-radius: 18px;
	display: grid;
	gap: 20px;
	padding: 18px;
}

.snmg-word-grid-clues h3 {
	font-size: 18px;
	margin: 0 0 9px;
}

.snmg-word-grid-clues ol {
	display: grid;
	gap: 9px;
	margin: 0;
	padding-left: 25px;
}

.snmg-word-grid-clues li {
	color: var(--snmg-muted);
	font-size: 12px;
	line-height: 1.45;
	padding-left: 3px;
}

.snmg-word-grid-clues li::marker {
	color: var(--snmg-ink);
	font-weight: 900;
}

.snmg-word-grid-clues li.is-complete {
	color: #12835c;
	text-decoration: line-through;
}

.snmg-memory-wrap {
	margin: auto;
	max-width: 690px;
}

.snmg-memory-status {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
	margin-bottom: 15px;
}

.snmg-memory-status span,
.snmg-network-status span {
	background: var(--snmg-soft);
	border: 1px solid var(--snmg-line);
	border-radius: 999px;
	color: var(--snmg-muted);
	font-size: 11px;
	font-weight: 750;
	padding: 8px 11px;
}

.snmg-memory-status strong {
	color: var(--snmg-ink);
}

.snmg-memory {
	display: grid;
	gap: clamp(7px, 1.5vw, 11px);
	margin: 0 auto 18px;
}

.snmg-memory button {
	-webkit-tap-highlight-color: transparent;
	aspect-ratio: 1;
	background: linear-gradient(145deg, color-mix(in srgb, var(--game-accent) 85%, #fff), var(--game-accent));
	border: 0;
	border-radius: 16px;
	box-shadow: 0 7px 18px color-mix(in srgb, var(--game-accent) 22%, transparent);
	color: #fff;
	cursor: pointer;
	font: inherit;
	overflow: hidden;
	padding: 0;
	position: relative;
	touch-action: manipulation;
	transform-style: preserve-3d;
	transition: transform .25s ease, box-shadow .2s ease;
}

.snmg-memory button:hover:not(:disabled) {
	box-shadow: 0 10px 25px color-mix(in srgb, var(--game-accent) 32%, transparent);
	transform: translateY(-2px);
}

.snmg-memory button:focus-visible,
.snmg-network-tile:focus-visible {
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--game-accent) 28%, transparent);
	outline: 2px solid var(--game-accent);
	outline-offset: 2px;
}

.snmg-memory__back,
.snmg-memory__front {
	align-items: center;
	backface-visibility: hidden;
	display: flex;
	height: 100%;
	inset: 0;
	justify-content: center;
	position: absolute;
	transition: opacity .2s ease, transform .25s ease;
	width: 100%;
}

.snmg-memory__back {
	font-size: clamp(25px, 5vw, 46px);
	font-weight: 900;
}

.snmg-memory__front {
	background: var(--snmg-surface);
	border: 2px solid color-mix(in srgb, var(--game-accent) 45%, var(--snmg-line));
	color: var(--snmg-ink);
	flex-direction: column;
	gap: 4px;
	opacity: 0;
	transform: rotateY(180deg);
}

.snmg-memory__front b {
	font-size: clamp(27px, 5vw, 48px);
	line-height: 1;
}

.snmg-memory__front small {
	color: var(--snmg-muted);
	font-size: clamp(8px, 1.5vw, 11px);
	font-weight: 800;
}

.snmg-memory button.is-open .snmg-memory__back {
	opacity: 0;
	transform: rotateY(180deg);
}

.snmg-memory button.is-open .snmg-memory__front {
	opacity: 1;
	transform: rotateY(0);
}

.snmg-memory button.is-matched .snmg-memory__front {
	background: color-mix(in srgb, #17a673 10%, var(--snmg-surface));
	border-color: #17a673;
}

.snmg-network-wrap {
	margin: auto;
	max-width: 720px;
}

.snmg-network {
	background: color-mix(in srgb, var(--game-accent) 8%, var(--snmg-soft));
	border: 1px solid color-mix(in srgb, var(--game-accent) 22%, var(--snmg-line));
	border-radius: 22px;
	display: grid;
	gap: clamp(3px, 1vw, 6px);
	margin: auto;
	padding: clamp(7px, 1.6vw, 12px);
	touch-action: manipulation;
	user-select: none;
}

.snmg-network-tile {
	-webkit-tap-highlight-color: transparent;
	aspect-ratio: 1;
	background: var(--snmg-surface);
	border: 1px solid var(--snmg-line);
	border-radius: 12px;
	cursor: pointer;
	overflow: hidden;
	padding: 0;
	position: relative;
	touch-action: manipulation;
}

.snmg-network-tile:hover {
	border-color: var(--game-accent);
	box-shadow: 0 4px 15px color-mix(in srgb, var(--game-accent) 16%, transparent);
}

.snmg-network-tile b {
	background: var(--game-accent);
	border: 3px solid color-mix(in srgb, var(--game-accent) 18%, var(--snmg-surface));
	border-radius: 50%;
	height: 20%;
	left: 40%;
	position: absolute;
	top: 40%;
	width: 20%;
	z-index: 2;
}

.snmg-network-line {
	background: var(--game-accent);
	display: block;
	position: absolute;
}

.snmg-network-line[hidden] {
	display: none;
}

.snmg-network-line--1 { height: 50%; left: calc(50% - 3px); top: 0; width: 6px; }
.snmg-network-line--2 { height: 6px; left: 50%; top: calc(50% - 3px); width: 50%; }
.snmg-network-line--4 { height: 50%; left: calc(50% - 3px); top: 50%; width: 6px; }
.snmg-network-line--8 { height: 6px; left: 0; top: calc(50% - 3px); width: 50%; }

.snmg-network-status {
	align-items: center;
	color: var(--snmg-muted);
	display: flex;
	flex-wrap: wrap;
	font-size: 11px;
	gap: 12px;
	justify-content: center;
	margin-top: 13px;
}

@media (max-width: 780px) {
	.snmg-word-grid-layout { grid-template-columns: 1fr; }
	.snmg-word-grid-clues { grid-template-columns: 1fr 1fr; }
	.snmg-network { border-radius: 16px; }
	.snmg-network-tile { border-radius: 9px; }
}

@media (max-width: 520px) {
	.snmg-word-grid { gap: 2px; }
	.snmg-word-grid__cell { border-radius: 4px; }
	.snmg-word-grid__cell input { padding: 1px; }
	.snmg-word-grid-clues { grid-template-columns: 1fr; padding: 15px; }
	.snmg-memory button { border-radius: 12px; }
	.snmg-memory__front small { max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.snmg-network-status { align-items: flex-start; flex-direction: column; gap: 6px; }
	.snmg-network-status small { padding-inline: 4px; }
}

@media (max-width: 380px) {
	.snmg-memory { gap: 5px; }
	.snmg-memory button { border-radius: 9px; }
	.snmg-memory__front b { font-size: 25px; }
	.snmg-network { gap: 2px; padding: 5px; }
	.snmg-network-tile { border-radius: 7px; }
	.snmg-network-line--1,
	.snmg-network-line--4 { left: calc(50% - 2px); width: 4px; }
	.snmg-network-line--2,
	.snmg-network-line--8 { height: 4px; top: calc(50% - 2px); }
}

@media (prefers-reduced-motion: reduce) {
	.snmg-memory button,
	.snmg-memory__back,
	.snmg-memory__front { transition: none; }
}
