/**
 * PlayRox game player.
 *
 * The theme's slider.js creates .game-mode, .viral-game-frame, .game-loader,
 * .game-loader-spinner and .game-loader-text, but the theme stylesheet has no
 * rules for any of them. The iframe therefore fell back to the HTML default
 * 300x150 inside a 450px wide 9/16 box, and the fixed close button floated
 * over whatever happened to be underneath.
 *
 * This file supplies the missing presentation and adds a header bar so the
 * close control sits above the game rather than on top of it.
 *
 * Everything is scoped to #viral-slider-popup.game-mode, so the reels and
 * stories popup is completely unaffected.
 */

/* ==========================================================================
   Shell
   ========================================================================== */

#viral-slider-popup.game-mode {
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	background: #070a0f;
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
}

/* ==========================================================================
   Header bar
   ========================================================================== */

.playrox-gamebar {
	position: relative;
	z-index: 12;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	height: calc(52px + env(safe-area-inset-top));
	/* Right padding reserves space for the theme's own close button. */
	padding: env(safe-area-inset-top) 58px 0 16px;
	background: linear-gradient(180deg, #124a24 0%, #0d3a1c 100%);
	color: #fff;
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}

.playrox-gamebar__icon {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	background: rgba(255, 255, 255, 0.12);
	color: #6fcf6f;
	font-size: 15px;
	cursor: pointer;
	transition: background 0.16s ease;
}

.playrox-gamebar__icon:hover {
	background: rgba(255, 255, 255, 0.22);
}

.playrox-gamebar__title {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	font-size: 14.5px;
	font-weight: 700;
	line-height: 1.2;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.playrox-gamebar__actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
}

.playrox-gamebar__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.18s ease;
}

.playrox-gamebar__btn:hover {
	background: rgba(255, 255, 255, 0.22);
}

/*
 * Pull the theme's fixed close button into the bar. It keeps its own click
 * handler, so closing behaves exactly as before.
 */
#viral-slider-popup.game-mode .viral-popup-close {
	position: absolute !important;
	top: calc(env(safe-area-inset-top) + 8px) !important;
	right: 12px !important;
	z-index: 14 !important;
	width: 36px !important;
	height: 36px !important;
	background: rgba(255, 255, 255, 0.12) !important;
	transition: background 0.18s ease !important;
}

#viral-slider-popup.game-mode .viral-popup-close:hover {
	background: rgba(255, 92, 114, 0.85) !important;
}

/* Article controls have no meaning during a game. */
#viral-slider-popup.game-mode .viral-side-actions,
#viral-slider-popup.game-mode .viral-slider-progress,
#viral-slider-popup.game-mode .viral-share-trigger {
	display: none !important;
}

/* ==========================================================================
   Game surface
   ========================================================================== */

/*
 * `flex: 1 1 auto` with `height: auto` leaves this box's height indefinite
 * as far as the sizing model is concerned, even though it visibly fills the
 * popup. A child asking for `height: 100%` then has nothing to resolve
 * against and an iframe falls back to its intrinsic 150px — which is why a
 * game opened as a short strip at the top of the popup instead of filling
 * it.
 *
 * `flex-basis: 0` plus `min-height: 0` makes the height definite, and the
 * frame is positioned rather than sized in percentages so it does not depend
 * on that resolution at all. Belt and braces, because the two engines
 * disagree about the belt.
 */
#viral-slider-popup.game-mode .viral-popup-content {
	position: relative;
	flex: 1 1 0%;
	width: 100%;
	max-width: none;
	height: auto;
	min-height: 0;
	/* Override the 9/16 phone frame the reels popup uses. */
	aspect-ratio: auto;
	border-radius: 0;
	box-shadow: none;
	background: #000;
	touch-action: auto;
}

#viral-slider-popup.game-mode .viral-game-frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #000;
	display: block;
	transition: opacity .2s ease;
}

/* Desktop: a framed surface rather than edge-to-edge. */
@media (min-width: 1025px) {
	#viral-slider-popup.game-mode .viral-popup-content {
		width: min(96vw, 1360px);
		margin: 14px auto 18px;
		min-height: 0;
		border-radius: 14px;
		overflow: hidden;
		box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
	}
}

/* ==========================================================================
   Loader
   ========================================================================== */

#viral-slider-popup.game-mode .game-loader {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	background: #000;
}

#viral-slider-popup.game-mode .game-loader-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid rgba(255, 255, 255, 0.16);
	border-top-color: #4caf50;
	border-radius: 50%;
	animation: playrox-game-spin 0.8s linear infinite;
}

#viral-slider-popup.game-mode .game-loader-text {
	color: rgba(255, 255, 255, 0.66);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.05em;
}

@keyframes playrox-game-spin {
	to { transform: rotate(360deg); }
}

/* ==========================================================================
   Fullscreen
   ========================================================================== */

#viral-slider-popup.game-mode:fullscreen {
	background: #000;
}

#viral-slider-popup.game-mode:fullscreen .viral-popup-content {
	width: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 700px) {
	.playrox-gamebar {
		height: calc(48px + env(safe-area-inset-top));
		padding-left: 14px;
	}

	.playrox-gamebar__title {
		font-size: 13.5px;
	}
}

/* Landscape phones: slim the bar so the game keeps the height. */
@media (max-height: 480px) and (orientation: landscape) {
	.playrox-gamebar {
		height: calc(40px + env(safe-area-inset-top));
	}

	.playrox-gamebar__btn,
	#viral-slider-popup.game-mode .viral-popup-close {
		width: 30px !important;
		height: 30px !important;
		font-size: 13px !important;
	}

	#viral-slider-popup.game-mode .viral-popup-close {
		top: calc(env(safe-area-inset-top) + 5px) !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	#viral-slider-popup.game-mode .game-loader-spinner {
		animation-duration: 2.4s;
	}
}

/* ==========================================================================
   Player links under the game
   ========================================================================== */

.playrox-gamedock {
	position: relative;
	z-index: 12;
	flex: 0 0 auto;
	display: flex;
	align-items: stretch;
	width: 100%;
	padding-bottom: env(safe-area-inset-bottom);
	background: linear-gradient(180deg, #0d3a1c 0%, #0a2d16 100%);
	box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.4);
}

.playrox-gamedock__link {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 10px 6px;
	color: rgba(255, 255, 255, 0.82);
	font-size: 11.5px;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	transition: background 0.16s ease, color 0.16s ease;
}

.playrox-gamedock__link:hover,
.playrox-gamedock__link:focus {
	background: rgba(255, 255, 255, 0.07);
	color: #fff;
	text-decoration: none;
}

.playrox-gamedock__link i {
	font-size: 17px;
	color: #6fcf6f;
}

.playrox-gamedock__link span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
}

/* Desktop: the surface is inset, so match the dock to it. */
@media (min-width: 1025px) {
	.playrox-gamedock {
		width: min(96vw, 1360px);
		margin: 0 auto 16px;
		border-radius: 14px;
		box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
	}

	#viral-slider-popup.game-mode .viral-popup-content {
		margin-bottom: 10px;
	}
}

/* Landscape phones: single row, labels hidden to save height. */
@media (max-height: 480px) and (orientation: landscape) {
	.playrox-gamedock__link {
		flex-direction: row;
		gap: 7px;
		padding: 6px;
		font-size: 11px;
	}

	.playrox-gamedock__link i {
		font-size: 14px;
	}
}

/* Fullscreen hides the chrome so the game gets the whole screen. */
#viral-slider-popup.game-mode:fullscreen .playrox-gamedock {
	display: none;
}
