:root {
	--bg: #0f0a1e;
	--bg2: #1a1233;
	--panel: rgba(255, 255, 255, 0.06);
	--panel-border: rgba(255, 255, 255, 0.12);
	--accent: #ffb347;
	--accent2: #ff6b6b;
	--good: #4ade80;
	--text: #f4f1ff;
	--muted: #a99fd6;
	--wolf: #6d28d9;
	--radius: 18px;
	--shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
	--font: "Fredoka", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html,
body {
	margin: 0;
	padding: 0;
	min-height: 100%;
	background: radial-gradient(ellipse at top, #1f1640 0%, var(--bg) 60%);
	color: var(--text);
	font-family: var(--font);
	font-size: 17px;
	line-height: 1.45;
	overflow-x: hidden;
	overscroll-behavior: none;
}

body {
	min-height: 100dvh;
}

#app {
	width: 100%;
	max-width: 540px;
	margin: 0 auto;
	min-height: 100dvh;
	position: relative;
}

/* ===== Screens ===== */
.screen {
	display: none;
	padding: max(env(safe-area-inset-top), 20px) 22px max(env(safe-area-inset-bottom), 24px);
	min-height: 100dvh;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	gap: 18px;
}
.screen.active {
	display: flex;
	animation: fade 0.35s ease;
}
@keyframes fade {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ===== Home / Hero ===== */
.hero {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 220px;
	margin-bottom: 6px;
}
.moon {
	position: absolute;
	width: 120px;
	height: 120px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 35%, #fff7e0, #ffd97a 60%, #f5b94a);
	box-shadow: 0 0 50px rgba(255, 200, 100, 0.45), 0 0 100px rgba(255, 160, 60, 0.25);
	top: 10px;
}
.hero-wolf {
	position: relative;
	z-index: 2;
	height: 170px;
	width: auto;
	filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
	animation: bob 4s ease-in-out infinite;
}
@keyframes bob {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-8px); }
}
.stars {
	position: absolute;
	inset: 0;
	background-image:
		radial-gradient(1.5px 1.5px at 20% 30%, #fff, transparent),
		radial-gradient(1px 1px at 60% 20%, #fff, transparent),
		radial-gradient(1.5px 1.5px at 80% 50%, #fff, transparent),
		radial-gradient(1px 1px at 35% 70%, #fff, transparent),
		radial-gradient(1.2px 1.2px at 75% 80%, #fff, transparent),
		radial-gradient(1px 1px at 50% 40%, #fff, transparent);
	opacity: 0.7;
}

.title {
	text-align: center;
	font-size: clamp(2.4rem, 9vw, 3.4rem);
	font-weight: 700;
	margin: 0;
	letter-spacing: 0.5px;
	background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	text-shadow: 0 4px 24px rgba(255, 107, 107, 0.25);
}
.subtitle {
	text-align: center;
	color: var(--muted);
	margin: -8px 0 10px;
	font-size: 1.05rem;
}

/* ===== Buttons ===== */
.btn {
	appearance: none;
	border: none;
	font-family: inherit;
	font-size: 1.1rem;
	font-weight: 600;
	padding: 16px 24px;
	border-radius: 999px;
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
	width: 100%;
}
.btn:active {
	transform: scale(0.97);
}
.btn-primary {
	background: linear-gradient(135deg, var(--accent), var(--accent2));
	color: #1a0d00;
	box-shadow: 0 8px 24px rgba(255, 107, 107, 0.35);
}
.btn-primary:hover {
	filter: brightness(1.06);
}
.btn-ghost {
	background: var(--panel);
	color: var(--text);
	border: 1px solid var(--panel-border);
	backdrop-filter: blur(6px);
}
.btn-ghost:hover {
	background: rgba(255, 255, 255, 0.1);
}

.back {
	align-self: flex-start;
	background: none;
	border: none;
	color: var(--muted);
	font-family: inherit;
	font-size: 1rem;
	padding: 6px 0;
	cursor: pointer;
}
.back:hover {
	color: var(--text);
}

/* ===== How to play ===== */
h2 {
	font-size: 1.6rem;
	margin: 0 0 4px;
	text-align: center;
}
.rules {
	padding-left: 20px;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.rules li {
	color: var(--text);
}
.rules b {
	color: var(--accent);
}

/* ===== Setup ===== */
.field {
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: var(--radius);
	padding: 16px 18px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.field label {
	font-size: 0.95rem;
	color: var(--muted);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.6px;
}
.stepper {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}
.step {
	width: 48px;
	height: 48px;
	border-radius: 14px;
	border: 1px solid var(--panel-border);
	background: rgba(255, 255, 255, 0.08);
	color: var(--text);
	font-size: 1.6rem;
	font-weight: 600;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, transform 0.1s ease;
}
.step:active {
	transform: scale(0.92);
}
.step:hover {
	background: rgba(255, 255, 255, 0.16);
}
.step-value {
	font-size: 1.5rem;
	font-weight: 700;
	flex: 1;
	text-align: center;
}
.hint {
	margin: 0;
	font-size: 0.82rem;
	color: var(--muted);
}

/* ===== Reveal ===== */
.reveal-top {
	text-align: center;
}
.reveal-topic {
	font-size: 1rem;
	color: var(--muted);
	margin: 0;
}
.reveal-topic span {
	color: var(--accent);
	font-weight: 600;
}
.reveal-progress {
	font-size: 1.2rem;
	font-weight: 600;
	margin: 4px 0 0;
}

.card-stage {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	perspective: 1200px;
	min-height: 320px;
}
.word-card {
	width: 100%;
	max-width: 360px;
	aspect-ratio: 3 / 4;
	position: relative;
	transform-style: preserve-3d;
	transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
	cursor: pointer;
}
.word-card.flipped {
	transform: rotateY(180deg);
}
.card-face {
	position: absolute;
	inset: 0;
	border-radius: 24px;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-shadow: var(--shadow);
	border: 1px solid var(--panel-border);
}
.card-back {
	background: linear-gradient(160deg, #2a1d54, #1a1233);
	gap: 14px;
}
.card-back-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
}
.card-emoji {
	font-size: 3.4rem;
	filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}
.card-prompt {
	font-size: 1.15rem;
	font-weight: 600;
	text-align: center;
	color: var(--text);
}
.card-name {
	color: var(--accent);
	font-weight: 700;
	font-size: 1.05rem;
}
.card-front {
	background: linear-gradient(160deg, #3a2766, #211640);
	transform: rotateY(180deg);
	gap: 10px;
}
.your-word-label {
	text-transform: uppercase;
	letter-spacing: 1.5px;
	font-size: 0.8rem;
	color: var(--muted);
	margin: 0;
}
.word-text {
	font-size: clamp(2rem, 10vw, 3rem);
	font-weight: 700;
	margin: 4px 0;
	text-align: center;
	color: #fff;
	word-break: break-word;
}
.word-role {
	margin: 0;
	font-size: 1rem;
	color: var(--muted);
}
.word-role.citizen {
	color: var(--good);
}
.word-role.wolf {
	color: var(--accent2);
	font-weight: 600;
}
.card-done {
	margin-top: 14px;
}
.pass-hint {
	text-align: center;
	color: var(--muted);
	font-size: 1rem;
}

/* ===== Discussion / Timer ===== */
.discuss-title,
.vote-title {
	text-align: center;
}
.discuss-topic {
	text-align: center;
	color: var(--muted);
	margin: -8px 0 6px;
}
.timer-ring {
	position: relative;
	width: 220px;
	height: 220px;
	margin: 8px auto;
	display: flex;
	align-items: center;
	justify-content: center;
}
.timer-svg {
	width: 100%;
	height: 100%;
	transform: rotate(-90deg);
}
.timer-track {
	fill: none;
	stroke: rgba(255, 255, 255, 0.1);
	stroke-width: 8;
}
.timer-prog {
	fill: none;
	stroke: url(#g);
	stroke: var(--accent);
	stroke-width: 8;
	stroke-linecap: round;
	stroke-dasharray: 326.7;
	stroke-dashoffset: 0;
	transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}
.timer-prog.warn {
	stroke: var(--accent2);
}
.timer-text {
	position: absolute;
	font-size: 2.6rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}
.discuss-controls {
	display: flex;
	gap: 12px;
}
.discuss-controls .btn {
	flex: 1;
}

/* ===== Voting ===== */
.vote-sub {
	text-align: center;
	color: var(--muted);
	margin: -8px 0 6px;
}
.vote-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 12px;
}
.vote-card {
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: 16px;
	padding: 18px 12px;
	text-align: center;
	cursor: pointer;
	font-weight: 600;
	font-size: 1.05rem;
	transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.vote-card:active {
	transform: scale(0.96);
}
.vote-card:hover {
	border-color: var(--accent);
	background: rgba(255, 179, 71, 0.12);
}
.vote-card.disabled {
	opacity: 0.4;
	pointer-events: none;
}
.vote-card.selected {
	border-color: var(--accent2);
	background: rgba(255, 107, 107, 0.18);
}

/* ===== Results ===== */
#result-content {
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: 14px;
	align-items: center;
}
.result-emoji {
	font-size: 4rem;
}
.result-title {
	font-size: 1.8rem;
	font-weight: 700;
	margin: 0;
}
.result-words {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: var(--radius);
	padding: 16px;
}
.result-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	font-size: 1.02rem;
}
.result-row .name {
	font-weight: 600;
}
.result-row .word {
	color: var(--muted);
}
.result-row.wolf .word {
	color: var(--accent2);
	font-weight: 700;
}
.result-row.wolf .name::after {
	content: " 🐺";
}
.result-summary {
	color: var(--muted);
	margin: 0;
}

@media (min-width: 480px) {
	.screen {
		padding-top: 32px;
	}
	.vote-grid {
		grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	}
}

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