:root {
	color-scheme: light dark;
	--bg: #ffffff;
	--fg: #0b0d12;
	--muted: #5b6472;
	--accent: #2f6df6;
	--border: #e4e7ec;
	--danger: #b42318;
	--radius: 10px;
	--space: 1rem;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b0d12;
		--fg: #f4f6fa;
		--muted: #9aa4b2;
		--accent: #6f9bff;
		--border: #232833;
		--danger: #ff9a8f;
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(1.05);
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

/*
 * 390px-safe, like .grid below. A grid with no column list gets one implicit
 * auto column, and an auto column is never narrower than its widest item's
 * min-content width. One nowrap scrolling strip (days, time slots) anywhere
 * inside an item therefore widened the whole column past the screen: the page
 * scrolled sideways instead of the strip scrolling on its own. minmax(0, 1fr)
 * caps the column at the container; the min-width rule keeps a child from
 * bringing the same floor back if an app redefines the columns. :where() adds
 * no specificity, so a min-width the app sets on a child still wins.
 */
.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

body{background:#0d0a1f;color:#f4f0ff}
.hub,.auth-wrap,.soc-main{max-width:40rem;margin:0 auto;padding:1rem}
.hub-top,.soc-top{display:flex;justify-content:space-between;align-items:center;padding:.5rem 1rem}
.brand,.brand-big{font-weight:900;letter-spacing:.08em;font-size:1.4rem}.brand-big{font-size:2rem;text-align:center}
.brand span,.brand-big span{color:#ff5fa2}.tag{color:#ffcc33;letter-spacing:.2em;font-size:.8rem;text-align:center}
.star-entry{background:none;border:0;color:#ffcc33;font:inherit;cursor:pointer;padding:0}
.icon-btn,.ghost-link{background:none;border:0;color:inherit;font:inherit;cursor:pointer;min-height:2.4rem}.ghost-link{color:#b9a8ff}
.btn-glow{background:linear-gradient(135deg,#7b5cff,#ff5fa2)}
.daily,.game-card{display:grid;gap:.3rem;text-align:left;padding:1.2rem;border-radius:16px;border:1px solid #3a2f6b;background:#1a1440;color:inherit;font:inherit;cursor:pointer}
.daily{background:linear-gradient(135deg,#3b1f7a,#7a1f5a)}.daily small,.game-card small{opacity:.75}.gc-ico{font-size:2rem}
.game-grid{display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(min(14rem,100%),1fr))}
.game-box{display:grid;gap:.75rem}.hud{display:flex;flex-wrap:wrap;gap:1rem;font-weight:700}
.canvas-wrap,.arena{position:relative;width:100%;aspect-ratio:1;border-radius:14px;overflow:hidden;background:#140f30;touch-action:none}
.game-canvas{width:100%;height:100%;display:block}
.overlay{position:absolute;inset:0;display:grid;place-content:center;text-align:center;background:#0008;gap:.3rem;font-size:1.2rem}
.target{position:absolute;aspect-ratio:1;transform:translate(-50%,-50%);border-radius:50%;border:4px solid #fff;background:radial-gradient(#ffcc33 30%,#ff5fa2 31% 60%,#7b5cff 61%);cursor:pointer}
.auth-card,.panel{background:#1a1440;border:1px solid #3a2f6b;border-radius:16px;padding:1rem}.panel h2{font-size:1rem;margin:0 0 .6rem}
.input,.textarea{background:#0d0a1f;color:inherit;border-color:#3a2f6b}
.seg{display:flex;gap:.3rem}.seg button{flex:1;padding:.5rem;border-radius:10px;border:1px solid #3a2f6b;background:none;color:inherit;font:inherit}.seg .on{background:#7b5cff}
.social{min-height:100vh;padding-bottom:4.5rem}
.tabs{position:fixed;bottom:0;left:0;right:0;display:flex;background:#140f30;border-top:1px solid #3a2f6b}
.tabs button{flex:1;display:grid;justify-items:center;padding:.5rem;background:none;border:0;color:#b9a8ff;font:inherit;cursor:pointer}.tabs .on{color:#fff}
.tabs span{position:relative}.count{display:inline-block;min-width:1.2rem;padding:0 .3rem;border-radius:99px;background:#ff5fa2;color:#fff;font-size:.7rem;font-style:normal;text-align:center}
.avatar{position:relative;flex:none;display:inline-grid;place-items:center;width:2.6rem;height:2.6rem;border-radius:50%;background:linear-gradient(135deg,#7b5cff,#ff5fa2);font-weight:800}
.dot{position:absolute;right:0;bottom:0;width:.7rem;height:.7rem;border-radius:50%;background:#3fd6b0;border:2px solid #1a1440}
.person,.conv,.chip-person{display:flex;align-items:center;gap:.6rem;background:none;border:0;color:inherit;font:inherit;cursor:pointer;text-align:left}
.person small,.conv small,.chat-head small{display:block;opacity:.7}.conv{width:100%;padding:.6rem;border-radius:12px;border:1px solid #3a2f6b}
.conv-main{flex:1;min-width:0}.conv-main small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.conv-side{display:grid;justify-items:end}
.chips{display:flex;flex-wrap:wrap;gap:.8rem}.chip-person{flex-direction:column}.unread{border-color:#ff5fa2}
.profile{display:grid;justify-items:center;text-align:center;gap:.4rem}.profile h2{margin:0}.stats{justify-content:center}
.chat{display:flex;flex-direction:column;height:calc(100vh - 9rem)}.chat-head{display:flex;align-items:center;gap:.6rem;padding-bottom:.5rem}.push{margin-left:auto}
.msgs{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:.4rem;padding:.5rem 0}
.bubble{max-width:80%;align-self:flex-start;background:#2a2160;padding:.5rem .7rem;border-radius:14px 14px 14px 4px;display:grid;gap:.15rem;overflow-wrap:anywhere}
.bubble.mine{align-self:flex-end;background:#5b3fd6;border-radius:14px 14px 4px 14px}.bubble small{opacity:.7;font-size:.7rem;justify-self:end}
.quote{border-left:3px solid #ffcc33;padding-left:.4rem;opacity:.8;font-size:.85rem}
.bub-act button{background:none;border:0;color:#d8ccff;font-size:.72rem;cursor:pointer}
.replying{font-size:.85rem;opacity:.85}.composer{display:flex;gap:.3rem;align-items:center}.composer .input{flex:1;min-width:0}
@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
