/* Live multiplayer rooms, shared by every game that has them: joining, the
   lobby, the timer, standings and the action bar. Phones first: one column,
   the main button pinned to the bottom of the screen. Each game's own live.css
   adds its question and reveal screens. */

.live-app {
	max-width: 640px;
}

main:has(.live-app) {
	padding-bottom: 0;
}

.live-app[data-screen="entry"] .screen-entry,
.live-app[data-screen="lobby"] .screen-lobby,
.live-app[data-screen="question"] .screen-question,
.live-app[data-screen="reveal"] .screen-reveal,
.live-app[data-screen="final"] .screen-final {
	display: block;
	animation: screen-in 0.4s var(--ease-out);
}

.live-app [hidden] {
	display: none !important;
}

/* ---------- Room strip ---------- */

.room-strip {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 36px;
	margin: -14px 0 12px;
}

.room-strip-code {
	font-weight: 800;
	font-size: 15px;
	letter-spacing: 0.04em;
}

.room-strip-tools {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 4px;
	margin-left: auto;
}

.room-strip .btn.small {
	color: var(--muted);
	font-size: 14px;
}

.room-strip .btn.is-armed {
	border-color: var(--ink);
	background: var(--coral);
	color: var(--ink);
	animation: pop-in 0.3s var(--ease-spring);
}

/* ---------- Avatars, tags, chips ---------- */

.avatar {
	flex: none;
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: var(--border);
	border-radius: 50%;
	background: var(--av, var(--pink));
	font-weight: 800;
	font-size: 17px;
	line-height: 1;
}

.avatar.small {
	width: 28px;
	height: 28px;
	font-size: 14px;
}

.tag {
	flex: none;
	padding: 1px 9px;
	border: 2px solid var(--ink);
	border-radius: 50px;
	background: var(--yellow);
	font-size: 13px;
	font-weight: 700;
}

.tag-you {
	background: var(--surface);
}

.tag-away {
	border-style: dashed;
	background: transparent;
	color: var(--muted);
}

.count-pill {
	padding: 1px 11px;
	border: var(--border);
	border-radius: 50px;
	background: var(--surface);
	font-size: 14px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.chip-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 40px;
	padding: 6px 14px;
	border: var(--border);
	border-radius: 50px;
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-weight: 600;
	font-size: 15px;
	cursor: pointer;
	transition: background-color 0.15s, transform 0.2s var(--ease-spring);
}

.chip:active {
	transform: scale(0.95);
}

.chip[aria-pressed="true"] {
	background: var(--ink);
	color: #fff;
}

.chip-count {
	color: var(--muted);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] .chip-count {
	color: inherit;
	opacity: 0.7;
}

/* ---------- Entry ---------- */

.entry-card {
	display: grid;
	gap: 14px;
	margin-bottom: 20px;
}

.entry-card h2 {
	font-size: 26px;
}

.entry-host {
	background: transparent;
	border-style: dashed;
}

.entry-note {
	color: var(--muted);
	font-size: 15px;
	line-height: 1.4;
}

.field {
	display: grid;
	gap: 5px;
}

.field > span {
	font-weight: 700;
	font-size: 15px;
}

.field input {
	width: 100%;
	min-height: 50px;
	padding: 10px 14px;
	border: var(--border);
	border-radius: var(--radius-control);
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-size: 18px; /* 16+ keeps iOS from zooming in */
	font-weight: 600;
}

.field input:focus-visible {
	outline: 3px solid var(--mint-strong);
	outline-offset: 1px;
}

.field .code-input {
	font-weight: 800;
	font-size: 34px;
	letter-spacing: 0.4em;
	text-transform: uppercase;
	text-align: center;
	padding-left: 0.4em; /* balance the trailing letter-spacing */
}

.code-input::placeholder {
	color: var(--bg-dot);
}

.entry-solo {
	margin: 4px 0 30px;
	text-align: center;
	font-weight: 600;
}

/* ---------- Lobby ---------- */

.room-head {
	display: grid;
	justify-items: center;
	gap: 10px;
	margin-bottom: 24px;
	text-align: center;
}

.room-label {
	color: var(--muted);
	font-weight: 700;
}

/* The code is the thing to read out loud. Each game styles its letters. */
.room-code {
	display: flex;
	gap: 8px;
	font-weight: 800;
	font-size: clamp(64px, 22vw, 104px);
	line-height: 1;
	letter-spacing: -0.02em;
}

.share-btn {
	margin-top: 6px;
}

.card-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
}

.players-card,
.settings-card,
.settings-summary {
	margin-bottom: 18px;
	padding: 18px;
}

.players-card h3,
.settings-card h3,
.settings-summary h3 {
	font-size: 21px;
}

.player-list {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.player {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 6px 8px 6px 6px;
	border: 2px solid transparent;
	border-radius: 12px;
	animation: pop-in 0.4s var(--ease-spring);
}

.player.is-me {
	border-color: var(--ink);
	background: #fff8d6;
}

.player.is-away {
	opacity: 0.55;
}

.player-name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-weight: 700;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.kick {
	flex: none;
	width: 34px;
	height: 34px;
	border: 2px solid transparent;
	border-radius: 50%;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.kick:hover {
	border-color: var(--ink);
	color: var(--ink);
}

@keyframes pop-in {
	from {
		opacity: 0;
		transform: scale(0.9) translateY(6px);
	}
}

.setting {
	margin-top: 18px;
}

.setting-label {
	margin-bottom: 8px;
	font-weight: 700;
	font-size: 15px;
}

.settings-card .seg span {
	min-width: 48px;
	padding: 8px 14px;
	text-align: center;
}

.settings-summary p {
	margin-top: 8px;
	line-height: 1.45;
}

/* ---------- Question ---------- */

.q-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 12px;
	margin-bottom: 12px;
	font-weight: 700;
}

.q-round {
	font-weight: 800;
}

.q-locked {
	color: var(--muted);
	font-size: 15px;
	font-variant-numeric: tabular-nums;
}

/* The fill shrinks as time runs down. */
.timer {
	--left: 1;
	position: relative;
	height: 24px;
	margin-bottom: 10px;
	border: var(--border);
	border-radius: 50px;
	background: var(--surface);
	overflow: hidden;
}

.timer-fill {
	position: absolute;
	inset: 0 auto 0 0;
	width: calc(var(--left) * 100%);
	background: var(--mint);
	border-right: var(--border);
	transition: background-color 0.3s;
}

.timer.is-low .timer-fill {
	background: var(--coral);
	animation: throb 0.5s ease-in-out infinite alternate;
}

@keyframes throb {
	to {
		opacity: 0.7;
	}
}

.timer-text {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 14px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.waiting {
	display: grid;
	justify-items: center;
	gap: 8px;
	margin-bottom: 14px;
	padding: 22px 18px;
	text-align: center;
	animation: pop-in 0.4s var(--ease-spring);
}

.waiting-title {
	font-weight: 800;
	font-size: 26px;
}

.waiting-text {
	color: var(--muted);
	font-weight: 600;
}

.waiting-avatars {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	margin: 6px 0 0;
	padding: 0;
	list-style: none;
}

.waiting-avatars li {
	opacity: 0.35;
	transition: opacity 0.3s, transform 0.3s var(--ease-spring);
}

.waiting-avatars li.is-locked {
	opacity: 1;
	transform: translateY(-3px);
}

/* ---------- Reveal ---------- */

/* Last place is dealt first, so the winner lands last. */
@keyframes deal-in {
	from {
		opacity: 0;
		transform: translateY(30px) rotate(-5deg) scale(0.92);
	}
}

/* ---------- Final ---------- */

.final-title {
	margin: 10px 0 22px;
	font-size: clamp(44px, 13vw, 76px);
	text-align: center;
	letter-spacing: -0.035em;
}

.standings {
	display: grid;
	gap: 10px;
	margin: 0 0 20px;
	padding: 0;
	list-style: none;
}

/* Each row is filled with the player's color, as far as their share of a perfect game. */
.standing {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 58px;
	padding: 8px 14px 8px 8px;
	border: var(--border);
	border-radius: 14px;
	background: linear-gradient(90deg, var(--av) calc(var(--share) * 100%), var(--surface) 0);
	box-shadow: var(--shadow);
	animation: deal-in 0.55s var(--ease-spring) both;
	animation-delay: calc(var(--i) * 90ms + 200ms);
}

.standing.is-top {
	min-height: 76px;
	transform: rotate(-1deg);
}

.standing.is-me {
	outline: 4px solid var(--mint-strong);
	outline-offset: 2px;
}

.standing-rank {
	flex: none;
	width: 30px;
	font-weight: 800;
	font-size: 22px;
	text-align: center;
}

.standing .avatar {
	background: var(--surface);
}

.standing-name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-weight: 800;
	font-size: 19px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.standing.is-top .standing-name {
	font-size: 24px;
}

.standing-score {
	font-weight: 800;
	font-size: 24px;
	font-variant-numeric: tabular-nums;
}

/* ---------- Action bar ---------- */

.action-bar {
	position: sticky;
	bottom: 0;
	z-index: 10;
	display: grid;
	gap: 8px;
	margin: 18px -16px 0;
	padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
	border-top: var(--border);
	background: var(--surface);
}

.action-note {
	color: var(--muted);
	font-weight: 600;
	text-align: center;
}

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

.action-buttons .btn.big {
	flex: 1;
}

.action-buttons .btn.ghost:only-child {
	margin: 0 auto;
}

.conn-note {
	position: fixed;
	top: 12px;
	left: 50%;
	z-index: 20;
	padding: 6px 16px;
	border-radius: 50px;
	background: var(--ink);
	color: #fff;
	font-weight: 700;
	transform: translateX(-50%);
}

/* ---------- Wider screens ---------- */

@media (min-width: 600px) {
	.action-bar {
		bottom: 14px;
		margin: 22px 0 14px;
		border: var(--border);
		border-radius: var(--radius-card);
		box-shadow: var(--shadow-lg);
	}
}

@media (min-width: 960px) {
	.live-app:not([data-screen="entry"]) {
		max-width: 1040px;
	}

	.screen-lobby {
		display: grid !important;
		grid-template-columns: 1fr 1.3fr;
		gap: 0 24px;
		align-items: start;
	}

	.screen-lobby .room-head {
		grid-column: 1 / -1;
	}

	.live-app:not([data-screen="lobby"]) .screen-lobby {
		display: none !important;
	}
}
