/* Bounce 'Em — dark cinematic, mobile-first vertical-phone UI. Matches the
   RumyFriend dark-monochrome brand (pure black, Inter, accent highlights). */

:root {
	--bg: #000000;
	--panel: rgba(255, 255, 255, 0.045);
	--panel-line: rgba(255, 255, 255, 0.1);
	--text: #f4f5f7;
	--muted: #9aa0ad;
	--accent: #ff7a3c; /* warm orange (tagline accent in the spec) */
	--accent-2: #6db7ff;
	--good: #51cf66;
	--danger: #ff6b6b;
	--radius: 16px;
	--safe-top: env(safe-area-inset-top, 0px);
	--safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family:
		"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	overscroll-behavior: none;
}

body {
	/* subtle radial vignette so pure black isn't flat */
	background:
		radial-gradient(
			120% 80% at 50% 0%,
			rgba(60, 80, 140, 0.18),
			transparent 60%
		),
		radial-gradient(
			100% 70% at 50% 100%,
			rgba(120, 60, 40, 0.12),
			transparent 55%
		),
		var(--bg);
}

#app {
	max-width: 520px;
	margin: 0 auto;
	min-height: 100%;
	min-height: 100dvh;
	position: relative;
	display: flex;
	flex-direction: column;
}

.screen {
	display: none;
	flex: 1;
	flex-direction: column;
	padding: calc(16px + var(--safe-top)) 18px calc(16px + var(--safe-bottom));
}
.screen.active {
	display: flex;
}

/* ----------------------------------------------------------- connect / brand */
.brand {
	text-align: center;
	margin: 8vh 0 4vh;
}
.brand h1 {
	font-size: clamp(40px, 13vw, 64px);
	margin: 0;
	letter-spacing: -0.02em;
	font-weight: 800;
}
.brand h1 .accent {
	color: var(--accent);
	font-style: italic;
	font-family: "Instrument Serif", Georgia, serif;
	font-weight: 400;
}
.tagline {
	color: var(--accent);
	font-size: 16px;
	margin: 8px 0 0;
	font-weight: 600;
}

.card,
.summary-card {
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: var(--radius);
	padding: 20px;
	backdrop-filter: blur(8px);
}
.card {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
	color: var(--muted);
}
.field input {
	background: rgba(0, 0, 0, 0.45);
	border: 1px solid var(--panel-line);
	border-radius: 12px;
	color: var(--text);
	font-size: 17px;
	padding: 14px 14px;
	outline: none;
}
.field input:focus {
	border-color: var(--accent-2);
}

.btn {
	appearance: none;
	border: 1px solid var(--panel-line);
	background: rgba(255, 255, 255, 0.06);
	color: var(--text);
	font-size: 16px;
	font-weight: 600;
	padding: 14px 16px;
	border-radius: 12px;
	cursor: pointer;
	min-height: 48px;
	transition:
		transform 0.06s ease,
		background 0.15s ease,
		opacity 0.15s ease;
}
.btn:active {
	transform: scale(0.98);
}
.btn.primary {
	background: linear-gradient(180deg, #ff8a4f, var(--accent));
	border-color: transparent;
	color: #1a0e06;
}
.btn.small {
	font-size: 14px;
	padding: 10px 12px;
	min-height: 40px;
}
.btn[disabled] {
	opacity: 0.45;
	pointer-events: none;
}

.divider {
	text-align: center;
	color: var(--muted);
	font-size: 12px;
	position: relative;
	margin: 2px 0;
}
.divider span {
	background: transparent;
	padding: 0 10px;
}
.divider::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 1px;
	background: var(--panel-line);
	z-index: -1;
}

.error {
	color: var(--danger);
	font-size: 14px;
	text-align: center;
	margin-top: 12px;
}
.hint {
	color: var(--muted);
	font-size: 13px;
	text-align: center;
}

/* ------------------------------------------------------------------- lobby */
.lobby-head h2 {
	margin: 0 0 12px;
	font-size: 24px;
}
.code-row {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-bottom: 10px;
}
.code-label {
	font-size: 12px;
	color: var(--muted);
}
.code-big {
	font-size: clamp(22px, 7vw, 32px);
	font-weight: 800;
	letter-spacing: 0.04em;
	color: var(--accent);
	word-break: break-all;
}
.player-list {
	list-style: none;
	margin: 16px 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.player-list li {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: 12px;
	padding: 12px 14px;
	font-size: 16px;
}
.player-list .dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--good);
	flex: none;
}
.player-list .dot.off {
	background: var(--muted);
}
.player-list .tag {
	margin-left: auto;
	font-size: 11px;
	color: var(--muted);
	border: 1px solid var(--panel-line);
	border-radius: 999px;
	padding: 2px 8px;
}
.player-list .tag.host {
	color: var(--accent);
	border-color: var(--accent);
}

.host-controls {
	margin-top: auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.control-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.control-label {
	font-size: 15px;
	color: var(--muted);
}
.stepper {
	display: flex;
	align-items: center;
	gap: 14px;
}
.stepper .step {
	width: 44px;
	height: 44px;
	border-radius: 12px;
	border: 1px solid var(--panel-line);
	background: rgba(255, 255, 255, 0.06);
	color: var(--text);
	font-size: 22px;
	cursor: pointer;
}
.stepper .step-value {
	min-width: 28px;
	text-align: center;
	font-size: 20px;
	font-weight: 700;
}

/* -------------------------------------------------------------------- game */
#screen-game {
	padding: 0;
}
.hud {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: calc(8px + var(--safe-top)) 12px 8px;
}
.scoreboard {
	display: flex;
	gap: 6px;
	flex: 1;
	min-width: 0;
	overflow: hidden;
}
.chip {
	flex: 1 1 0;
	min-width: 0;
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: 10px;
	padding: 6px 8px;
	display: flex;
	flex-direction: column;
	gap: 1px;
}
.chip .chip-name {
	font-size: 11px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.chip .chip-sub {
	font-size: 10px;
	color: var(--muted);
	display: flex;
	justify-content: space-between;
	gap: 6px;
}
.chip.me {
	border-color: var(--accent);
}
.chip.done {
	background: rgba(81, 207, 102, 0.12);
}
.chip .blocks {
	color: var(--text);
	font-weight: 700;
}
.hud-right {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: none;
}
.round-pill,
.timer-pill {
	font-size: 12px;
	font-weight: 700;
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: 999px;
	padding: 5px 9px;
}
.timer-pill.warn {
	color: var(--danger);
	border-color: var(--danger);
}
.icon-btn {
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: 10px;
	width: 34px;
	height: 34px;
	font-size: 16px;
	cursor: pointer;
}
/* Top-left leave-the-match button (spec §9). Small + danger-tinted so it reads as
 *  "exit" without competing with the scoreboard. */
.exit-btn {
	flex: none;
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: 10px;
	width: 34px;
	height: 34px;
	font-size: 15px;
	font-weight: 700;
	color: var(--muted);
	cursor: pointer;
}
.exit-btn:active {
	transform: scale(0.94);
}
.exit-btn:hover {
	color: var(--danger);
	border-color: var(--danger);
}

/* Leave-confirm sheet: a dimmed overlay over the play stage. */
.exit-confirm {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(0, 0, 0, 0.62);
	backdrop-filter: blur(2px);
	z-index: 5;
}
.exit-confirm[hidden] {
	display: none;
}
.exit-card {
	background: var(--panel);
	border: 1px solid var(--panel-line);
	border-radius: var(--radius);
	padding: 20px;
	max-width: 340px;
	text-align: center;
}
.exit-card h3 {
	margin: 0 0 8px;
	font-size: 18px;
}
.exit-card p {
	margin: 0 0 16px;
	font-size: 13px;
	color: var(--muted);
	line-height: 1.4;
}
.exit-actions {
	display: flex;
	gap: 10px;
}
.exit-actions .btn {
	flex: 1;
}

.stage {
	position: relative;
	flex: 1;
	min-height: 0;
}
#game-canvas {
	display: block;
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	touch-action: none;
}

.toast {
	position: absolute;
	top: 12px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(0, 0, 0, 0.7);
	border: 1px solid var(--panel-line);
	border-radius: 999px;
	padding: 8px 16px;
	font-size: 14px;
	font-weight: 700;
	white-space: nowrap;
	pointer-events: none;
}
.toast.pop {
	animation: pop 0.25s ease;
}
@keyframes pop {
	from {
		transform: translateX(-50%) scale(0.8);
		opacity: 0;
	}
}

.respawn-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22vw;
	font-weight: 800;
	color: #fff;
	text-shadow: 0 0 30px rgba(120, 160, 255, 0.8);
	pointer-events: none;
}

.joystick {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: calc(14px + var(--safe-bottom));
	width: 108px;
	height: 108px;
	border-radius: 50%;
	/* Slightly visible assistive-touch feel, not visually dominant (spec §3). */
	background: rgba(255, 255, 255, 0.035);
	border: 1px solid rgba(255, 255, 255, 0.09);
	touch-action: none;
	transition: opacity 0.2s ease;
}
/* Hidden the moment a keyboard player moves; restored on touch (spec §3). */
.joystick.hidden {
	opacity: 0;
	pointer-events: none;
}
.joystick-knob {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 52px;
	height: 52px;
	margin: -26px 0 0 -26px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	border: 1px solid rgba(255, 255, 255, 0.28);
	transition: opacity 0.2s ease;
}

/* --------------------------------------------------------- summaries */
#screen-round,
#screen-match {
	justify-content: center;
}
.summary-card {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.summary-card h2 {
	margin: 0;
	font-size: 26px;
}
.winner-line {
	color: var(--accent);
	font-weight: 700;
	font-size: 18px;
	margin: 0;
}
.results {
	list-style: none;
	margin: 6px 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.results li {
	display: grid;
	grid-template-columns: 28px 1fr auto auto;
	align-items: center;
	gap: 10px;
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid var(--panel-line);
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 15px;
}
.results .place {
	color: var(--muted);
	font-weight: 700;
}
.results .pname {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.results .pts {
	color: var(--accent);
	font-weight: 700;
}
.results .total {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.champ-head {
	color: var(--muted);
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	margin: 0;
}
.champ-name {
	font-size: 30px;
	font-weight: 800;
	color: var(--accent);
	margin: 0;
}
.drama-head {
	margin: 8px 0 0;
	font-size: 15px;
	color: var(--muted);
}
.drama {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
}
.drama li {
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid var(--panel-line);
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 12px;
}
.drama .dlabel {
	color: var(--muted);
	display: block;
}
.drama .dwho {
	font-weight: 700;
}
.drama .dval {
	color: var(--accent);
	font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
	.toast.pop {
		animation: none;
	}
	.btn {
		transition: none;
	}
}
