/* Mahjong Solitär – Legespiel
   Alle Regeln sind auf .mah gescoped, damit kein Theme-CSS kollidiert.
   Gemeinsames Designsystem über die --sp-*-Variablen wie bei den übrigen Spielen. */

.mah {
	--sp-paper:  #eef1f3;
	--sp-ink:    #14293b;
	--sp-muted:  #5b6f7f;
	--sp-line:   #c2ccd3;
	--sp-win:    #1f7a4d;
	--sp-lose:   #b3382c;
	--sp-radius: 12px;
	--sp-sans:   system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--sp-mono:   ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	--sp-accent: #2f7d5e;   /* Kachelfarbe Mahjong */

	/* Spielfläche */
	--mah-felt:   #2f6f52;   /* Filz, dunkleres Grün als Akzent */
	--mah-face:   #f6f1e4;   /* Elfenbein-Stein */
	--mah-face2:  #e7dec8;   /* untere Kante */
	--mah-edge:   #b8ac8c;   /* Steinrand */
	--mah-red:    #b3382c;
	--mah-green:  #1f7a4d;
	--mah-blue:   #2f6fb5;
	--mah-warm:   #b8702e;

	container-type: inline-size;

	background: var(--sp-paper);
	color: var(--sp-ink);
	font-family: var(--sp-sans);
	border: 1px solid var(--sp-line);
	border-radius: var(--sp-radius);
	max-width: 720px;
	margin: 0 auto;
	box-sizing: border-box;
}

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

.mah__inner { padding: clamp(14px, 3vw, 22px); }

/* ---------- Kopf ---------- */

.mah__head {
	padding-bottom: 12px;
	margin-bottom: 14px;
	border-bottom: 1px solid var(--sp-line);
}

.mah__eyebrow {
	font-family: var(--sp-mono);
	font-size: 11px;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--sp-accent);
	margin: 0 0 4px;
}

.mah__title {
	font-family: var(--sp-sans);
	font-size: clamp(21px, 6cqi, 30px);
	font-weight: 800;
	letter-spacing: 0.01em;
	line-height: 1.05;
	margin: 0;
	color: var(--sp-ink);
}

/* ---------- Statuszeile ---------- */

.mah__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 18px;
	margin-bottom: 12px;
}

.mah__stat {
	font-family: var(--sp-mono);
	font-size: 12px;
	letter-spacing: 0.06em;
	color: var(--sp-muted);
}

/* ---------- Brett ---------- */

.mah__boardWrap {
	position: relative;
	background: var(--mah-felt);
	background-image: linear-gradient( 180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.18) );
	border: 1px solid rgba(0, 0, 0, 0.25);
	border-radius: 10px;
	padding: 10px 6px;
	overflow: hidden;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mah__board {
	position: relative;
	margin: 0 auto;
	transform-origin: top center;
}

/* ---------- Steine ---------- */

.mah__tile {
	position: absolute;
	width: 44px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--mah-edge);
	border-radius: 6px;
	background:
		linear-gradient( 165deg, #fffdf6 0%, var(--mah-face) 42%, var(--mah-face2) 100% );
	box-shadow:
		0 2px 0 #c9bd9b,          /* untere Steinkante (3D-Höhe) */
		0 3px 3px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 1;
	cursor: default;
	color: var(--sp-ink);
	transition: filter 120ms ease, transform 120ms ease, opacity 200ms ease;
	-webkit-tap-highlight-color: transparent;
	overflow: hidden;
}

/* Freie Steine sind anklickbar und heben sich ab. */
.mah__tile[data-free="1"] { cursor: pointer; }
.mah__tile[data-free="1"]:hover { filter: brightness(1.04); }

/* Verdeckte/blockierte Steine treten zurück. */
.mah__tile[data-free="0"] {
	filter: brightness(0.9) saturate(0.92);
}
.mah__tile[data-free="0"]::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(20, 30, 40, 0.16);
	pointer-events: none;
}

.mah__tile.is-sel {
	outline: 3px solid var(--sp-accent);
	outline-offset: -1px;
	filter: brightness(1.08);
	transform: translateY(-1px);
}

.mah__tile.is-hint {
	animation: mah-pulse 0.6s ease-in-out 2;
}

@keyframes mah-pulse {
	0%, 100% { box-shadow: 0 2px 0 #c9bd9b, 0 3px 3px rgba(0,0,0,0.35); }
	50%      { box-shadow: 0 0 0 3px var(--sp-accent), 0 3px 6px rgba(0,0,0,0.4); }
}

.mah__tile.is-gone {
	opacity: 0;
	transform: scale(0.7);
	pointer-events: none;
}

/* Steingesicht */
.mah__main {
	font-weight: 800;
	font-size: 24px;
	font-family: "Hiragino Sans", "Yu Gothic", "Microsoft YaHei", "Noto Sans CJK SC", var(--sp-sans);
}
.mah__sub {
	font-size: 11px;
	font-weight: 700;
	margin-top: 2px;
	opacity: 0.85;
	font-family: "Hiragino Sans", "Yu Gothic", "Microsoft YaHei", "Noto Sans CJK SC", var(--sp-sans);
}

/* Zahl-Suits: große Ziffer + kleines Zeichen */
.mah__tile--wan .mah__main { color: var(--sp-ink); }
.mah__tile--wan .mah__sub  { color: var(--mah-red); }
.mah__tile--sou .mah__main { color: var(--mah-green); }
.mah__tile--sou .mah__sub  { color: var(--mah-green); }
.mah__tile--pin .mah__main { color: var(--mah-blue); }
.mah__tile--pin .mah__sub  { color: var(--mah-blue); }

.mah__tile--wind .mah__main   { color: var(--sp-ink); font-size: 26px; }
.mah__tile--drg-red .mah__main   { color: var(--mah-red);   font-size: 26px; }
.mah__tile--drg-green .mah__main { color: var(--mah-green); font-size: 26px; }
.mah__tile--drg-white .mah__main { color: var(--mah-blue);  font-size: 26px; }

.mah__tile--flower .mah__main { color: var(--mah-warm); font-size: 25px; }
.mah__tile--flower .mah__sub  { color: var(--mah-warm); }
.mah__tile--season .mah__main { color: #2f8f99; font-size: 25px; }
.mah__tile--season .mah__sub  { color: #2f8f99; }

/* ---------- Status / Aktionen / Hinweis ---------- */

.mah__status {
	font-family: var(--sp-mono);
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--sp-muted);
	margin: 12px 0 0;
	min-height: 1.5em;
}
.mah__status--win  { color: var(--sp-win);  font-weight: 700; }
.mah__status--warn { color: var(--sp-lose); font-weight: 700; }

.mah__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 14px;
}

.mah__btn {
	font-family: var(--sp-mono);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	padding: 10px 16px;
	border-radius: 6px;
	background: var(--sp-accent);
	color: #fff;
	border: 1px solid var(--sp-accent);
	cursor: pointer;
}

.mah__btn--ghost {
	background: transparent;
	color: var(--sp-ink);
	border-color: var(--sp-line);
	font-weight: 400;
}

.mah__btn:hover:not([disabled]) { filter: brightness(1.08); }
.mah__btn--ghost:hover:not([disabled]) { background: var(--sp-accent); color: #fff; border-color: var(--sp-accent); }
.mah__btn[disabled] { opacity: 0.38; cursor: not-allowed; }
.mah__btn:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }

.mah__hint {
	font-family: var(--sp-sans);
	font-size: 12px;
	line-height: 1.6;
	color: var(--sp-muted);
	margin: 12px 0 0;
}
.mah__hint kbd {
	font-family: var(--sp-mono);
	font-size: 11px;
	background: rgba(0, 0, 0, 0.06);
	border: 1px solid var(--sp-line);
	border-radius: 3px;
	padding: 1px 5px;
	color: var(--sp-ink);
}

@media (prefers-reduced-motion: reduce) {
	.mah__tile { transition: none; }
	.mah__tile.is-hint { animation: none; }
}
