:root {
	--spider-red: #e22a35;
	--spider-blue: #1467c8;
	--spider-ink: #f5f8ff;
	--spider-night: #07111f;
	--spider-night-soft: #102746;
	--spider-yellow: #ffd94a;
	--spider-green: #1fbf8e;
	--comic-font: Righteous, Coiny, Nunito, "Trebuchet MS", sans-serif;
	--body-font: Nunito, "Trebuchet MS", Verdana, sans-serif;
}

#app {
	min-height: 100svh;
	background:
		radial-gradient(circle at 72% 14%, rgba(226, 42, 53, 0.26), transparent 28%),
		radial-gradient(circle at 12% 22%, rgba(20, 103, 200, 0.4), transparent 32%),
		linear-gradient(180deg, rgba(8, 19, 34, 0.15), rgba(1, 6, 14, 0.55)),
		linear-gradient(155deg, #102746 0%, #07111f 50%, #020710 100%);
	color: var(--spider-ink);
	font-family: var(--body-font);
	overflow: hidden;
}

.spiderblocks {
	position: relative;
	min-height: 100svh;
	padding: clamp(10px, 2vw, 22px);
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	gap: 10px;
}

.spiderblocks::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background-image:
		radial-gradient(circle, rgba(255, 255, 255, 0.13) 0 1.5px, transparent 2px),
		linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
		linear-gradient(0deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
	background-size: 18px 18px, 58px 58px, 58px 58px;
	mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.76), transparent 76%);
}

.spiderblocks-topbar {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.spiderblocks-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.spiderblocks-mark {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background:
		radial-gradient(circle at 50% 38%, #ffffff 0 12%, transparent 13%),
		linear-gradient(135deg, var(--spider-red), #a51624 58%, var(--spider-blue) 59%);
	border: 3px solid #f7fbff;
	box-shadow: 0 8px 18px rgba(0, 0, 0, 0.36), 0 0 0 2px rgba(255, 217, 74, 0.28);
}

.spiderblocks h1 {
	margin: 0;
	font: 900 clamp(28px, 4.8vw, 48px)/0.95 var(--comic-font);
	color: #ffffff;
	text-shadow: 3px 3px 0 #07111f, 5px 5px 0 rgba(226, 42, 53, 0.72);
}

.spiderblocks-score {
	font-size: clamp(15px, 2.2vw, 19px);
	font-weight: 900;
	color: #ffd94a;
	white-space: nowrap;
	text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

.spiderblocks-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	flex-wrap: wrap;
}

.spiderblocks button {
	min-height: 42px;
	border: 0;
	border-radius: 8px;
	padding: 10px 14px;
	background: #ffd94a;
	color: #07111f;
	font: 900 15px/1 var(--comic-font);
	box-shadow: 0 5px 0 #a77713, 0 10px 18px rgba(0, 0, 0, 0.28);
	cursor: pointer;
	touch-action: manipulation;
}

.spiderblocks button:hover {
	transform: translateY(-1px);
}

.spiderblocks button:focus-visible,
.letter-block:focus-visible {
	outline: 4px solid rgba(255, 212, 71, 0.88);
	outline-offset: 3px;
}

.spiderblocks button[aria-pressed="true"] {
	background: #e22a35;
	color: #ffffff;
	box-shadow: 0 5px 0 #7f1420, 0 10px 18px rgba(0, 0, 0, 0.28);
}

.start-screen,
.loading-screen,
.error-screen {
	position: relative;
	z-index: 1;
	min-height: calc(100svh - clamp(20px, 4vw, 44px));
	display: grid;
	place-items: center;
}

.start-screen {
	grid-template-columns: minmax(260px, 0.95fr) minmax(280px, 0.72fr);
	gap: clamp(16px, 4vw, 54px);
	align-items: center;
	width: min(1120px, 100%);
	margin: 0 auto;
}

.start-hero {
	position: relative;
	width: min(100%, 620px);
	aspect-ratio: 1.2;
	display: grid;
	place-items: center;
}

.start-hero .web-hero {
	left: 38%;
	top: 18%;
	width: clamp(112px, 18vw, 178px);
	animation: hero-swing 2.8s ease-in-out infinite alternate;
}

.start-web,
.loading-web {
	position: absolute;
	width: 78%;
	height: 78%;
	border-radius: 50%;
}

.start-web {
	background-color: transparent;
	box-shadow: none;
	background:
		radial-gradient(circle, transparent 0 17%, rgba(255, 255, 255, 0.82) 17.4% 18.2%, transparent 18.6% 31%, rgba(255, 255, 255, 0.76) 31.4% 32.2%, transparent 32.6% 45%, rgba(255, 255, 255, 0.7) 45.4% 46.2%, transparent 46.6% 59%, rgba(255, 255, 255, 0.64) 59.4% 60.2%, transparent 60.6%),
		linear-gradient(0deg, transparent 49.55%, rgba(255, 255, 255, 0.72) 49.55% 50.45%, transparent 50.45%),
		linear-gradient(30deg, transparent 49.55%, rgba(255, 255, 255, 0.66) 49.55% 50.45%, transparent 50.45%),
		linear-gradient(60deg, transparent 49.55%, rgba(255, 255, 255, 0.66) 49.55% 50.45%, transparent 50.45%),
		linear-gradient(90deg, transparent 49.55%, rgba(255, 255, 255, 0.72) 49.55% 50.45%, transparent 50.45%),
		linear-gradient(120deg, transparent 49.55%, rgba(255, 255, 255, 0.66) 49.55% 50.45%, transparent 50.45%),
		linear-gradient(150deg, transparent 49.55%, rgba(255, 255, 255, 0.66) 49.55% 50.45%, transparent 50.45%);
}

.loading-web {
	border: 4px solid rgba(255, 255, 255, 0.82);
	box-shadow: inset 0 0 0 2px rgba(117, 187, 255, 0.2), 0 0 28px rgba(255, 255, 255, 0.16);
}

.loading-web::before,
.loading-web::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 112%;
	height: 4px;
	background: rgba(255, 255, 255, 0.82);
	transform-origin: 0 50%;
}

.loading-web::before {
	transform: rotate(28deg) translateX(-50%);
}

.loading-web::after {
	transform: rotate(-28deg) translateX(-50%);
}

.start-web-b {
	display: none;
}

.start-blocks,
.loading-blocks {
	position: absolute;
	left: 8%;
	bottom: 7%;
	display: flex;
	gap: clamp(8px, 2vw, 14px);
}

.start-blocks span,
.loading-blocks span {
	width: clamp(58px, 8vw, 86px);
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	border-radius: 8px;
	background: #ffd447;
	box-shadow: inset -5px -7px 0 rgba(0, 0, 0, 0.13), 0 11px 0 #d8a62d, 0 17px 20px rgba(25, 38, 63, 0.18);
	font: 1000 clamp(32px, 5vw, 54px)/1 var(--comic-font);
	color: #07111f;
}

.start-blocks span:nth-child(2),
.loading-blocks span:nth-child(2) {
	background: #71d5ff;
	box-shadow: inset -5px -7px 0 rgba(0, 0, 0, 0.13), 0 11px 0 #3ca1cc, 0 17px 20px rgba(25, 38, 63, 0.18);
	transform: translateY(-18px) rotate(6deg);
}

.start-blocks span:nth-child(3),
.loading-blocks span:nth-child(3) {
	background: #ff8c94;
	box-shadow: inset -5px -7px 0 rgba(0, 0, 0, 0.13), 0 11px 0 #c75562, 0 17px 20px rgba(25, 38, 63, 0.18);
	transform: rotate(-8deg);
}

.start-panel,
.error-screen {
	width: min(100%, 430px);
	padding: clamp(18px, 3vw, 28px);
	border-radius: 8px;
	background:
		linear-gradient(135deg, rgba(16, 39, 70, 0.92), rgba(7, 17, 31, 0.9)),
		var(--spider-night-soft);
	border: 3px solid rgba(255, 217, 74, 0.7);
	box-shadow: 0 22px 54px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
	backdrop-filter: blur(10px);
}

.start-panel .spiderblocks-brand {
	margin-bottom: 22px;
}

.start-settings {
	display: grid;
	gap: 12px;
	margin-bottom: 20px;
}

.setting-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	min-height: 50px;
	padding: 9px 11px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.1);
	color: #f5f8ff;
	font-weight: 900;
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.setting-row select {
	max-width: 190px;
	border: 2px solid rgba(35, 92, 146, 0.18);
	border-radius: 8px;
	padding: 8px;
	background: #ffffff;
	font: 800 14px/1 Nunito, sans-serif;
	color: #17314e;
}

.setting-check input {
	width: 28px;
	height: 28px;
	accent-color: var(--spider-green);
}

.start-button {
	width: 100%;
	min-height: 58px !important;
	background: linear-gradient(135deg, var(--spider-red), #a51422) !important;
	color: #ffffff !important;
	font-size: 24px !important;
	text-shadow: 2px 2px 0 #07111f;
}

.loading-screen {
	gap: 12px;
	text-align: center;
}

.loading-scene {
	position: relative;
	width: min(74vw, 360px);
	aspect-ratio: 1;
}

.loading-scene .web-hero {
	left: 36%;
	top: 16%;
	width: clamp(92px, 22vw, 136px);
	animation: hero-swing 1.2s ease-in-out infinite alternate;
}

.loading-web {
	inset: 8%;
	animation: loading-spin 3.4s linear infinite;
}

.loading-blocks {
	left: 10%;
	bottom: 12%;
	transform: scale(0.72);
	transform-origin: left bottom;
}

.loading-text {
	font: 1000 clamp(28px, 5vw, 48px)/1 var(--comic-font);
	color: #ffffff;
	text-shadow: 3px 3px 0 #07111f, 5px 5px 0 rgba(226, 42, 53, 0.7);
}

.loading-dots {
	display: flex;
	gap: 8px;
}

.loading-dots span {
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: var(--spider-red);
	animation: dot-bounce 0.8s ease-in-out infinite alternate;
}

.loading-dots span:nth-child(2) {
	background: var(--spider-yellow);
	animation-delay: 0.12s;
}

.loading-dots span:nth-child(3) {
	background: var(--spider-blue);
	animation-delay: 0.24s;
}

.error-screen {
	text-align: center;
}

.error-screen .spiderblocks-mark {
	margin: 0 auto 10px;
}

.error-screen p {
	margin: 12px 0;
	font-size: 20px;
	font-weight: 900;
}

.error-detail {
	margin: 12px 0 18px;
	padding: 10px;
	border-radius: 8px;
	background: rgba(226, 42, 53, 0.16);
	color: #ffd9de;
	font: 800 14px/1.35 Nunito, sans-serif;
}

.error-actions {
	display: flex;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
}

.spiderblocks-main {
	position: relative;
	z-index: 1;
	min-height: 0;
	display: grid;
	grid-template-rows: minmax(230px, 1fr) minmax(210px, 32svh);
	gap: clamp(4px, 1.2vw, 12px);
}

.picture-stage {
	position: relative;
	min-height: 290px;
	display: grid;
	grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr);
	align-items: center;
	gap: clamp(10px, 3vw, 34px);
	border-radius: 0;
	overflow: hidden;
}

.picture-panel {
	display: grid;
	place-items: center;
	min-height: clamp(180px, 36svh, 390px);
}

.picture-card {
	position: relative;
	width: min(100%, 390px);
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	border-radius: 8px;
	overflow: hidden;
	background:
		radial-gradient(circle, rgba(255, 255, 255, 0.28) 0 2px, transparent 2.5px),
		linear-gradient(135deg, #ffd94a 0 52%, #f14b55 52% 100%);
	background-size: 18px 18px, auto;
	border: 4px solid #07111f;
	box-shadow:
		inset 0 0 0 5px rgba(255, 255, 255, 0.28),
		0 0 0 4px rgba(255, 217, 74, 0.55),
		0 18px 40px rgba(0, 0, 0, 0.34);
	cursor: pointer;
	touch-action: manipulation;
}

.picture-card::before {
	content: "";
	position: absolute;
	inset: -36%;
	background:
		repeating-conic-gradient(from -8deg at 50% 50%, rgba(255, 255, 255, 0.72) 0deg 8deg, rgba(20, 103, 200, 0.72) 8deg 16deg, rgba(255, 217, 74, 0.62) 16deg 24deg);
	opacity: 0.78;
	transform: rotate(-8deg);
}

.picture-card::after {
	content: "";
	position: absolute;
	inset: 10%;
	border-radius: 8px;
	background:
		radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.94) 0 48%, rgba(255, 255, 255, 0.72) 49% 64%, transparent 65%);
	box-shadow:
		inset 0 0 0 4px rgba(7, 17, 31, 0.16),
		0 0 0 3px rgba(7, 17, 31, 0.34);
}

.picture-emoji {
	position: relative;
	z-index: 1;
	font-size: clamp(92px, 20vw, 190px);
	filter: drop-shadow(0 14px 12px rgba(7, 17, 31, 0.34));
}

.word-area {
	display: grid;
	gap: clamp(12px, 2vw, 18px);
	align-content: center;
	justify-items: center;
}

.word-slots {
	display: flex;
	justify-content: center;
	gap: clamp(8px, 1.8vw, 16px);
	flex-wrap: wrap;
}

.word-slot {
	width: clamp(54px, 9vw, 92px);
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	border-radius: 8px;
	background: rgba(245, 248, 255, 0.88);
	border: 4px dashed rgba(255, 217, 74, 0.6);
	color: #12233c;
	font: 1000 clamp(28px, 5vw, 54px)/1 var(--comic-font);
	box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.86);
}

.word-slot.is-next {
	border-color: var(--spider-yellow);
	background: #fff4ba;
	box-shadow: 0 0 0 7px rgba(255, 217, 74, 0.3), 0 0 26px rgba(255, 217, 74, 0.22), inset 0 3px 0 rgba(255, 255, 255, 0.9);
}

.word-slot.is-hint::after {
	content: attr(data-letter);
	opacity: 0.25;
}

.word-slot.is-filled {
	border-style: solid;
	border-color: rgba(31, 159, 122, 0.55);
	background: #effdf6;
}

.word-text-hint {
	min-height: 32px;
	color: rgba(255, 255, 255, 0.3);
	font: 1000 clamp(28px, 5vw, 56px)/1 var(--comic-font);
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

.word-text-hint[hidden] {
	display: block;
	visibility: hidden;
}

.message {
	min-height: 34px;
	padding: 7px 13px;
	border-radius: 999px;
	background: rgba(7, 17, 31, 0.68);
	font-size: clamp(16px, 2.5vw, 23px);
	font-weight: 900;
	color: #ffffff;
	text-align: center;
	box-shadow: inset 0 0 0 2px rgba(255, 217, 74, 0.3);
}

.helper-layer {
	position: absolute;
	inset: 0;
	z-index: 12;
	pointer-events: none;
	overflow: visible;
}

.web-hero {
	position: absolute;
	left: -160px;
	top: 34%;
	width: clamp(88px, 13vw, 132px);
	height: auto;
	transform-origin: 50% -120px;
	filter: drop-shadow(0 14px 10px rgba(0, 0, 0, 0.42));
}

.web-line {
	position: absolute;
	left: 0;
	top: 0;
	width: 0;
	height: 5px;
	border-radius: 999px;
	background: repeating-linear-gradient(90deg, #ffffff 0 14px, #bfeaff 14px 20px);
	box-shadow: 0 0 10px rgba(255, 255, 255, 0.78), 0 1px 0 rgba(30, 70, 120, 0.18);
	transform-origin: 0 50%;
	opacity: 0;
}

.heap {
	position: relative;
	z-index: 2;
	min-height: 210px;
	padding: 0;
	overflow: hidden;
	background: transparent;
}

.spiderblocks .letter-block {
	--tilt: 0deg;
	--block-face: rgba(255, 255, 255, 0.25);
	--block-border: rgba(91, 57, 28, 0.16);
	--block-dot: rgba(255, 255, 255, 0.55);
	--block-letter-shadow: rgba(255, 255, 255, 0.42);
	position: absolute;
	left: 50%;
	top: 0;
	width: clamp(52px, 9vw, 82px);
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	border: 3px solid var(--block-border);
	border-radius: 9px;
	padding: 0;
	background:
		radial-gradient(circle at 18% 18%, var(--block-dot) 0 4px, transparent 5px),
		radial-gradient(circle at 82% 18%, var(--block-dot) 0 4px, transparent 5px),
		radial-gradient(circle at 18% 82%, rgba(0, 0, 0, 0.1) 0 3px, transparent 4px),
		linear-gradient(145deg, var(--block-face), transparent 42%),
		var(--block-color, #ffd447) !important;
	color: #07111f;
	font: 1000 clamp(34px, 7vw, 64px)/1 var(--comic-font);
	text-shadow: 0 2px 0 var(--block-letter-shadow);
	box-shadow:
		inset 0 0 0 4px rgba(255, 255, 255, 0.24),
		inset -7px -8px 0 rgba(0, 0, 0, 0.12),
		inset 5px 5px 0 rgba(255, 255, 255, 0.24),
		0 10px 0 var(--block-shadow, #d7a22d),
		0 17px 20px rgba(25, 38, 63, 0.18);
	transform: rotate(var(--tilt));
	cursor: pointer;
	user-select: none;
	touch-action: manipulation;
	will-change: left, top, transform;
}

.spiderblocks .letter-block:nth-child(3n + 1) {
	--block-color: #ffd76d;
	--block-shadow: #d4a84b;
	--block-border: rgba(137, 88, 31, 0.2);
}

.spiderblocks .letter-block:nth-child(3n + 2) {
	--block-color: #7fd7ff;
	--block-shadow: #449ec7;
	--block-border: rgba(26, 91, 128, 0.22);
}

.spiderblocks .letter-block:nth-child(3n + 3) {
	--block-color: #ff9da3;
	--block-shadow: #c95b66;
	--block-border: rgba(134, 40, 51, 0.22);
}

.spiderblocks .letter-block:nth-child(4n) {
	--block-color: #86dfa8;
	--block-shadow: #4aa76f;
	--block-border: rgba(35, 104, 63, 0.22);
}

.spiderblocks .letter-block::before {
	content: "";
	position: absolute;
	inset: 12%;
	border-radius: 6px;
	border: 3px solid rgba(255, 255, 255, 0.42);
	box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
	pointer-events: none;
}

.spiderblocks .letter-block::after {
	content: "";
	position: absolute;
	left: 15%;
	right: 15%;
	top: 9%;
	height: 12%;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.28);
	pointer-events: none;
}

.spiderblocks .letter-block:hover {
	filter: brightness(1.04);
	transform: none;
}

.spiderblocks .letter-block.is-used {
	visibility: hidden;
	pointer-events: none;
}

.spiderblocks .letter-block.is-prompted {
	animation: block-prompt 0.8s ease-in-out infinite alternate;
}

.flying-letter {
	position: fixed;
	z-index: 20;
	pointer-events: none;
}

.flying-letter.letter-block {
	font: 1000 clamp(34px, 7vw, 64px)/1 var(--comic-font);
}

.completion-burst {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	pointer-events: none;
	font-size: clamp(38px, 8vw, 84px);
	opacity: 0;
}

@keyframes block-prompt {
	from {
		transform: translateY(0) rotate(var(--tilt)) scale(1);
	}
	to {
		transform: translateY(-12px) rotate(var(--tilt)) scale(1.06);
	}
}

@keyframes hero-swing {
	from {
		transform: rotate(-9deg) translateY(0);
	}
	to {
		transform: rotate(9deg) translateY(10px);
	}
}

@keyframes loading-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes dot-bounce {
	from {
		transform: translateY(0);
	}
	to {
		transform: translateY(-10px);
	}
}

@media (max-width: 760px) {
	.spiderblocks {
		padding: 8px;
	}

	.start-screen {
		grid-template-columns: 1fr;
		gap: 8px;
		align-content: center;
	}

	.start-hero {
		width: min(100%, 360px);
		margin: 0 auto;
	}

	.start-panel {
		margin: 0 auto;
	}

	.spiderblocks-topbar {
		align-items: flex-start;
	}

	.spiderblocks-actions {
		max-width: 190px;
	}

	.spiderblocks button {
		min-height: 38px;
		padding: 9px 11px;
		font-size: 13px;
	}

	.picture-stage {
		grid-template-columns: 1fr;
		gap: 6px;
		min-height: 0;
	}

	.picture-panel {
		min-height: 142px;
	}

	.picture-card {
		width: min(48svh, 230px);
	}

	.web-hero {
		width: 82px;
	}

	.heap {
		min-height: 185px;
	}
}

@media (orientation: landscape) and (max-height: 640px) {
	.spiderblocks {
		padding-top: 6px;
		padding-bottom: 4px;
		gap: 4px;
	}

	.spiderblocks-main {
		grid-template-rows: minmax(160px, 1fr) minmax(230px, 40svh);
		gap: 0;
	}

	.picture-panel {
		min-height: 140px;
	}

	.picture-card {
		width: min(31svh, 250px);
	}

	.word-area {
		gap: 8px;
	}

	.heap {
		min-height: 230px;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}
