/*
  Quizfish stylesheet. One file, plain CSS, no framework.

  How it is organised, top to bottom:
    1. Tokens      — colours, radii, shadows as custom properties. Each
                     colour is light-dark(light, dark), so a token reads as
                     one line and dark mode needs no second block.
    2. Base        — element defaults. A <button> *is* a button, an <input>
                     is a form control, a <table> is a table, a <dialog> is a
                     modal. No class needed for the common case.
    3. Components  — the handful of things elements cannot express alone:
                     .alert, .list, .spinner, .navbar, .topic-grid, the
                     question board (.board-*), the profile medals.
    4. Utilities   — a small fixed set for layout, spacing and text. No
                     responsive variants: layouts wrap with flex/grid instead
                     of switching at breakpoints.

  The rules the layout depends on (see AGENTS.md for the reasons):
    - Never size anything with vh; the shell is 100dvh and everything inside
      it is h-100 / flex.
    - :hover styling lives inside @media (hover: hover) — touch browsers pin
      :hover to the last tap and would paint it on the next question.
    - The answer area of the board (.board-options, .board-spell) must fit,
      never scroll: its gaps and padding scale with dvh.

  Button variants (on <button>, or on an <a class="btn"> that should look like one):
    (none)     neutral: surface background, hairline border
    .primary   filled brand colour        .outline   brand border, no fill
    .success   filled green               .danger    filled pink
    .link      looks like a link (no border, no padding); .link.danger for red
    .sm / .lg  smaller / larger           .icon      square, for a lone glyph
    .tile      the topic tile (icon over label; a row on narrow screens)

  Utilities:
    layout   .flex .stack .wrap .center .start .baseline .between .jc-center
             .jc-end .grow .shrink-0 .self-start .inline-flex .block .hidden
             .hide-narrow (≤ 30em)  .gap-1..5  .mx-auto .ml-auto .mt-auto
             .grid-2 (auto two columns)  .h-100 .w-100 .overflow-auto
             .overflow-hidden
    spacing  m{t,b,l,r,x,y}-{0..5}, p{t,b,l,r,x,y}-{0..5}
             scale: 0 → 0, 1 → .25rem, 2 → .5rem, 3 → 1rem, 4 → 1.5rem, 5 → 3rem
    text     .small .xs .muted .text-center .text-end .text-primary
             .text-danger .text-success .fw-medium .fw-semibold .fw-bold
             .lead .display .display.sm .eyebrow .nowrap .truncate .lh-1
             .tnum .plain (a link in body colour, no underline)
    misc     .rounded .rounded-circle .border .border-top .border-bottom
             .opacity-50 .bg-2
*/

/* ---------------------------------------------------------------- tokens */

:root {
	/* light-dark() below picks its second value whenever the viewer's system
	   is dark; this declaration is what switches it on (and adapts the
	   browser's own form controls and scrollbars too). */
	color-scheme: light dark;

	--bg: light-dark(#f6f6f4, #131416);
	--surface: light-dark(#ffffff, #1c1e21);
	--bg-2: light-dark(#eeeeeb, #25282c);
	--fg: light-dark(#1c1f23, #e8e8e6);
	--fg-2: light-dark(#666c75, #9aa0a8);
	--border: light-dark(#e3e4e6, #2b2f34);
	--border-strong: light-dark(#c9ccd1, #3d4248);

	--primary: light-dark(#0981a1, #2fb1d4);
	--primary-hover: light-dark(#076d88, #4cc0df);
	--primary-fg: light-dark(#ffffff, #071a20);
	--primary-soft: light-dark(#e3f2f6, #14313a);
	--primary-ink: light-dark(#06607a, #7ed3ea);

	--success: light-dark(#159a68, #2ec085);
	--success-hover: light-dark(#12855a, #4acc97);
	--success-soft: light-dark(#e0f5ec, #133326);
	--success-ink: light-dark(#0f6b49, #7fdcb4);

	--danger: light-dark(#d63384, #e75a9f);
	--danger-hover: light-dark(#bf2a75, #ee76b0);
	--danger-soft: light-dark(#fbe6f0, #3a1a2a);
	--danger-ink: light-dark(#a0215f, #f39cc7);

	--warning-soft: light-dark(#fff4d6, #3a2f10);
	--warning-ink: light-dark(#7a5400, #f0cf66);

	--radius: 0.375rem;
	--radius-lg: 0.625rem;
	--shadow: 0 1px 2px light-dark(rgb(0 0 0 / 0.06), rgb(0 0 0 / 0.4));
	--shadow-lg: 0 18px 48px light-dark(rgb(0 0 0 / 0.22), rgb(0 0 0 / 0.6));
	--ring: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);

	--font:
		"Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
		Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
}

/* ------------------------------------------------------------------ font */

/* Self-hosted product font: Inter (SIL OFL 1.1, license in frontend/assets/fonts).
   The latin-subset woff2s are vendored under frontend/assets/fonts/ (weights
   the app actually uses) and copied to /static/fonts by build.mjs. */
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("/static/fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url("/static/fonts/inter-latin-500-normal.woff2") format("woff2");
}
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url("/static/fonts/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url("/static/fonts/inter-latin-700-normal.woff2") format("woff2");
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
	box-sizing: border-box;
	scrollbar-width: thin;
	scrollbar-color: var(--border-strong) transparent;
}

/* The app shell is exactly one viewport tall and never scrolls as a whole;
   only inner panes scroll. 100dvh, not 100vh: on a phone browser 100vh is
   the viewport measured with the browser chrome *retracted*, so a 100vh
   shell is taller than what you can see and the navbar ends up cut off.
   (dvh has shipped in every browser since 2022; no vh fallback needed.) */
html,
body {
	height: 100dvh;
	margin: 0;
	overflow: hidden;
	/* No whole-page rubber-band drag: it let the shell creep out of alignment
     and has nothing to reveal here. */
	overscroll-behavior: none;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	font-size: 1rem;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
}

/* Inset for the notch and the home indicator. index.html opts into
   viewport-fit=cover so the background paints edge to edge; these keep the
   content out from under the hardware. env() is 0 on a plain screen. */
#app {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: env(safe-area-inset-top) env(safe-area-inset-right)
		env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Vertical rhythm comes from flex gaps (.stack), not element margins, so
   nothing carries a default margin. */
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
figure,
fieldset,
blockquote,
dl,
dd {
	margin: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

h1 {
	font-size: 1.75rem;
}
h2 {
	font-size: 1.25rem;
}
h3 {
	font-size: 1.05rem;
}
h4,
h5,
h6 {
	font-size: 1rem;
}

ul,
ol {
	padding-left: 1.25rem;
}

small {
	font-size: 0.875em;
}
strong,
b {
	font-weight: 600;
}

a {
	color: var(--primary);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
}

hr {
	border: 0;
	border-top: 1px solid var(--border);
	margin: 0;
}

img,
svg {
	vertical-align: middle;
}
img {
	max-width: 100%;
}

fieldset {
	border: 0;
	padding: 0;
	min-width: 0;
}
legend {
	padding: 0;
}

/* Tap ergonomics: no grey flash overlay on a tapped control (it fights the
   button's own :active state), and no double-tap-to-zoom wait on controls. */
a,
button,
[role="button"],
label,
summary,
input {
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

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

/* --- buttons --------------------------------------------------------- */

button,
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.5rem 0.9rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--fg);
	font: inherit;
	font-weight: 500;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	user-select: none;
	transition:
		background-color 0.12s,
		border-color 0.12s,
		color 0.12s,
		box-shadow 0.12s,
		transform 0.08s;
}

button:active,
.btn:active {
	transform: translateY(1px);
}

button:disabled,
.btn:disabled {
	opacity: 0.55;
	cursor: default;
	transform: none;
}

.primary {
	background: var(--primary);
	border-color: var(--primary);
	color: var(--primary-fg);
}
.success {
	background: var(--success);
	border-color: var(--success);
	color: #fff;
}
.danger {
	background: var(--danger);
	border-color: var(--danger);
	color: #fff;
}
.outline {
	background: transparent;
	border-color: var(--primary);
	color: var(--primary);
}

.link {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: var(--primary);
	font-weight: inherit;
	line-height: inherit;
	text-align: inherit;
	vertical-align: baseline;
}
.link.danger {
	color: var(--danger);
}
.link.muted {
	color: var(--fg-2);
}
.link:active {
	transform: none;
}

/* Sizes are scoped to buttons: .sm also means "small" on .display and
   .spinner, which must not pick up button padding. */
button.sm,
.btn.sm {
	padding: 0.3rem 0.65rem;
	font-size: 0.875rem;
}
button.lg,
.btn.lg {
	padding: 0.7rem 1.25rem;
	font-size: 1.125rem;
}
button.icon,
.btn.icon {
	padding: 0.4rem;
	line-height: 1;
}
button.sm.icon,
.btn.sm.icon {
	padding: 0.25rem;
}

/* Hover only where hovering is a real thing. Touch browsers pin :hover to
   the last tapped point and re-apply it to whatever the next render puts
   there — the tapped choice button stayed lit through the following
   question. So no hover rule at all on a touch device. */
@media (hover: hover) {
	button:hover,
	.btn:hover {
		background: var(--bg-2);
		border-color: var(--fg-2);
	}
	.primary:hover {
		background: var(--primary-hover);
		border-color: var(--primary-hover);
		color: var(--primary-fg);
	}
	.success:hover {
		background: var(--success-hover);
		border-color: var(--success-hover);
		color: #fff;
	}
	.danger:hover {
		background: var(--danger-hover);
		border-color: var(--danger-hover);
		color: #fff;
	}
	.outline:hover {
		background: var(--primary-soft);
		border-color: var(--primary);
		color: var(--primary-ink);
	}
	.link:hover {
		background: none;
		border-color: transparent;
		color: var(--primary-hover);
		text-decoration: underline;
		text-underline-offset: 0.15em;
	}
	.link.danger:hover {
		color: var(--danger-hover);
	}
	.link.muted:hover {
		color: var(--fg);
	}
	button:disabled:hover,
	.btn:disabled:hover {
		background: var(--surface);
		border-color: var(--border-strong);
	}
	.primary:disabled:hover {
		background: var(--primary);
		border-color: var(--primary);
	}
	.success:disabled:hover {
		background: var(--success);
		border-color: var(--success);
	}
	.danger:disabled:hover {
		background: var(--danger);
		border-color: var(--danger);
	}
	.outline:disabled:hover {
		background: transparent;
		border-color: var(--primary);
		color: var(--primary);
	}
}

/* --- forms ----------------------------------------------------------- */

input:not([type="radio"]):not([type="checkbox"]),
select,
textarea {
	display: block;
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--fg);
	font: inherit;
	line-height: 1.4;
	transition:
		border-color 0.12s,
		box-shadow 0.12s;
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
	color: var(--fg-2);
	opacity: 0.8;
}
input:disabled,
select:disabled,
textarea:disabled {
	opacity: 0.6;
}

input[type="radio"],
input[type="checkbox"] {
	width: 1rem;
	height: 1rem;
	margin: 0;
	accent-color: var(--primary);
	cursor: pointer;
}

/* A form field: label over control. <div class="field"><label/><input/></div> */
.field {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}
.field > label {
	font-size: 0.875rem;
	font-weight: 500;
}
.hint {
	font-size: 0.8rem;
	color: var(--fg-2);
}

/* A radio or checkbox with its label on one line. */
.check {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	cursor: pointer;
	font-weight: 400;
}

/* --- tables ---------------------------------------------------------- */

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}
th,
td {
	padding: 0.6rem 0.5rem;
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: middle;
}
th {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--fg-2);
}
.table-wrap {
	overflow-x: auto;
}

/* --- dialog ---------------------------------------------------------- */

dialog {
	width: min(100% - 2rem, 28rem);
	max-height: calc(100dvh - 2rem);
	padding: 0;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
	color: var(--fg);
	box-shadow: var(--shadow-lg);
	display: flex;
	flex-direction: column;
}
dialog:not([open]) {
	display: none;
}
dialog::backdrop {
	background: rgb(0 0 0 / 0.45);
	backdrop-filter: blur(2px);
}
dialog[open] {
	animation: dialog-in 0.16s ease-out;
}
@keyframes dialog-in {
	from {
		opacity: 0;
		transform: translateY(0.5rem) scale(0.98);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem 0.5rem;
}
.modal-header h2 {
	font-size: 1.15rem;
}
.modal-body {
	padding: 0.5rem 1.25rem 1.25rem;
	overflow: auto;
}

/* ------------------------------------------------------------- components */

.container {
	width: 100%;
	max-width: 46rem;
	margin-inline: auto;
	padding-inline: 1rem;
}

/* A document-shaped page: a stack of sections with the page padding. */
.page {
	display: flex;
	flex-direction: column;
	gap: 1.75rem;
	padding-block: 1.5rem 2rem;
}

.alert {
	padding: 0.6rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	font-size: 0.9rem;
	background: var(--bg-2);
	color: var(--fg);
}
.alert.danger {
	background: var(--danger-soft);
	border-color: color-mix(in srgb, var(--danger) 30%, transparent);
	color: var(--danger-ink);
}
.alert.success {
	background: var(--success-soft);
	border-color: color-mix(in srgb, var(--success) 30%, transparent);
	color: var(--success-ink);
}
.alert.warning {
	background: var(--warning-soft);
	border-color: color-mix(in srgb, var(--warning-ink) 25%, transparent);
	color: var(--warning-ink);
}
.alert.info {
	background: var(--primary-soft);
	border-color: color-mix(in srgb, var(--primary) 30%, transparent);
	color: var(--primary-ink);
}
/* A .alert that hugs its sentence rather than painting a full-width slab. */
.alert.inline {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	align-self: flex-start;
}
.alert .link {
	color: inherit;
	font-weight: 600;
}

.spinner {
	display: inline-block;
	width: 1.5rem;
	height: 1.5rem;
	flex-shrink: 0;
	border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}
.spinner.sm {
	width: 1rem;
	height: 1rem;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* A bordered stack of rows. Rows are whatever you put in it — a div, an <a>,
   a <button>; the direct children get the row padding and the hairlines. */
.list {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--surface);
	overflow: hidden;
}
.list > * {
	padding: 0.7rem 0.9rem;
	border-top: 1px solid var(--border);
}
.list > :first-child {
	border-top: 0;
}
/* A row that is itself a control: full width, left-aligned, no chrome of its own. */
.list > button,
.list > a {
	width: 100%;
	border-left: 0;
	border-right: 0;
	border-bottom: 0;
	border-radius: 0;
	background: transparent;
	justify-content: flex-start;
	text-align: left;
	font-weight: 400;
	color: inherit;
	text-decoration: none;
	transform: none;
}
.list > button:disabled {
	opacity: 1;
	color: var(--fg-2);
}
@media (hover: hover) {
	.list > button:hover,
	.list > a:hover {
		background: var(--bg-2);
		border-color: var(--border);
	}
}

/* The topic grid: tiles that wrap to however many columns fit. */
.topic-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(8.75rem, 1fr));
	gap: 0.6rem;
}
.tile {
	flex-direction: column;
	gap: 0.5rem;
	padding: 1rem 0.5rem 0.8rem;
	border-color: var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.2;
	color: var(--fg);
}
.tile svg {
	color: var(--primary);
}
/* On a phone a tile is ~150px wide, so the name wraps to two or three
   centred lines and the grid reads as a wall. Below the width where two
   comfortable columns fit, the grid becomes a single column of rows: the
   icon is the bullet, the name sits beside it, left aligned and on one line. */
@media (max-width: 30rem) {
	.topic-grid {
		grid-template-columns: 1fr;
		gap: 0.4rem;
	}
	.tile {
		flex-direction: row;
		justify-content: flex-start;
		gap: 0.75rem;
		padding: 0.7rem 0.9rem;
		text-align: left;
		font-size: 1rem;
	}
	.tile svg {
		flex: none;
		width: 1.75rem;
		height: 1.75rem;
	}
}

@media (hover: hover) {
	.tile:hover {
		background: var(--surface);
		border-color: var(--primary);
		color: var(--primary-ink);
		box-shadow: 0 4px 14px rgb(0 0 0 / 0.08);
		transform: translateY(-1px);
	}
}

.navbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem;
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}
.nav-link {
	padding: 0.35rem 0.65rem;
	border-radius: var(--radius);
	color: var(--fg-2);
	font-weight: 500;
	text-decoration: none;
}
.nav-link[aria-current="page"] {
	background: var(--primary-soft);
	color: var(--primary-ink);
}
@media (hover: hover) {
	.nav-link:hover {
		color: var(--fg);
		background: var(--bg-2);
	}
	.nav-link[aria-current="page"]:hover {
		background: var(--primary-soft);
		color: var(--primary-ink);
	}
}

/* Brand identity: no letter-spacing on purpose — Inter's default tracking
   is tighter than the system fonts it replaced. */
.brand-name {
	font-size: 1.4rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

/* Presence dot next to a friend's name. */
.dot {
	display: inline-block;
	width: 0.5rem;
	height: 0.5rem;
	flex-shrink: 0;
	border-radius: 50%;
	background: var(--success);
}

/* --- the play surface ------------------------------------------------ */

/* Portrait stacks the prompt over the options; landscape puts them side by
   side (see the orientation query below). The vertical padding lives here
   rather than as a utility so the landscape block can shrink it. */
.board {
	max-width: 40rem;
	padding-top: 0.75rem;
	padding-bottom: 0.75rem;
}
.board-split {
	flex-direction: column;
}
.board-prompt {
	flex: 1 1 auto;
	min-height: 0;
}
.board-prompt h1 {
	font-size: 1.75rem;
	font-weight: 600;
}
.board-prompt h1.big {
	font-size: 2.25rem;
}

.board-options {
	display: grid;
	gap: 0.5rem;
}
/* Instant reveal: a colour fade on the play surface reads as lag between
   the tap and the answer registering. */
.board-options button {
	transition: none;
	padding-top: 1rem;
	padding-bottom: 1rem;
	font-size: 1.125rem;
	opacity: 1;
}
.board-options button:active {
	transform: none;
}
.board-key {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 1.6rem;
	height: 1.6rem;
	border: 1px solid currentColor;
	border-radius: 0.25rem;
	font-size: 0.8rem;
	opacity: 0.5;
}

/* SpellBoard's built word, keypad and Done button. Same rule as
   .board-options: it holds the controls, so it must fit, never scroll —
   every gap and tile size scales with dvh. */
.board-spell {
	display: flex;
	flex-direction: column;
	gap: clamp(0.4rem, 2dvh, 1rem);
	justify-content: center;
}
/* Three columns, the outer two equal, so the word is centred on the board
   rather than on the space Undo leaves it. */
.board-word-row {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 0.5rem;
}
.board-word-row > button {
	grid-column: 3;
	justify-self: start;
}
.board-word {
	grid-column: 2;
	font-size: clamp(1.5rem, 5dvh, 2.5rem);
	font-weight: 600;
	line-height: 1.2;
	min-height: clamp(1.8rem, 6dvh, 3rem);
	text-align: center;
	overflow-wrap: anywhere;
}
.board-tiles {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: clamp(0.25rem, 1.5dvh, 0.5rem);
}
.board-tiles button {
	transition: none;
	font-size: clamp(1rem, 3dvh, 1.5rem);
	font-weight: 600;
	line-height: 1;
	padding: clamp(0.4rem, 1.6dvh, 0.75rem);
	min-width: clamp(2.4rem, 8dvh, 3.5rem);
}

/* The picture shrinks to whatever room the prompt half has left rather than
   claiming a fixed slice of the viewport. */
.board-image {
	flex: 0 1 auto;
	min-height: 0;
	max-height: 100%;
	max-width: min(100%, 20rem);
	object-fit: contain;
}

/* A country silhouette (frontend/assets/shapes, all square). The SVG is the
   mask and currentColor is the paint, so it follows the text colour in
   either mode — no invert filter, no per-theme rule. The element sets
   --shape to the file's URL. */
.shape {
	display: inline-block;
	aspect-ratio: 1;
	/* Sized by height where inline (the review thumbnail sets 1.5em); the
	   board variant below fills its slot instead. */
	vertical-align: middle;
	background: currentColor;
	-webkit-mask: var(--shape) center / contain no-repeat;
	mask: var(--shape) center / contain no-repeat;
}
.shape.board-image {
	width: 100%;
}

/* On a pointer device the halves size to content and the pair is centred,
   so a tall window does not strand the options a screen away from the
   prompt. Touch is left out: the bottom edge is where the thumb is. */
@media (hover: hover) and (pointer: fine) {
	.board-split {
		justify-content: center;
		gap: 2rem;
	}
	.board-prompt {
		flex: 0 1 auto;
	}
}
/* Optical centring on a tall window: bias the pair up a little. */
@media (hover: hover) and (pointer: fine) and (min-height: 48em) {
	.board-split {
		padding-bottom: 6dvh;
	}
}

/* Landscape phone: too short to stack, so prompt left, options right. The
   max-height gate keeps a desktop (tall, also landscape) stacked. */
@media (orientation: landscape) and (min-width: 34em) and (max-height: 40em) {
	.board {
		max-width: 66rem;
		padding-top: 0.5rem;
		padding-bottom: 0.5rem;
	}
	.board-split {
		flex-direction: row;
		gap: 3rem;
		margin-top: 1rem;
	}
	.board-split > * {
		flex: 1 1 0;
		min-width: 0;
	}
	/* Centre the rows in the full-height column; the gap and padding scale so
     four buttons fit a 340px-tall landscape phone. */
	.board-options {
		align-content: center;
		gap: clamp(0.25rem, 2dvh, 1rem);
	}
	.board-options button {
		padding-top: clamp(0.5rem, 2.2dvh, 1rem);
		padding-bottom: clamp(0.5rem, 2.2dvh, 1rem);
	}
	.board-image {
		max-width: min(100%, 26rem);
	}
}

/* --- medals ---------------------------------------------------------- */

/* Gold, silver and bronze are the one place literal colours are hardcoded.
   Each tier sets the metal's highlight/body/shadow and the ink; the generic
   rules draw the pill and the domed disc from those. */
.medal {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.4rem 0.8rem 0.4rem 0.45rem;
	border: 1px solid color-mix(in srgb, var(--medal-mid) 55%, transparent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--medal-mid) 12%, var(--bg));
	box-shadow: inset 0 1px 0
		color-mix(in srgb, var(--medal-light) 45%, transparent);
}
.medal-disc {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	flex: 0 0 auto;
	border-radius: 50%;
	color: var(--medal-dark);
	background: radial-gradient(
		circle at 35% 30%,
		var(--medal-light) 0%,
		var(--medal-mid) 45%,
		var(--medal-dark) 100%
	);
	box-shadow:
		inset 0 0 0 1.5px color-mix(in srgb, var(--medal-light) 60%, transparent),
		inset 0 -2px 3px rgb(0 0 0 / 0.25),
		0 1px 2px rgb(0 0 0 / 0.3);
}
.medal-gold {
	--medal-light: #fff3b0;
	--medal-mid: #f2c41d;
	--medal-dark: #9a6f00;
	color: light-dark(#7a5c00, #f0cf66);
}
.medal-silver {
	--medal-light: #ffffff;
	--medal-mid: #c6ced6;
	--medal-dark: #6c7680;
	color: light-dark(#545c64, #c9d1d9);
}
.medal-bronze {
	--medal-light: #ffd9bd;
	--medal-mid: #d8863f;
	--medal-dark: #8a4314;
	color: light-dark(#8f4318, #eca173);
}

/* -------------------------------------------------------------- utilities */

.flex {
	display: flex;
}
.stack {
	display: flex;
	flex-direction: column;
}
.inline-flex {
	display: inline-flex;
}
.block {
	display: block;
}
.hidden {
	display: none;
}
.wrap {
	flex-wrap: wrap;
}
.center {
	align-items: center;
}
.start {
	align-items: flex-start;
}
.baseline {
	align-items: baseline;
}
.between {
	justify-content: space-between;
}
.jc-center {
	justify-content: center;
}
.jc-end {
	justify-content: flex-end;
}
.grow {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 0;
}
.shrink-0 {
	flex-shrink: 0;
}
.self-start {
	align-self: flex-start;
}
.mx-auto {
	margin-inline: auto;
}
.ml-auto {
	margin-left: auto;
}
.mt-auto {
	margin-top: auto;
}
.h-100 {
	height: 100%;
}
.w-100 {
	width: 100%;
}
.overflow-auto {
	overflow: auto;
}
.overflow-hidden {
	overflow: hidden;
}
.grid-2 {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
	gap: 1.5rem;
}
@media (max-width: 30em) {
	.hide-narrow {
		display: none;
	}
}

.gap-1 {
	gap: 0.25rem;
}
.gap-2 {
	gap: 0.5rem;
}
.gap-3 {
	gap: 1rem;
}
.gap-4 {
	gap: 1.5rem;
}
.gap-5 {
	gap: 3rem;
}

.m-0 {
	margin: 0;
}
.mt-0 {
	margin-top: 0;
}
.mt-1 {
	margin-top: 0.25rem;
}
.mt-2 {
	margin-top: 0.5rem;
}
.mt-3 {
	margin-top: 1rem;
}
.mt-4 {
	margin-top: 1.5rem;
}
.mt-5 {
	margin-top: 3rem;
}
.mb-0 {
	margin-bottom: 0;
}
.mb-1 {
	margin-bottom: 0.25rem;
}
.mb-2 {
	margin-bottom: 0.5rem;
}
.mb-3 {
	margin-bottom: 1rem;
}
.mb-4 {
	margin-bottom: 1.5rem;
}
.mb-5 {
	margin-bottom: 3rem;
}
.ml-0 {
	margin-left: 0;
}
.ml-1 {
	margin-left: 0.25rem;
}
.ml-2 {
	margin-left: 0.5rem;
}
.ml-3 {
	margin-left: 1rem;
}
.ml-4 {
	margin-left: 1.5rem;
}
.ml-5 {
	margin-left: 3rem;
}
.mr-0 {
	margin-right: 0;
}
.mr-1 {
	margin-right: 0.25rem;
}
.mr-2 {
	margin-right: 0.5rem;
}
.mr-3 {
	margin-right: 1rem;
}
.mr-4 {
	margin-right: 1.5rem;
}
.mr-5 {
	margin-right: 3rem;
}
.mx-0 {
	margin-inline: 0;
}
.mx-1 {
	margin-inline: 0.25rem;
}
.mx-2 {
	margin-inline: 0.5rem;
}
.mx-3 {
	margin-inline: 1rem;
}
.mx-4 {
	margin-inline: 1.5rem;
}
.mx-5 {
	margin-inline: 3rem;
}
.my-0 {
	margin-block: 0;
}
.my-1 {
	margin-block: 0.25rem;
}
.my-2 {
	margin-block: 0.5rem;
}
.my-3 {
	margin-block: 1rem;
}
.my-4 {
	margin-block: 1.5rem;
}
.my-5 {
	margin-block: 3rem;
}
.p-0 {
	padding: 0;
}
.p-1 {
	padding: 0.25rem;
}
.p-2 {
	padding: 0.5rem;
}
.p-3 {
	padding: 1rem;
}
.p-4 {
	padding: 1.5rem;
}
.p-5 {
	padding: 3rem;
}
.pt-0 {
	padding-top: 0;
}
.pt-1 {
	padding-top: 0.25rem;
}
.pt-2 {
	padding-top: 0.5rem;
}
.pt-3 {
	padding-top: 1rem;
}
.pt-4 {
	padding-top: 1.5rem;
}
.pt-5 {
	padding-top: 3rem;
}
.pb-0 {
	padding-bottom: 0;
}
.pb-1 {
	padding-bottom: 0.25rem;
}
.pb-2 {
	padding-bottom: 0.5rem;
}
.pb-3 {
	padding-bottom: 1rem;
}
.pb-4 {
	padding-bottom: 1.5rem;
}
.pb-5 {
	padding-bottom: 3rem;
}
.pl-0 {
	padding-left: 0;
}
.pl-1 {
	padding-left: 0.25rem;
}
.pl-2 {
	padding-left: 0.5rem;
}
.pl-3 {
	padding-left: 1rem;
}
.pl-4 {
	padding-left: 1.5rem;
}
.pl-5 {
	padding-left: 3rem;
}
.pr-0 {
	padding-right: 0;
}
.pr-1 {
	padding-right: 0.25rem;
}
.pr-2 {
	padding-right: 0.5rem;
}
.pr-3 {
	padding-right: 1rem;
}
.pr-4 {
	padding-right: 1.5rem;
}
.pr-5 {
	padding-right: 3rem;
}
.px-0 {
	padding-inline: 0;
}
.px-1 {
	padding-inline: 0.25rem;
}
.px-2 {
	padding-inline: 0.5rem;
}
.px-3 {
	padding-inline: 1rem;
}
.px-4 {
	padding-inline: 1.5rem;
}
.px-5 {
	padding-inline: 3rem;
}
.py-0 {
	padding-block: 0;
}
.py-1 {
	padding-block: 0.25rem;
}
.py-2 {
	padding-block: 0.5rem;
}
.py-3 {
	padding-block: 1rem;
}
.py-4 {
	padding-block: 1.5rem;
}
.py-5 {
	padding-block: 3rem;
}

.small {
	font-size: 0.875rem;
}
.xs {
	font-size: 0.8rem;
}
.muted {
	color: var(--fg-2);
}
.text-center {
	text-align: center;
}
.text-end {
	text-align: right;
}
.text-primary {
	color: var(--primary);
}
.text-danger {
	color: var(--danger);
}
.text-success {
	color: var(--success);
}
.fw-medium {
	font-weight: 500;
}
.fw-semibold {
	font-weight: 600;
}
.fw-bold {
	font-weight: 700;
}
.lead {
	font-size: 1.15rem;
	color: var(--fg-2);
}
.display {
	font-size: 3rem;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
}
.display.sm {
	font-size: 2rem;
}
/* Small caps label over a group: "General", "How hard?", "Challenge a friend". */
.eyebrow {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--fg-2);
}
.nowrap {
	white-space: nowrap;
}
.truncate {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.lh-1 {
	line-height: 1;
}
/* Tabular figures for scores: equal-width digits keep a readout from shifting. */
.tnum {
	font-variant-numeric: tabular-nums;
}
a.plain {
	color: inherit;
	text-decoration: none;
}
.capitalize {
	text-transform: capitalize;
}

.rounded {
	border-radius: var(--radius);
}
.rounded-circle {
	border-radius: 50%;
}
.border {
	border: 1px solid var(--border);
}
.border-top {
	border-top: 1px solid var(--border);
}
.border-bottom {
	border-bottom: 1px solid var(--border);
}
.opacity-50 {
	opacity: 0.5;
}
.bg-2 {
	background: var(--bg-2);
}
