Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

17.7 KB
Raw Blame
/* Coin Wars arena (/play/war): the battle HUD over the 3D field.
 *
 * A fighting HUD has one job: never get between the player and the fight. So it
 * lives at the screen edges, uses opaque-enough panels to stay readable over a
 * bright floodlit floor, and every control is thumb-reachable on a phone with the
 * canvas still fully visible between them.
 *
 * The two sides of a war are colour-coded (us / them) but never colour-ONLY:
 * every score carries its community's name beside it. */

:root {
	--war-bg: #05060a;
	--war-panel: rgba(12, 14, 20, 0.78);
	--war-line: rgba(255, 255, 255, 0.1);
	--war-ink: #e9edf6;
	--war-muted: #8b93a7;
	--war-us: #7fd8ff;
	--war-them: #ff9d7a;
	--war-win: #5fd08a;
	--war-loss: #e06c75;
	--war-draw: #c9a227;
	--war-blur: saturate(150%) blur(14px);
	--war-mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: var(--war-bg);
	color: var(--war-ink);
	font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

#scene {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	touch-action: none;
	z-index: 0;
}

.war-vignette {
	position: fixed;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background: radial-gradient(130% 100% at 50% 20%, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
}

.war-page-title {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

#labels { position: fixed; inset: 0; z-index: 4; pointer-events: none; }

.war-tag {
	position: absolute;
	top: 0;
	left: 0;
	padding: 2px 8px;
	border: 1px solid var(--war-line);
	border-radius: 999px;
	background: var(--war-panel);
	backdrop-filter: var(--war-blur);
	-webkit-backdrop-filter: var(--war-blur);
	font: 600 11px/1.5 Inter, system-ui, sans-serif;
	white-space: nowrap;
	will-change: transform;
	transition: opacity var(--duration-base) var(--ease-standard);
}

.war-tag-a { border-color: color-mix(in srgb, var(--war-us) 45%, var(--war-line)); color: var(--war-us); }
.war-tag-b { border-color: color-mix(in srgb, var(--war-them) 45%, var(--war-line)); color: var(--war-them); }
.war-tag-me { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18); }

/* ── status ──────────────────────────────────────────────────────────────── */

.war-status {
	position: fixed;
	inset: auto 0 auto 0;
	top: 50%;
	z-index: 6;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	color: var(--war-muted);
	font-size: 14px;
	pointer-events: none;
}

.war-spinner {
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.16);
	border-top-color: var(--war-us);
	border-radius: 50%;
	animation: war-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.war-spinner { animation-duration: 3s; }
}

/* ── scoreboard ──────────────────────────────────────────────────────────── */

.war-hud {
	position: fixed;
	top: max(10px, env(safe-area-inset-top));
	left: 50%;
	transform: translateX(-50%);
	z-index: 5;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 14px;
	width: min(620px, calc(100vw - 20px));
	padding: 10px 14px;
	border: 1px solid var(--war-line);
	border-radius: 14px;
	background: var(--war-panel);
	backdrop-filter: var(--war-blur);
	-webkit-backdrop-filter: var(--war-blur);
	box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.85);
}

.war-side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.war-side-them { flex-direction: row-reverse; text-align: right; }

.war-score { font: 900 30px/1 var(--war-mono); }
.war-side-us .war-score { color: var(--war-us); }
.war-side-them .war-score { color: var(--war-them); }

.war-side-meta { display: flex; flex-direction: column; min-width: 0; }

.war-side-name {
	font-weight: 700;
	font-size: 13px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.war-side-roster { color: var(--war-muted); font-size: 11px; }

.war-mid { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.war-clock { font: 800 20px/1 var(--war-mono); }
.war-cap { color: var(--war-muted); font-size: 11px; }

.war-coin {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin-top: 3px;
	color: var(--war-muted);
	font-size: 11px;
}

.war-coin-img { width: 14px; height: 14px; border-radius: 50%; object-fit: cover; }

/* ── phase banner ────────────────────────────────────────────────────────── */

.war-phase {
	position: fixed;
	top: 34%;
	left: 0;
	right: 0;
	z-index: 5;
	margin: 0;
	text-align: center;
	font: 900 clamp(28px, 7vw, 56px)/1 Inter, system-ui, sans-serif;
	letter-spacing: 0.02em;
	text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
	pointer-events: none;
	animation: war-pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.war-phase[data-phase="live"] { color: var(--war-win); }
.war-phase[data-phase="sudden_death"] { color: var(--war-them); font-size: clamp(20px, 4.5vw, 34px); }
.war-phase[data-phase="countdown"] { color: var(--war-ink); }
.war-phase[data-phase="lobby"] { color: var(--war-muted); font-size: clamp(18px, 4vw, 30px); }

@keyframes war-pop {
	from { opacity: 0; transform: scale(0.9); }
	to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.war-phase { animation: none; }
}

.war-lobby-note {
	position: fixed;
	top: 46%;
	left: 50%;
	transform: translateX(-50%);
	z-index: 5;
	max-width: min(420px, calc(100vw - 32px));
	margin: 0;
	text-align: center;
	color: var(--war-muted);
	font-size: 13px;
	pointer-events: none;
}

/* ── controls ────────────────────────────────────────────────────────────── */

.war-controls {
	position: fixed;
	inset: auto 0 0 0;
	z-index: 5;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	padding: 0 max(14px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
	pointer-events: none;
}

.war-controls > * { pointer-events: auto; }

.war-stick {
	position: relative;
	width: 116px;
	height: 116px;
	border: 1px solid var(--war-line);
	border-radius: 50%;
	background: rgba(12, 14, 20, 0.5);
	backdrop-filter: var(--war-blur);
	-webkit-backdrop-filter: var(--war-blur);
	touch-action: none;
}

.war-stick-nub {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 46px;
	height: 46px;
	margin: -23px 0 0 -23px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.war-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.war-vitals {
	display: flex;
	gap: 14px;
	margin: 0;
	padding: 6px 12px;
	border: 1px solid var(--war-line);
	border-radius: 10px;
	background: var(--war-panel);
	backdrop-filter: var(--war-blur);
	-webkit-backdrop-filter: var(--war-blur);
}

.war-vitals div { display: flex; flex-direction: column; align-items: center; }
.war-vitals dt { color: var(--war-muted); font: 700 9px/1 Inter, system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.war-vitals dd { margin: 3px 0 0; font: 800 16px/1 var(--war-mono); }

.war-attack {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	width: 108px;
	padding: 14px 0;
	border: 1px solid color-mix(in srgb, var(--war-us) 50%, var(--war-line));
	border-radius: 14px;
	background: linear-gradient(180deg, rgba(127, 216, 255, 0.26), rgba(127, 216, 255, 0.1));
	color: #eaf7ff;
	font: 800 16px/1 Inter, system-ui, sans-serif;
	transition: transform var(--duration-instant) var(--ease-standard), opacity var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
}

.war-attack small { color: var(--war-muted); font: 600 10px/1 Inter, system-ui, sans-serif; }
.war-attack:hover:not(:disabled) { background: linear-gradient(180deg, rgba(127, 216, 255, 0.36), rgba(127, 216, 255, 0.15)); }
.war-attack:active:not(:disabled) { transform: scale(0.95); }
.war-attack:focus-visible { outline: 2px solid var(--war-us); outline-offset: 3px; }
.war-attack:disabled { opacity: 0.4; cursor: default; }
.war-attack.is-cooling { opacity: 0.55; }

.war-leave {
	padding: 7px 14px;
	border: 1px solid var(--war-line);
	border-radius: 10px;
	background: rgba(12, 14, 20, 0.6);
	color: var(--war-muted);
	font: 600 12px/1 Inter, system-ui, sans-serif;
	transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.war-leave:hover { color: var(--war-ink); border-color: rgba(255, 255, 255, 0.24); }
.war-leave:focus-visible { outline: 2px solid var(--war-us); outline-offset: 2px; }

.war-keys {
	position: fixed;
	left: 50%;
	bottom: max(8px, calc(env(safe-area-inset-bottom) + 8px));
	transform: translateX(-50%);
	margin: 0;
	color: var(--war-muted);
	font: 600 11px/1 Inter, system-ui, sans-serif;
	letter-spacing: 0.02em;
	pointer-events: none;
	opacity: 0.75;
}

/* A phone has the stick and no keyboard, and the hint would sit under the thumb. */
@media (pointer: coarse), (max-width: 520px) {
	.war-keys { display: none; }
}

.war-downed {
	position: fixed;
	left: 50%;
	bottom: max(160px, calc(env(safe-area-inset-bottom) + 160px));
	transform: translateX(-50%);
	margin: 0;
	padding: 7px 14px;
	border: 1px solid color-mix(in srgb, var(--war-loss) 45%, var(--war-line));
	border-radius: 999px;
	background: var(--war-panel);
	color: var(--war-loss);
	font: 700 12px/1 Inter, system-ui, sans-serif;
	pointer-events: none;
}

/* ── terminal cards ──────────────────────────────────────────────────────── */

.war-modal {
	position: fixed;
	inset: 0;
	z-index: 7;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(4, 5, 8, 0.72);
	backdrop-filter: blur(3px);
	/* The body is overflow:hidden so the battlefield never scrolls. The card
	   carries the war room, which on a short phone is taller than the viewport,
	   so the scroll lives here. */
	overflow-y: auto;
	overscroll-behavior: contain;
}

.war-modal-card {
	width: min(420px, 100%);
	margin: auto;
	padding: 26px 24px;
	border: 1px solid var(--war-line);
	border-radius: 18px;
	background: linear-gradient(180deg, #14161e, #0a0b10);
	box-shadow: 0 28px 70px -22px rgba(0, 0, 0, 0.9);
	text-align: center;
}

.war-result-title,
.war-fail-title {
	margin: 0 0 6px;
	font: 900 32px/1.1 Inter, system-ui, sans-serif;
}

.war-result-title[data-outcome="win"] { color: var(--war-win); }
.war-result-title[data-outcome="loss"] { color: var(--war-loss); }
.war-result-title[data-outcome="draw"] { color: var(--war-draw); }

.war-result-score { margin: 0 0 12px; font: 800 26px/1 var(--war-mono); }
.war-modal-b { margin: 0 0 8px; color: var(--war-muted); font-size: 13px; }
.war-modal-faint { color: rgba(255, 255, 255, 0.4); }

.war-modal-btn {
	width: 100%;
	margin-top: 14px;
	padding: 12px 16px;
	border: 1px solid color-mix(in srgb, var(--war-us) 50%, var(--war-line));
	border-radius: 12px;
	background: linear-gradient(180deg, rgba(127, 216, 255, 0.24), rgba(127, 216, 255, 0.1));
	color: #eaf7ff;
	font: 700 15px/1 Inter, system-ui, sans-serif;
	transition: background var(--duration-fast) var(--ease-standard), transform var(--duration-instant) var(--ease-standard);
}

.war-modal-btn:hover { background: linear-gradient(180deg, rgba(127, 216, 255, 0.34), rgba(127, 216, 255, 0.15)); }
.war-modal-btn:active { transform: scale(0.985); }
.war-modal-btn:focus-visible { outline: 2px solid var(--war-us); outline-offset: 3px; }

/* ── the war room ────────────────────────────────────────────────────────── */

/* Rendered into the fail card by src/play/war-board.js: live wars, the
 * matchmaking queue, and the top of the Elo ladder, each row a link into that
 * coin's world where the war portal stands. Left-aligned on purpose: the card
 * above it centres a single message, a list of records is read down an edge. */

.war-board {
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid var(--war-line);
	text-align: left;
}

.war-board-heading {
	margin: 14px 0 8px;
	color: var(--war-muted);
	font: 700 10px/1.4 Inter, system-ui, sans-serif;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.war-board-heading:first-child { margin-top: 0; }

.war-board-note {
	margin: 0 0 8px;
	color: var(--war-muted);
	font-size: 12.5px;
	line-height: 1.55;
}

.war-board-list { margin: 0; padding: 0; list-style: none; }
.war-board-row { margin: 0 0 6px; }

.war-board-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border: 1px solid transparent;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.03);
	color: var(--war-ink);
	text-decoration: none;
	transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-instant) var(--ease-standard);
}

.war-board-link:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--war-line); }
.war-board-link:active { transform: scale(0.99); }
.war-board-link:focus-visible { outline: 2px solid var(--war-us); outline-offset: 2px; }
.war-board-link.is-yours { border-color: color-mix(in srgb, var(--war-us) 45%, var(--war-line)); background: rgba(127, 216, 255, 0.08); }

.war-board-rank {
	flex: none;
	min-width: 24px;
	color: var(--war-muted);
	font: 700 11px/1 var(--war-mono);
}

.war-board-avatar {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	overflow: hidden;
	border: 1px solid var(--war-line);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.06);
	color: var(--war-muted);
	font: 700 11px/1 Inter, system-ui, sans-serif;
}

.war-board-avatar img { width: 100%; height: 100%; object-fit: cover; }

.war-board-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }

.war-board-title {
	overflow: hidden;
	font: 700 13px/1.3 Inter, system-ui, sans-serif;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.war-board-sub {
	/* Two lines, then clip. A single nowrap line cut a sentence mid-word at every
	   width, because the card is 420px at its widest and the phone case is the
	   one that matters. */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	color: var(--war-muted);
	font-size: 11.5px;
	line-height: 1.4;
}

.war-board-tag {
	flex: none;
	padding: 3px 8px;
	border: 1px solid var(--war-line);
	border-radius: 999px;
	color: var(--war-muted);
	font: 700 9.5px/1.3 Inter, system-ui, sans-serif;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.war-board-tag-live {
	border-color: color-mix(in srgb, var(--war-win) 50%, var(--war-line));
	color: var(--war-win);
}

.war-board-rating { flex: none; font: 800 15px/1 var(--war-mono); }

.war-board-skeleton { display: flex; flex-direction: column; gap: 6px; }

.war-board-skeleton-row {
	height: 42px;
	border-radius: 10px;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
	background-size: 300% 100%;
	animation: war-shimmer 1.4s linear infinite;
}

@keyframes war-shimmer {
	from { background-position: 100% 0; }
	to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
	.war-board-skeleton-row { animation: none; }
}

.war-board-retry {
	width: 100%;
	margin: 4px 0 2px;
	padding: 9px 14px;
	border: 1px solid var(--war-line);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.04);
	color: var(--war-ink);
	font: 700 13px/1 Inter, system-ui, sans-serif;
	transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.war-board-retry:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.24); }
.war-board-retry:focus-visible { outline: 2px solid var(--war-us); outline-offset: 2px; }

.war-board-links {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	margin: 16px 0 0;
}

.war-board-textlink {
	color: var(--war-us);
	font: 600 12px/1.4 Inter, system-ui, sans-serif;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}

.war-board-textlink:hover { border-bottom-color: currentColor; }
.war-board-textlink:focus-visible { outline: 2px solid var(--war-us); outline-offset: 3px; border-radius: 3px; }

/* ── small screens ───────────────────────────────────────────────────────── */

@media (max-width: 520px) {
	.war-hud { gap: 8px; padding: 8px 10px; }
	.war-score { font-size: 24px; }
	.war-side-name { font-size: 12px; }
	.war-stick { width: 100px; height: 100px; }
	.war-attack { width: 92px; padding: 12px 0; }
	.war-modal { padding: 14px 12px; }
	.war-modal-card { padding: 22px 16px; }
	.war-result-title, .war-fail-title { font-size: 26px; }
	.war-board-link { gap: 8px; padding: 8px; }
	.war-board-avatar { width: 22px; height: 22px; }
	.war-board-title { font-size: 12.5px; }
	.war-board-tag { padding: 3px 6px; letter-spacing: 0.05em; }
}