/* Pankmarket unified game modals — scoped; does not affect footer or canvas gameplay */

/* ── Overlay shell ── */
.game-modal-overlay {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	padding: clamp(12px, 3vw, 32px);
	box-sizing: border-box;
	background: rgba(0, 0, 0, 0.38);
	z-index: 100360;
	pointer-events: auto;
	font-family: Arial, Helvetica, sans-serif;
	color: #31505d;
}

.game-modal-overlay *,
.game-modal-overlay *::before,
.game-modal-overlay *::after {
	box-sizing: border-box;
}

#marketFarmWalletPopupForm.game-modal-overlay { z-index: 100020; }
#marketFarmLeaderboardPopupList.game-modal-overlay { z-index: 100021; }
#marketFarmDailyRewardPopup.game-modal-overlay { z-index: 100022; }
#marketFarmReferralsPopup.game-modal-overlay { z-index: 100023; }
#marketFarmGamesPopup.game-modal-overlay { z-index: 100024; }
#marketFarmWalletHistoryPopup.game-modal-overlay { z-index: 100620; }

/* ── Modal panel ── */
.game-modal-overlay .game-modal {
	width: min(92vw, 560px);
	max-height: min(88vh, 760px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: 8px;
	background: #f4f8fb;
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

.game-modal-overlay .game-modal.game-modal--games {
	width: min(92vw, 560px);
}

.game-modal-overlay .game-modal.game-modal--wallet,
.game-modal-overlay .game-modal.game-modal--rank,
.game-modal-overlay .game-modal.game-modal--daily,
.game-modal-overlay .game-modal.game-modal--referrals {
	width: min(92vw, 440px);
}

/* ── Header ── */
.game-modal-overlay .game-modal-header {
	flex: 0 0 auto;
	min-height: 58px;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	padding: 0 52px;
	background: #23bf31;
	border-radius: 8px 8px 0 0;
}

.game-modal-overlay .game-modal-title {
	margin: 0;
	color: #fff;
	font: bold 22px/1.1 Arial, Helvetica, sans-serif;
	text-align: center;
	letter-spacing: 0.3px;
}

.game-modal-overlay .game-modal-close {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 6px;
	background: #0f6f7e;
	color: #fff;
	font: bold 18px/1 Arial, Helvetica, sans-serif;
	cursor: pointer;
	padding: 0;
}

/* ── Body ── */
.game-modal-overlay .game-modal-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: clamp(14px, 3vw, 24px);
	background: #f8fbff;
	border-radius: 0 0 8px 8px;
}

/* Hide legacy mobile-only header (replaced by game-modal-header) */
.game-modal-overlay .mfl-mobile-head {
	display: none !important;
}

/* ── Games ── */
.game-modal-overlay .games-modal-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
	width: 100%;
	max-width: 100%;
}

.game-modal-overlay .games-modal-card {
	min-width: 0;
	width: 100%;
	border: 1px solid #d9e4ea;
	border-radius: 6px;
	background: #fff;
	padding: 6px 7px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: inset 0 -4px 0 rgba(15, 111, 126, 0.08);
}

.game-modal-overlay .games-modal-card-image {
	width: 100%;
	height: 84px;
	max-height: 84px;
	margin-bottom: 4px;
	border-radius: 6px;
	overflow: hidden;
	border: 1px solid #d9e4ea;
	background: #f8fbff;
	flex-shrink: 0;
}

.game-modal-overlay .games-modal-card-image img {
	width: 100%;
	max-width: 100%;
	height: 100%;
	display: block;
	object-fit: contain;
	object-position: center center;
}

.game-modal-overlay .games-modal-card-image.is-cover img {
	object-fit: cover;
}

.game-modal-overlay .games-modal-plays {
	display: flex;
	gap: 2px;
	width: 100%;
	margin: 0 0 4px;
	flex-shrink: 0;
}

.game-modal-overlay .games-modal-play-seg {
	flex: 1;
	min-width: 0;
	height: 7px;
	border-radius: 2px;
	background: #e2eaef;
	border: 1px solid #cdd8df;
}

.game-modal-overlay .games-modal-play-seg.is-used {
	background: linear-gradient(180deg, #ffb347, #ff8c1a);
	border-color: #e67600;
}

.game-modal-overlay .games-modal-card-title {
	width: 100%;
	color: #0f6f7e;
	font: bold 12px Arial, Helvetica, sans-serif;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 2px;
	flex-shrink: 0;
}

.game-modal-overlay .games-modal-card-subtitle {
	width: 100%;
	min-height: 24px;
	max-height: 24px;
	color: #607080;
	font: bold 9px/12px Arial, Helvetica, sans-serif;
	margin-bottom: 4px;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	flex-shrink: 0;
}

.game-modal-overlay .games-modal-play-button {
	width: 100%;
	height: 26px;
	margin-top: auto;
	flex-shrink: 0;
	border: 0;
	border-radius: 6px;
	background: #0f6f7e;
	color: #fff;
	font: bold 10px Arial, Helvetica, sans-serif;
	cursor: pointer;
}

.game-modal-overlay .games-modal-card.is-play-limited .games-modal-play-button {
	background: #8aa0aa;
	cursor: not-allowed;
}

.game-modal-overlay .games-modal-play-button:disabled {
	opacity: 0.55;
	cursor: default;
}

/* ── Wallet ── */
.game-modal-overlay .mfl-wallet-balance-item {
	border: 1px solid #d9e4ea;
	border-radius: 6px;
	background: #fff;
	padding: 6px 8px;
	min-width: 0;
}

.game-modal-overlay .mfl-wallet-balance-label {
	color: #607080;
	font: bold 10px Arial, Helvetica, sans-serif;
	margin-bottom: 2px;
}

.game-modal-overlay .mfl-wallet-balance-value {
	color: #0f6f7e;
	font: bold 14px Arial, Helvetica, sans-serif;
	line-height: 1.2;
	word-break: break-word;
}

.game-modal-overlay .wallet-balance-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	margin-bottom: 10px;
	width: 100%;
}

.game-modal-overlay .wallet-field-input {
	width: 100%;
	height: 32px;
	border: 2px solid #d9e4ea;
	border-radius: 6px;
	background: #fff;
	color: #31505d;
	padding: 0 10px;
	font: bold 13px Arial, Helvetica, sans-serif;
	margin-bottom: 8px;
	outline: none;
}

.game-modal-overlay .wallet-submit-btn {
	width: 100%;
	height: 34px;
	border: 0;
	border-radius: 6px;
	background: #23bf31;
	color: #fff;
	font: bold 13px Arial, Helvetica, sans-serif;
	cursor: pointer;
	margin: 5px 0 8px;
}

.game-modal-overlay .wallet-message {
	min-height: 18px;
	margin-bottom: 8px;
	text-align: center;
	font: bold 12px Arial, Helvetica, sans-serif;
	color: #607080;
}

.game-modal-overlay .wallet-history-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	margin-top: 4px;
	width: 100%;
	max-width: 100%;
}

.game-modal-overlay .wallet-history-card {
	min-width: 0;
	min-height: 96px;
	border: 1px solid #d9e4ea;
	border-radius: 6px;
	background: #fff;
	padding: 6px;
	display: flex;
	flex-direction: column;
	font: bold 10px/1.2 Arial, Helvetica, sans-serif;
	overflow: hidden;
}

.game-modal-overlay .wallet-history-card-title {
	color: #0f6f7e;
	margin-bottom: 4px;
	flex-shrink: 0;
}

.game-modal-overlay .wallet-list-body {
	color: #607080;
	white-space: pre-line;
	min-height: 0;
	flex: 1 1 auto;
	overflow: hidden;
}

.game-modal-overlay .wallet-history-btn {
	height: 22px;
	border: 0;
	border-radius: 5px;
	background: #0f6f7e;
	color: #fff;
	font: bold 10px Arial, Helvetica, sans-serif;
	cursor: pointer;
	margin-top: 5px;
	width: 100%;
	flex-shrink: 0;
}

.game-modal-overlay .wallet-history-rows {
	max-height: min(50vh, 300px);
	overflow-y: auto;
	padding: 0;
	scrollbar-width: thin;
}

/* ── Leaderboard / Rank ── */
.game-modal-overlay .leaderboard-modal-stats {
	margin: 0 auto 10px;
	width: 100%;
	max-width: 224px;
	text-align: center;
}

.game-modal-overlay .leaderboard-modal-rows {
	width: 100%;
	max-width: 100%;
	margin-bottom: 8px;
}

.game-modal-overlay .leaderboard-modal-summary {
	min-height: 17px;
	text-align: center;
	color: #607080;
	font: bold 11px Arial, Helvetica, sans-serif;
	margin-bottom: 7px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.game-modal-overlay .leaderboard-modal-pager {
	display: grid;
	grid-template-columns: 36px 1fr 36px;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
	width: 100%;
}

.game-modal-overlay .leaderboard-modal-pages {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	min-width: 0;
	flex-wrap: wrap;
}

.game-modal-overlay .leaderboard-modal-page-label {
	text-align: center;
	color: #607080;
	font: bold 11px Arial, Helvetica, sans-serif;
	margin-bottom: 4px;
}

.game-modal-overlay .leaderboard-modal-mode-btn,
.game-modal-overlay .leaderboard-modal-arrow-btn {
	border: 0;
	border-radius: 6px;
	background: #0f6f7e;
	color: #fff;
	cursor: pointer;
}

.game-modal-overlay .leaderboard-modal-mode-btn {
	width: 100%;
	height: 34px;
	font: bold 13px Arial, Helvetica, sans-serif;
	margin-top: 8px;
	flex-shrink: 0;
}

.game-modal-overlay .leaderboard-modal-arrow-btn {
	height: 32px;
	font: bold 20px/1 Arial, Helvetica, sans-serif;
}

/* ── Daily reward ── */
.game-modal-overlay.game-modal--daily .game-modal-body {
	text-align: center;
}

.game-modal-overlay .mfd-message {
	min-height: 20px;
	margin-bottom: 12px;
	color: #607080;
	font: bold 13px Arial, Helvetica, sans-serif;
}

.game-modal-overlay .mfd-chests,
.game-modal-overlay .daily-chest-row {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: clamp(8px, 3vw, 14px);
	flex-wrap: wrap;
	width: 100%;
	max-width: 100%;
	margin-bottom: 12px;
	padding: 8px 0;
	overflow: hidden;
}

.game-modal-overlay .mfd-chest {
	width: clamp(72px, 18vw, 110px);
	height: clamp(76px, 19vw, 124px);
	max-width: 32%;
	border: 0;
	background: transparent;
	position: relative;
	cursor: pointer;
	flex-shrink: 1;
	filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.14));
}

.game-modal-overlay .mfd-chest-sprite {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	display: block;
	pointer-events: none;
	background-image: url('../assets/daily-reward/box-gold-clean.png');
	background-repeat: no-repeat;
	background-size: 500% auto;
	background-position: 25% 50%;
	z-index: 1;
}

.game-modal-overlay .mfd-chest.is-frame-1 .mfd-chest-sprite { background-position: 0% 50%; }
.game-modal-overlay .mfd-chest.is-frame-2 .mfd-chest-sprite { background-position: 25% 50%; }
.game-modal-overlay .mfd-chest.is-frame-3 .mfd-chest-sprite { background-position: 49.2% 50%; }
.game-modal-overlay .mfd-chest.is-frame-4 .mfd-chest-sprite { background-position: 73.8% 50%; }
.game-modal-overlay .mfd-chest.is-frame-5 .mfd-chest-sprite { background-position: 98.5% 50%; }
.game-modal-overlay .mfd-chest.is-opened .mfd-chest-sprite { background-position: 98.5% 50%; }

.game-modal-overlay .mfd-chest:before {
	content: '';
	position: absolute;
	left: 10%;
	right: 10%;
	top: 16%;
	height: 68%;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(255, 238, 116, 0.9) 0%, rgba(255, 190, 22, 0.4) 44%, rgba(255, 174, 0, 0) 72%);
	opacity: 0;
	transform: scale(0.55);
	transition: opacity 0.25s ease, transform 0.38s ease;
}

.game-modal-overlay .mfd-chest:after {
	content: '';
	position: absolute;
	inset: -24%;
	border-radius: 50%;
	opacity: 0;
	transform: scale(0.55) rotate(0deg);
	transition: opacity 0.25s ease, transform 0.38s ease;
	z-index: 0;
	filter: blur(0.35px);
	-webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, 0) 0 24%, rgba(0, 0, 0, 0.95) 37%, rgba(0, 0, 0, 0.75) 58%, rgba(0, 0, 0, 0) 77%);
	mask-image: radial-gradient(circle, rgba(0, 0, 0, 0) 0 24%, rgba(0, 0, 0, 0.95) 37%, rgba(0, 0, 0, 0.75) 58%, rgba(0, 0, 0, 0) 77%);
}

.game-modal-overlay .mfd-chest.is-ray-gray { --mfd-ray-color: rgba(170, 178, 188, 0.58); }
.game-modal-overlay .mfd-chest.is-ray-green { --mfd-ray-color: rgba(74, 214, 113, 0.58); }
.game-modal-overlay .mfd-chest.is-ray-red { --mfd-ray-color: rgba(239, 78, 78, 0.58); }
.game-modal-overlay .mfd-chest.is-ray-orange { --mfd-ray-color: rgba(255, 145, 36, 0.6); }
.game-modal-overlay .mfd-chest.is-ray-gold { --mfd-ray-color: rgba(255, 216, 39, 0.68); }

.game-modal-overlay .mfd-chest[disabled] { cursor: default; }
.game-modal-overlay .mfd-chests.is-opening .mfd-chest:not(.is-selected) { opacity: 0.28; transform: scale(0.82); }
.game-modal-overlay .mfd-chest.is-selected { transform: scale(1.12); z-index: 2; }
.game-modal-overlay .mfd-chest.is-opening.is-selected { animation: mfdChestShake 0.58s ease-in-out infinite; }
.game-modal-overlay .mfd-chest.is-opened { animation: none; }
.game-modal-overlay .mfd-chest.is-winning:before {
	opacity: 1;
	transform: scale(1.05);
}
.game-modal-overlay .mfd-chest.is-winning:after {
	opacity: 0.78;
	transform: scale(1.12) rotate(8deg);
	animation: mfdRewardRays 2.8s ease-in-out infinite;
}

.game-modal-overlay .mfd-reward {
	min-height: 32px;
	color: #0f6f7e;
	font: bold 22px Arial, Helvetica, sans-serif;
}

/* ── Referrals ── */
.game-modal-overlay .referrals-modal-stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	margin-bottom: 8px;
	width: 100%;
}

.game-modal-overlay .referrals-modal-code-box {
	border: 1px solid #d9e4ea;
	border-radius: 6px;
	background: #fff;
	padding: 7px 9px;
	margin-bottom: 7px;
	width: 100%;
}

.game-modal-overlay .referrals-modal-link-input {
	width: 100%;
	height: 30px;
	border: 2px solid #d9e4ea;
	border-radius: 6px;
	background: #fff;
	color: #31505d;
	padding: 0 9px;
	font: bold 11px Arial, Helvetica, sans-serif;
	margin-bottom: 7px;
	outline: none;
}

.game-modal-overlay .referrals-modal-copy-btn {
	width: 100%;
	height: 32px;
	border: 0;
	border-radius: 6px;
	background: #0f6f7e;
	color: #fff;
	font: bold 12px Arial, Helvetica, sans-serif;
	cursor: pointer;
	margin-bottom: 8px;
	flex-shrink: 0;
}

.game-modal-overlay .referrals-modal-rows {
	width: 100%;
	max-width: 100%;
	margin-bottom: 8px;
}

.game-modal-overlay .referrals-modal-message {
	min-height: 28px;
	text-align: center;
	color: #607080;
	font: bold 11px/14px Arial, Helvetica, sans-serif;
	white-space: normal;
	word-break: break-word;
}

/* ── Responsive ── */
@media (max-width: 560px) {
	.game-modal-overlay .games-modal-grid {
		grid-template-columns: 1fr;
	}

	.game-modal-overlay .wallet-history-grid {
		grid-template-columns: 1fr;
	}

	.game-modal-overlay .wallet-balance-grid {
		grid-template-columns: 1fr;
	}

	.game-modal-overlay .referrals-modal-stats {
		grid-template-columns: 1fr;
	}
}

@media (max-height: 720px) {
	.game-modal-overlay .game-modal {
		max-height: calc(100vh - 24px);
	}

	.game-modal-overlay .games-modal-card-image {
		height: 72px;
		max-height: 72px;
	}
}

@keyframes mfdChestShake {
	0%, 100% { transform: scale(1.12) rotate(0deg); }
	25% { transform: scale(1.16) rotate(-4deg); }
	50% { transform: scale(1.18) rotate(4deg); }
	75% { transform: scale(1.14) rotate(-2deg); }
}

@keyframes mfdRewardRays {
	0%, 100% { opacity: 0.52; transform: scale(1.04) rotate(2deg); }
	45% { opacity: 0.88; transform: scale(1.16) rotate(11deg); }
	70% { opacity: 0.68; transform: scale(1.1) rotate(15deg); }
}
