:root {
	--bg-0: #0a0e1f;
	--bg-1: #111733;
	--card: rgba(23, 30, 56, 0.72);
	--card-border: rgba(148, 163, 255, 0.14);
	--cell: rgba(17, 23, 48, 0.55);
	--cell-hover: rgba(99, 110, 180, 0.16);
	--line-soft: rgba(120, 130, 190, 0.18);
	--line-strong: rgba(160, 172, 235, 0.55);
	--text: #eef1ff;
	--muted: #9aa4d4;
	--given: #f4f6ff;
	--filled: #6ea8ff;
	--accent: #7c9cff;
	--accent-2: #56e0ff;
	--accent-glow: rgba(124, 156, 255, 0.45);
	--peer: rgba(124, 156, 255, 0.10);
	--same: rgba(86, 224, 255, 0.20);
	--conflict: #ff7a92;
	--conflict-soft: rgba(255, 122, 146, 0.16);
	--wrong: #ffa94d;
	--wrong-soft: rgba(255, 169, 77, 0.16);
	--win: #5ef0c0;
	--shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.7);
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	color: var(--text);
	font-family: 'Inter', system-ui, -apple-system, sans-serif;
	padding: 16px 10px 28px;
	background:
		radial-gradient(900px 600px at 12% -8%, rgba(124, 92, 255, 0.28), transparent 60%),
		radial-gradient(800px 600px at 100% 0%, rgba(56, 224, 255, 0.18), transparent 55%),
		radial-gradient(900px 700px at 50% 120%, rgba(124, 156, 255, 0.16), transparent 60%),
		linear-gradient(160deg, var(--bg-1), var(--bg-0));
	background-attachment: fixed;
}

.app {
	width: 100%;
	max-width: 560px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 18px;
	border-radius: 22px;
	background: var(--card);
	border: 1px solid var(--card-border);
	box-shadow: var(--shadow);
	backdrop-filter: blur(18px) saturate(140%);
	-webkit-backdrop-filter: blur(18px) saturate(140%);
	animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
	from { opacity: 0; transform: translateY(16px) scale(0.98); }
	to { opacity: 1; transform: none; }
}

.topbar {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
}

.brand h1 {
	margin: 0;
	font-family: 'Sora', 'Inter', sans-serif;
	font-size: 34px;
	font-weight: 800;
	letter-spacing: 0.5px;
	background: linear-gradient(120deg, #fff 10%, var(--accent) 55%, var(--accent-2));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}

.tagline {
	margin: 2px 0 0;
	font-size: 12.5px;
	color: var(--muted);
	letter-spacing: 0.6px;
}

.meta {
	display: flex;
	gap: 12px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	font-size: 10.5px;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 1.2px;
	font-weight: 600;
}

.timer {
	font-variant-numeric: tabular-nums;
	font-size: 22px;
	font-weight: 700;
	color: var(--text);
	font-family: 'Sora', sans-serif;
}

.difficulty {
	appearance: none;
	-webkit-appearance: none;
	background: rgba(124, 156, 255, 0.10);
	color: var(--text);
	border: 1px solid var(--card-border);
	border-radius: 10px;
	padding: 7px 30px 7px 12px;
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
	background-position: calc(100% - 16px) center, calc(100% - 11px) center;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.difficulty:hover {
	border-color: var(--accent);
}

.board-wrap {
	padding: 0;
	display: contents;
}

.board {
	display: grid;
	grid-template-columns: repeat(9, 1fr);
	gap: 0;
	background: transparent;
	border: 2px solid var(--line-strong);
	border-radius: 14px;
	overflow: hidden;
	aspect-ratio: 1 / 1;
}

.cell {
	position: relative;
	background: var(--cell);
	border-right: 1px solid var(--line-soft);
	border-bottom: 1px solid var(--line-soft);
	color: var(--filled);
	font-family: 'Sora', 'Inter', sans-serif;
	font-size: clamp(18px, 5.4vw, 27px);
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	transition: background 0.13s ease, color 0.13s ease, box-shadow 0.13s ease;
	font-variant-numeric: tabular-nums;
	outline: none;
}

.cell:nth-child(9n) {
	border-right: none;
}

.cell:nth-child(n+73) {
	border-bottom: none;
}

.cell:nth-child(9n+3),
.cell:nth-child(9n+6) {
	border-right: 2px solid var(--line-strong);
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
	border-bottom: 2px solid var(--line-strong);
}

.cell:hover {
	background: var(--cell-hover);
}

.cell.status-given {
	color: var(--given);
	cursor: default;
}

.cell.status-filled {
	color: var(--filled);
}

@keyframes shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-2px); }
	75% { transform: translateX(2px); }
}

.cell.highlighted {
	background: var(--peer);
}

.cell.same-value {
	background: var(--same);
	color: var(--accent-2);
}

.cell.selected {
	background: rgba(124, 156, 255, 0.20);
	color: var(--text);
	box-shadow: inset 0 0 0 2px var(--accent), 0 0 16px var(--accent-glow);
	z-index: 2;
	animation: pop 0.18s ease;
}

.cell.status-wrong,
.cell.status-wrong.same-value,
.cell.status-wrong.selected {
	color: var(--wrong);
	background: var(--wrong-soft);
}

.cell.status-conflict,
.cell.status-conflict.same-value,
.cell.status-conflict.selected {
	color: var(--conflict);
	background: var(--conflict-soft);
	animation: shake 0.32s ease;
}

@keyframes pop {
	from { transform: scale(0.92); }
	to { transform: scale(1); }
}

.notes {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	width: 100%;
	height: 100%;
	padding: 2px;
}

.notes span {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: clamp(8px, 2vw, 11px);
	font-weight: 500;
	color: var(--muted);
	font-family: 'Inter', sans-serif;
}

.board.solved .cell {
	color: var(--win) !important;
	animation: glow 1.4s ease infinite alternate;
}

@keyframes glow {
	from { box-shadow: none; }
	to { box-shadow: inset 0 0 14px rgba(94, 240, 192, 0.25); }
}

.status {
	min-height: 22px;
	margin: 0;
	text-align: center;
	font-size: 17px;
	font-weight: 600;
	color: var(--muted);
	transition: color 0.2s ease;
}

.status.won {
	color: var(--win);
	font-family: 'Sora', sans-serif;
	font-weight: 700;
	animation: pop 0.4s ease;
}

.numberpad {
	display: grid;
	grid-template-columns: repeat(9, 1fr);
	gap: 7px;
}

.pad-btn {
	position: relative;
	background: linear-gradient(180deg, rgba(124, 156, 255, 0.12), rgba(124, 156, 255, 0.04));
	border: 1px solid var(--card-border);
	border-radius: 12px;
	color: var(--text);
	padding: 11px 0 15px;
	cursor: pointer;
	transition: transform 0.06s ease, background 0.13s ease, border-color 0.13s ease, box-shadow 0.13s ease;
}

.pad-btn:hover {
	background: linear-gradient(180deg, rgba(124, 156, 255, 0.26), rgba(124, 156, 255, 0.10));
	border-color: var(--accent);
	box-shadow: 0 6px 18px -8px var(--accent-glow);
}

.pad-btn:active {
	transform: translateY(2px);
}

.pad-btn.exhausted {
	opacity: 0.32;
	box-shadow: none;
}

.pad-digit {
	font-family: 'Sora', sans-serif;
	font-size: 22px;
	font-weight: 700;
}

.pad-count {
	position: absolute;
	bottom: 4px;
	left: 0;
	right: 0;
	text-align: center;
	font-size: 9.5px;
	font-weight: 600;
	color: var(--muted);
}

.controls {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 9px;
}

.action {
	background: rgba(124, 156, 255, 0.10);
	border: 1px solid var(--card-border);
	border-radius: 12px;
	color: var(--text);
	padding: 13px 0;
	font-size: 14.5px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: transform 0.06s ease, background 0.13s ease, border-color 0.13s ease, box-shadow 0.13s ease;
}

.action:hover {
	background: rgba(124, 156, 255, 0.20);
	border-color: var(--accent);
}

.action:active {
	transform: translateY(1px);
}

.action.new-game {
	background: linear-gradient(135deg, var(--accent), var(--accent-2));
	border-color: transparent;
	color: #08122e;
	font-weight: 700;
	box-shadow: 0 10px 24px -10px var(--accent-glow);
}

.action.new-game:hover {
	filter: brightness(1.08);
}

.action.notes-toggle.active {
	background: linear-gradient(135deg, rgba(86, 224, 255, 0.28), rgba(124, 156, 255, 0.22));
	border-color: var(--accent-2);
	color: var(--accent-2);
	box-shadow: inset 0 0 0 1px rgba(86, 224, 255, 0.4);
}

.help {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 14px;
	color: var(--muted);
	font-size: 12.5px;
}

.credit {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 5px;
	margin: 0;
	color: var(--muted);
	font-size: 12.5px;
}

.credit .heart {
	color: var(--conflict);
	vertical-align: -2px;
}

.credit a {
	color: var(--accent);
	text-decoration: none;
	font-weight: 600;
}

.credit a:hover {
	text-decoration: underline;
}

kbd {
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid var(--card-border);
	border-bottom-width: 2px;
	border-radius: 6px;
	padding: 1px 6px;
	font-family: 'Inter', sans-serif;
	font-size: 11.5px;
	color: var(--text);
}

@media (max-width: 430px) {
	body {
		padding: 0;
		align-items: stretch;
	}

	.help {
		display: none;
	}

	.app {
		width: 100%;
		max-width: none;
		min-height: 100vh;
		min-height: 100dvh;
		padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
		padding-top: calc(14px + env(safe-area-inset-top));
		gap: 12px;
		border: none;
		border-radius: 0;
		background: transparent;
		box-shadow: none;
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
	}

	.board {
		margin-left: -12px;
		margin-right: -12px;
		margin-top: auto;
		margin-bottom: auto;
		border-radius: 0;
	}

	.topbar {
		flex-direction: column;
		align-items: flex-start;
		gap: 12px;
	}

	.meta {
		width: 100%;
		justify-content: space-between;
	}

	.numberpad {
		gap: 5px;
	}

	.controls {
		gap: 6px;
	}

	.action {
		font-size: 13px;
		padding: 12px 0;
	}
}
