/* Word Weave — golden palette; shell layout from word-blossom.css. */

.wordweave-page {
	--ww-ink: #c9a227;
	--ww-gold: #5c4500;
	--ww-gold-dark: #a67c00;
	--ww-gold-light: #e8c547;
	--ww-mist: #fbf6e8;
	--ww-cream: #fffdf6;
	--ww-block: #3d3200;
	--ww-border: #8a7420;
	--ww-active: #f5e6b8;
	--ww-active-cell: #efd56a;
	--ww-error: #b33a3a;
	--ww-reveal: #7a5c00;
	--ww-stats-bg: #c9a227;
	--ww-stats-border: #7a5c00;
	--ww-stats-divider: #8a6e10;
}

.wordweave-page .word-blossom-banner-fallback-title {
	color: var(--ww-gold-dark);
}

.wordweave-page .word-blossom-banner--fallback {
	min-height: 120px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #fbf3d8 0%, #f0dc8a 50%, #e8c547 100%);
}

.wordweave-page .word-blossom-banner-img {
	display: block;
	width: 100%;
	max-width: 710px;
	height: auto;
	aspect-ratio: 710 / 248;
	object-fit: cover;
	margin: 0 auto;
}

.wordweave-page .word-blossom-play-shell {
	--wb-stats-bg: var(--ww-stats-bg);
	--wb-stats-border: var(--ww-stats-border);
	--wb-stats-text: #3d3200;
	--wb-archive-title: var(--ww-gold);
	--wb-archive-lede: #7a6520;
	--wb-archive-table-border: #ead9a0;
	--wb-archive-th-bg: var(--ww-mist);
	--wb-archive-th-color: var(--ww-gold);
	--wb-archive-td-border: #f0e4b8;
	--wb-archive-muted: #9a8230;
	--wb-archive-current-bg: #fff8e0;
	--wb-archive-badge-bg: var(--ww-gold);
	--wb-archive-empty-bg: var(--ww-mist);
	--wb-archive-empty-border: #ead9a0;
	--wb-archive-empty-title: var(--ww-gold);
	--wb-archive-empty-sub: #7a6520;
	--wb-archive-status-completed-bg: #f5e6b8;
	--wb-archive-status-completed-color: var(--ww-gold);
}

.wordweave-page .word-blossom-archive-title {
	color: var(--ww-ink);
}

.wordweave-page .word-blossom-archive-panel {
	background: var(--ww-cream);
	border-color: #ead9a0;
	box-shadow: 0 4px 18px rgba(92, 69, 0, 0.1);
}

.wordweave-page .word-blossom-archive-action .gemini-btn--primary {
	background: var(--ww-gold);
	border-color: var(--ww-gold-dark);
	color: var(--ww-ink);
}

.wordweave-page .word-blossom-archive-action .gemini-btn--primary:hover,
.wordweave-page .word-blossom-archive-action .gemini-btn--primary:focus {
	background: var(--ww-gold-light);
	border-color: var(--ww-gold-dark);
	color: var(--ww-ink);
}

.wordweave-page .word-blossom-stats-bar {
	background: var(--ww-stats-bg);
	border-color: var(--ww-stats-border);
	color: #3d3200;
}

.wordweave-page .word-blossom-stat-value,
.wordweave-page .word-blossom-stat-label {
	color: #3d3200;
}

.wordweave-page .word-blossom-stat + .word-blossom-stat {
	border-left-color: var(--ww-stats-divider);
}

.wordweave-page .word-blossom-card {
	background: var(--ww-cream);
	border-color: #ead9a0;
	box-shadow: 0 4px 18px rgba(92, 69, 0, 0.1);
}

.wordweave-page #wordweave-app {
	--wb-accent: var(--ww-gold);
	--wb-accent-dark: var(--ww-ink);
	--wb-accent-light: var(--ww-mist);
	--wb-accent-border: #ead9a0;
	--wb-accent-muted: var(--ww-gold-light);
	--wb-accent-text: var(--ww-ink);
	--wb-accent-soft: var(--ww-cream);
	--wb-text-muted: #7a6520;
	position: relative;
}

.wordweave-meta-line {
	margin: 0;
	font-size: 15px;
	color: var(--ww-ink);
}

.wordweave-meta-date {
	font-weight: 700;
}

.wordweave-meta-complete[hidden],
.wordweave-results[hidden] {
	display: none !important;
}

.wordweave-victory {
	margin: 10px 0 0;
	padding: 12px 16px 10px;
	border-radius: 10px;
	background: linear-gradient(180deg, var(--ww-mist) 0%, var(--ww-cream) 100%);
	border: 1px solid #ead9a0;
	text-align: center;
	animation: wordweave-victory-in 0.65s ease-out both;
}

.wordweave-victory__eyebrow {
	margin: 0 0 2px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ww-gold-deep, #a67c00);
}

.wordweave-victory__title {
	margin: 0;
	font-size: clamp(28px, 3.2vw, 36px);
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: -0.02em;
	color: var(--ww-ink);
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.wordweave-victory__sub {
	margin: 6px 0 0;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	color: #7a6520;
}

.wordweave-view-rankings-wrap {
	margin: 12px 0 0;
}

.wordweave-view-rankings-wrap .gemini-btn {
	min-height: 40px;
}

@keyframes wordweave-victory-in {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.96);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wordweave-victory {
		animation: none;
	}
}

.wordweave-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
	gap: 20px;
	align-items: start;
	margin-top: 12px;
}

.wordweave-active-clue {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--ww-mist);
	border: 1px solid #ead9a0;
}

.wordweave-active-clue__meta {
	margin: 0 0 4px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--ww-gold-dark);
}

.wordweave-active-clue__text {
	margin: 0;
	font-size: 15px;
	line-height: 1.35;
	color: var(--ww-ink);
}

.crossword-grid-wrap {
	max-width: 480px;
	width: 100%;
	margin: 0 auto;
}

.crossword-grid {
	display: grid;
	grid-template-columns: repeat(var(--grid-size, 5), 1fr);
	aspect-ratio: 1 / 1;
	width: 100%;
	border: 2px solid var(--ww-border);
	background: var(--ww-border);
	gap: 1px;
	user-select: none;
	transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.crossword-grid--filled-incorrect {
	border-color: #c98989;
	box-shadow: 0 0 0 1px rgba(179, 58, 58, 0.18);
}

.crossword-grid--filled-incorrect .crossword-cell:not(.crossword-cell--blocked) {
	background: #f8ecec;
}

.crossword-grid--filled-incorrect .crossword-cell--active-word:not(.crossword-cell--blocked) {
	background: #f3dede;
}

.crossword-grid--filled-incorrect .crossword-cell--active:not(.crossword-cell--blocked) {
	background: #efd0d0;
	box-shadow: inset 0 0 0 2px #a85a5a;
}

.crossword-cell {
	position: relative;
	aspect-ratio: 1 / 1;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	min-width: 0;
	min-height: 0;
}

.crossword-cell--blocked {
	background: var(--ww-block);
	cursor: default;
	pointer-events: none;
}

.crossword-cell--active-word {
	background: var(--ww-active);
}

.crossword-cell--active {
	background: var(--ww-active-cell);
	box-shadow: inset 0 0 0 2px var(--ww-ink);
	z-index: 1;
}

.crossword-cell--incorrect {
	box-shadow: inset 0 0 0 2px var(--ww-error);
}

.crossword-cell--incorrect::after {
	content: "";
	position: absolute;
	right: 3px;
	bottom: 3px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ww-error);
}

.crossword-cell--revealed .cell-letter {
	color: var(--ww-reveal);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.crossword-cell.is-complete-lock {
	cursor: default;
}

.crossword-grid--celebrating .crossword-cell--active,
.crossword-grid--celebrating .crossword-cell--active-word {
	box-shadow: none;
}

.crossword-cell--celebrate-line:not(.crossword-cell--blocked) {
	background: linear-gradient(180deg, #ffe9a0 0%, #efd56a 100%) !important;
	box-shadow: inset 0 0 0 1px #5c4500;
	transition: background 0.12s ease, box-shadow 0.12s ease;
}

.crossword-grid--celebrate-flash {
	animation: wordweave-grid-flash 0.48s ease;
}

.crossword-grid--celebrate-flash .crossword-cell--celebrate-line:not(.crossword-cell--blocked) {
	background: linear-gradient(180deg, #fff6d0 0%, #ffd94d 45%, #e8c547 100%) !important;
	box-shadow: inset 0 0 0 2px #a67c00, 0 0 12px rgba(232, 197, 71, 0.65);
}

@keyframes wordweave-grid-flash {
	0% {
		filter: brightness(1);
		transform: scale(1);
	}
	40% {
		filter: brightness(1.12);
		transform: scale(1.015);
	}
	100% {
		filter: brightness(1);
		transform: scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.crossword-grid--celebrate-flash {
		animation: none;
	}
}

.clue-number {
	position: absolute;
	top: 2px;
	left: 3px;
	font-size: clamp(8px, 1.6vw, 11px);
	line-height: 1;
	font-weight: 600;
	color: #333;
	pointer-events: none;
	z-index: 2;
}

.cell-letter {
	font-size: clamp(14px, 4.2vw, 28px);
	font-weight: 700;
	line-height: 1;
	color: #111;
	text-transform: uppercase;
	pointer-events: none;
}

/* Desktop on-screen QWERTY (touch / no hardware keyboard). Mobile shell keeps
   its own fit styles in wordweave-mobile.css. */
.wordweave-page:not(.wordweave-page--mobile) .wordweave-soft-keyboard {
	max-width: 480px;
	margin: 12px auto 0;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-soft-keyboard__toolbar {
	display: flex;
	margin-bottom: 8px;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-soft-keyboard__toolbar .reading-toolbar-btn {
	flex: 1 1 auto;
	width: 100%;
	justify-content: center;
	box-sizing: border-box;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-soft-keyboard__toolbar .reading-toolbar-btn[hidden] {
	display: none !important;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
	padding: 10px 8px;
	border-radius: 10px;
	background: linear-gradient(180deg, #f3e6c0 0%, #e8d49a 100%);
	border: 1px solid #d4bc72;
	box-shadow: inset 0 1px 0 rgba(255, 253, 246, 0.55);
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard[hidden] {
	display: none !important;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__row {
	display: flex;
	justify-content: center;
	gap: 5px;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__row:nth-child(2) {
	padding: 0 12px;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__key {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 0;
	max-width: 40px;
	min-height: 44px;
	padding: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
	color: var(--ww-gold);
	background: linear-gradient(180deg, #fffdf8 0%, #f3e8c8 100%);
	border: 1px solid #c9a85a;
	border-radius: 7px;
	box-shadow:
		0 1px 0 rgba(92, 69, 0, 0.18),
		0 2px 3px rgba(92, 69, 0, 0.12),
		inset 0 1px 0 rgba(255, 255, 255, 0.85);
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	cursor: pointer;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__row:nth-child(2) .wordweave-mobile-keyboard__key {
	max-width: 38px;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__key--action {
	flex: 1.35 1 0;
	max-width: 52px;
	font-size: 14px;
	background: linear-gradient(180deg, #f7efd6 0%, #e6d39a 100%);
	border-color: #b8943a;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__key:hover,
.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__key:focus {
	background: linear-gradient(180deg, #fffef9 0%, #f7ecc8 100%);
	border-color: var(--ww-gold);
	outline: none;
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__key:active {
	background: linear-gradient(180deg, #e8d9a8 0%, #dfc88a 100%);
	box-shadow:
		0 0 0 rgba(92, 69, 0, 0),
		inset 0 1px 2px rgba(92, 69, 0, 0.22);
	transform: translateY(1px);
}

.wordweave-page:not(.wordweave-page--mobile) .wordweave-mobile-keyboard__key:disabled {
	opacity: 0.45;
	cursor: default;
	box-shadow: none;
	transform: none;
}

.wordweave-controls.game-controls {
	max-width: 480px;
	margin: 14px auto 0;
}

.wordweave-control-btn {
	gap: 5px;
	min-height: 72px;
	padding: 10px 8px;
	color: var(--ww-ink);
	background: linear-gradient(180deg, #fffdf6 0%, #fbf3d8 100%);
	border: 1px solid #e0c96a;
	border-radius: 10px;
	box-shadow: 0 2px 0 #d4b84a, 0 3px 8px rgba(92, 69, 0, 0.08);
	transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.wordweave-control-btn .game-control-icon {
	font-size: 20px;
	line-height: 1;
	color: var(--ww-gold-dark);
}

.wordweave-control-btn .game-control-label {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.wordweave-control-btn .game-control-cost {
	font-size: 11px;
	font-weight: 600;
	color: #8a7420;
}

.wordweave-control-btn:hover,
.wordweave-control-btn:focus {
	background: linear-gradient(180deg, #fffef8 0%, #f5e6b8 100%);
	border-color: var(--ww-gold);
	box-shadow: 0 2px 0 #5c4500, 0 4px 10px rgba(92, 69, 0, 0.12);
	outline: none;
}

.wordweave-control-btn:active:not(:disabled) {
	transform: translateY(1px);
	box-shadow: 0 1px 0 #d4b84a;
}

.wordweave-control-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
	box-shadow: none;
}

.wordweave-control-btn--check .game-control-icon {
	color: #2f7a3e;
}

.wordweave-control-btn--reveal .game-control-icon {
	color: var(--ww-gold-dark);
}

.wordweave-control-btn--clear .game-control-icon {
	color: #9a4a3a;
}

.wordweave-message {
	min-height: 1.25em;
	margin-top: 10px;
	text-align: center;
	font-size: 14px;
	color: var(--ww-gold-dark);
}

.wordweave-results {
	margin-top: 14px;
	padding: 12px;
	border-radius: 8px;
	background: var(--ww-mist);
	border: 1px solid #ead9a0;
}

.wordweave-results-list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px 12px;
	font-size: 13px;
	color: var(--ww-ink);
}

.wordweave-clues {
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-height: 640px;
	overflow: auto;
}

.wordweave-clue-heading {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ww-ink);
}

.wordweave-clue-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wordweave-clue-item {
	display: block;
	width: 100%;
	text-align: left;
	padding: 6px 8px;
	margin: 0 0 2px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.35;
	color: var(--ww-ink);
}

.wordweave-clue-item:hover,
.wordweave-clue-item:focus {
	background: var(--ww-mist);
	outline: none;
}

.wordweave-clue-item.is-active {
	background: var(--ww-active);
	font-weight: 600;
}

.wordweave-clue-item.is-filled {
	opacity: 0.78;
}

.wordweave-clue-num {
	font-weight: 700;
	margin-right: 6px;
}

.wordweave-reveal-actions {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px;
	align-items: center;
}

.wordweave-page.wordweave--completed .crossword-grid {
	box-shadow: 0 0 0 3px var(--ww-gold-light);
}

/* Weave modals: gold chrome + Gemini actions */
.wordweave-page .reading-modal-header {
	background: linear-gradient(120deg, #5c4500 0%, #7a5c00 55%, #a67c00 100%);
	color: #fffdf6;
}

.wordweave-page .reading-modal-header h2,
.wordweave-page .reading-modal-header .yws-game-rankings-modal-lede {
	color: #fffdf6;
}

.wordweave-page .reading-modal-header .yws-game-rankings-modal-lede {
	margin: 6px 0 0;
	opacity: 0.9;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.35;
}

.wordweave-page .reading-modal-actions {
	background: var(--ww-mist);
	border-top: 1px solid #ead9a0;
}

.wordweave-page .reading-modal-body .gemini-hint {
	margin-top: 10px;
	color: #7a6520;
}

.wordweave-page .reading-modal-actions .gemini-btn.gemini-btn--primary {
	background: #5c4500 !important;
	border-color: #3d3200 !important;
	color: #fffdf6 !important;
}

.wordweave-page .reading-modal-actions .gemini-btn.gemini-btn--primary:hover,
.wordweave-page .reading-modal-actions .gemini-btn.gemini-btn--primary:focus {
	background: #7a5c00 !important;
	border-color: #5c4500 !important;
	color: #fffdf6 !important;
}

/* Rankings modal: golden accents */
.wordweave-page #wordweave-rankings-modal.yws-game-rankings-modal {
	--wb-accent: var(--ww-gold);
	--wb-accent-dark: #3d3200;
	--wb-accent-light: var(--ww-mist);
	--wb-accent-border: #ead9a0;
	--wb-accent-muted: var(--ww-gold-light);
	--wb-accent-text: var(--ww-gold);
	--wb-accent-soft: var(--ww-cream);
}

.wordweave-page #wordweave-rankings-modal .yws-game-rankings-row--self {
	background: linear-gradient(135deg, rgba(245, 230, 184, 0.7) 0%, rgba(255, 253, 246, 0.95) 100%);
	border-color: #ead9a0;
	box-shadow: inset 3px 0 0 #5c4500, 0 2px 8px rgba(92, 69, 0, 0.1);
}

.wordweave-page #wordweave-rankings-modal .yws-game-rankings-row__rank {
	color: var(--ww-gold);
	background: rgba(92, 69, 0, 0.12);
}

.wordweave-page #wordweave-rankings-modal .yws-game-rankings-player__avatar--placeholder {
	background: var(--ww-gold);
	color: #fffdf6;
}

.wordweave-page #wordweave-rankings-modal .yws-game-rankings-empty-card__title {
	color: var(--ww-gold);
}

@media (max-width: 860px) {
	.wordweave-layout {
		grid-template-columns: 1fr;
	}

	.crossword-grid-wrap {
		max-width: min(480px, calc(100vw - 48px));
	}

	.wordweave-clues {
		max-height: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.crossword-cell,
	.wordweave-clue-item {
		transition: none;
	}
}
