/* दर्शन पहेली board. */

.sb-jigsaw,
.sb-jigsaw-win {
	--sb-jigsaw-primary: linear-gradient(160deg, #5a1d0e 0%, #7a2e14 55%, #a4471d 100%);
	--sb-jigsaw-primary-solid: #7a2e14;
}

.sb-jigsaw-stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin: 12px 0;
}

.sb-jigsaw-stat {
	padding: 8px 6px;
	border: 1px solid rgba(179, 104, 40, .16);
	border-radius: 14px;
	background: #fffdf8;
	text-align: center;
}

.sb-jigsaw-stat small {
	display: block;
	color: #9a7250;
	font-size: 10.5px;
	letter-spacing: .04em;
}

.sb-jigsaw-stat b {
	display: block;
	margin-top: 2px;
	color: #7d3f14;
	font-size: 16px;
}

.sb-jigsaw-stat--correct {
	border-color: #a8d1ac;
	background: #eef8ef;
	transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.sb-jigsaw-stat--correct small,
.sb-jigsaw-stat--correct b {
	color: #28733a;
}

.sb-jigsaw-stat--correct.is-gain {
	border-color: #4ca45f;
	background: #dff3e2;
	box-shadow: 0 0 0 3px rgba(76, 164, 95, .18);
	transform: translateY(-2px);
}

.sb-jigsaw-stat--correct.is-loss {
	border-color: #cf6658;
	background: #fde7e3;
	box-shadow: 0 0 0 3px rgba(207, 102, 88, .16);
}

.sb-jigsaw-stat--correct.is-loss small,
.sb-jigsaw-stat--correct.is-loss b {
	color: #a23d32;
}

/* Picture chooser - rounded, at the top: pick whose darshan to assemble. */
.sb-jigsaw-scenes {
	display: flex;
	gap: 12px;
	margin-bottom: 12px;
	padding-bottom: 4px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.sb-jigsaw-scenes::-webkit-scrollbar {
	display: none;
}

.sb-jigsaw-scene {
	display: flex;
	flex: 0 0 auto;
	width: 64px;
	padding: 0;
	flex-direction: column;
	align-items: center;
	gap: 5px;
	border: none;
	background: none;
	cursor: pointer;
}

.sb-jigsaw-scene img {
	display: block;
	width: 58px;
	height: 58px;
	padding: 2px;
	border: 2px solid #e2c39c;
	border-radius: 50%;
	background: #fff;
	object-fit: cover;
}

.sb-jigsaw-scene.is-active img {
	border-color: #ec8f2f;
	box-shadow: 0 0 0 3px rgba(242, 166, 74, .26);
}

.sb-jigsaw-scene span {
	width: 100%;
	overflow: hidden;
	color: #8a4b1c;
	font-size: 10px;
	line-height: 1.25;
	text-align: center;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sb-jigsaw-scene.is-active span {
	color: #a2551f;
	font-weight: 800;
}

/* The "see the whole picture" button sits right above the board, centred and
   gold, so it reads as the help it is. */
.sb-jigsaw-peek-button {
	display: block;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid rgba(255, 227, 180, .6);
	border-radius: 999px;
	background: var(--sb-jigsaw-primary);
	color: #fff6e6;
	font-size: 13.5px;
	font-weight: 800;
	cursor: pointer;
	box-shadow: 0 8px 20px rgba(90, 29, 14, .28);
}

.sb-jigsaw-board-actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	margin: 12px 0 14px;
}

.sb-jigsaw-board-actions .sb-jigsaw-button {
	width: 100%;
	min-height: 48px;
}

.sb-jigsaw-button--secondary {
	border-color: #d7ad79;
	background: linear-gradient(145deg, #fffaf0, #f1ddbf);
	box-shadow: 0 5px 14px rgba(90, 29, 14, .1);
	color: #762c17;
}

.sb-jigsaw-peek-button span {
	font-size: 15px;
	vertical-align: -1px;
}

.sb-jigsaw-section-divider {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 2px 0 0;
	color: var(--sb-muted, #96725a);
	font-size: 11px;
	font-weight: 800;
	white-space: nowrap;
}

.sb-jigsaw-section-divider::before,
.sb-jigsaw-section-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgba(122, 46, 20, .3));
}

.sb-jigsaw-section-divider::after {
	background: linear-gradient(90deg, rgba(122, 46, 20, .3), transparent);
}

/* The play area is a FIXED box. The board inside it is sized by JS to the
   picture's own proportion and centred here, so a tall photo and a square one
   both play in the same space and the page never grows to the image's height. */
.sb-jigsaw-area {
	position: relative;
	display: grid;
	place-items: center;
	width: 100%;
	/* The cap is what keeps a very tall photo from taking over the page. The
	   actual height is set by JS to the fitted board, so a square or wide
	   picture leaves no dead space under it. */
	max-height: none;
	height: min(46dvh, 430px);
	margin-bottom: 10px;
}

.sb-jigsaw-board {
	display: grid;
	box-sizing: border-box;
	min-width: 0;
	min-height: 0;
	gap: 2px;
	padding: 2px;
	border-radius: 16px;
	background: rgba(179, 104, 40, .22);
	box-shadow: 0 14px 34px rgba(120, 70, 30, .18);
	overflow: hidden;
	touch-action: manipulation;
}

.sb-jigsaw-tile {
	position: relative;
	min-width: 0;
	min-height: 0;
	padding: 0;
	border: none;
	border-radius: 3px;
	background-color: #f6e7cf;
	background-repeat: no-repeat;
	cursor: pointer;
	transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
	-webkit-tap-highlight-color: transparent;
}

.sb-jigsaw-tile.is-correct::after {
	content: "✓";
	position: absolute;
	inset: 0;
	display: flex;
	padding: 5px 6px;
	align-items: flex-start;
	justify-content: flex-end;
	box-sizing: border-box;
	box-shadow: inset 0 0 0 3px rgba(54, 145, 72, .82);
	color: #21823a;
	font-size: 17px;
	font-weight: 900;
	line-height: 1;
	text-shadow: 0 1px 2px #fff, 0 0 5px #fff;
	pointer-events: none;
}

.sb-jigsaw-tile.is-selected {
	z-index: 2;
	transform: scale(.93);
	box-shadow: inset 0 0 0 3px var(--sb-jigsaw-primary-solid), 0 0 0 2px rgba(90, 29, 14, .35);
	filter: brightness(1.08);
}

/* These two are display:grid below, which would otherwise beat the browser's
   own [hidden] rule and leave them permanently on screen. */
.sb-jigsaw-peek[hidden],
.sb-jigsaw-win[hidden] {
	display: none;
}

.sb-jigsaw-peek {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	z-index: 3;
	padding: 12px;
	box-sizing: border-box;
	overflow: hidden;
	border-radius: 16px;
	background: rgba(60, 32, 12, .82);
}

.sb-jigsaw-peek img {
	display: block;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	object-fit: contain;
	border-radius: 12px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, .38);
}

.sb-jigsaw.is-loading .sb-jigsaw-board {
	opacity: .35;
}

/* The one line of guidance, directly under the button and above the board. */
.sb-jigsaw-status {
	display: flex;
	height: 80px;
	min-height: 80px;
	margin: 10px 0 12px;
	padding: 10px 12px;
	border: 1px solid rgba(169, 80, 37, .28);
	border-left: 4px solid var(--sb-jigsaw-primary-solid);
	border-radius: 12px;
	background: #fff6e9;
	box-shadow: 0 5px 14px rgba(79, 47, 32, .08);
	color: var(--sb-heading, #4f2f20);
	font-size: 13px;
	font-weight: 700;
	line-height: 1.55;
	align-items: center;
	box-sizing: border-box;
	text-align: left;
}

.sb-jigsaw-levels {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin: 12px 0 10px;
}

.sb-jigsaw-level {
	padding: 10px 6px;
	border: 1px solid rgba(179, 104, 40, .22);
	border-radius: 13px;
	background: #fffdf8;
	color: #8a4b1c;
	font-size: 12.5px;
	font-weight: 700;
	cursor: pointer;
}

.sb-jigsaw-level.is-active {
	border-color: transparent;
	background: var(--sb-jigsaw-primary);
	color: #fff6e6;
}

.sb-jigsaw-button--wide {
	display: block;
	width: 100%;
}

.sb-jigsaw-button {
	padding: 12px 10px;
	border: 1px solid rgba(179, 104, 40, .22);
	border-radius: 14px;
	background: #fffdf8;
	color: #8a4b1c;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
}

.sb-jigsaw-button--primary {
	border-color: transparent;
	background: var(--sb-jigsaw-primary);
	color: #fff6e6;
}

/* Finished */
.sb-jigsaw-win {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: grid;
	place-items: center;
	padding: 20px;
	background: rgba(60, 32, 12, .72);
}

.sb-jigsaw-win-card {
	position: relative;
	width: min(360px, 100%);
	padding: 26px 20px;
	border: 1px solid rgba(255, 227, 180, .5);
	border-radius: 22px;
	background: linear-gradient(170deg, #fffaf1, #fdeed8);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
	text-align: center;
}

.sb-jigsaw-win-close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: grid;
	width: 38px;
	height: 38px;
	padding: 0;
	place-items: center;
	border: 1px solid rgba(90, 29, 14, .18);
	border-radius: 50%;
	background: #f4e5d2;
	color: #6f2815;
	font-size: 25px;
	line-height: 1;
	cursor: pointer;
}

.sb-jigsaw-win-icon {
	font-size: 54px;
	line-height: 1;
}

.sb-jigsaw-win-card h2 {
	margin: 8px 0 6px;
	color: #7d3f14;
	font-size: 21px;
}

.sb-jigsaw-win-card p {
	margin: 0 0 16px;
	color: #9a7250;
	font-size: 13px;
	line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
	.sb-jigsaw-tile { transition: none; }
}
