/* Fivefold — self-contained, no dependencies. */

:root {
	--bg: #0f141b;
	--surface: #171f2a;
	--primary: #5b8def;
	--silver: #9aaac4;
	--text: #edf1f7;
	--muted: #a7b2c1;
	--border: #2a3441;

	--p0: #5b8def;
	--p1: #e0a83e;

	--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	--font-display: "Space Grotesk", "Inter", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
	margin: 0;
	background:
		radial-gradient(ellipse 90% 55% at 50% -10%, rgba(91, 141, 239, 0.18), transparent 70%),
		var(--bg);
	color: var(--text);
	font-family: var(--font);
	display: grid;
	place-items: center;
	padding: clamp(0.75rem, 2.5vw, 2rem);
	overflow-x: hidden;
	color-scheme: dark;
}

h1 {
	font-family: var(--font-display);
	font-size: clamp(2rem, 1rem + 5vw, 3.5rem);
	font-weight: 700;
	letter-spacing: -0.03em;
	margin: 0 0 0.75rem;
}

/* ---- menu ---- */

.menu {
	width: 100%;
	max-width: 34rem;
	text-align: center;
}

.menu[hidden] { display: none; }

.lede {
	color: var(--muted);
	font-size: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
	margin: 0 auto 2rem;
	max-width: 32ch;
	text-wrap: pretty;
}

.menu__actions {
	display: grid;
	gap: 0.75rem;
	justify-content: center;
}

.record {
	color: var(--silver);
	font-size: 0.875rem;
	margin: 1.25rem 0 0;
	min-height: 1.2em;
}

.linkish {
	font-family: var(--font);
	font-size: 0.875rem;
	color: var(--muted);
	background: none;
	border: 0;
	border-bottom: 1px dotted var(--border);
	padding: 0.25rem 0;
	margin-top: 1.5rem;
	cursor: pointer;
}

.linkish:hover { color: var(--text); }

.rules {
	margin-top: 1.5rem;
	text-align: left;
	background: rgba(23, 31, 42, 0.7);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 1.25rem;
	color: var(--muted);
	font-size: 0.9375rem;
	line-height: 1.65;
}

.rules[hidden] { display: none; }

.rules h2 {
	font-family: var(--font-display);
	font-size: 0.8125rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--primary);
	margin: 1.25rem 0 0.5rem;
}

.rules h2:first-child { margin-top: 0; }
.rules p { margin: 0 0 0.75rem; }
.rules strong { color: var(--text); }

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

.game {
	width: 100%;
	max-width: 40rem;
}

.game[hidden] { display: none; }

.bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 0.75rem;
	flex-wrap: wrap;
}

.scores { display: flex; gap: 1rem; }

.score {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.8125rem;
	color: var(--muted);
}

.score strong {
	font-family: var(--font-display);
	color: var(--text);
	font-size: 1rem;
}

.dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	flex: none;
}

.score--p0 .dot { background: var(--p0); }
.score--p1 .dot { background: var(--p1); }

.turn {
	font-family: var(--font-display);
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text);
	margin: 0;
}

/* ---- board ---- */

.board {
	display: grid;
	grid-template-columns: repeat(10, 1fr);
	gap: clamp(2px, 0.5vw, 4px);
	width: 100%;
	aspect-ratio: 1;
	margin-bottom: 0.75rem;
}

.cell {
	position: relative;
	display: grid;
	place-items: center;
	padding: 0;
	aspect-ratio: 1;
	background: rgba(23, 31, 42, 0.85);
	border: 1px solid var(--border);
	border-radius: clamp(3px, 0.8vw, 6px);
	color: var(--silver);
	font-family: var(--font);
	cursor: default;
	overflow: hidden;
	min-width: 0;
}

.cell__face {
	font-size: clamp(0.5rem, 1.55vw, 0.8125rem);
	font-weight: 600;
	line-height: 1;
	letter-spacing: -0.03em;
	pointer-events: none;
}

.cell__face.is-red { color: #d98a8a; }

.cell--corner {
	background: rgba(154, 170, 196, 0.16);
	border-color: var(--silver);
	color: var(--silver);
}

/*
   Tokens are a filled disc over the card face. Ownership is shown by colour
   AND by a ring, so the two players remain distinguishable without relying on
   colour perception alone.
*/
.cell--p0::after,
.cell--p1::after {
	content: "";
	position: absolute;
	inset: 14%;
	border-radius: 50%;
	box-shadow: inset 0 0 0 2px rgba(11, 16, 23, 0.55);
}

.cell--p0::after { background: var(--p0); }

.cell--p1::after {
	background: var(--p1);
	/* Second player's token also carries a visible inner dot. */
	box-shadow: inset 0 0 0 2px rgba(11, 16, 23, 0.55), inset 0 0 0 5px rgba(11, 16, 23, 0.35);
}

.cell--locked { border-color: var(--text); }

.cell--locked::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: inset 0 0 0 2px rgba(237, 241, 247, 0.85);
	z-index: 1;
	pointer-events: none;
}

.cell--target {
	cursor: pointer;
	border-color: var(--primary);
	background: rgba(91, 141, 239, 0.22);
}

.cell--target:hover { background: rgba(91, 141, 239, 0.38); }

.cell:disabled { cursor: default; }

/* ---- status + hand ---- */

.status {
	min-height: 2.6em;
	margin: 0 0 0.5rem;
	font-size: 0.875rem;
	color: var(--muted);
	text-align: center;
	line-height: 1.4;
}

.handbar {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.hand,
.cardrow {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.4rem;
}

.cardrow { margin-top: 1rem; }

.card {
	font-family: var(--font-display);
	font-size: clamp(0.8125rem, 0.75rem + 0.3vw, 0.9375rem);
	font-weight: 600;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 9px;
	padding: 0.6rem 0.7rem;
	min-width: 3.1rem;
	cursor: pointer;
	line-height: 1.1;
}

.card--red { color: #e79a9a; }

.card--special {
	font-size: 0.6875rem;
	letter-spacing: 0.02em;
	color: var(--primary);
	border-color: rgba(91, 141, 239, 0.5);
	min-width: 4.4rem;
}

.card:hover { border-color: var(--silver); }

.card--on {
	border-color: var(--primary);
	background: rgba(91, 141, 239, 0.2);
}

.card--dead { opacity: 0.42; }

.deckline {
	text-align: center;
	font-size: 0.75rem;
	color: var(--muted);
	margin: 0.75rem 0 0;
	opacity: 0.75;
}

/* ---- overlay ---- */

.overlay {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: grid;
	place-items: center;
	padding: 1rem;
	background: rgba(8, 12, 18, 0.72);
	backdrop-filter: blur(4px);
}

.overlay[hidden] { display: none; }

.sheet {
	width: 100%;
	max-width: 26rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: clamp(1.25rem, 4vw, 1.75rem);
	text-align: center;
}

.sheet h2 {
	font-family: var(--font-display);
	font-size: 1.375rem;
	margin: 0 0 0.5rem;
}

.sheet p {
	color: var(--muted);
	font-size: 0.9375rem;
	margin: 0 0 0.5rem;
	line-height: 1.55;
}

.sheet__actions {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-top: 1.25rem;
}

.sheet__actions:empty { display: none; }

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

.btn {
	font-family: var(--font-display);
	font-size: 1rem;
	font-weight: 600;
	color: #0b1017;
	background: var(--primary);
	border: 1px solid transparent;
	border-radius: 12px;
	padding: 0.8rem 1.5rem;
	cursor: pointer;
}

.btn:hover { background: #7da3f5; }

.btn--lg { font-size: 1.0625rem; padding: 0.95rem 1.75rem; }

.btn--ghost {
	background: transparent;
	color: var(--text);
	border-color: var(--border);
}

.btn--ghost:hover { background: rgba(154, 170, 196, 0.12); }

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

@media (prefers-reduced-motion: no-preference) {
	.btn, .card, .cell { transition: background-color 130ms ease, border-color 130ms ease; }
}

@media (max-width: 30rem) {
	.bar { justify-content: center; }
	.turn { width: 100%; text-align: center; }
}
