:root {
	--black: #000000;
	--white: #ffffff;
	--almost-white: #efe9e6;
	--almost-black: #111a20;
	--gray: #b3aca8;
	--share-color: rgb(88, 163, 81);
	--board-max: 360px;
	--bg: var(--white);
	--fg: var(--black);
	--panel: var(--almost-white);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: var(--almost-black);
		--fg: var(--white);
		--panel: #1c2830;
	}
}

html {
	font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
	font-size: 1.3em;
	line-height: 1.5rem;
}

html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--fg);
}

* {
	user-select: none;
	box-sizing: border-box;
}

/* hidden must beat the display:flex rules below (splash/game/results, guess area, feedback) */
[hidden] {
	display: none !important;
}

body {
	max-width: 520px;
	margin: 0 auto;
	padding: 10px 16px;
	display: flex;
	flex-direction: column;
	height: 100dvh;
}

/* header */
header {
	flex: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--fg);
}

header h1 {
	margin: 0;
	line-height: 42px;
}

.header-actions {
	display: flex;
	gap: 8px;
}

/* buttons */
button {
	font-size: 20px;
	font-weight: 700;
	padding: 10px;
	border: none;
	border-radius: 5px;
	cursor: pointer;
	touch-action: manipulation;
	font-family: inherit;
}

button.black {
	height: 44px;
	padding: 0 30px;
	background: var(--fg);
	color: var(--bg);
	border: 3px solid var(--fg);
	border-radius: 40px;
}

button.black:active {
	background: var(--bg);
	color: var(--fg);
}

button.white {
	height: 44px;
	padding: 0 30px;
	background: var(--bg);
	color: var(--fg);
	border: 3px solid var(--fg);
	border-radius: 40px;
}

button.white:active {
	background: var(--fg);
	color: var(--bg);
}

button.with-icon {
	padding: 0;
	width: 42px;
	height: 42px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	background: none;
	color: var(--fg);
	border: 2px solid var(--fg);
	border-radius: 50%;
}

button.with-icon:active {
	background: var(--fg);
	color: var(--bg);
}

button.closeDialog {
	position: absolute;
	top: 16px;
	right: 16px;
	padding: 0;
	border-radius: 50%;
	width: 40px;
	height: 40px;
}

button.closeDialog::after {
	content: "✕";
}

button.share {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 44px;
	padding: 0 26px;
	background: var(--share-color);
	color: #fff;
	border-radius: 40px;
}

button.share:active {
	opacity: 0.8;
}

/* screens */
.screen {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	gap: 2px;
}

h2 {
	text-align: center;
	margin: 6px 0 2px;
}

.tagline {
	margin: 0 0 10px;
	color: var(--gray);
	font-weight: 600;
	font-style: italic;
}

.subtitle {
	max-width: 24ch;
	margin: 14px 0 18px;
	font-weight: 600;
}

.controls {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
	max-width: 280px;
	align-items: stretch;
}

.controls button {
	width: 100%;
}

/* board */
.board-wrap {
	position: relative;
	/* cap by width AND height so the full game always fits one screen, no scroll */
	width: min(82vw, 300px, 42vh);
	aspect-ratio: 1 / 1;
	border: 3px solid var(--fg);
	border-radius: 12px;
	box-shadow: 6px 6px 0px 1px var(--fg);
	overflow: hidden;
	background: var(--bg);
}

.board-wrap.preview {
	box-shadow: 4px 4px 0px 1px var(--fg);
	width: min(60vw, 210px, 26vh);
}

canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.board-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg);
}

.board-overlay[hidden] {
	display: none;
}

/* progress dots */
.progress {
	display: flex;
	gap: 10px;
	margin: 0 0 14px;
}

.pip {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 2px solid var(--fg);
	background: var(--bg);
}

.pip.done {
	background: var(--fg);
}

.pip.current {
	outline: 2px solid var(--fg);
	outline-offset: 2px;
}

/* guess area */
.guess-area {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	margin-top: 16px;
	width: 100%;
}

.prompt {
	margin: 0;
	font-weight: 700;
}

.stepper {
	display: flex;
	align-items: center;
	gap: 10px;
}

.stepper .step {
	width: 52px;
	height: 52px;
	padding: 0;
	border-radius: 50%;
	font-size: 28px;
	line-height: 1;
}

#guessInput {
	width: 110px;
	height: 56px;
	text-align: center;
	font-size: 34px;
	font-weight: 800;
	font-family: inherit;
	color: var(--fg);
	background: var(--bg);
	border: 3px solid var(--fg);
	border-radius: 12px;
	-moz-appearance: textfield;
}

#guessInput::-webkit-outer-spin-button,
#guessInput::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* feedback */
.feedback {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	margin-top: 16px;
}

.feedback-line {
	margin: 0;
	font-weight: 700;
	max-width: 26ch;
}

.feedback-line .big {
	font-size: 1.5em;
	display: block;
	margin-bottom: 4px;
}

.feedback-line .muted {
	color: var(--gray);
	font-weight: 600;
}

/* results */
.score-big {
	font-size: 4rem;
	font-weight: 800;
	line-height: 1;
	margin: 10px 0 2px;
}

.score-big small {
	font-size: 1.2rem;
	color: var(--gray);
	font-weight: 700;
}

.grade {
	font-weight: 700;
	max-width: 26ch;
	margin: 6px 0 18px;
}

.round-emojis {
	font-size: 2rem;
	letter-spacing: 4px;
	margin-bottom: 22px;
}

.come-back {
	color: var(--gray);
	font-size: 0.85rem;
	font-weight: 600;
	margin: 22px 0 4px;
}

.more-games {
	font-size: 0.85rem;
}

.more-games a {
	color: var(--fg);
	text-decoration: none;
	font-weight: bold;
}

/* dialogs */
dialog {
	max-width: 400px;
	width: calc(100% - 32px);
	border: 3px solid var(--fg);
	border-radius: 0;
	background: var(--bg);
	color: var(--fg);
	padding: 24px;
}

dialog::backdrop {
	background: rgba(0, 0, 0, 0.5);
}

dialog h2 {
	margin-top: 0;
	text-align: left;
}

.help-list,
.help-list li {
	margin: 10px 0;
}

.help-list {
	padding-left: 22px;
}

.small-text {
	color: var(--gray);
	font-size: 0.8rem;
	line-height: 1.3rem;
	margin-top: 16px;
}

.brand {
	position: relative;
}

/* footer */
footer {
	flex: none;
	text-align: center;
	padding: 8px 0 4px;
	font-size: 0.72rem;
	line-height: 1rem;
	color: var(--gray);
}

footer a {
	color: var(--gray);
	font-weight: bold;
	text-decoration: none;
}

.header-subs {
	margin-bottom: 4px;
}

/* toast */
.toast-container {
	position: fixed;
	top: 90px;
	left: 0;
	right: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	z-index: 100;
	pointer-events: none;
}

.toast {
	padding: 10px 16px;
	background: var(--panel);
	color: var(--fg);
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 600;
	opacity: 0;
}

.toast.show {
	animation: toast 2.2s ease forwards;
}

@keyframes toast {
	0% { opacity: 0; transform: translateY(-6px); }
	10%, 80% { opacity: 1; transform: translateY(0); }
	100% { opacity: 0; }
}

@media screen and (max-width: 380px) {
	h1 { font-size: 34px; }
	html { font-size: 1.15em; }
}
