/*
 * Modak Catch — Divine Ganesha Festival v2
 * UI shell around the canvas. Gameplay art is drawn in game.js.
 *
 * Touch rule that matters: only the canvas swallows touch gestures.
 * Everything else (inputs, buttons, cards) keeps native behaviour,
 * otherwise the name field cannot be focused on a phone.
 */

.mcg-stage {
	--mcg-crimson: #800020;
	--mcg-crimson-deep: #4a0016;
	--mcg-crimson-ink: #3a0011;
	--mcg-saffron: #ff9933;
	--mcg-amber: #ffd700;
	--mcg-cream: #fffdd0;
	--mcg-marigold: #ffc30b;
	--mcg-leaf: #2f6b4f;
	--mcg-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
	--mcg-ui: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	position: relative;
	overflow: hidden;
	background: var(--mcg-crimson-deep);
	font-family: var(--mcg-ui);
	color: var(--mcg-cream);
	touch-action: manipulation;
	isolation: isolate;
}

/* ---------- Fullscreen takeover ---------- */

html:has(> body.mcg-fullscreen) {
	height: 100%;
	overflow: hidden;
}

body.mcg-fullscreen {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background: #4a0016;
	overscroll-behavior: none;
}

body.mcg-fullscreen #wpadminbar {
	display: none;
}

.mcg-stage--full {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
}

.mcg-stage--embed {
	width: 100%;
	max-width: 100%;
	min-height: 380px;
	border-radius: 14px;
	box-shadow: 0 18px 44px rgba(58, 0, 17, 0.32);
}

.mcg-canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
	-webkit-tap-highlight-color: transparent;
	-webkit-user-select: none;
	user-select: none;
}

/* ---------- HUD ---------- */

.mcg-hud {
	position: absolute;
	inset: 0 0 auto 0;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
	padding: clamp(9px, 2vmin, 20px);
	pointer-events: none;
	z-index: 3;
}

.mcg-hud__left,
.mcg-hud__right {
	display: flex;
	flex-direction: column;
	gap: 7px;
	min-width: 0;
}

.mcg-hud__right {
	align-items: flex-end;
	max-width: 52%;
}

.mcg-plaque {
	min-width: 0;
	padding: 6px 13px 8px;
	border: 1px solid rgba(255, 215, 0, 0.5);
	border-radius: 3px 3px 11px 11px;
	background: linear-gradient(180deg, rgba(48, 0, 14, 0.88), rgba(112, 0, 28, 0.78));
	box-shadow: 0 4px 16px rgba(30, 0, 8, 0.38), inset 0 1px 0 rgba(255, 253, 208, 0.2);
}

.mcg-plaque--leader {
	text-align: right;
}

.mcg-plaque__label {
	display: block;
	font-size: clamp(9px, 1.4vmin, 11px);
	letter-spacing: 0.08em;
	color: rgba(255, 253, 208, 0.72);
}

.mcg-plaque__value {
	display: block;
	font-family: var(--mcg-display);
	font-size: clamp(22px, 3.8vmin, 32px);
	line-height: 1.1;
	color: var(--mcg-amber);
	text-shadow: 0 1px 0 rgba(58, 0, 17, 0.8);
	font-variant-numeric: tabular-nums;
}

.mcg-plaque__value--sm {
	font-size: clamp(13px, 2.1vmin, 18px);
	max-width: 40vw;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mcg-plaque__hint {
	display: block;
	margin-top: 3px;
	font-size: 10.5px;
	color: rgba(255, 253, 208, 0.6);
}

/* progress toward the next parade */
.mcg-meter {
	height: 4px;
	margin-top: 5px;
	overflow: hidden;
	background: rgba(255, 253, 208, 0.18);
	border-radius: 3px;
}

.mcg-meter__fill {
	display: block;
	width: 0;
	height: 100%;
	background: linear-gradient(90deg, var(--mcg-saffron), var(--mcg-amber));
	transform-origin: left center;
	transition: width 0.18s linear;
}

/* lives */
.mcg-lives {
	display: flex;
	gap: 5px;
	padding-left: 2px;
}

.mcg-lives i {
	width: 13px;
	height: 15px;
	background: linear-gradient(180deg, #fff3c4, var(--mcg-marigold) 55%, #d8901d);
	border: 1px solid rgba(138, 95, 6, 0.8);
	border-radius: 50% 50% 44% 44% / 62% 62% 38% 38%;
	box-shadow: 0 2px 6px rgba(30, 0, 8, 0.35);
}

.mcg-lives i.is-spent {
	background: rgba(255, 253, 208, 0.16);
	border-color: rgba(255, 253, 208, 0.25);
	box-shadow: none;
}

/* live indicator */
.mcg-live {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-right: 5px;
	border-radius: 50%;
	background: rgba(255, 253, 208, 0.3);
	vertical-align: middle;
}

.mcg-live.is-hot {
	background: #4ade80;
	box-shadow: 0 0 8px rgba(74, 222, 128, 0.9);
}

.mcg-speed {
	padding: 3px 9px;
	font-size: 11px;
	letter-spacing: 0.04em;
	color: rgba(255, 253, 208, 0.7);
	background: rgba(48, 0, 14, 0.55);
	border-radius: 9px;
	font-variant-numeric: tabular-nums;
}

/* ---------- Tool chips ---------- */

.mcg-tools {
	position: absolute;
	right: clamp(9px, 2vmin, 20px);
	bottom: clamp(9px, 2vmin, 20px);
	z-index: 4;
	display: flex;
	gap: 8px;
}

.mcg-chip {
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 1px solid rgba(255, 215, 0, 0.5);
	border-radius: 50%;
	background: rgba(48, 0, 14, 0.66);
	color: var(--mcg-amber);
	font-family: var(--mcg-ui);
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	touch-action: manipulation;
	transition: background 0.18s ease, color 0.18s ease;
}

.mcg-chip:hover {
	background: rgba(128, 0, 32, 0.9);
}

.mcg-chip[aria-pressed="true"] {
	color: rgba(255, 253, 208, 0.38);
}

.mcg-chip[aria-pressed="true"]::after {
	content: "";
	position: absolute;
	width: 24px;
	height: 1px;
	background: currentColor;
	transform: rotate(-38deg);
}

/* ---------- Veils and cards ---------- */

.mcg-veil {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: radial-gradient(120% 90% at 50% 30%, rgba(74, 0, 22, 0.58), rgba(26, 0, 8, 0.9));
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.26s ease, visibility 0.26s ease;
}

.mcg-veil.is-open {
	opacity: 1;
	visibility: visible;
}

/* keyboard open on a phone: pin the card near the top so it stays visible */
.mcg-stage.is-typing .mcg-veil {
	align-items: flex-start;
	padding-top: 12px;
}

.mcg-card {
	position: relative;
	width: min(420px, 100%);
	padding: clamp(22px, 4.4vmin, 34px) clamp(18px, 4vmin, 32px) clamp(20px, 3.6vmin, 28px);
	text-align: center;
	color: var(--mcg-crimson-ink);
	background:
		radial-gradient(circle at 16% 10%, rgba(255, 195, 11, 0.22), transparent 40%),
		radial-gradient(circle at 86% 90%, rgba(255, 153, 51, 0.2), transparent 44%),
		linear-gradient(175deg, #fffdf2, var(--mcg-cream) 55%, #ffeeb8);
	border: 2px solid var(--mcg-crimson);
	border-radius: 22px;
	box-shadow:
		0 0 0 4px rgba(255, 215, 0, 0.5),
		0 0 0 6px var(--mcg-crimson),
		0 22px 54px rgba(20, 0, 6, 0.55);
	transform: translate3d(0, 14px, 0) scale(0.98);
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.16, 0.9, 0.3, 1), opacity 0.24s ease;
	will-change: transform, opacity;
}

.mcg-card--slim {
	width: min(320px, 100%);
}

.mcg-veil.is-open .mcg-card {
	transform: translate3d(0, 0, 0) scale(1);
	opacity: 1;
}

/* gold keyline inside the card */
.mcg-card::before {
	content: "";
	position: absolute;
	inset: 7px;
	border: 1px solid rgba(128, 0, 32, 0.22);
	border-radius: 16px;
	pointer-events: none;
}

.mcg-card__om {
	margin: 0 0 2px;
	font-family: var(--mcg-display);
	font-size: clamp(26px, 5vmin, 36px);
	line-height: 1;
	color: var(--mcg-crimson);
}

.mcg-card__title {
	margin: 0 0 8px;
	font-family: var(--mcg-display);
	font-weight: 700;
	font-size: clamp(28px, 5.4vmin, 40px);
	line-height: 1.06;
	letter-spacing: -0.01em;
	color: var(--mcg-crimson);
}

.mcg-card__title--sm {
	font-size: clamp(19px, 3.6vmin, 26px);
	margin-bottom: 14px;
}

.mcg-card__sub {
	margin: 0 auto 18px;
	max-width: 30ch;
	font-size: clamp(13px, 2vmin, 15px);
	line-height: 1.55;
	color: rgba(58, 0, 17, 0.78);
}

.mcg-card__praise {
	margin: 0 0 14px;
	min-height: 1.4em;
	font-family: var(--mcg-display);
	font-size: clamp(14px, 2.2vmin, 17px);
	color: var(--mcg-crimson);
}

/* ---------- Name field ---------- */

.mcg-field {
	display: block;
	text-align: left;
	margin: 0 0 4px;
}

.mcg-field__label {
	display: block;
	margin-bottom: 6px;
	font-size: 12px;
	letter-spacing: 0.05em;
	color: rgba(58, 0, 17, 0.7);
}

.mcg-field__input {
	width: 100%;
	box-sizing: border-box;
	padding: 13px 14px;
	font-family: var(--mcg-display);
	/* 16px minimum, otherwise iOS zooms the whole page on focus */
	font-size: 16px;
	color: var(--mcg-crimson-ink);
	background: rgba(255, 255, 255, 0.82);
	border: 1.5px solid rgba(128, 0, 32, 0.35);
	border-radius: 10px;
	outline: none;
	-webkit-user-select: text;
	user-select: text;
	touch-action: manipulation;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.mcg-field__input::placeholder {
	color: rgba(58, 0, 17, 0.34);
}

.mcg-field__input:focus {
	border-color: var(--mcg-crimson);
	box-shadow: 0 0 0 3px rgba(255, 195, 11, 0.5);
}

.mcg-field__error {
	margin: 6px 0 0;
	min-height: 1.2em;
	font-size: 12.5px;
	text-align: left;
	color: #a3122b;
}

/* ---------- Buttons ---------- */

.mcg-btn {
	position: relative;
	display: block;
	width: 100%;
	margin-top: 16px;
	padding: 15px 22px;
	overflow: hidden;
	font-family: var(--mcg-display);
	font-size: clamp(16px, 2.6vmin, 20px);
	font-weight: 700;
	color: #5a0016;
	background: linear-gradient(180deg, #ffe98a 0%, var(--mcg-amber) 34%, var(--mcg-marigold) 66%, var(--mcg-saffron) 100%);
	border: 2px solid #b8860b;
	border-radius: 999px;
	cursor: pointer;
	touch-action: manipulation;
	text-shadow: 0 1px 0 rgba(255, 253, 208, 0.6);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.75),
		inset 0 -3px 6px rgba(184, 134, 11, 0.4),
		0 6px 0 #a8770a,
		0 12px 26px rgba(255, 153, 51, 0.42);
	transition: transform 0.12s ease, box-shadow 0.2s ease;
	animation: mcg-glow 2.6s ease-in-out infinite;
}

.mcg-btn::after {
	content: "";
	position: absolute;
	top: -60%;
	left: -30%;
	width: 26%;
	height: 220%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
	transform: translate3d(0, 0, 0) rotate(18deg);
	animation: mcg-sheen 3.4s ease-in-out infinite;
	pointer-events: none;
}

.mcg-btn:hover {
	transform: translate3d(0, -1px, 0);
}

.mcg-btn:active {
	transform: translate3d(0, 4px, 0);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.6),
		inset 0 -2px 5px rgba(184, 134, 11, 0.45),
		0 2px 0 #a8770a,
		0 6px 14px rgba(255, 153, 51, 0.35);
}

.mcg-btn--link {
	display: block;
	box-sizing: border-box;
	text-decoration: none;
	text-align: center;
	line-height: 1.3;
}

.mcg-btn--link:hover,
.mcg-btn--link:focus {
	text-decoration: none;
}

.mcg-btn--ghost {
	margin-top: 9px;
	padding: 11px 20px;
	font-size: 14px;
	color: var(--mcg-crimson);
	background: transparent;
	border: 1.5px solid rgba(128, 0, 32, 0.4);
	box-shadow: none;
	animation: none;
	text-shadow: none;
}

.mcg-btn--ghost::after {
	display: none;
}

.mcg-btn--ghost:hover {
	background: rgba(128, 0, 32, 0.07);
}

.mcg-btn:focus-visible,
.mcg-field__input:focus-visible,
.mcg-chip:focus-visible {
	outline: 3px solid #2f6b4f;
	outline-offset: 3px;
}

@keyframes mcg-glow {
	0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.75), inset 0 -3px 6px rgba(184,134,11,.4), 0 6px 0 #a8770a, 0 12px 26px rgba(255,153,51,.38); }
	50%      { box-shadow: inset 0 1px 0 rgba(255,255,255,.85), inset 0 -3px 6px rgba(184,134,11,.4), 0 6px 0 #a8770a, 0 14px 40px rgba(255,215,0,.7); }
}

@keyframes mcg-sheen {
	0%, 62% { transform: translate3d(0, 0, 0) rotate(18deg); }
	100%    { transform: translate3d(430%, 0, 0) rotate(18deg); }
}

/* ---------- Controls row ---------- */

.mcg-controls {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: 14px;
}

.mcg-controls__item {
	padding: 5px 11px;
	font-size: 11.5px;
	color: rgba(58, 0, 17, 0.72);
	background: rgba(128, 0, 32, 0.08);
	border-radius: 999px;
}

/* ---------- Score tally ---------- */

.mcg-tally {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp(14px, 4vmin, 26px);
	margin: 2px 0 14px;
}

.mcg-tally__item {
	flex: 1 1 0;
}

.mcg-tally__rule {
	width: 1px;
	align-self: stretch;
	background: linear-gradient(180deg, transparent, rgba(128, 0, 32, 0.4), transparent);
}

.mcg-tally__label {
	display: block;
	margin-bottom: 2px;
	font-size: 11.5px;
	letter-spacing: 0.05em;
	color: rgba(58, 0, 17, 0.65);
}

.mcg-tally__value {
	display: block;
	font-family: var(--mcg-display);
	font-size: clamp(32px, 6.4vmin, 48px);
	line-height: 1;
	color: var(--mcg-crimson);
	font-variant-numeric: tabular-nums;
}

/* ---------- Mini leaderboard ---------- */

.mcg-mini {
	margin: 4px 0 0;
	text-align: left;
}

.mcg-mini:empty {
	display: none;
}

.mcg-mini__title {
	margin: 0 0 6px;
	font-size: 11px;
	letter-spacing: 0.08em;
	color: rgba(58, 0, 17, 0.6);
}

.mcg-mini__row {
	display: flex;
	align-items: baseline;
	gap: 8px;
	padding: 4px 8px;
	border-radius: 7px;
	font-size: 13.5px;
	color: rgba(58, 0, 17, 0.85);
}

.mcg-mini__row + .mcg-mini__row {
	margin-top: 1px;
}

.mcg-mini__row.is-you {
	background: rgba(255, 195, 11, 0.32);
	font-weight: 700;
}

.mcg-mini__rank {
	width: 18px;
	color: rgba(58, 0, 17, 0.5);
	font-variant-numeric: tabular-nums;
}

.mcg-mini__name {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mcg-mini__score {
	font-family: var(--mcg-display);
	color: var(--mcg-crimson);
	font-variant-numeric: tabular-nums;
}

/* ---------- Utilities ---------- */

.mcg-stage .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 460px) {
	.mcg-hud__right {
		max-width: 56%;
	}
	.mcg-plaque {
		padding: 5px 10px 7px;
	}
	.mcg-chip {
		width: 46px;
		height: 46px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mcg-btn,
	.mcg-btn::after {
		animation: none;
	}
	.mcg-card,
	.mcg-veil {
		transition-duration: 0.01ms;
	}
}
