/* ============================================================
 * GLThai 翻翻樂 - 樣式
 * 所有樣式都包在 .glthai-memory-game 容器底下，
 * 避免影響 WordPress 主題、文章、側欄、選單。
 * ============================================================ */

.glthai-memory-game {
	box-sizing: border-box;
	max-width: 620px;
	margin: 24px auto;
	padding: 16px;
	background-color: #ffffff;
	border-radius: 16px;
	border: 1px solid rgba(14,90,99,0.18);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
	color: #183f46;
	text-align: center;
	position: relative;
}

.glthai-memory-game * {
	box-sizing: border-box;
}

.glthai-memory-game .glthai-mg-title {
	font-size: 1.3em;
	font-weight: 700;
	color: #0e5a63;
	margin: 0 0 8px;
}

.glthai-memory-game .glthai-mg-desc {
	font-size: 0.95em;
	color: #225a63;
	margin: 0 0 16px;
	line-height: 1.6;
}

/* 配對成功提示文字 */
.glthai-memory-game .glthai-mg-match-toast {
	min-height: 28px;
	margin: 2px auto 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background-color: rgba(14,90,99,0.10);
	color: #0e5a63;
	border: 1px solid rgba(14,90,99,0.28);
	border-radius: 999px;
	padding: 5px 14px;
	font-size: 0.88em;
	font-weight: 600;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
	white-space: nowrap;
}

.glthai-memory-game .glthai-mg-match-toast.is-visible {
	opacity: 1;
}

/* 統計資訊區：手機版壓成一行，減少上方高度 */
.glthai-memory-game .glthai-mg-stats {
	display: flex;
	flex-wrap: nowrap;
	justify-content: center;
	align-items: center;
	gap: 4px;
	font-size: 0.9em;
	margin-bottom: 12px;
	color: #225a63;
	white-space: nowrap;
}

.glthai-memory-game .glthai-mg-stats span {
	padding: 0 1px;
}

.glthai-memory-game .glthai-mg-divider {
	opacity: 0.45;
}

/* 完成後隱藏遊戲進行中的資訊列，避免與完成成績重複 */
.glthai-memory-game.is-complete .glthai-mg-stats {
	display: none !important;
}

/* 按鈕控制區 */
.glthai-memory-game .glthai-mg-controls {
	display: flex;
	justify-content: center;
	gap: 10px;
	margin-bottom: 16px;
}

.glthai-memory-game button.glthai-mg-btn {
	background: linear-gradient(135deg, #071a2d 0%, #0b3140 45%, #15565b 100%);
	color: #ffffff;
	border: none;
	border-radius: 999px;
	padding: 10px 20px;
	font-size: 0.95em;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease, opacity 0.2s ease;
}

.glthai-memory-game button.glthai-mg-btn:hover:not(:disabled) {
	background: linear-gradient(135deg, #061828 0%, #0a4048 50%, #0f4e54 100%);
}

.glthai-memory-game button.glthai-mg-btn:disabled {
	background: #8bb8bd;
	cursor: not-allowed;
	opacity: 0.7;
}

/* 翻牌區 4x4 */
.glthai-memory-game .glthai-mg-board {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
	margin: 0 auto 16px;
	max-width: 480px;
}

.glthai-memory-game .glthai-mg-card {
	position: relative;
	aspect-ratio: 3 / 4;
	border-radius: 10px;
	cursor: pointer;
	perspective: 600px;
}

.glthai-memory-game .glthai-mg-card-inner {
	position: relative;
	width: 100%;
	height: 100%;
	border-radius: 10px;
	transition: transform 0.4s;
	transform-style: preserve-3d;
}

.glthai-memory-game .glthai-mg-card.is-flipped .glthai-mg-card-inner,
.glthai-memory-game .glthai-mg-card.is-matched .glthai-mg-card-inner {
	transform: rotateY(180deg);
}

.glthai-memory-game .glthai-mg-card-face {
	position: absolute;
	inset: 0;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	backface-visibility: hidden;
	overflow: hidden;
}

/* 卡片背面：BBFF 靜謐夜空感，純 CSS 深藍綠漸層，不使用圖片、文字或星點 */
.glthai-memory-game .glthai-mg-card-back {
	position: absolute;
	background:
		radial-gradient(circle at 50% 46%, rgba(123, 215, 211, 0.22) 0%, rgba(123, 215, 211, 0.12) 24%, transparent 54%),
		linear-gradient(135deg, #071a2d 0%, #0b3140 45%, #15565b 100%);
	box-shadow: inset 0 0 18px rgba(255,255,255,0.08), inset 0 0 0 1px rgba(255,255,255,0.08);
	color: transparent;
	font-size: 0;
}

.glthai-memory-game .glthai-mg-card-back::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 38%, rgba(0,0,0,0.12) 100%);
	pointer-events: none;
}

/* 卡片正面 */
.glthai-memory-game .glthai-mg-card-front {
	background-color: rgba(14,90,99,0.06);
	transform: rotateY(180deg);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(14,90,99,0.28);
	padding: 4px;
}

.glthai-memory-game .glthai-mg-card-front img {
	width: 100%;
	height: 75%;
	object-fit: cover;
	border-radius: 6px 6px 0 0;
}

.glthai-memory-game .glthai-mg-card-front .glthai-mg-nickname {
	font-size: 0.75em;
	font-weight: 600;
	color: #0e5a63;
	margin-top: 2px;
	text-align: center;
	line-height: 1.2;
	width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 配對成功時：保留原本格子位置，只讓卡片淡出留白，避免破壞記憶位置 */
.glthai-memory-game .glthai-mg-card.is-matched {
	cursor: default;
	pointer-events: none;
}

.glthai-memory-game .glthai-mg-card.is-cleared {
	opacity: 0;
	transform: scale(0.92);
	transition: opacity 0.35s ease, transform 0.35s ease;
}

.glthai-memory-game .glthai-mg-card.is-matched .glthai-mg-card-front {
	border-color: #0e5a63;
}

.glthai-memory-game .glthai-mg-board.is-complete .glthai-mg-card {
	opacity: 1;
	transform: none;
}

/* 本裝置最佳紀錄 */
.glthai-memory-game .glthai-mg-best {
	font-size: 0.92em;
	color: #225a63;
	font-weight: 500;
	margin: 10px 0 12px;
	line-height: 1.45;
	white-space: nowrap;
}

.glthai-memory-game .glthai-mg-best-title {
	font-weight: 600;
	margin-right: 6px;
}

.glthai-memory-game .glthai-mg-best-value {
	color: #225a63;
}

/* 完成畫面 */
.glthai-memory-game .glthai-mg-result {
	margin: 10px auto 14px;
	padding: 16px;
	background-color: rgba(14,90,99,0.06);
	border-radius: 12px;
	border: 1px solid rgba(14,90,99,0.28);
}

.glthai-memory-game .glthai-mg-result-title {
	font-size: 1.15em;
	font-weight: 700;
	color: #0e5a63;
	margin: 0 0 8px;
}

.glthai-memory-game .glthai-mg-result p {
	margin: 4px 0;
	color: #183f46;
}

.glthai-memory-game .glthai-mg-complete-wall {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 6px;
	max-width: 360px;
	margin: 0 auto 14px;
}

.glthai-memory-game .glthai-mg-complete-item {
	background-color: #ffffff;
	border: 1px solid rgba(14,90,99,0.28);
	border-radius: 8px;
	overflow: hidden;
}

.glthai-memory-game .glthai-mg-complete-item img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	display: block;
}

.glthai-memory-game .glthai-mg-complete-name {
	font-size: 0.7em;
	font-weight: 600;
	color: #0e5a63;
	line-height: 1.3;
	padding: 2px 3px 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.glthai-memory-game .glthai-mg-complete-actions {
	margin-top: 8px;
}

.glthai-memory-game .glthai-mg-result-actions {
	display: flex;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 12px;
}

.glthai-memory-game .glthai-mg-share-status {
	margin-top: 8px;
	font-size: 0.9em;
	font-weight: 600;
	color: #0e5a63;
}

/* 錯誤訊息 */
.glthai-memory-game .glthai-mg-error {
	color: #0e5a63;
	font-weight: 600;
	padding: 12px;
}

/* 手機版調整 */
@media (max-width: 480px) {
	.glthai-memory-game {
		padding: 12px;
		border-radius: 12px;
	}

	.glthai-memory-game .glthai-mg-board {
		gap: 6px;
	}

	.glthai-memory-game .glthai-mg-complete-wall {
		gap: 5px;
	}

	.glthai-memory-game .glthai-mg-card-front .glthai-mg-nickname {
		font-size: 0.7em;
	}

	.glthai-memory-game .glthai-mg-stats {
		font-size: 0.82em;
		gap: 2px;
	}

	.glthai-memory-game button.glthai-mg-btn {
		padding: 8px 14px;
		font-size: 0.9em;
	}
}

/* 全站 Top 10 排行榜 */
.glthai-memory-game .glthai-mg-result-rank {
	font-weight: 700;
	color: #0e5a63;
}

.glthai-memory-game .glthai-mg-top3 {
	margin: 26px auto 16px;
	padding: 10px 12px;
	max-width: 360px;
	background-color: rgba(14,90,99,0.05);
	border: 1px solid rgba(14,90,99,0.18);
	border-radius: 12px;
	color: #225a63;
	font-size: 0.78em;
}

.glthai-memory-game .glthai-mg-top3-title {
	font-weight: 700;
	color: #0e5a63;
	margin-bottom: 5px;
}

.glthai-memory-game .glthai-mg-top3-list {
	margin: 0;
	padding-left: 1.6em;
	text-align: left;
}

.glthai-memory-game .glthai-mg-top3-list li {
	margin: 2px 0;
}


@media (min-width: 768px) {
	.glthai-memory-game .glthai-mg-best {
		font-size: 0.95em;
	}
}
