:root
{
	--bg: #ffffff;
	--fg: #1a1a1b;
	--muted: #6f7377;
	--line: #d3d6da;
	--soft: #f3f4f5;
	--btn: #1a1a1b;
	--btn-fg: #ffffff;
	--danger: #d64545;
	--shade: rgba(0, 0, 0, 0.45);
	color-scheme: light;
}

:root[data-theme="dark"]
{
	--bg: #121213;
	--fg: #f4f4f5;
	--muted: #9a9da1;
	--line: #3a3a3c;
	--soft: #1d1d1f;
	--btn: #f4f4f5;
	--btn-fg: #121213;
	--danger: #f06a6a;
	--shade: rgba(0, 0, 0, 0.65);
	color-scheme: dark;
}

*, *::before, *::after
{
	box-sizing: border-box;
}

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

body
{
	margin: 0;
	min-height: 100%;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--fg);
	font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-tap-highlight-color: transparent;
}

[hidden]
{
	display: none !important;
}

button
{
	font: inherit;
	color: inherit;
	cursor: pointer;
}

h1, h2, h3, p
{
	margin: 0;
}

.muted
{
	color: var(--muted);
}

.small
{
	font-size: 14px;
}

/* ---------------------------------------------------------------- header */

.top
{
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	height: 54px;
	padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
	border-bottom: 1px solid var(--line);
	flex: none;
}

.top-side
{
	display: flex;
	gap: 2px;
}

.top-side.right
{
	justify-content: flex-end;
}

.wordmark
{
	border: 0;
	background: none;
	padding: 4px 8px;
	font-size: 26px;
	font-weight: 400;
	letter-spacing: -0.03em;
	line-height: 1;
}

.wordmark b
{
	font-weight: 800;
}

body[data-screen="game"] .wordmark, body[data-screen="home"] .wordmark
{
	cursor: default;
}

.icon
{
	width: 40px;
	height: 40px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 10px;
	background: none;
	padding: 0;
}

.icon svg
{
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.icon:hover
{
	background: var(--soft);
}

:focus-visible
{
	outline: 2px solid var(--fg);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------- layout */

main
{
	width: 100%;
	max-width: 540px;
	margin: 0 auto;
	padding: 18px max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	flex: 1;
}

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

.btn
{
	height: 52px;
	padding: 0 20px;
	border: 0;
	border-radius: 12px;
	background: var(--btn);
	color: var(--btn-fg);
	font-weight: 700;
	font-size: 16px;
}

.btn.wide
{
	width: 100%;
}

.btn.ghost
{
	background: none;
	color: var(--fg);
	box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn:disabled
{
	opacity: 0.45;
	cursor: default;
}

.btn:not(:disabled):active
{
	transform: scale(0.98);
}

.link
{
	border: 0;
	background: none;
	padding: 8px 0;
	color: var(--muted);
	font-size: 14px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.link:hover
{
	color: var(--fg);
}

.eyebrow, .g-top
{
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
}

/* ---------------------------------------------------------------- home */

.tagline
{
	margin: 7vh 0 28px;
	text-align: center;
	font-size: 22px;
	line-height: 1.3;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.modes
{
	display: grid;
	gap: 12px;
}

.mode
{
	display: grid;
	gap: 2px;
	width: 100%;
	padding: 18px 20px;
	border: 1.5px solid var(--line);
	border-radius: 16px;
	background: none;
	text-align: left;
}

.mode.primary
{
	border-color: var(--btn);
	background: var(--btn);
	color: var(--btn-fg);
}

.mode:active
{
	transform: scale(0.99);
}

.mode-title
{
	font-size: 21px;
	font-weight: 800;
	letter-spacing: -0.01em;
}

.mode-sub
{
	font-size: 14px;
	opacity: 0.72;
}

.legend
{
	list-style: none;
	margin: 26px 0 0;
	padding: 0;
	display: grid;
	gap: 8px;
	font-size: 14px;
	color: var(--muted);
}

.legend li
{
	display: flex;
	align-items: center;
	gap: 8px;
}

.legend li b
{
	color: var(--fg);
	font-weight: 600;
	min-width: 84px;
}

.dot
{
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--rc);
	flex: none;
}

/* ---------------------------------------------------------------- game */

#screen-game
{
	text-align: center;
}

.g-top
{
	display: flex;
	justify-content: space-between;
	gap: 12px;
}

#g-score
{
	color: var(--fg);
	font-variant-numeric: tabular-nums;
}

.g-title
{
	margin-top: 12px;
	font-size: 28px;
	line-height: 1.15;
	font-weight: 800;
	letter-spacing: -0.02em;
	text-wrap: balance;
}

.g-title.pop
{
	animation: pop 0.28s ease-out;
}

.g-hint
{
	min-height: 20px;
	margin-top: 4px;
	color: var(--muted);
	font-size: 14px;
}

.clock
{
	position: relative;
	margin: 6px 0 14px;
}

.time
{
	font-size: 60px;
	line-height: 1.1;
	font-weight: 800;
	letter-spacing: -0.03em;
	font-variant-numeric: tabular-nums;
}

.clock.low .time
{
	color: var(--danger);
}

.clock.ready .time
{
	opacity: 0.45;
}

.bar
{
	height: 6px;
	border-radius: 3px;
	background: var(--soft);
	overflow: hidden;
}

.bar-fill
{
	height: 100%;
	width: 100%;
	border-radius: 3px;
	background: var(--fg);
	transform-origin: left center;
	transition: background-color 0.5s;
}

.clock.low .bar-fill
{
	background: var(--danger);
}

.float
{
	position: absolute;
	left: 50%;
	top: 16px;
	margin-left: 76px;
	color: var(--rc);
	font-size: 18px;
	font-weight: 800;
	white-space: nowrap;
	pointer-events: none;
	animation: float 0.9s ease-out forwards;
}

.answer
{
	display: flex;
	gap: 8px;
}

.answer input
{
	flex: 1;
	min-width: 0;
	height: 52px;
	padding: 0 14px;
	border: 2px solid var(--line);
	border-radius: 12px;
	background: var(--bg);
	color: var(--fg);
	font: inherit;
	font-size: 18px;
	outline: none;
}

.answer input:focus
{
	border-color: var(--fg);
}

.answer input.shake
{
	border-color: var(--danger);
	animation: shake 0.3s;
}

.feedback
{
	min-height: 24px;
	margin-top: 8px;
	font-size: 15px;
	color: var(--muted);
}

.feedback b
{
	color: var(--rc, var(--fg));
}

.chips
{
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	margin-top: 10px;
}

.chip
{
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 11px 4px 9px;
	border: 1.5px solid var(--rc);
	border-radius: 999px;
	font-size: 14px;
	line-height: 1.35;
}

.chip.new
{
	animation: pop 0.25s ease-out;
}

.chip .dot
{
	width: 8px;
	height: 8px;
}

.g-foot
{
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 16px;
	font-size: 14px;
}

/* ---------------------------------------------------------------- after a category, results */

.b-reason
{
	margin-top: 6px;
	font-size: 16px;
	font-weight: 700;
}

.big, .score
{
	margin-top: 10px;
	font-size: 52px;
	line-height: 1.1;
	font-weight: 800;
	letter-spacing: -0.03em;
	font-variant-numeric: tabular-nums;
}

.score
{
	font-size: 64px;
}

.missed
{
	margin: 16px 0 22px;
	color: var(--muted);
	font-size: 14px;
}

.missed b
{
	display: block;
	margin-bottom: 2px;
	color: var(--fg);
	font-weight: 600;
}

.tiles
{
	display: flex;
	justify-content: center;
	gap: 5px;
	margin: 16px 0 4px;
}

.tile
{
	width: 26px;
	height: 26px;
	border-radius: 6px;
	background: var(--rc, var(--soft));
	box-shadow: inset 0 0 0 1.5px var(--line);
}

.tile[style]
{
	box-shadow: none;
}

.actions
{
	display: grid;
	gap: 10px;
	margin: 18px 0 12px;
}

.breakdown
{
	margin-top: 22px;
	text-align: left;
	border-top: 1px solid var(--line);
}

.breakdown details
{
	border-bottom: 1px solid var(--line);
}

.breakdown summary
{
	display: flex;
	align-items: baseline;
	gap: 10px;
	padding: 12px 2px;
	cursor: pointer;
	list-style: none;
}

.breakdown summary::-webkit-details-marker
{
	display: none;
}

.breakdown summary .name
{
	flex: 1;
	font-weight: 600;
}

.breakdown summary .num
{
	color: var(--muted);
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.breakdown .inside
{
	padding: 0 2px 14px;
}

.breakdown .chips
{
	justify-content: flex-start;
	margin-top: 0;
}

.breakdown .missed
{
	margin: 10px 0 0;
}

/* ---------------------------------------------------------------- dialogs */

dialog
{
	width: min(440px, calc(100vw - 24px));
	max-height: calc(100dvh - 24px);
	padding: 22px 22px 24px;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: var(--bg);
	color: var(--fg);
}

dialog::backdrop
{
	background: var(--shade);
}

dialog h2
{
	font-size: 22px;
	letter-spacing: -0.01em;
}

dialog h3
{
	margin-top: 18px;
	font-size: 12px;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--muted);
}

dialog p
{
	margin-top: 10px;
}

dialog .legend
{
	margin-top: 12px;
}

dialog .close
{
	float: right;
	margin: -10px -10px 0 0;
	font-size: 26px;
	line-height: 1;
}

.stats
{
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
	gap: 8px;
	margin-top: 10px;
	text-align: center;
}

.stats div
{
	padding: 10px 4px;
	border-radius: 12px;
	background: var(--soft);
}

.stats strong
{
	display: block;
	font-size: 24px;
	font-variant-numeric: tabular-nums;
}

.stats span
{
	color: var(--muted);
	font-size: 12px;
}

.setting
{
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 18px;
}

.segmented
{
	display: flex;
	padding: 3px;
	border-radius: 11px;
	background: var(--soft);
}

.segmented button
{
	padding: 7px 14px;
	border: 0;
	border-radius: 8px;
	background: none;
	font-size: 14px;
}

.segmented button[aria-checked="true"]
{
	background: var(--bg);
	font-weight: 700;
	box-shadow: 0 0 0 1px var(--line);
}

.toast
{
	position: fixed;
	left: 50%;
	top: 66px;
	transform: translateX(-50%);
	padding: 9px 16px;
	border-radius: 10px;
	background: var(--btn);
	color: var(--btn-fg);
	font-size: 14px;
	font-weight: 600;
	z-index: 10;
}

/* ---------------------------------------------------------------- motion, small screens */

@keyframes pop
{
	from { transform: scale(0.9); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

@keyframes shake
{
	20% { transform: translateX(-6px); }
	40% { transform: translateX(6px); }
	60% { transform: translateX(-4px); }
	80% { transform: translateX(4px); }
}

@keyframes float
{
	from { transform: translateY(8px); opacity: 0; }
	20% { transform: translateY(0); opacity: 1; }
	70% { opacity: 1; }
	to { transform: translateY(-18px); opacity: 0; }
}

@media (max-width: 420px)
{
	.g-title { font-size: 24px; }
	.time { font-size: 52px; }
	.float { margin-left: 64px; font-size: 16px; }
	.tagline { font-size: 20px; }
}

/* A phone with the keyboard up: keep the answer box in view. */
@media (max-height: 560px)
{
	.top { height: 44px; }
	.wordmark { font-size: 22px; }
	main { padding-top: 10px; }
	.g-title { margin-top: 6px; font-size: 22px; }
	.g-hint { min-height: 0; }
	.time { font-size: 40px; }
	.clock { margin: 2px 0 8px; }
	.float { top: 8px; margin-left: 54px; }
	.answer input, .answer .btn { height: 46px; }
}

@media (prefers-reduced-motion: reduce)
{
	*, *::before, *::after
	{
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

.noscript
{
	text-align: center;
	padding: 2rem;
}
