/* Daily Upgrade: core */
.umdu-enabled {
	--umdu-accent: #7a1b1b;
	--umdu-bg: #fbf7f1;
	--umdu-text: #211b18;
	--umdu-muted: #706761;
	--umdu-border: rgba(74, 51, 42, 0.17);
	--umdu-shadow: 0 18px 55px rgba(28, 16, 12, 0.2);
}

/* Sites indent every list in an article or page; the plugin lays its own lists out itself. */
:is(.entry-content, .wp-block-post-content) [class*="umdu-"] :is(ul, ol)[class*="umdu-"] {
	margin-left: 0;
}

/* Headings keep their face and case even if the theme's CSS arrives late.
   A site can set --umdu-heading-font to use its own face. */
.umdu-enabled:where(:not(body)) :where(h1, h2, h3, h4, h5, h6) {
	font-family: var(--umdu-heading-font, inherit);
	letter-spacing: normal;
	text-transform: none;
}

.umdu-sr-status {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.umdu-preview-badge {
	position: fixed;
	z-index: 99999;
	left: 12px;
	bottom: 12px;
	padding: 0.3rem 0.65rem;
	border-radius: 999px;
	background: #1d2327;
	color: #fff;
	font: 600 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	letter-spacing: 0.02em;
	pointer-events: none;
}

.umdu-reader-settings {
	margin: 0;
	padding: 0.75rem 1rem;
	border: 1px solid var(--umdu-border);
	border-radius: 12px;
	color: var(--umdu-text);
}

.umdu-reader-settings__row {
	display: flex;
	gap: 0.5rem;
	align-items: center;
	min-height: 44px;
}

/* Play mode: one fixed overlay, sized with svh so it never resizes as the
   browser's bars come and go, clear of the notch when a theme adds
   viewport-fit=cover. The page underneath is scroll-locked. */
html.umdu-play-open,
html.umdu-play-open body {
	overflow: hidden;
}

html.umdu-play-open body {
	position: fixed;
	left: 0;
	right: 0;
	width: 100%;
}

.umdu-play {
	position: fixed;
	z-index: 100000;
	inset: 0;
	height: 100vh;
	height: 100svh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
	overflow: hidden;
	overscroll-behavior: contain;
	background: #142b30;
	background-image: radial-gradient(ellipse at 50% 35%, #2d5559, transparent 75%);
	color: var(--umdu-text);
	font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* One bounded surface owns the header, board and controls. The surrounding
   space frames a game; it never separates the things needed to play it. */
.umdu-play__surface {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: var(--umdu-play-width, 800px);
	height: 100%;
	max-height: var(--umdu-play-height, 940px);
	min-height: 0;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 24px;
	background: var(--umdu-bg);
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

/* The frame is known before an engine's stylesheet or run arrives. A
   slow connection must not turn a small loading box into a large game. */
.umdu-play--word_puzzle:not(.is-results) {
	--umdu-play-width: 640px;
	--umdu-play-height: 820px;
}

.umdu-play--trivia_ladder:not(.is-results) {
	--umdu-play-width: 760px;
	--umdu-play-height: 660px;
}

.umdu-play--timeline:not(.is-results) {
	--umdu-play-width: 1000px;
	--umdu-play-height: 760px;
}

.umdu-play--block_drop:not(.is-results) {
	--umdu-play-width: 560px;
}

.umdu-play--block_drop:not(.is-results) .umdu-play__surface {
	--umdu-bg: #111e30;
	--umdu-text: #e9f0f8;
	--umdu-muted: #adbed2;
	--umdu-border: rgba(197, 217, 240, 0.2);
	color: var(--umdu-text);
}

@media (max-width: 899px) {
	.umdu-play--timeline:not(.is-results) { --umdu-play-width: 680px; }
}

.umdu-play__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-height: 0;
	padding: 24px;
	overflow: hidden;
	overscroll-behavior: contain;
	scrollbar-gutter: stable;
}

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

.umdu-play__bar {
	display: flex;
	flex: none;
	gap: 0.5rem;
	align-items: center;
	min-height: 44px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--umdu-border);
	background: rgba(255, 255, 255, 0.5);
}

.umdu-play--block_drop:not(.is-results) .umdu-play__bar {
	background: #17273c;
}

.umdu-play__close,
.umdu-play__sound,
.umdu-play__gear {
	min-width: 44px;
	min-height: 44px;
	padding: 0 0.75rem;
	border: 1px solid var(--umdu-border);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.65);
	color: inherit;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	touch-action: manipulation;
}

/* Themes restyle every button:hover and :focus (GeneratePress: white on dark grey); a button here keeps its own colours. */
.umdu-play__close:hover,
.umdu-play__close:focus,
.umdu-play__sound:hover,
.umdu-play__sound:focus,
.umdu-play__gear:hover,
.umdu-play__gear:focus {
	background: color-mix(in srgb, var(--umdu-accent) 8%, var(--umdu-bg));
	color: inherit;
}

.umdu-play--block_drop:not(.is-results) .umdu-play__bar button {
	background: rgba(255, 255, 255, 0.04);
}

.umdu-play button:focus-visible,
.umdu-play a:focus-visible,
.umdu-play input:focus-visible {
	outline: 3px solid var(--umdu-accent);
	outline-offset: 3px;
}

/* The speaker: muted until "Sound effects" is on, then the accent with its waves. */
.umdu-play__sound {
	display: inline-grid;
	place-items: center;
	padding: 0;
	color: var(--umdu-muted);
}

.umdu-play__sound[hidden] {
	display: none;
}

.umdu-play__sound[aria-pressed="true"],
.umdu-play__sound[aria-pressed="true"]:hover,
.umdu-play__sound[aria-pressed="true"]:focus {
	border-color: var(--umdu-accent);
	background: color-mix(in srgb, var(--umdu-accent) 10%, transparent);
	color: var(--umdu-accent);
}

.umdu-play__sound[aria-pressed="true"] .umdu-play__muted,
.umdu-play__sound[aria-pressed="false"] .umdu-play__waves {
	display: none;
}

.umdu-play__sound:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--umdu-accent) 55%, transparent);
	outline-offset: 2px;
}

/* On a phone the close button is its ✕ alone, and the game's name has the bar. */
@media (max-width: 479px) {
	.umdu-play__close {
		padding: 0;
	}

	.umdu-play__close-text {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
}

.umdu-play__title {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-weight: 800;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.umdu-play__status {
	flex: none;
	color: var(--umdu-muted);
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
}

.umdu-play__status:empty {
	display: none;
}

.umdu-play__settings {
	position: absolute;
	z-index: 5;
	top: 76px;
	right: 16px;
	width: min(400px, calc(100% - 32px));
	max-height: calc(100% - 92px);
	overflow-y: auto;
	border-radius: 14px;
	background: var(--umdu-bg);
	box-shadow: var(--umdu-shadow);
}

.umdu-play__banner {
	flex: none;
	margin: 0 0 16px;
	padding: 0.4rem 0.75rem;
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.06);
	font-size: 0.9rem;
}

.umdu-play__stage {
	flex: 1;
	min-height: 0;
	min-width: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	touch-action: pan-y;
	-webkit-overflow-scrolling: touch;
}

/* An engine's playfield inside the stage: gestures are the game's. */
.umdu-playfield {
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

.umdu-play__controls {
	flex: none;
	min-width: 0;
	margin-top: 16px;
	touch-action: manipulation;
}

.umdu-play__controls:empty {
	display: none;
}

/* A phone is the surface, not a miniature desktop dialog. Safe areas stay
   outside its contents, and svh keeps browser chrome from moving a game. */
@media (max-width: 599px) {
	.umdu-play {
		padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
		background: var(--umdu-bg);
	}

	.umdu-play__surface {
		max-height: 100%;
		border: 0;
		border-radius: 0;
		box-shadow: none;
	}

	.umdu-play__bar {
		padding: 12px;
	}

	.umdu-play__body {
		padding: 16px 12px;
	}

	.umdu-play__settings {
		top: 68px;
	}
}

@media (max-height: 600px) and (min-width: 600px) {
	.umdu-play { padding: 12px; }
	.umdu-play__bar { padding-block: 10px; }
	.umdu-play__body { padding: 16px; }
	.umdu-play__settings { top: 64px; }
}

.umdu-play__message {
	display: grid;
	gap: 1rem;
	place-items: center;
	min-height: 40%;
	text-align: center;
}

/* Play mode moves focus to headings and boxes (tabindex="-1") so screen
   readers announce them; they aren't controls, so no focus ring. */
.umdu-play [tabindex="-1"]:focus,
.umdu-play [tabindex="-1"]:focus-visible {
	outline: none;
	box-shadow: none;
}
