:root {
	--ink: #14200f;
	--paper: #fffaf0;
	--grass: #2f6f2a;
	--accent: #ffcf3a;
	--danger: #e5372b;
	--water: #2f7fbf;
	--shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: #9fd3f5;
	color: var(--ink);
	font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
}

#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button {
	font: inherit;
	font-weight: 900;
	border: 3px solid var(--ink);
	border-radius: 12px;
	padding: 12px 18px;
	background: var(--paper);
	color: var(--ink);
	cursor: pointer;
	box-shadow: var(--shadow);
	transition: transform 0.06s;
}
button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
button.primary { background: var(--accent); }
button.small { padding: 6px 10px; font-size: 14px; border-width: 2px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }

/* ---- start screen ---- */

.screen {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 16px;
	background: radial-gradient(circle at 50% 30%, rgba(47, 111, 42, 0.55), rgba(10, 30, 10, 0.85));
	z-index: 20;
	overflow-y: auto;
}
.screen[hidden] { display: none; }

.card {
	width: min(460px, 100%);
	background: var(--paper);
	border: 4px solid var(--ink);
	border-radius: 20px;
	padding: 22px 22px 16px;
	box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35);
	text-align: center;
}
.card h1 {
	font-family: Bungee, Impact, sans-serif;
	font-weight: 400;
	font-size: clamp(42px, 12vw, 64px);
	line-height: 0.95;
	margin: 6px 0 4px;
	color: var(--danger);
	text-shadow: 3px 3px 0 var(--ink);
	letter-spacing: 1px;
}
.card h2 { font-family: Bungee, Impact, sans-serif; font-weight: 400; margin: 8px 0; }
.pov {
	display: inline-block;
	margin: 0;
	padding: 4px 10px;
	background: var(--ink);
	color: #fff;
	border-radius: 6px;
	font-weight: 700;
	font-size: 13px;
}
.sub { margin: 0 0 16px; font-weight: 700; font-size: 18px; }
.card label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; text-align: left; }
.card input {
	width: 100%;
	font: inherit;
	font-weight: 700;
	font-size: 18px;
	padding: 10px 12px;
	border: 3px solid var(--ink);
	border-radius: 12px;
	background: #fff;
	user-select: text;
	-webkit-user-select: text;
}
.row { display: flex; gap: 10px; margin-top: 12px; }
.row button { flex: 1; }
.row.join input { flex: 1.4; text-transform: uppercase; letter-spacing: 3px; }
#err { color: var(--danger); font-weight: 700; min-height: 1.2em; margin: 10px 0 0; }
details { text-align: left; margin-top: 6px; font-size: 14px; }
summary { font-weight: 900; cursor: pointer; }
details li { margin: 6px 0; }
kbd { border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 5px; padding: 0 5px; font-size: 12px; background: #fff; }
.credit { font-size: 12px; opacity: 0.75; margin: 12px 0 0; }
.credit a { color: inherit; }

/* ---- HUD ---- */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud[hidden] { display: none; }
#hud button { pointer-events: auto; }

#topbar {
	position: absolute;
	top: max(10px, env(safe-area-inset-top));
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 12px;
	width: min(560px, calc(100% - 140px));
}
#timer {
	font-family: Bungee, Impact, sans-serif;
	font-size: 26px;
	color: #fff;
	text-shadow: 2px 2px 0 var(--ink);
	min-width: 72px;
}
#goal { flex: 1; }
#goalBar { height: 16px; border: 3px solid var(--ink); border-radius: 10px; background: rgba(255, 255, 255, 0.6); overflow: hidden; }
#goalFill { height: 100%; width: 0; background: linear-gradient(90deg, #44b0ff, #2f7fbf); transition: width 0.3s; }
#goalText { font-weight: 900; font-size: 13px; color: #fff; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); margin-top: 2px; }
#role {
	font-weight: 900;
	font-size: 12px;
	padding: 4px 8px;
	border: 2px solid var(--ink);
	border-radius: 8px;
	background: var(--paper);
	white-space: nowrap;
}
#role.old { background: var(--danger); color: #fff; }

#topright { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; display: flex; gap: 6px; }

#notepad {
	position: absolute;
	top: 64px;
	left: 10px;
	width: 190px;
	background: #fffbe0 repeating-linear-gradient(transparent 0 19px, #c9d7f2 19px 20px);
	border: 2px solid var(--ink);
	border-radius: 6px;
	padding: 6px 10px 8px;
	font-family: "Comic Sans MS", "Bradley Hand", cursive;
	font-size: 14px;
	transform: rotate(-2deg);
	box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}
#notepad h3 { margin: 0 0 2px; font-size: 13px; font-family: Inter, sans-serif; font-weight: 900; }
#notepad ul { list-style: none; margin: 0; padding: 0; line-height: 20px; }
#notepad .x { color: var(--danger); font-weight: 900; letter-spacing: 1px; }
#notepad .gone { text-decoration: line-through; opacity: 0.6; }
#notepad:has(ul:empty) { display: none; }

#feed {
	position: absolute;
	top: 64px;
	right: 10px;
	width: min(300px, 45vw);
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 13px;
	font-weight: 700;
	text-align: right;
}
#feed li {
	display: block;
	width: fit-content;
	margin: 0 0 4px auto;
	padding: 3px 8px;
	background: rgba(20, 32, 15, 0.7);
	color: #fff;
	border-radius: 8px;
	animation: fadeout 6s forwards;
}
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#caption {
	position: absolute;
	left: 50%;
	bottom: calc(200px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	width: min(92vw, 720px);
	z-index: 2;
	text-align: center;
	font-weight: 900;
	font-size: clamp(22px, 5vw, 38px);
	line-height: 1.15;
	color: #fff;
	-webkit-text-stroke: 2px #000;
	paint-order: stroke fill;
	text-shadow: 0 3px 0 #000;
}
#caption .who { display: block; font-size: 0.45em; -webkit-text-stroke: 1px #000; color: var(--accent); }
#caption .line { display: block; animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(1.35); } to { transform: scale(1); } }

#hint {
	position: absolute;
	left: 50%;
	bottom: calc(150px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	padding: 6px 14px;
	background: rgba(20, 32, 15, 0.75);
	color: #fff;
	border-radius: 999px;
	font-weight: 900;
	font-size: 15px;
	white-space: nowrap;
}
#hint:empty { display: none; }
#hint.hot { background: var(--danger); animation: pulse 0.35s infinite alternate; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.12); } }

#labels { position: absolute; inset: 0; overflow: hidden; }
.label {
	position: absolute;
	left: 0;
	top: 0;
	transform: translate(-50%, -100%);
	text-align: center;
	white-space: nowrap;
	font-weight: 900;
	font-size: 12px;
	color: #fff;
	text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
	will-change: transform;
}
.label .lb { color: #9fe1ff; }
.label .x { color: #ff6b5e; }
.label.me .nm { color: var(--accent); }
.bubble {
	display: block;
	margin: 0 auto 4px;
	max-width: 220px;
	white-space: normal;
	padding: 5px 9px;
	background: #fff;
	color: var(--ink);
	text-shadow: none;
	border: 2px solid var(--ink);
	border-radius: 12px;
	font-size: 13px;
	animation: pop 0.2s ease-out;
}
.bubble.old { background: #ffe9a8; }
.bubble[hidden] { display: none; }
.bubble.bite { background: var(--danger); color: #fff; font-size: 18px; }

#banner {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	text-align: center;
	background: rgba(10, 20, 8, 0.45);
	color: #fff;
	padding: 16px;
}
#banner[hidden] { display: none; }
#banner .big {
	font-family: Bungee, Impact, sans-serif;
	font-size: clamp(34px, 9vw, 72px);
	line-height: 1;
	text-shadow: 4px 4px 0 #000;
}
#banner .small { font-weight: 900; font-size: clamp(16px, 3.6vw, 22px); margin-top: 12px; text-shadow: 2px 2px 0 #000; }
#banner .tag { display: inline-block; margin-bottom: 10px; padding: 4px 10px; border-radius: 8px; background: var(--accent); color: var(--ink); font-weight: 900; text-shadow: none; }
#banner .tag.old { background: var(--danger); color: #fff; }

/* ---- controls ---- */

#controls {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 150px;
	padding: 0 16px calc(14px + env(safe-area-inset-bottom));
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
}
#stick {
	width: 120px;
	height: 120px;
	border-radius: 50%;
	border: 3px solid rgba(255, 255, 255, 0.7);
	background: rgba(20, 32, 15, 0.25);
	position: relative;
	pointer-events: auto;
	visibility: hidden;
}
.touch #stick { visibility: visible; }
#knob {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 54px;
	height: 54px;
	margin: -27px 0 0 -27px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	border: 3px solid var(--ink);
}
#buttons { display: flex; align-items: flex-end; gap: 12px; }
button.act {
	position: relative;
	width: 92px;
	height: 92px;
	border-radius: 50%;
	padding: 0;
	font-size: 12px;
	line-height: 1.1;
	overflow: hidden;
	background: var(--paper);
}
button.act.big { width: 116px; height: 116px; font-size: 18px; background: var(--accent); }
button.act.hot { background: var(--danger); color: #fff; animation: pulse2 0.35s infinite alternate; }
@keyframes pulse2 { to { transform: scale(1.08); } }
button.act .key { display: block; font-size: 10px; opacity: 0.6; margin-top: 3px; }
.touch button.act .key { display: none; }
button.act .cd {
	position: absolute;
	inset: 0;
	background: rgba(20, 32, 15, 0.6);
	color: #fff;
	display: grid;
	place-items: center;
	font-size: 26px;
}
button.act .cd:empty { display: none; }
button.act[disabled] { opacity: 0.45; }

@media (max-width: 640px) {
	#notepad { top: 58px; width: 150px; font-size: 12px; }
	#feed { top: auto; bottom: 170px; font-size: 11px; }
	#topbar { width: calc(100% - 120px); left: 10px; transform: none; }
	#timer { font-size: 20px; min-width: 56px; }
	#role { display: none; }
	#caption { bottom: calc(196px + env(safe-area-inset-bottom)); }
}
