* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	width: 100%;
	font-size: 16px;
}

:root {
	--bg: #050505;
	--surface: #0d0d0d;
	--surface-2: #111111;
	--surface-3: #151515;
	--border: #242424;
	--border-soft: #1c1c1c;
	--text: #f3f3f3;
	--muted: #9a9a9a;
	--accent: #ffffff;
	--correct: #22c55e;
	--incorrect: #ef4444;
	--current: #facc15;
	--shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
	--radius-md: 14px;
	--radius-lg: 18px;
	--radius-xl: 24px;
}

body {
	min-height: 100vh;
	margin: 0;
	font-family: Inter, Arial, Arial, Helvetica, sans-serif;
	color: var(--text);
	background-color: var(--bg);
}

button,
textarea {
	font: inherit;
}

.page {
	min-height: 100dvh;
	padding: 20px;
}

.app-shell {
	max-width: 1180px;
	margin: 0 auto;
	border: 1px solid var(--border-soft);
	border-radius: 28px;
	box-shadow: var(--shadow);
	background: linear-gradient(180deg, #090909 0%, #060606 100%);
	overflow: hidden;
}

.topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 20px;
	padding: 28px;
	border-bottom: 1px solid var(--border-soft);
}

.brand h1 {
	margin: 12px 0 8px;
	font-size: clamp(1.8rem, 3vw, 2.8rem);
	line-height: 1.05;
	letter-spacing: -0.03;
	font-weight: 700;
}

.brand p {
	max-width: 560px;
	margin: 0;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--muted);
}

.brand-badge {
	display: inline-flex;
	align-items: center;
	padding: 7px 12px;
	font-size: 0.76rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	border: 1px solid var(--border);
	border-radius: 999px;
	color: #d8d8d8;
	background-color: #101010;
}

.top-actions {
	display: flex;
	align-items: center;
	gap: 12px;
}

.best-score {
	padding: 12px 16px;
	font-size: 0.95rem;
	white-space: nowrap;
	border: 1px solid var(--border);
	border-radius: 999px;
	color: var(--text);
	background-color: #101010;
}

.layout {
	display: grid;
	grid-template-columns: 320px 1fr;
	gap: 20px;
	padding: 20px;
}

.panel {
	padding: 20px;
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-xl);
	background-color: var(--surface);
}

.panel-header {
	margin-bottom: 18px;
}

.panel-header h2 {
	margin: 0 0 6px;
	font-size: 1.05rem;
	letter-spacing: -0.02em;
}

.panel-header p {
	margin: 0;
	font-size: 0.94rem;
	line-height: 1.5;
	color: var(--muted);
}

.mode-buttons {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-bottom: 14px;
}

.actions-buttons {
	display: grid;
	gap: 10px;
}

button {
	padding: 13px 16px;
	font-weight: 600;
	border: none;
	border-radius: 14px;
	transition:
		transform 0.18s ease,
		opacity 0.18s ease,
		background-color 0.18s ease,
		border-color 0.18s ease;
	cursor: pointer;
}

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

button:active {
	transform: translateY(0);
}

.mode-btn,
.secondary-btn {
	border: 1px solid var(--border);
	color: var(--text);
	background-color: var(--surface-3);
}

.mode-btn.active,
.primary-btn {
	color: #000;
	background: var(--accent);
}

.full-width {
	width: 100%;
}

.stats-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-top: 18px;
}

.stat-card,
.result-item {
	padding: 16px;
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-lg);
	background-color: var(--surface-2);
}

.stat-label {
	display: block;
	margin-bottom: 8px;
	font-size: 0.82rem;
	color: var(--muted);
}

.stat-value {
	font-size: clamp(1.2rem, 2vw, 1.6rem);
	line-height: 1;
	letter-spacing: -0.03em;
}

.typing-panel {
	display: flex;
	flex-direction: column;
}

.typing-text {
	min-height: 220px;
	padding: 20px;
	font-size: clamp(1rem, 1.5vw, 1.15rem);
	line-height: 2;
	word-break: break-word;
	overflow-wrap: break-word;
	border: 1px solid var(--border);
	border-radius: 20px;
	color: #d6d6d6;
	background-color: #080808;
}

.typing-text span.correct {
	color: var(--correct);
}

.typing-text span.incorrect {
	border-radius: 4px;
	color: var(--incorrect);
	background-color: rgba(239, 68, 68, 0.12);
}

.typing-text span.current {
	border-radius: 4px;
	outline: 1px solid rgba(250, 204, 21, 0.8);
	background-color: rgba(250, 204, 21, 0.15);
}

.typing-text span.space-visible.incorrect {
	outline: 1px solid rgba(239, 68, 68, 0.55);
}

textarea {
	min-height: 160px;
	width: 100%;
	margin-top: 16px;
	padding: 16px 18px;
	resize: vertical;
	line-height: 1.7;
	border: 1px solid var(--border);
	border-radius: 18px;
	outline: none;
	color: var(--text);
	background-color: #080808;
}

textarea:focus {
	border-color: #444;
}

.bottom-note {
	margin-top: 12px;
	font-size: 0.92rem;
	color: var(--muted);
}

.result-overlay {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(0, 0, 0, 0.72);
}

.result-overlay.show {
	display: flex;
}

.result-card {
	width: 100%;
	max-width: 600px;
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: 28px;
	box-shadow: var(--shadow);
	background-color: #0b0b0b;
}

.result-head {
	margin-bottom: 18px;
	text-align: center;
}

.result-head h2 {
	margin: 12px 0 8px;
	font-size: 2rem;
	letter-spacing: -0.03em;
}

.result-head p {
	margin: 0;
	color: var(--muted);
}

.result-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 18px;
}

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

@media (max-width: 640px) {
	.page {
		padding: 10px;
	}
	.topbar,
	.layout {
		padding: 14px;
	}
	.panel {
		padding: 16px;
		border-radius: 18px;
	}
	.mode-buttons,
	.stats-grid,
	.result-grid {
		grid-template-columns: 1fr;
	}
	.typing-text {
		min-height: 180px;
		padding: 16px;
		line-height: 1.85;
	}
	textarea {
		min-height: 130px;
	}
	.best-score {
		white-space: normal;
	}
}