/* Woordle Engine — game.css
 * Uses CSS custom properties so it inherits Kadence theme tokens where present,
 * but works standalone if used outside Kadence.
 */

.woordle-wrap {
	--woordle-bg: var(--global-palette8, #ffffff);
	--woordle-fg: var(--global-palette4, #1f2937);
	--woordle-muted: var(--global-palette6, #d1d5db);
	--woordle-border: var(--global-palette7, #e5e7eb);
	--woordle-correct: #6aaa64;
	--woordle-present: #c9b458;
	--woordle-absent: #787c7e;
	/* Brand accents follow the host theme's (Astra+Elementor) blue; the game
	   tile colours above stay green/yellow/gray — Wordle convention. */
	--woordle-accent: var(--e-global-color-astglobalcolor0, #046bd2);
	--woordle-accent-dark: var(--e-global-color-astglobalcolor1, #045cb4);
	--woordle-key-bg: #d3d6da;
	--woordle-key-fg: #1a1a1b;
	--woordle-accent-soft: rgba(4, 107, 210, 0.08);
	--woordle-accent-soft-hover: rgba(4, 107, 210, 0.16);

	/* Sizes are clamped against BOTH viewport-width and viewport-height so the
	   whole game (header + 6×5 board + 3-row keyboard) stays on one screen.
	   With the umlaut row removed we have headroom to grow the tiles bigger. */
	--woordle-tile-size: clamp(36px, min(13vw, 6.6vh), 64px);
	--woordle-gap: clamp(4px, 0.8vw, 7px);
	--woordle-radius: 6px;
	--woordle-key-height: clamp(42px, min(12vw, 5.6vh), 54px);
	--woordle-font: var(--global-body-font-family, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);

	max-width: 540px;
	margin: 16px auto;
	font-family: var(--woordle-font);
	color: var(--woordle-fg);
	background:
		linear-gradient(180deg, var(--woordle-bg) 0%, rgba(4, 107, 210, 0.025) 100%),
		var(--woordle-bg);
	padding: 14px 16px 18px;
	user-select: none;
	-webkit-user-select: none;
	box-sizing: border-box;
	border: 1px solid rgba(4, 107, 210, 0.14);
	border-radius: 14px;
	box-shadow:
		0 1px 3px rgba(0, 0, 0, 0.04),
		0 6px 24px rgba(0, 0, 0, 0.05);
	-webkit-tap-highlight-color: transparent;
	container-type: inline-size;
	animation: woordle-wrap-in 320ms ease both;
}

/* Short-viewport tightening (typical desktop windows ≤ 720px tall) */
@media (max-height: 720px) {
	.woordle-wrap {
		margin: 8px auto;
		padding: 10px 14px 12px;
		--woordle-tile-size: clamp(28px, 6vh, 46px);
		--woordle-key-height: clamp(34px, 5vh, 42px);
	}
	.woordle-board { margin: 4px 0; }
	.woordle-message { min-height: 20px; margin: 2px 0; }
	.woordle-keyboard { margin-top: 6px; }
	.woordle-header { padding-bottom: 6px; margin-bottom: 6px; }
}

/* Even shorter (e.g. 1280×600 dev tools, split-screen) */
@media (max-height: 600px) {
	.woordle-wrap {
		--woordle-tile-size: clamp(24px, 5vh, 38px);
		--woordle-key-height: clamp(30px, 4.5vh, 38px);
	}
	.woordle-btn { width: 32px; height: 32px; font-size: 0.95rem; }
}
@keyframes woordle-wrap-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

/* Container-query fallback: when the wrap itself is narrow, shrink tiles further. */
@container (max-width: 380px) {
	.woordle-wrap {
		--woordle-tile-size: clamp(26px, 13cqw, 46px);
		--woordle-gap: 4px;
		--woordle-key-height: 42px;
	}
}

.woordle-wrap[data-theme="dark"] {
	--woordle-bg: #121213;
	--woordle-fg: #ffffff;
	--woordle-muted: #3a3a3c;
	--woordle-border: #3a3a3c;
	--woordle-key-bg: #818384;
	--woordle-key-fg: #ffffff;
}

/* Colorblind / high-contrast mode — orange (correct) + blue (present), the
   NYT convention. Neither theme overrides these two vars, so one attribute
   selector covers light and dark. */
.woordle-wrap[data-cb="1"] {
	--woordle-correct: #f5793a;
	--woordle-present: #85c0f9;
	--woordle-accent-soft: rgba(245, 121, 58, 0.08);
	--woordle-accent-soft-hover: rgba(245, 121, 58, 0.16);
}
/* Light blue needs dark text to stay readable */
.woordle-wrap[data-cb="1"] .woordle-tile-present,
.woordle-wrap[data-cb="1"] .woordle-key-present { color: #1a1a1b; }

.woordle-wrap *,
.woordle-wrap *::before,
.woordle-wrap *::after {
	box-sizing: border-box;
}

.woordle-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	border-bottom: 1px solid var(--woordle-border);
	padding-bottom: 10px;
	margin-bottom: 10px;
	flex-wrap: wrap;
}
.woordle-title {
	font-weight: 900;
	font-size: clamp(1.1rem, 4.5vw, 1.45rem);
	letter-spacing: 0.06em;
	text-transform: uppercase;
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
	background: linear-gradient(135deg, var(--woordle-accent) 0%, var(--woordle-accent-dark) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
	position: relative;
}
.woordle-title::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 1.1em;
	background: linear-gradient(180deg, var(--woordle-accent) 0%, var(--woordle-accent-dark) 100%);
	border-radius: 3px;
	flex-shrink: 0;
}
/* "#123 · 5. Juli" pill (daily mode) — inside the gradient-clipped title, so
   text color must be re-asserted like .woordle-slot-label does. */
.woordle-puzzle-label {
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--woordle-fg);
	-webkit-text-fill-color: var(--woordle-fg);
	opacity: 0.65;
	border: 1px solid var(--woordle-border);
	padding: 2px 8px;
	border-radius: 999px;
	white-space: nowrap;
	text-transform: none;
	font-variant-numeric: tabular-nums;
	flex-shrink: 0;
}

.woordle-slot-label {
	font-size: 0.7rem;
	background: var(--woordle-accent);
	color: #fff;
	-webkit-text-fill-color: #fff;
	padding: 3px 8px;
	border-radius: 999px;
	font-weight: 700;
	letter-spacing: 0;
}
.woordle-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* Emoji-glyph button (sound toggle) — align with the SVG icon buttons */
.woordle-btn-sound { font-size: 15px; line-height: 1; }
/* Second share button (PNG card) sits next to the text-share button */
.woordle-btn-shareimg { margin-left: 8px; }

/* Daily speed leaderboard (end modal). Reuses the .woordle-aggregate shell;
   gold accent to set it apart from the blue community box. */
.woordle-lb-box {
	background: rgba(245, 158, 11, 0.07);
	border-color: rgba(245, 158, 11, 0.3);
}
.woordle-lb-box .woordle-aggregate-title { color: #b45309; }
.woordle-wrap[data-theme="dark"] .woordle-lb-box {
	background: rgba(245, 158, 11, 0.1);
	border-color: rgba(245, 158, 11, 0.35);
}
.woordle-wrap[data-theme="dark"] .woordle-lb-box .woordle-aggregate-title { color: #fbbf24; }
.woordle-lb-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-top: 6px;
	font-variant-numeric: tabular-nums;
}
.woordle-lb-row {
	display: grid;
	grid-template-columns: 32px 1fr 52px;
	gap: 6px;
	align-items: center;
	font-size: 0.8rem;
	padding: 2px 4px;
	border-radius: 5px;
}
.woordle-lb-row-you {
	background: rgba(4, 107, 210, 0.14);
	font-weight: 700;
}
.woordle-lb-rank { text-align: center; font-weight: 700; }
.woordle-lb-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: left;
}
.woordle-lb-name em { opacity: 0.55; font-style: italic; }
.woordle-lb-time { text-align: right; font-weight: 700; }
.woordle-lb-you-tag {
	display: inline-block;
	background: var(--woordle-correct);
	color: #fff;
	font-size: 0.62rem;
	font-weight: 800;
	padding: 1px 6px;
	border-radius: 999px;
	margin-left: 4px;
	vertical-align: 1px;
}
.woordle-lb-yourrank {
	margin-top: 8px;
	font-size: 0.8rem;
	font-weight: 700;
	color: #b45309;
}
.woordle-wrap[data-theme="dark"] .woordle-lb-yourrank { color: #fbbf24; }
.woordle-lb-form {
	display: flex;
	gap: 6px;
	margin-top: 10px;
}
.woordle-lb-form input {
	flex: 1;
	min-width: 0;
	padding: 7px 10px;
	border: 1px solid var(--woordle-border);
	border-radius: 6px;
	font-size: 0.82rem;
	font-family: inherit;
	background: var(--woordle-bg);
	color: var(--woordle-fg);
}
.woordle-lb-form input:focus-visible {
	outline: 2px solid var(--woordle-accent);
	outline-offset: 1px;
}
.woordle-lb-form .woordle-btn {
	width: auto;
	padding: 0 14px;
	font-size: 0.78rem;
	font-weight: 700;
}

/* Blitz-mode live timer pill (inside the gradient-clipped title, so the text
   color must be re-asserted like .woordle-puzzle-label does) */
.woordle-blitz-timer {
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.03em;
	color: var(--woordle-fg);
	-webkit-text-fill-color: var(--woordle-fg);
	background: rgba(245, 158, 11, 0.14);
	border: 1px solid rgba(245, 158, 11, 0.4);
	padding: 3px 9px;
	border-radius: 999px;
	margin-left: 8px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* Hint-token wallet: count bubble on the hint button */
.woordle-btn[data-action="hint"] { position: relative; }
.woordle-hint-count {
	position: absolute;
	top: -5px;
	right: -5px;
	min-width: 16px;
	height: 16px;
	border-radius: 999px;
	background: #f59e0b;
	color: #fff;
	font-size: 10px;
	font-weight: 800;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 3px;
	pointer-events: none;
}
.woordle-btn-hint-empty { opacity: 0.45; }
.woordle-btn-hint-empty .woordle-hint-count { background: #9ca3af; }

/* "+1 token earned" celebration line in the end modal */
.woordle-token-earned {
	margin: 10px 0 2px;
	padding: 8px 12px;
	background: rgba(245, 158, 11, 0.12);
	border: 1px solid rgba(245, 158, 11, 0.35);
	border-radius: 8px;
	font-size: 0.85rem;
	font-weight: 700;
	color: #b45309;
}
.woordle-wrap[data-theme="dark"] .woordle-token-earned { color: #fbbf24; }

.woordle-btn {
	background: var(--woordle-accent-soft);
	border: 1px solid rgba(4, 107, 210, 0.22);
	color: var(--woordle-fg);
	width: 40px;
	height: 40px;
	border-radius: 10px;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 150ms ease, transform 80ms ease, border-color 150ms ease, box-shadow 150ms ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.woordle-btn:hover {
	background: var(--woordle-accent-soft-hover);
	border-color: var(--woordle-accent);
	box-shadow: 0 2px 6px rgba(4, 107, 210, 0.18);
}
.woordle-btn:hover svg { color: var(--woordle-accent); }
.woordle-btn:active { transform: scale(0.94); }
.woordle-btn:focus-visible {
	outline: 2px solid var(--woordle-accent);
	outline-offset: 2px;
}
/* Make sure inline SVG icons stay correctly sized + colored regardless of
   what theme styles try to do to them. */
.woordle-btn svg {
	width: 18px;
	height: 18px;
	display: block;
	color: currentColor;
	stroke: currentColor;
	fill: none;
	flex-shrink: 0;
	pointer-events: none;
}
.woordle-wrap[data-theme="dark"] .woordle-btn {
	background: rgba(4, 107, 210, 0.18);
	border-color: rgba(4, 107, 210, 0.35);
	color: #fff;
}
.woordle-wrap[data-theme="dark"] .woordle-btn:hover {
	background: rgba(4, 107, 210, 0.32);
}
.woordle-btn-primary {
	background: var(--woordle-accent);
	color: #fff;
	border-color: var(--woordle-accent);
	width: auto;
	padding: 10px 18px;
	margin-top: 10px;
	font-weight: 700;
}

.woordle-board {
	display: grid;
	grid-template-rows: repeat(var(--woordle-rows, 6), var(--woordle-tile-size));
	gap: var(--woordle-gap);
	justify-content: center;
	margin: 8px 0;
}
.woordle-row {
	display: grid;
	grid-template-columns: repeat(var(--woordle-cols, 5), var(--woordle-tile-size));
	gap: var(--woordle-gap);
}
.woordle-tile {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	/* Fixed-contrast border + background — independent of Kadence palette so
	   tiles are always visible against any theme background. */
	border: 2px solid rgba(0, 0, 0, 0.18);
	border-radius: var(--woordle-radius);
	font-weight: 800;
	font-size: calc(var(--woordle-tile-size) * 0.5);
	text-transform: uppercase;
	background: rgba(0, 0, 0, 0.025);
	color: var(--woordle-fg);
	box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.04);
	transition: transform 200ms ease, background 250ms ease, border-color 200ms ease, color 250ms ease, box-shadow 200ms ease;
	will-change: transform, background-color;
}
.woordle-tile-filled {
	border-color: rgba(0, 0, 0, 0.55);
	background: var(--woordle-bg);
	transform: scale(1.06);
	box-shadow:
		inset 0 -2px 0 rgba(0, 0, 0, 0.06),
		0 1px 4px rgba(0, 0, 0, 0.08);
}
/* Dark-mode empty-state ONLY — :not() prevents this rule from flattening the
   colored .woordle-tile-correct / -present / -absent backgrounds. Without :not(),
   this selector's higher specificity (3 classes) beats the colored modifiers
   (1 class), making the green/yellow/grey example tiles invisible in dark mode. */
.woordle-wrap[data-theme="dark"] .woordle-tile:not(.woordle-tile-correct):not(.woordle-tile-present):not(.woordle-tile-absent) {
	border-color: rgba(255, 255, 255, 0.32);
	background: rgba(255, 255, 255, 0.05);
}
.woordle-wrap[data-theme="dark"] .woordle-tile-filled:not(.woordle-tile-correct):not(.woordle-tile-present):not(.woordle-tile-absent) {
	border-color: rgba(255, 255, 255, 0.7);
	background: rgba(255, 255, 255, 0.08);
}
.woordle-tile-flip { animation: woordle-flip 600ms ease forwards; }
@keyframes woordle-flip {
	0%   { transform: rotateX(0); }
	50%  { transform: rotateX(90deg); }
	100% { transform: rotateX(0); }
}

/* Invalid-word feedback: the whole row shakes (the classic Wordle "no"). */
.woordle-row-shake { animation: woordle-shake 550ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes woordle-shake {
	10%, 90%      { transform: translateX(-2px); }
	20%, 80%      { transform: translateX(4px); }
	30%, 50%, 70% { transform: translateX(-6px); }
	40%, 60%      { transform: translateX(6px); }
}

/* Winning-row celebration: staggered "dance" after the flips finish —
   high jump with squash & stretch on landing, then a small rebound. */
.woordle-tile-bounce { animation: woordle-bounce 850ms ease both; }
@keyframes woordle-bounce {
	0%   { transform: translateY(0) scale(1, 1); }
	18%  { transform: translateY(-58%) scale(0.96, 1.06); }
	40%  { transform: translateY(4%) scale(1.1, 0.88); }
	58%  { transform: translateY(-24%) scale(0.98, 1.03); }
	74%  { transform: translateY(2%) scale(1.04, 0.96); }
	88%  { transform: translateY(-7%) scale(1, 1); }
	100% { transform: translateY(0) scale(1, 1); }
}

/* A row consumed by a hint — no longer playable. */
.woordle-row-consumed { opacity: 0.32; filter: grayscale(0.6); }
.woordle-row-consumed .woordle-tile { border-style: dashed; }
.woordle-tile-correct { background: var(--woordle-correct); border-color: var(--woordle-correct); color: #fff; }
.woordle-tile-present { background: var(--woordle-present); border-color: var(--woordle-present); color: #fff; }
.woordle-tile-absent  { background: var(--woordle-absent);  border-color: var(--woordle-absent);  color: #fff; }
.woordle-tile-hint    { border-color: var(--woordle-correct); border-style: dashed; border-width: 3px; color: var(--woordle-correct); }

.woordle-message {
	min-height: 24px;
	text-align: center;
	font-weight: 600;
	margin: 4px 0;
	font-size: 0.9rem;
}
.woordle-flash {
	background: var(--woordle-fg);
	color: var(--woordle-bg);
	padding: 6px 14px;
	border-radius: var(--woordle-radius);
	display: inline-block;
}

.woordle-keyboard {
	display: grid;
	gap: 5px;
	margin-top: 8px;
}
.woordle-kb-row {
	display: flex;
	justify-content: center;
	gap: 4px;
}
.woordle-key {
	flex: 1 1 0;
	min-width: 0;
	height: var(--woordle-key-height);
	padding: 0 2px;
	border: 1.5px solid rgba(0, 0, 0, 0.14);
	border-radius: 8px;
	background: #ffffff;
	color: var(--woordle-key-fg);
	font-weight: 700;
	font-size: clamp(0.85rem, 2.8vw, 1rem);
	cursor: pointer;
	text-transform: uppercase;
	transition: transform 80ms ease, background 150ms ease, border-color 150ms ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.woordle-key:hover { background: #f3f4f6; border-color: rgba(0, 0, 0, 0.22); }
.woordle-key:active { transform: translateY(1px) scale(0.95); box-shadow: none; }
.woordle-key:focus-visible {
	outline: 2px solid var(--woordle-accent);
	outline-offset: 1px;
}
.woordle-key-wide { flex: 1.6 1 0; font-size: clamp(0.7rem, 2.2vw, 0.85rem); padding: 0 6px; }
.woordle-key-enter { font-weight: 700; letter-spacing: 0.02em; }
.woordle-key-back svg { width: 22px; height: 22px; flex-shrink: 0; }
.woordle-wrap[data-theme="dark"] .woordle-key {
	background: #2a2a2c;
	border-color: rgba(255, 255, 255, 0.18);
	color: #f3f4f6;
}
.woordle-wrap[data-theme="dark"] .woordle-key:hover {
	background: #3a3a3c;
	border-color: rgba(255, 255, 255, 0.32);
}

/* Umlaut explainer block in the how-to modal */
.woordle-howto-umlaut {
	margin-top: 14px;
	padding: 10px 12px;
	background: rgba(4, 107, 210, 0.1);
	border-left: 3px solid var(--woordle-accent);
	border-radius: 4px;
	font-size: 0.88rem;
	line-height: 1.45;
}
.woordle-wrap[data-theme="dark"] .woordle-howto-umlaut {
	background: rgba(4, 107, 210, 0.15);
}
/* First-visit onboarding demo */
.woordle-onboard { text-align: center; }
.woordle-onboard [hidden] { display: none !important; }
.woordle-onboard-lead { font-weight: 600; margin: 0 0 4px; }
.woordle-onboard-row { justify-content: center; margin: 14px 0; }
.woordle-onboard-cap {
	font-size: 0.92rem;
	line-height: 1.45;
	text-align: left;
	margin: 8px 0;
	animation: woordle-cap-in 400ms ease both;
}
@keyframes woordle-cap-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}
.woordle-btn-link {
	background: none;
	border: none;
	color: var(--woordle-accent);
	font-size: 0.82rem;
	font-weight: 600;
	text-decoration: underline;
	cursor: pointer;
	display: block;
	margin: 10px auto 0;
	padding: 4px;
}
@media (prefers-reduced-motion: reduce) {
	.woordle-onboard-cap { animation: none !important; }
}

/* Colorblind-mode toggle row at the bottom of the how-to modal */
.woordle-cb-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 14px;
	padding: 10px 12px;
	border: 1px solid var(--woordle-border);
	border-radius: 6px;
	font-size: 0.86rem;
	font-weight: 600;
	cursor: pointer;
	user-select: none;
}
.woordle-cb-toggle input {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: #f5793a;
	cursor: pointer;
	flex-shrink: 0;
}
.woordle-cb-swatches {
	display: inline-flex;
	gap: 4px;
	margin-left: auto;
}
.woordle-cb-swatches span {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	display: inline-block;
}
.woordle-key-correct { background: var(--woordle-correct); color: #fff; }
.woordle-key-present { background: var(--woordle-present); color: #fff; }
.woordle-key-absent  { background: var(--woordle-absent);  color: #fff; }

/* Modal */
.woordle-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	animation: woordle-fade 180ms ease;
	padding: 16px;
}
@keyframes woordle-fade { from { opacity: 0; } to { opacity: 1; } }
.woordle-modal {
	background: var(--woordle-bg);
	color: var(--woordle-fg);
	padding: 24px 20px;
	border-radius: 10px;
	max-width: 380px;
	width: 100%;
	max-height: calc(100dvh - 32px);
	overflow-y: auto;
	text-align: center;
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
	position: relative;
	outline: none;
}
/* Visible close button — before this, modals only closed on backdrop click. */
.woordle-modal-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 8px;
	background: transparent;
	color: var(--woordle-fg);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	opacity: 0.6;
	transition: opacity 150ms ease, background 150ms ease;
}
.woordle-modal-close:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
.woordle-wrap[data-theme="dark"] .woordle-modal-close:hover { background: rgba(255, 255, 255, 0.1); }
.woordle-modal-close:focus-visible {
	outline: 2px solid var(--woordle-accent);
	opacity: 1;
}
.woordle-modal-title {
	font-size: 1.2rem;
	font-weight: 800;
	margin-bottom: 16px;
}
.woordle-stats-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
	margin-bottom: 16px;
}
.woordle-stats-grid > div {
	display: flex;
	flex-direction: column;
	align-items: center;
}
.woordle-stats-grid b { font-size: 1.6rem; font-weight: 800; }
.woordle-stats-grid span { font-size: 0.7rem; opacity: 0.7; }
/* Solve-time line — shown in stats + end modals after a win */
.woordle-time-line {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px 10px;
	margin: 4px 0 12px;
	font-size: 0.85rem;
	color: var(--woordle-fg);
	opacity: 0.85;
	font-variant-numeric: tabular-nums;
}
.woordle-time-line b {
	font-weight: 800;
	opacity: 1;
}
.woordle-time-newbest {
	flex: 1 1 100%;
	font-size: 0.95rem;
	font-weight: 800;
	color: #b45309;
	background: #fef3c7;
	padding: 6px 12px;
	border-radius: 999px;
	text-align: center;
	margin-bottom: 6px;
	animation: woordle-newbest-pop 700ms ease;
}
@keyframes woordle-newbest-pop {
	0%   { transform: scale(0.6); opacity: 0; }
	60%  { transform: scale(1.1); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}
.woordle-wrap[data-theme="dark"] .woordle-time-newbest {
	background: #422006;
	color: #fbbf24;
}

/* Confetti win celebration — pure CSS, no JS animation loop */
.woordle-wrap { position: relative; }
.woordle-confetti {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 99998;
}
.woordle-confetti span {
	position: absolute;
	top: -20px;
	left: var(--x, 50%);
	width: var(--w, 8px);
	height: var(--h, 12px);
	background: var(--c, #6aaa64);
	border-radius: 1px;
	transform-origin: center;
	animation: woordle-confetti-fall var(--dur, 2.4s) var(--delay, 0s) forwards cubic-bezier(0.55, 0.06, 0.68, 0.19);
	will-change: transform, opacity;
	opacity: 0.95;
}
@keyframes woordle-confetti-fall {
	0%   { transform: translate(0, 0) rotate(0deg); opacity: 0.95; }
	60%  { opacity: 0.85; }
	100% { transform: translate(var(--sway, 0), 130vh) rotate(var(--rot-end, 720deg)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.woordle-confetti { display: none !important; }
}

/* History section — last 10 plays */
.woordle-history-section {
	margin: 16px 0 4px;
	padding-top: 14px;
	border-top: 1px solid var(--woordle-border);
	text-align: left;
}
.woordle-history-title {
	font-size: 0.95rem;
	font-weight: 800;
	margin-bottom: 8px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.woordle-history-count {
	margin-left: auto;
	font-size: 0.78rem;
	color: #6b7280;
	background: #f3f4f6;
	padding: 2px 8px;
	border-radius: 999px;
}
.woordle-wrap[data-theme="dark"] .woordle-history-count {
	color: #d1d5db;
	background: #2a2a2c;
}
.woordle-history-list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 240px;
	overflow-y: auto;
}
.woordle-history-row {
	display: grid;
	grid-template-columns: 22px 1fr 38px 50px auto;
	gap: 6px 8px;
	align-items: center;
	padding: 6px 4px;
	border-bottom: 1px solid #f3f4f6;
	font-size: 0.82rem;
}
.woordle-history-row:last-child { border-bottom: 0; }
.woordle-history-row.lost { opacity: 0.7; }
.woordle-history-icon { font-size: 0.85rem; }
.woordle-history-word {
	font-weight: 800;
	letter-spacing: 0.05em;
	font-variant-numeric: tabular-nums;
}
.woordle-history-score, .woordle-history-time {
	font-variant-numeric: tabular-nums;
	color: #6b7280;
	font-size: 0.78rem;
	text-align: right;
}
.woordle-history-date {
	color: #9ca3af;
	font-size: 0.75rem;
	text-align: right;
}
.woordle-wrap[data-theme="dark"] .woordle-history-row {
	border-color: #2a2a2c;
}
.woordle-wrap[data-theme="dark"] .woordle-history-score,
.woordle-wrap[data-theme="dark"] .woordle-history-time {
	color: #9ca3af;
}
.woordle-wrap[data-theme="dark"] .woordle-history-date {
	color: #6b7280;
}

/* Anonymous global aggregate ("yesterday's stats") */
.woordle-aggregate {
	margin: 14px 0 6px;
	padding: 12px 14px;
	background: rgba(96, 165, 250, 0.08);
	border: 1px solid rgba(96, 165, 250, 0.22);
	border-radius: 8px;
	text-align: left;
}
.woordle-aggregate-title {
	font-size: 0.88rem;
	font-weight: 800;
	color: #1d4ed8;
}
.woordle-aggregate-summary {
	font-size: 0.78rem;
	color: #475569;
	margin-bottom: 8px;
}
.woordle-aggregate-dist {
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-variant-numeric: tabular-nums;
}
.woordle-agg-row {
	display: grid;
	grid-template-columns: 18px 1fr 38px;
	gap: 6px;
	align-items: center;
	font-size: 0.74rem;
}
.woordle-agg-rownum {
	font-weight: 700;
	color: #475569;
	text-align: center;
}
.woordle-agg-bar {
	display: block;
	background: rgba(15, 23, 42, 0.06);
	border-radius: 3px;
	height: 12px;
	overflow: hidden;
}
.woordle-agg-fill {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 100%);
	border-radius: 3px;
	transition: width 400ms ease;
}
.woordle-agg-row-lost .woordle-agg-fill {
	background: linear-gradient(90deg, #fb923c 0%, #ef4444 100%);
}
.woordle-agg-count {
	color: #475569;
	text-align: right;
	font-size: 0.72rem;
}
.woordle-wrap[data-theme="dark"] .woordle-aggregate {
	background: rgba(96, 165, 250, 0.1);
	border-color: rgba(96, 165, 250, 0.3);
}
.woordle-wrap[data-theme="dark"] .woordle-aggregate-title { color: #93c5fd; }
.woordle-wrap[data-theme="dark"] .woordle-aggregate-summary,
.woordle-wrap[data-theme="dark"] .woordle-agg-rownum,
.woordle-wrap[data-theme="dark"] .woordle-agg-count { color: #cbd5e1; }
.woordle-wrap[data-theme="dark"] .woordle-agg-bar { background: rgba(255,255,255,0.06); }

/* Today's community stats (end modal) — the player's own row is highlighted */
.woordle-community-beat {
	font-size: 0.82rem;
	font-weight: 800;
	color: #15803d;
	margin: 2px 0 8px;
}
.woordle-agg-row-you .woordle-agg-rownum,
.woordle-agg-row-you .woordle-agg-count {
	color: #15803d;
	font-weight: 800;
}
.woordle-agg-row-you .woordle-agg-fill {
	background: linear-gradient(90deg, #7bc86f 0%, var(--woordle-correct) 100%);
}
.woordle-wrap[data-cb="1"] .woordle-agg-row-you .woordle-agg-fill {
	background: #f5793a;
}
.woordle-agg-row-you.woordle-agg-row-lost .woordle-agg-fill {
	background: linear-gradient(90deg, #fb923c 0%, #ef4444 100%);
}
.woordle-agg-row-you.woordle-agg-row-lost .woordle-agg-rownum,
.woordle-agg-row-you.woordle-agg-row-lost .woordle-agg-count { color: #dc2626; }
.woordle-wrap[data-theme="dark"] .woordle-community-beat,
.woordle-wrap[data-theme="dark"] .woordle-agg-row-you .woordle-agg-rownum,
.woordle-wrap[data-theme="dark"] .woordle-agg-row-you .woordle-agg-count { color: #4ade80; }
.woordle-wrap[data-theme="dark"] .woordle-agg-row-you.woordle-agg-row-lost .woordle-agg-rownum,
.woordle-wrap[data-theme="dark"] .woordle-agg-row-you.woordle-agg-row-lost .woordle-agg-count { color: #f87171; }

/* Cross-promotion cards (shown in end-game modal — drives clicks into archive / strategy / latest auto-post) */
.woordle-promo {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin: 14px 0 12px;
}
@media (max-width: 380px) {
	.woordle-promo { grid-template-columns: 1fr; }
}
.woordle-promo-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 14px 8px;
	border: 1px solid var(--woordle-border);
	border-radius: 8px;
	text-decoration: none !important;
	color: var(--woordle-fg) !important;
	background: var(--woordle-bg);
	transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
	min-height: 70px;
}
.woordle-promo-card:hover,
.woordle-promo-card:focus-visible {
	transform: translateY(-2px);
	border-color: var(--woordle-accent);
	background: rgba(4, 107, 210, 0.08);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.woordle-promo-icon {
	font-size: 1.5rem;
	line-height: 1;
}
.woordle-promo-label {
	font-size: 0.78rem;
	font-weight: 600;
	text-align: center;
	line-height: 1.2;
}
.woordle-wrap[data-theme="dark"] .woordle-promo-card {
	background: #1f1f20;
	border-color: #3a3a3c;
}
.woordle-wrap[data-theme="dark"] .woordle-promo-card:hover {
	background: rgba(4, 107, 210, 0.15);
}

/* Achievements / Badges */
.woordle-badges-section {
	margin: 16px 0 8px;
	padding-top: 14px;
	border-top: 1px solid var(--woordle-border);
	text-align: left;
}
.woordle-badges-section-title {
	font-size: 0.95rem;
	font-weight: 800;
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.woordle-badges-count {
	margin-left: auto;
	font-size: 0.78rem;
	font-weight: 700;
	color: #6b7280;
	background: #f3f4f6;
	padding: 2px 8px;
	border-radius: 999px;
}
.woordle-wrap[data-theme="dark"] .woordle-badges-count {
	color: #d1d5db;
	background: #2a2a2c;
}
.woordle-badges-grid {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 6px;
}
@media (max-width: 380px) {
	.woordle-badges-grid { grid-template-columns: repeat(4, 1fr); }
}
.woordle-badge {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 8px 4px;
	border-radius: 6px;
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	text-align: center;
	cursor: help;
	user-select: none;
	transition: transform 150ms ease;
}
.woordle-badge-icon {
	font-size: 1.5rem;
	line-height: 1;
}
.woordle-badge-name {
	font-size: 0.68rem;
	font-weight: 700;
	line-height: 1.15;
	color: var(--woordle-fg);
	letter-spacing: 0.01em;
}
.woordle-badge-got {
	background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
	border-color: #f59e0b;
}
.woordle-badge-locked {
	opacity: 0.45;
	filter: grayscale(0.8);
}
.woordle-badge-locked .woordle-badge-name { color: #6b7280; }
.woordle-wrap[data-theme="dark"] .woordle-badge {
	background: #2a2a2c;
	border-color: #3a3a3c;
}
.woordle-wrap[data-theme="dark"] .woordle-badge-got {
	background: linear-gradient(135deg, #422006 0%, #78350f 100%);
	border-color: #fbbf24;
}

/* Win-modal celebration banner for newly-earned badges */
.woordle-badges-celebration {
	margin: 12px 0;
	padding: 14px 12px;
	background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
	border: 2px solid #f59e0b;
	border-radius: 10px;
	animation: woordle-badge-pop 700ms ease;
}
.woordle-badges-celebration-title {
	font-size: 0.9rem;
	font-weight: 800;
	color: #92400e;
	margin-bottom: 8px;
	text-align: center;
}
.woordle-badges-celebration .woordle-badges-grid {
	grid-template-columns: repeat(auto-fit, minmax(80px, 120px));
	justify-content: center;
}
.woordle-badge-celebrate {
	background: #fff;
	border-color: #f59e0b;
	border-width: 2px;
}
@keyframes woordle-badge-pop {
	0%   { transform: scale(0.6); opacity: 0; }
	60%  { transform: scale(1.06); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}
.woordle-wrap[data-theme="dark"] .woordle-badges-celebration {
	background: linear-gradient(135deg, #422006 0%, #78350f 100%);
	color: #fef3c7;
}
.woordle-wrap[data-theme="dark"] .woordle-badges-celebration-title {
	color: #fde68a;
}
.woordle-wrap[data-theme="dark"] .woordle-badge-celebrate {
	background: #1a1a1b;
}

/* Streak freeze badge — shown in stats + end modals (daily mode only) */
.woordle-freeze-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	margin: 4px 0 12px;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: help;
	user-select: none;
	border: 1px solid transparent;
	transition: transform 200ms ease;
}
.woordle-freeze-ready {
	background: #e0f2fe;
	color: #075985;
	border-color: #bae6fd;
}
.woordle-freeze-just-used {
	background: #dcfce7;
	color: #166534;
	border-color: #86efac;
	animation: woordle-freeze-pop 600ms ease;
}
@keyframes woordle-freeze-pop {
	0%   { transform: scale(0.7); opacity: 0; }
	50%  { transform: scale(1.08); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}
.woordle-freeze-cooldown {
	background: #f3f4f6;
	color: #6b7280;
	border-color: #e5e7eb;
}
.woordle-wrap[data-theme="dark"] .woordle-freeze-ready    { background: #082f49; color: #bae6fd; border-color: #075985; }
.woordle-wrap[data-theme="dark"] .woordle-freeze-just-used { background: #14532d; color: #bbf7d0; border-color: #16a34a; }
.woordle-wrap[data-theme="dark"] .woordle-freeze-cooldown  { background: #2a2a2c; color: #9ca3af; border-color: #3a3a3c; }

.woordle-howto { text-align: left; font-size: 0.95rem; line-height: 1.5; }
.woordle-howto p { margin: 8px 0; }
.woordle-example {
	display: flex;
	gap: 4px;
	margin: 8px 0;
}
.woordle-example .woordle-tile {
	width: 36px;
	height: 36px;
	font-size: 1rem;
}
.woordle-next {
	margin-top: 12px;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	opacity: 0.85;
}

/* Inline word definition in the end modal (served by /define) */
.woordle-define {
	margin: -4px 0 12px;
	padding: 10px 14px;
	background: rgba(4, 107, 210, 0.08);
	border-left: 3px solid var(--woordle-accent);
	border-radius: 6px;
	text-align: left;
	font-size: 0.86rem;
	line-height: 1.5;
}
.woordle-define[hidden] { display: none; }
.woordle-define-lemma {
	font-weight: 800;
	margin-right: 6px;
}
.woordle-define-gloss { opacity: 0.9; }
.woordle-define-src {
	display: inline-block;
	margin-left: 6px;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--woordle-accent) !important;
	text-decoration: none;
	white-space: nowrap;
}
.woordle-define-src:hover { text-decoration: underline; }
.woordle-wrap[data-theme="dark"] .woordle-define {
	background: rgba(4, 107, 210, 0.14);
}

/* Dictionary lookup link under the end-modal title */
.woordle-dict-link {
	display: inline-block;
	margin: -6px 0 12px;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--woordle-accent) !important;
	text-decoration: none;
	border: 1px solid rgba(4, 107, 210, 0.35);
	border-radius: 999px;
	padding: 5px 14px;
	transition: background 150ms ease;
}
.woordle-dict-link:hover,
.woordle-dict-link:focus-visible {
	background: rgba(4, 107, 210, 0.12);
	text-decoration: none;
}

/* Daily puzzle still loading — board visible but not interactive yet. */
.woordle-loading .woordle-board {
	opacity: 0.55;
	pointer-events: none;
}

/* Visually hidden live region for screen-reader announcements */
.woordle-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* Solver */
.woordle-solver {
	text-align: center;
	font-size: 0.9rem;
	margin-bottom: 8px;
	opacity: 0.85;
}
.woordle-solver-results {
	margin-top: 12px;
	text-align: center;
}
.woordle-solver-count {
	font-weight: 700;
	margin-bottom: 8px;
}
.woordle-solver-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
}
.woordle-solver-list span {
	background: var(--woordle-correct);
	color: #fff;
	padding: 6px 10px;
	border-radius: 4px;
	font-weight: 700;
	font-size: 0.85rem;
	letter-spacing: 0.05em;
}

/* Phone layout (≤ 480px viewport — covers most modern phones) */
@media (max-width: 480px) {
	.woordle-wrap {
		margin: 8px auto;
		padding: 10px 12px 14px;
		border-radius: 12px;
		--woordle-tile-size: clamp(28px, min(13vw, 7vh), 50px);
		--woordle-gap: 4px;
		--woordle-key-height: clamp(40px, min(12vw, 6.5vh), 48px);
	}
	.woordle-btn { width: 38px; height: 38px; font-size: 1.1rem; }
	.woordle-modal { padding: 20px 16px; }
	.woordle-stats-grid b { font-size: 1.4rem; }
	.woordle-title { font-size: 1.1rem; }
}

/* Very narrow (≤ 360px — older / smaller phones) */
@media (max-width: 360px) {
	.woordle-wrap {
		--woordle-tile-size: clamp(26px, 13vw, 42px);
		--woordle-key-height: 40px;
	}
	.woordle-key { font-size: 0.74rem; padding: 0; }
	.woordle-key-wide { font-size: 0.68rem; }
	.woordle-actions { gap: 4px; }
	.woordle-btn { width: 34px; height: 34px; font-size: 0.95rem; }
}

/* Landscape on phones — flatter board so keyboard stays in view */
@media (max-height: 520px) and (orientation: landscape) {
	.woordle-wrap {
		margin: 4px auto;
		padding: 8px 12px;
		--woordle-tile-size: clamp(24px, 7vh, 38px);
		--woordle-key-height: clamp(34px, 9vh, 44px);
		--woordle-gap: 3px;
		max-width: 460px;
	}
	.woordle-btn { width: 30px; height: 30px; font-size: 0.95rem; }
	.woordle-board { margin: 4px 0; }
}

/* Streak flame — pops in next to the streak count after a daily win, then
   settles into a gentle flicker. */
.woordle-streak-flame {
	display: inline-block;
	font-size: 0.8em;
	margin-left: 2px;
	animation:
		woordle-flame-pop 700ms cubic-bezier(0.34, 1.56, 0.64, 1) 400ms both,
		woordle-flame-flicker 1.6s ease-in-out 1.2s infinite;
}
@keyframes woordle-flame-pop {
	0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
	70%  { transform: scale(1.35) rotate(8deg); opacity: 1; }
	100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes woordle-flame-flicker {
	0%, 100% { transform: scale(1) rotate(0); }
	50%      { transform: scale(1.12) rotate(4deg); }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
	.woordle-tile, .woordle-tile-flip, .woordle-key, .woordle-modal-overlay,
	.woordle-row-shake, .woordle-tile-bounce, .woordle-streak-flame {
		animation: none !important;
		transition: none !important;
	}
}
