/* Marble Race admin prototype. The race fills the viewport; controls float above it. Dark by default. */

.mr-page {
	margin: 0;
	overflow: hidden;
	background: var(--gray-900);
	color: var(--gray-300);
}

.mr-app,
.mr-app * {
	box-sizing: border-box;
}

.mr-app {
	--mr-accent: #00fba6;   /* 운영자 지정 — [연장하기] 라벨 */
	position: fixed;
	inset: 0;
	overflow: hidden;
	background: var(--gray-900);
	color: var(--gray-300);
	font-size: var(--font-sm);
}

.mr-app [hidden] {
	display: none;
}

/* Stage */

.mr-stage {
	position: absolute;
	inset: 0;
}

.mr-canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.mr-countdown {
	position: absolute;
	inset: 0;
	z-index: var(--z-overlay);
	display: grid;
	place-items: center;
	color: var(--text-white);
	font-size: calc(var(--font-3xl) * 4);
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

/* Minimap — top left */

.mr-minimap {
	position: absolute;
	top: var(--space-md);
	left: var(--space-md);
	z-index: var(--z-sticky);
	padding: var(--space-xs);
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-md);
	background: var(--gray-900);
	pointer-events: none;
}

.mr-minimap__canvas {
	display: block;
	width: auto;
	height: min(56vh, 520px);
}

/* Roster — top right */

.mr-roster {
	position: absolute;
	top: var(--space-md);
	right: var(--space-md);
	z-index: var(--z-sticky);
	width: min(260px, 40vw);
	max-height: calc(100vh - var(--space-md) * 2);
	overflow: hidden;
	text-align: right;
	pointer-events: none;
}

.mr-roster__count {
	margin: 0 0 var(--space-xs);
	color: var(--gray-500);
	font-size: var(--font-sm);
	font-variant-numeric: tabular-nums;
}

.mr-roster__list {
	display: grid;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mr-roster__item {
	overflow: hidden;
	color: var(--gray-300);
	font-weight: 600;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mr-roster__item[data-finished="true"] {
	color: var(--gray-500);
}

.mr-roster__item[data-winner="true"] {
	color: var(--color-warning);
	font-weight: 700;
}

.mr-roster__rank {
	margin-right: var(--space-xs);
	color: var(--gray-500);
	font-variant-numeric: tabular-nums;
}

.mr-roster__dot {
	display: inline-block;
	width: 0.6em;
	height: 0.6em;
	margin-left: var(--space-xs);
	border-radius: var(--radius-full);
	vertical-align: 0.05em;
}

.mr-roster__more {
	color: var(--gray-500);
	font-size: var(--font-xs);
}

/* The waiting screen already shows everyone large on the canvas. */
.mr-app[data-view="lineup"] .mr-roster {
	display: none;
}

/* Join room card — top right on the waiting screen */

.mr-room {
	position: absolute;
	top: var(--space-md);
	right: var(--space-md);
	z-index: var(--z-sticky);
	display: grid;
	justify-items: center;
	gap: var(--space-sm);
	width: min(300px, 34vw);
	max-height: calc(100vh - var(--space-md) * 2);
	overflow: auto;
	padding: var(--space-md);
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-nm);
	background: var(--gray-900);
	text-align: center;
}

.mr-app[data-view="race"] .mr-room {
	display: none;
}

.mr-room__eyebrow {
	margin: 0;
	color: var(--color-warning);
	font-size: var(--font-sm);
	font-weight: 700;
	word-break: keep-all;
}

.mr-room__code {
	position: relative;
	width: 100%;
}

.mr-room__qr {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--radius-md);
	background: var(--text-white);
	image-rendering: pixelated;
}

.mr-room[data-status="closed"] .mr-room__qr {
	opacity: 0.12;
}

.mr-room__closed {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	margin: 0;
	color: var(--text-white);
	font-size: var(--font-2xl);
	font-weight: 800;
}

.mr-room__count {
	margin: 0;
	color: var(--text-white);
	font-size: var(--font-lg);
	font-weight: 700;
}

.mr-room__count output {
	font-size: var(--font-3xl);
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.mr-room__timer {
	margin: 0;
	color: var(--gray-400);
	font-size: var(--font-xs);
	font-variant-numeric: tabular-nums;
}

/* 남은 시간 옆 라벨. 20분 미만일 때만 나온다(app.js updateRoomClock).
   어두운 카드 위에서 회색 시간과 확실히 갈리는 연두 — 운영자 지정색이라
   테마 토큰이 아니라 이 화면 전용 변수로 한 곳에 둔다. */
.mr-app .mr-room__extend {
	min-height: 0;
	margin-left: var(--space-sm);
	padding: 1px var(--space-xs);
	border-color: var(--mr-accent);
	background: none;
	color: var(--mr-accent);
	font-size: var(--font-2xs);
	vertical-align: baseline;
}

.mr-app .mr-room__extend:hover:not(:disabled) {
	background: var(--mr-accent);
	color: var(--gray-900);
}

/* QR 을 누르면 크게 보인다. 버튼이지만 생김새는 QR 그대로여야 한다. */
.mr-app .mr-room__zoom {
	display: block;
	width: 100%;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: var(--radius-md);
	background: none;
	cursor: zoom-in;
}

.mr-room__hint {
	margin: 0;
	color: var(--gray-400);
	font-size: var(--font-2xs);
}

/* 참가 방식 고르기 — QR 로 받을지, 진행자가 직접 적을지. */
.mr-room__modes {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--space-xs);
	width: 100%;
}

.mr-app .mr-room__mode[aria-pressed="true"] {
	border-color: var(--primary);
	background: var(--primary);
	color: var(--text-white);
}

/* 카드 안쪽 묶음. .mr-room 의 grid gap 은 여기까지만 닿으므로 자기 gap 을 따로 둔다. */
.mr-room__pane {
	display: grid;
	justify-items: center;
	gap: var(--space-sm);
	width: 100%;
}

.mr-room__pane[hidden] {
	display: none;
}

.mr-room__names {
	width: 100%;
	min-height: 0;
	padding: var(--space-sm);
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-md);
	background: var(--gray-800);
	color: var(--text-white);
	font: inherit;
	font-size: var(--font-xs);
	line-height: 1.6;
	resize: vertical;
}

.mr-app .mr-room__names:focus-visible {
	outline: 2px solid var(--primary-300);
	outline-offset: 2px;
}

.mr-qrzoom {
	position: fixed;
	inset: 0;
	z-index: var(--z-modal);
	display: grid;
	justify-items: center;
	align-content: center;
	gap: var(--space-md);
	padding: var(--space-lg);
	background: rgba(0, 0, 0, 0.88);
	cursor: zoom-out;
}

.mr-qrzoom[hidden] {
	display: none;
}

.mr-qrzoom__canvas {
	width: min(72vh, 88vw);
	height: auto;
	border-radius: var(--radius-md);
	background: var(--text-white);
	image-rendering: pixelated;
}

.mr-qrzoom__url {
	margin: 0;
	color: var(--gray-300);
	font-size: var(--font-sm);
	word-break: break-all;
}

.mr-room__people {
	width: 100%;
	text-align: left;
}

.mr-room__people summary {
	width: fit-content;
	color: var(--gray-400);
	font-size: var(--font-xs);
	cursor: pointer;
}

.mr-room__list {
	display: grid;
	gap: 2px;
	max-height: 32vh;
	margin: var(--space-xs) 0 0;
	padding: 0;
	overflow: auto;
	list-style: none;
}

.mr-room__person {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-sm);
	color: var(--gray-300);
	font-size: var(--font-xs);
}

.mr-room__person span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mr-app .mr-room__remove {
	flex: 0 0 auto;
	min-height: 24px;
	padding: 0 var(--space-sm);
}

/* Control panel — bottom left */

.mr-panel {
	position: absolute;
	bottom: var(--space-md);
	left: var(--space-md);
	z-index: var(--z-sticky);
	width: min(540px, calc(100vw - var(--space-md) * 2));
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-nm);
	background: var(--gray-900);
}

.mr-panel__bar {
	display: flex;
	align-items: center;
	gap: var(--space-sm);
	padding: var(--space-sm) var(--space-md);
	border-bottom: 1px solid var(--gray-800);
}

.mr-panel__title {
	flex: 0 0 auto;
	color: var(--text-white);
	font-size: var(--font-sm);
}

.mr-status {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	overflow: hidden;
	color: var(--gray-400);
	font-size: var(--font-xs);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mr-status[data-tone="error"] {
	color: var(--color-danger);
}

.mr-panel__body {
	display: grid;
	gap: var(--space-sm);
	padding: var(--space-md);
}

.mr-panel[data-collapsed="true"] .mr-panel__body,
.mr-app[data-state="running"] .mr-panel__body {
	display: none;
}

.mr-row {
	display: grid;
	grid-template-columns: 5.5em minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--space-sm);
}

.mr-row__label {
	color: var(--gray-400);
	font-size: var(--font-xs);
	font-weight: 600;
}

.mr-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-xs);
}

.mr-app button {
	min-height: 32px;
	padding: var(--space-xs) var(--space-sm);
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-md);
	background: var(--gray-800);
	color: var(--gray-300);
	font: inherit;
	font-size: var(--font-xs);
	font-weight: 600;
	cursor: pointer;
	transition: background-color var(--transition-fast), color var(--transition-fast);
}

.mr-app button:hover:not(:disabled) {
	background: var(--gray-700);
	color: var(--text-white);
}

.mr-app button:active:not(:disabled) {
	transform: translateY(1px);
}

.mr-app button[aria-pressed="true"] {
	border-color: var(--primary-300);
	color: var(--text-white);
}

.mr-app button:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.mr-app button:focus-visible,
.mr-room__people summary:focus-visible {
	outline: 2px solid var(--primary-300);
	outline-offset: 2px;
}

.mr-app .mr-button--primary {
	border-color: var(--primary);
	background: var(--primary);
	color: var(--text-white);
}

.mr-app .mr-button--primary:hover:not(:disabled) {
	background: var(--primary-dark);
}

.mr-app .mr-button--quiet {
	flex: 0 0 auto;
	border-color: transparent;
	background: transparent;
	color: var(--gray-400);
}

.mr-note {
	margin: 0;
	color: var(--color-warning);
	font-size: var(--font-xs);
}

.mr-panel__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-sm);
	padding: var(--space-sm) var(--space-md);
}

.mr-app[data-state="running"] [data-mr-idle-only],
.mr-app[data-state="idle"] [data-mr-running-only] {
	display: none;
}

/* First-run walkthrough — dimmed screen, one highlighted control at a time */

.mr-guide {
	position: absolute;
	inset: 0;
	z-index: var(--z-modal);
}

.mr-guide__spot {
	position: absolute;
	border: 2px solid var(--primary-300);
	border-radius: var(--radius-nm);
	/* The shadow is the dimmed screen itself, not decoration on the ring. */
	box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
	pointer-events: none;
}

.mr-guide__spot[hidden] + .mr-guide__card {
	box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
}

.mr-guide__card {
	position: absolute;
	left: 50%;
	top: 50%;
	width: min(360px, calc(100vw - var(--space-xl)));
	padding: var(--space-md);
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-nm);
	background: var(--gray-900);
}

.mr-guide__card[data-centred="true"] {
	transform: translate(-50%, -50%);
}

.mr-guide__step {
	margin: 0 0 var(--space-xs);
	color: var(--gray-500);
	font-size: var(--font-2xs);
	font-variant-numeric: tabular-nums;
}

.mr-guide__text {
	margin: 0 0 var(--space-md);
	color: var(--text-white);
	font-size: var(--font-sm);
	line-height: 1.6;
}

.mr-guide__actions {
	display: flex;
	justify-content: flex-end;
	gap: var(--space-xs);
}

.mr-guide__actions .mr-button--quiet {
	margin-right: auto;
}

/* Result overlay — centre */

.mr-results {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: var(--z-modal);
	width: min(560px, calc(100vw - var(--space-md) * 2));
	max-height: calc(100vh - var(--space-lg) * 2);
	overflow: auto;
	padding: var(--space-lg);
	border: 1px solid var(--gray-700);
	border-radius: var(--radius-nm);
	background: var(--gray-900);
	text-align: center;
	transform: translate(-50%, -50%);
}

.mr-results__eyebrow {
	margin: 0;
	color: var(--color-warning);
	font-size: var(--font-sm);
	font-weight: 700;
	letter-spacing: 0.08em;
}

.mr-results__summary {
	margin: var(--space-xs) 0 0;
	color: var(--gray-400);
	font-size: var(--font-xs);
}

.mr-winners {
	display: grid;
	gap: var(--space-sm);
	margin: var(--space-md) 0;
	padding: 0;
	list-style: none;
}

.mr-winners > li {
	color: var(--text-white);
	font-size: var(--font-2xl);
	font-weight: 800;
	line-height: 1.3;
}

.mr-winners > li small {
	display: block;
	color: var(--gray-400);
	font-size: var(--font-xs);
	font-weight: 600;
}

/*
 * Winner announcement — the one flashy moment. Glow (border + shadow) and the
 * staggered entrance follow the design-rule exception for honour areas
 * (operator decision 2026-09-02); both stop under prefers-reduced-motion.
 */
.mr-fx {
	position: absolute;
	inset: 0;
	z-index: var(--z-overlay);
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.mr-results[data-celebrate="true"] {
	border-color: var(--color-warning);
	box-shadow: 0 0 48px -8px var(--color-warning);
	animation: mr-card-in 520ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.mr-results[data-celebrate="true"] .mr-results__eyebrow {
	font-size: var(--font-xl);
	text-shadow: 0 0 16px var(--color-warning);
}

.mr-results[data-celebrate="true"] .mr-winners > li {
	text-shadow: 0 0 18px var(--color-warning);
	animation: mr-winner-in 600ms cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

.mr-results[data-celebrate="true"] .mr-winners > li:nth-child(2) { animation-delay: 220ms; }
.mr-results[data-celebrate="true"] .mr-winners > li:nth-child(3) { animation-delay: 440ms; }
.mr-results[data-celebrate="true"] .mr-winners > li:nth-child(4) { animation-delay: 660ms; }
.mr-results[data-celebrate="true"] .mr-winners > li:nth-child(n+5) { animation-delay: 880ms; }

@keyframes mr-card-in {
	from {
		opacity: 0;
		transform: translate(-50%, -50%) scale(0.86);
	}
	to {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1);
	}
}

@keyframes mr-winner-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.8);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.mr-results[data-celebrate="true"],
	.mr-results[data-celebrate="true"] .mr-winners > li {
		animation: none;
	}
}

@media (max-width: 720px) {
	.mr-minimap {
		display: none;
	}

	.mr-roster {
		width: min(180px, 45vw);
		max-height: 40vh;
		font-size: var(--font-xs);
	}

	.mr-row {
		grid-template-columns: minmax(0, 1fr) auto;
	}

	.mr-row__label {
		grid-column: 1 / -1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mr-app button {
		transition: none;
	}
}

/* 비로그인 진행자 안내 — 방 정원이 10명이라는 사실과 로그인 문 하나.
   ⚠️ 이 패널은 어두운 판(--gray-900) 위다. 색은 옆 줄들(.mr-room__hint·__count)과 같은 것을 쓴다.
   ⛔ 색 면·배지로 키우지 않는다. 진행 화면의 주인공은 QR 과 참가자 수다. */
.mr-room__gate {
	margin: 0;
	color: var(--gray-400);
	font-size: var(--font-2xs);
	line-height: 1.55;
}

.mr-room__gate strong { color: var(--text-white); font-weight: 700; }

.mr-room__gate-link {
	color: var(--mr-accent);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.mr-room__gate-link:hover,
.mr-room__gate-link:focus-visible { color: var(--mr-accent); text-decoration: underline; }
