:root {
	--bg: #f4efe8;
	--panel: #fcf9f5;
	--key: #ffffff;
	--key-border: #d7cdc0;
	--key-shadow: rgba(49, 31, 13, 0.15);
	--text: #2a1f14;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	padding: 10px;
	font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
	background: radial-gradient(circle at top, #fff8ee, var(--bg));
	color: var(--text);
	overflow: hidden;
}

.start-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(20, 16, 12, 0.35);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	z-index: 20;
}

.start-overlay.hidden {
	display: none;
}

.start-button {
	border: 1px solid #2a1f14;
	background: #fff;
	color: #2a1f14;
	font-size: clamp(18px, 2.2vw, 30px);
	font-weight: 700;
	padding: 14px 30px;
	border-radius: 14px;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.start-button:hover {
	background: #f4f1ec;
}

.overlay-card {
	background: #fff;
	border: 1px solid #2a1f14;
	border-radius: 16px;
	padding: 28px 32px;
	min-width: clamp(260px, 32vw, 460px);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
	display: flex;
	flex-direction: column;
	gap: 16px;
	align-items: stretch;
}

.overlay-title {
	margin: 0;
	font-size: clamp(20px, 2.4vw, 32px);
	text-align: center;
}

.exercise-picker-label {
	font-size: clamp(14px, 1.5vw, 18px);
	font-weight: 600;
	text-align: left;
}

.exercise-picker {
	width: 100%;
	border: 1px solid #c9bbab;
	border-radius: 10px;
	padding: 12px 14px;
	font: inherit;
	color: #2a1f14;
	background: #fff;
}

.stats-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(20, 16, 12, 0.35);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	z-index: 30;
}

.stats-card {
	background: #fff;
	border: 1px solid #2a1f14;
	border-radius: 16px;
	padding: 32px 40px;
	min-width: clamp(240px, 30vw, 420px);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
	text-align: center;
}

.stats-title {
	margin: 0 0 24px 0;
	font-size: clamp(18px, 2.2vw, 28px);
	color: #2a1f14;
}

.stats-list {
	margin: 0 0 28px 0;
	padding: 0;
}

.stats-row {
	display: flex;
	justify-content: space-between;
	gap: 32px;
	padding: 10px 0;
	border-bottom: 1px solid #e8e0d8;
	font-size: clamp(14px, 1.6vw, 20px);
	color: #2a1f14;
}

.stats-row:last-child {
	border-bottom: none;
}

.stats-row dt {
	font-weight: 400;
}

.stats-row dd {
	margin: 0;
	font-weight: 700;
}

.stats-buttons {
	display: flex;
	margin-top: 4px;
	gap: 12px;
	justify-content: center;
}

.stats-close-button,
.stats-retry-button {
	font-size: clamp(14px, 1.5vw, 20px);
	font-weight: 700;
	padding: 10px 28px;
	border-radius: 10px;
	cursor: pointer;
}

.stats-close-button {
	border: 1px solid #2a1f14;
	background: #2a1f14;
	color: #fff;
}

.stats-close-button:hover {
	background: #3d2e1f;
}

.stats-retry-button {
	border: 1px solid #2a1f14;
	background: #fff;
	color: #2a1f14;
}

.stats-retry-button:hover {
	background: #f4f1ec;
}

.keyboard {
	position: relative;
	width: 100%;
	background: var(--panel);
	border: 1px solid #dfd4c6;
	border-radius: 18px;
	padding: clamp(8px, 1vw, 16px);
	box-shadow: 0 16px 36px rgba(78, 57, 35, 0.16);
	display: flex;
	flex-direction: column;
	gap: var(--gap, 8px);
}

.exercise-display {
	width: 100%;
	margin: 0 0 10px 0;
	padding: 12px 14px;
	border: 1px solid #2a1f14;
	border-radius: 12px;
	background: #fff;
	color: #000;
	font-size: 3vw;
	line-height: 1.35;
	letter-spacing: 0.02em;
	min-height: 56px;
	white-space: pre-wrap;
}

.exercise-display .done {
	color: #14873a;
}

.exercise-display .current {
	color: #d4a400;
	font-weight: 400;
}

.hand-overlay {
	position: absolute;
	pointer-events: none;
	top: 5%;
	height: auto;
	z-index: 5;
}

.hand-left {
	top: -2%;
	left: -10%;
	width: 78%;
}

.hand-right {
	top: -2%;
	right: -2%;
	width: 78%;
}

.row {
	display: flex;
	gap: var(--gap, 8px);
	align-items: flex-start;
	position: relative;
	height: var(--kh, 48px);
}

.key {
	width: var(--kw, 48px);
	height: var(--kh, 48px);
	padding: 0 clamp(4px, 0.5vw, 10px);
	border: 1px solid var(--key-border);
	border-radius: 12px;
	background: linear-gradient(#fff, #f2ece5);
	color: var(--text);
	font-size: 2vw;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: left;
	white-space: pre-wrap;
	line-height: 1.05;
	box-shadow: 0 3px 8px var(--key-shadow);
	user-select: none;
	flex: 0 0 auto;
	transition: background-color 80ms ease, box-shadow 80ms ease, transform 80ms ease;
}

.key.active {
	background: linear-gradient(#e8dfd3, #ded1c2);
	box-shadow: inset 0 2px 6px rgba(49, 31, 13, 0.18);
	transform: translateY(1px);
}

.key.target {
	outline: 3px solid #1c1610;
	outline-offset: -2px;
	background: linear-gradient(#efefef, #e3e3e3);
}

.key.enter.target::before {
	background: linear-gradient(#efefef, #e3e3e3);
}

.key.enter {
	--enter-cut-x-r: 0.26;
	--enter-cut-y-r: 0.45;
	--enter-h: calc(var(--kh, 48px) * 2 + var(--gap, 8px));
	position: relative;
	color: transparent;
	background: transparent;
	border-color: transparent;
	box-shadow: none;
	overflow: visible;
}

.key.enter::before {
	content: attr(data-label);
	position: absolute;
	top: 0;
	left: 0;
	width: var(--kw, 96px);
	height: var(--enter-h);
	box-sizing: border-box;
	border: 1px solid var(--key-border);
	border-radius: 12px;
	background: linear-gradient(#fff, #f2ece5);
	color: var(--text);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	white-space: pre-wrap;
	padding-top: calc(var(--kh, 48px) * 0.35);
	box-shadow: 0 3px 8px var(--key-shadow);
	clip-path: polygon(0 0, 100% 0, 100% 100%, calc(var(--enter-cut-x-r) * 100%) 100%, calc(var(--enter-cut-x-r) * 100%) calc(var(--enter-cut-y-r) * 100%), 0 calc(var(--enter-cut-y-r) * 100%));
	z-index: 3;
	transition: background-color 80ms ease, box-shadow 80ms ease, transform 80ms ease;
}

.key.enter.active::before {
	background: linear-gradient(#e8dfd3, #ded1c2);
	box-shadow: inset 0 2px 6px rgba(49, 31, 13, 0.18);
	transform: translateY(1px);
}

.key.enter::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	width: var(--kw, 96px);
	height: var(--enter-h);
	background:
		linear-gradient(var(--key-border), var(--key-border)) left calc(var(--enter-h) * var(--enter-cut-y-r)) / calc(var(--kw, 96px) * var(--enter-cut-x-r)) 1px no-repeat,
		linear-gradient(var(--key-border), var(--key-border)) calc(var(--kw, 96px) * var(--enter-cut-x-r)) calc(var(--enter-h) * var(--enter-cut-y-r)) / 1px calc(var(--enter-h) * (1 - var(--enter-cut-y-r))) no-repeat;
	z-index: 4;
	pointer-events: none;
}

@media (max-width: 850px) {
	body {
		padding: 6px;
	}

	.overlay-card,
	.stats-card {
		padding: 22px 18px;
	}

	.stats-buttons {
		flex-direction: column;
	}
}