/* Spiele-Rad — mobile-first design (light + dark). */

:root {
	color-scheme: light dark;
	--bg: #f6f3f1;
	--bg-glow-1: transparent;
	--bg-glow-2: transparent;
	--surface: #ffffff;
	--surface-solid: #ffffff;
	--surface-2: #faf8f7;
	--fg: #231a20;
	--muted: #64585f;
	--line: #e8e0dc;
	--accent: #6d28d9;
	--accent-2: #4c1d95;
	--accent-soft: rgba(109, 40, 217, 0.1);
	--start: #16a34a;
	--stop: #f43f5e;
	--danger: #e11d48;
	--warn: #d97706;
	--shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
	--shadow-lg: 0 18px 40px -12px rgba(109, 40, 217, 0.45);
	--radius: 22px;
	--radius-sm: 14px;
	--font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--nav-h: 4.25rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0e0c0c;
		--bg-glow-1: transparent;
		--bg-glow-2: transparent;
		--surface: #292323;
		--surface-solid: #292323;
		--surface-2: #120f0f;
		--fg: #f5eef6;
		--muted: #b9adb6;
		--line: #2c2526;
		--accent: #a78bfa;
		--accent-2: #7c3aed;
		--accent-soft: rgba(167, 139, 250, 0.16);
		--start: #4ade80;
		--stop: #fb7185;
		--danger: #fb7185;
		--warn: #fbbf24;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
		--shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, 0.6);
	}
}

* { box-sizing: border-box; }

html { -webkit-tap-highlight-color: transparent; }

body {
	margin: 0;
	min-height: 100dvh;
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	font-variant-numeric: tabular-nums;
	background:
		radial-gradient(60rem 30rem at 10% -10%, var(--bg-glow-1), transparent 60%),
		radial-gradient(50rem 30rem at 110% 10%, var(--bg-glow-2), transparent 60%),
		var(--bg);
	background-attachment: fixed;
}

button, input, textarea, select { font: inherit; }

/* ---------- Layout ---------- */
.shell {
	max-width: 38rem;
	margin: 0 auto;
	padding: max(1.25rem, env(safe-area-inset-top)) 1.1rem 2rem;
}
.shell.app { padding-bottom: calc(var(--nav-h) + 2rem + env(safe-area-inset-bottom)); }
main > .stack { margin-top: 0.5rem; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; }

.topbar { margin: 0.25rem 0 1rem; }
.topbar h1 { margin: 0; }

h1 { margin: 0 0 1rem; font-size: clamp(1.75rem, 6vw, 2.2rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.15; }
h2 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.section-title { font-size: 0.8rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

.eyebrow {
	margin: 0 0 0.15rem;
	font-weight: 700;
	font-size: 0.75rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	background: linear-gradient(90deg, var(--accent), var(--accent-2));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.hint { margin: 0; color: var(--muted); font-size: 0.9rem; }
.hint.warn { color: var(--warn); }
.ok { margin: 0; color: var(--start); font-weight: 600; }
.muted { color: var(--muted); }
.date-line { margin: -0.5rem 0 0; color: var(--muted); font-weight: 500; }

/* ---------- Cards ---------- */
.card {
	background: var(--surface);
	-webkit-backdrop-filter: blur(16px) saturate(140%);
	backdrop-filter: blur(16px) saturate(140%);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 1.15rem;
	box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 2.9rem;
	padding: 0.6rem 1.15rem;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: linear-gradient(135deg, var(--accent), var(--accent-2));
	color: #fff;
	font-weight: 650;
	cursor: pointer;
	transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn:focus-visible, .tab:focus-visible, .input:focus-visible, .entry-button:focus-visible, .day-button:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
	outline-offset: 2px;
}
.btn-secondary { background: var(--surface-2); color: var(--fg); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.big-btn {
	width: 100%;
	min-height: 4.2rem;
	font-size: 1.2rem;
	font-weight: 750;
	border-radius: 20px;
	background: #fff;
	color: #0f172a;
	box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.45);
}
.big-btn-icon {
	display: inline-grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	font-size: 0.8rem;
	color: #fff;
}
.btn-start .big-btn-icon { background: var(--start); }
.btn-stop { color: #be123c; }
.btn-stop .big-btn-icon { background: var(--stop); }

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 1.6rem;
	height: 1.6rem;
	border: 0;
	border-radius: 50%;
	background: color-mix(in srgb, var(--danger) 12%, transparent);
	color: var(--danger);
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
}

/* ---------- Bottom navigation ---------- */
.tabs {
	position: fixed;
	left: 50%;
	bottom: calc(0.75rem + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	width: min(26rem, calc(100% - 1.5rem));
	height: var(--nav-h);
	z-index: 10;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0.25rem;
	padding: 0.4rem;
	border-radius: 24px;
	background: var(--surface);
	-webkit-backdrop-filter: blur(20px) saturate(160%);
	backdrop-filter: blur(20px) saturate(160%);
	border: 1px solid var(--line);
	box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.25);
}
.tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.1rem;
	border: 0;
	border-radius: 18px;
	background: transparent;
	color: var(--muted);
	font-size: 0.72rem;
	font-weight: 650;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Forms ---------- */
.field, .entry-form label, .pick-day {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	flex: 1;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--muted);
}
.input {
	width: 100%;
	min-height: 2.9rem;
	padding: 0.6rem 0.85rem;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--fg);
	font-weight: 500;
	transition: border-color 0.2s ease, background 0.2s ease;
}
.input:focus { border-color: var(--accent); background: var(--surface-solid); outline: none; }
.input:disabled { opacity: 0.5; }

.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; color: var(--fg); font-weight: 500; }
.switch input {
	appearance: none;
	-webkit-appearance: none;
	flex: none;
	position: relative;
	width: 2.4rem;
	height: 1.4rem;
	margin: 0;
	border-radius: 999px;
	background: color-mix(in srgb, var(--muted) 35%, transparent);
	cursor: pointer;
	transition: background 0.2s ease;
}
.switch input::after {
	content: "";
	position: absolute;
	top: 0.15rem;
	left: 0.15rem;
	width: 1.1rem;
	height: 1.1rem;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(1rem); }
.switch input:disabled { opacity: 0.5; }
.switch input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* ---------- Settings ---------- */
.break-rule {
	margin: 0;
	padding: 0.6rem 1rem 1rem;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
}
.break-rule legend { padding: 0 0.3rem; font-weight: 650; }
.weekdays { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.weekday {
	position: relative;
	display: inline-grid;
	place-items: center;
	min-width: 2.8rem;
	min-height: 2.6rem;
	border-radius: 12px;
	background: var(--surface-2);
	border: 1px solid var(--line);
	color: var(--muted);
	font-weight: 700;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}
.weekday.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.weekday input { position: absolute; opacity: 0; pointer-events: none; }
.weekday:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.push-box { border-top: 1px solid var(--line); padding-top: 0.9rem; }

/* ---------- Login ---------- */
.auth { padding-top: max(3rem, env(safe-area-inset-top)); }
.auth-logo {
	display: grid;
	place-items: center;
	width: 4rem;
	height: 4rem;
	margin-bottom: 1rem;
	border-radius: 20px;
	color: #fff;
	background: linear-gradient(145deg, #7c3aed, #4c1d95);
	box-shadow: var(--shadow-lg);
}

/* ---------- States ---------- */
.loading { display: flex; align-items: center; gap: 0.6rem; padding: 1.5rem 0; color: var(--muted); }
.spinner {
	width: 1.1rem;
	height: 1.1rem;
	border-radius: 50%;
	border: 2px solid var(--line);
	border-top-color: var(--accent);
	animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 2rem 0; }
.empty-title { margin: 0; font-weight: 650; color: var(--muted); }
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.7rem 0.9rem;
	border-radius: var(--radius-sm);
	background: color-mix(in srgb, var(--danger) 10%, transparent);
	color: var(--danger);
	font-weight: 500;
}
.alert .btn { min-height: 2.25rem; }

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

/* ---------- Family ---------- */
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.member {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.7rem 0.9rem;
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	border: 1px solid var(--line);
}
.member.inactive { opacity: 0.6; }
.member-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.member-info small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.member .btn { min-height: 2.4rem; padding: 0.4rem 0.8rem; }
.invite-box { padding: 0.9rem; border-radius: var(--radius-sm); background: var(--accent-soft); }
h3.section-title { margin: 0; }

/* ---------- Account / password ---------- */
.link-btn {
	align-self: center;
	border: 0;
	background: none;
	padding: 0.25rem;
	color: var(--accent);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}
.member { flex-wrap: wrap; }
.member-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.confirm-box { padding: 0.9rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.confirm-box.danger { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.danger-zone { padding-top: 0.9rem; border-top: 1px solid var(--line); }
.btn-danger-solid { background: var(--danger); color: #fff; }

/* ---------- Chips / filter ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
	min-height: 2.3rem;
	padding: 0.3rem 0.8rem;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--surface-2);
	color: var(--fg);
	font-weight: 600;
	font-size: 0.88rem;
	cursor: pointer;
}
.chip.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.chip.static { cursor: default; min-height: 1.9rem; display: inline-flex; align-items: center; font-size: 0.8rem; }
.chip:focus-visible, .game-row:focus-visible, .wheel:focus-visible, .filter-toggle:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
	outline-offset: 2px;
}
.filter-card { gap: 0.75rem; }
.filter-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	border: 0;
	padding: 0;
	background: none;
	color: var(--fg);
	text-align: left;
	cursor: pointer;
}
.filter-toggle span:first-child { display: flex; flex-direction: column; }
.filter-toggle small { color: var(--muted); }
.filter-group { display: flex; flex-direction: column; gap: 0.4rem; }
.filter-group .section-title { margin: 0; }
.center { text-align: center; }

/* ---------- Wheel ---------- */
.wheel-wrap { position: relative; width: min(100%, 24rem); margin: 0.5rem auto 0; }
.wheel { display: block; width: 100%; height: auto; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.wheel.spinning { cursor: progress; }
.wheel-rim { fill: var(--surface); stroke: var(--line); stroke-width: 2; filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.18)); }
.wheel-hub { fill: #fff; stroke: var(--accent); stroke-width: 4; }
.wheel-hub-text { font-size: 12px; font-weight: 800; fill: #4c1d95; letter-spacing: 0.04em; pointer-events: none; }
.slice-label { font-size: 13px; font-weight: 750; pointer-events: none; }
.wheel-pointer {
	position: absolute;
	top: -0.2rem;
	left: 50%;
	z-index: 2;
	width: 0;
	height: 0;
	transform: translateX(-50%);
	border-left: 0.95rem solid transparent;
	border-right: 0.95rem solid transparent;
	border-top: 1.7rem solid var(--fg);
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}
.wheel-actions { justify-content: center; }
.winner { display: flex; gap: 1rem; align-items: center; border: 2px solid var(--accent); animation: pop 0.35s ease-out; }
.winner-info { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.winner h2 { font-size: 1.4rem; }
.winner .btn { align-self: flex-start; }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Covers ---------- */
.cover { flex: none; object-fit: cover; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.cover-md { width: 3.4rem; height: 3.4rem; }
.cover-lg { width: 6.5rem; height: 6.5rem; border-radius: 16px; }
.cover-letter { display: inline-grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.4rem; border: 0; }
.cover-lg.cover-letter { font-size: 2.6rem; }
.cover-letter.mini { width: 2.4rem; height: 2.4rem; border-radius: 8px; background: var(--accent); font-size: 1rem; }

/* ---------- Collection ---------- */
.add-btn { width: 100%; }
.game-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.game-row {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 0.6rem 0.8rem;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: var(--surface);
	box-shadow: var(--shadow);
	color: inherit;
	text-align: left;
	cursor: pointer;
}
.game-row-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.game-row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row-text small { color: var(--muted); }
.badge { font-size: 1.1rem; }
.back { align-self: flex-start; padding-left: 0; text-decoration: none; }
.detail-head { display: flex; gap: 1rem; align-items: flex-start; }
.detail-info { gap: 0.5rem; min-width: 0; }
.detail-title { font-size: 1.35rem; }
.notes { margin: 0; white-space: pre-wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
textarea.input { resize: vertical; min-height: 5rem; }
.preview { align-items: center; }
.candidates summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.candidates ul { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.candidate {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.45rem 0.6rem;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: inherit;
	text-align: left;
	cursor: pointer;
}
.candidate img { width: 2.4rem; height: 2.4rem; object-fit: cover; border-radius: 8px; }

/* ---------- Rules ---------- */
.rules-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.rules-actions .btn { text-decoration: none; font-size: 0.92rem; }
.file-row { display: flex; align-items: center; gap: 0.6rem; }
.file-row .btn { flex: 1; text-decoration: none; }
.file-row .icon-btn { width: 2.2rem; height: 2.2rem; font-size: 1.3rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.5rem; }
.photo-thumb {
	position: relative;
	aspect-ratio: 3 / 4;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow: hidden;
	background: var(--surface-2);
	cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb span {
	position: absolute;
	right: 0.3rem;
	bottom: 0.3rem;
	min-width: 1.4rem;
	padding: 0 0.3rem;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 700;
}

/* ---------- Overlays (scanner, photo viewer) ---------- */
.overlay {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
	background: rgba(8, 6, 12, 0.92);
	color: #fff;
}
.overlay .loading { color: #fff; }
.scanner { position: relative; width: min(100%, 30rem); border-radius: 20px; overflow: hidden; background: #000; }
.scanner video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.scan-frame {
	position: absolute;
	left: 10%;
	right: 10%;
	top: 30%;
	bottom: 30%;
	border: 3px solid #fff;
	border-radius: 14px;
	box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
}
.scan-frame::after {
	content: "";
	position: absolute;
	left: 6%;
	right: 6%;
	top: 50%;
	height: 2px;
	background: #f43f5e;
	animation: scanline 1.6s ease-in-out infinite alternate;
}
@keyframes scanline { from { transform: translateY(-1.4rem); } to { transform: translateY(1.4rem); } }
.scan-hint { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 0.7rem 1rem; background: rgba(0, 0, 0, 0.6); text-align: center; font-weight: 600; }
.viewer { justify-content: space-between; padding-left: 0.5rem; padding-right: 0.5rem; }
.viewer img { flex: 1; min-height: 0; max-width: 100%; object-fit: contain; border-radius: 8px; background: #fff; }
.viewer-bar, .viewer-nav { display: flex; align-items: center; gap: 0.5rem; width: 100%; max-width: 40rem; }
.viewer-bar span { flex: 1; font-weight: 600; }
.viewer-nav { justify-content: space-between; }

@media (max-width: 22rem) {
	.grid-2, .rules-actions { grid-template-columns: 1fr; }
}
