:root {
	--bg: #0c0716;
	--panel: #170f27;
	--panel-2: #21163a;
	--line: #3a2a5c;
	--text: #efe7ff;
	--muted: #a99cc6;
	--gold: #f2c04f;
	--gold-2: #ffdf8a;
	--accent: #8c5cff;
	--danger: #ff6b7a;
	--ok: #6ee7a8;
	--radius: 12px;
	--safe-l: env(safe-area-inset-left, 0px);
	--safe-r: env(safe-area-inset-right, 0px);
	--safe-b: env(safe-area-inset-bottom, 0px);
	--safe-t: env(safe-area-inset-top, 0px);
	color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
	margin: 0;
	height: 100%;
	background: #000;
	color: var(--text);
	font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	overflow: hidden;
	overscroll-behavior: none;
	-webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
kbd {
	font: 12px ui-monospace, monospace;
	padding: 1px 5px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 4px;
	background: var(--panel-2);
}
code { font: 13px ui-monospace, monospace; color: var(--gold-2); }

/* ---- game picture ---- */
#stage {
	position: fixed;
	inset: 0;
	height: 100dvh;
	background: #000;
	transition: bottom .15s ease;
}
body.kb-open #stage { bottom: var(--kb-h, 38vh); height: auto; }
#canvas {
	display: block;
	width: 100% !important;
	height: 100% !important;
	outline: none;
	touch-action: none;
	image-rendering: auto;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

/* ---- toolbar ---- */
#toolbar {
	position: fixed;
	top: calc(8px + var(--safe-t));
	left: calc(50% - 96px);
	display: flex;
	gap: 6px;
	z-index: 30;
	opacity: .35;
	transition: opacity .2s;
}
#toolbar:hover, #toolbar:focus-within, body:not(.started) #toolbar { opacity: 1; }
body.touch-mode #toolbar { opacity: .7; }
#toolbar button {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, .15);
	background: rgba(20, 12, 36, .72);
	backdrop-filter: blur(6px);
	display: grid;
	place-items: center;
	cursor: pointer;
}
#toolbar button[hidden] { display: none; }
#toolbar svg { width: 22px; height: 22px; fill: none; stroke: var(--gold-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#toolbar button:hover { border-color: var(--gold); }

#toast, #lock-hint, #update-bar {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	z-index: 40;
	padding: 8px 14px;
	border-radius: 999px;
	background: rgba(20, 12, 36, .9);
	border: 1px solid var(--line);
	font-size: 13px;
	pointer-events: none;
	opacity: 0;
	transition: opacity .2s;
	white-space: nowrap;
	max-width: calc(100vw - 32px);
	overflow: hidden;
	text-overflow: ellipsis;
}
#toast { top: calc(58px + var(--safe-t)); }
#toast.show { opacity: 1; }
#lock-hint { bottom: calc(18px + var(--safe-b)); }
#lock-hint.show { opacity: 1; }
#update-bar { top: calc(58px + var(--safe-t)); opacity: 1; pointer-events: auto; }
#update-bar[hidden] { display: none; }
#update-bar button { margin-left: 8px; background: var(--gold); color: #1b1030; border: 0; border-radius: 999px; padding: 2px 10px; cursor: pointer; }

/* ---- boot card ---- */
#boot {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	place-items: center;
	padding: 16px;
	background:
		radial-gradient(1200px 600px at 50% -10%, rgba(140, 92, 255, .35), transparent 60%),
		radial-gradient(800px 500px at 80% 110%, rgba(242, 192, 79, .18), transparent 60%),
		var(--bg);
	overflow-y: auto;
}
#boot.hidden { display: none; }
#boot .card {
	width: min(560px, 100%);
	background: rgba(23, 15, 39, .85);
	border: 1px solid var(--line);
	border-radius: 20px;
	padding: 28px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
	text-align: center;
}
.brand h1 {
	margin: 10px 0 2px;
	font: 700 32px/1.1 Georgia, "Times New Roman", serif;
	letter-spacing: .5px;
	background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, #b07a1a);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}
.brand .sub { margin: 0 0 18px; color: var(--muted); }
.sigil {
	width: 64px;
	height: 64px;
	margin: 0 auto;
	border-radius: 50%;
	background: conic-gradient(from 0deg, var(--accent), var(--gold), var(--accent));
	-webkit-mask: radial-gradient(circle, transparent 46%, #000 48%, #000 62%, transparent 64%), radial-gradient(circle, #000 18%, transparent 20%);
	mask: radial-gradient(circle, transparent 46%, #000 48%, #000 62%, transparent 64%), radial-gradient(circle, #000 18%, transparent 20%);
	animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#boot [class^="when-"], #boot [class*=" when-"] { display: none; }
#boot[data-state="loading"] .when-loading,
#boot[data-state="importing"] .when-importing,
#boot[data-state="ready"] .when-ready,
#boot[data-state="setup"] .when-setup,
#boot[data-state="error"] .when-error,
#boot[data-state="ended"] .when-ended { display: block; }
.bar { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; margin: 10px 0 6px; }
#boot-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .2s; }
.muted { color: var(--muted); }
.note { padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(242, 192, 79, .4); background: rgba(242, 192, 79, .08); }
.note[hidden] { display: none; }
.note button.link { color: var(--gold-2); padding: 0; }
.small { font-size: 12px; }
.error { color: var(--danger); white-space: pre-wrap; }
button.big {
	min-width: 200px;
	padding: 14px 28px;
	font-size: 20px;
	font-weight: 700;
	letter-spacing: .5px;
	border-radius: 999px;
	border: 0;
	color: #1b1030;
	background: linear-gradient(180deg, var(--gold-2), var(--gold));
	box-shadow: 0 8px 30px rgba(242, 192, 79, .35);
	cursor: pointer;
	margin: 6px 0 14px;
}
button.big:hover { filter: brightness(1.06); }
.hint-mobile { display: none; }
body.mobile .hint-mobile { display: block; }
body.mobile .hint-desktop { display: none; }
#drop-zone {
	border: 2px dashed var(--line);
	border-radius: var(--radius);
	padding: 18px;
	margin: 14px 0;
	transition: border-color .15s, background .15s;
}
#drop-zone.over { border-color: var(--gold); background: rgba(242, 192, 79, .06); }
.pick, .button, #panel button, #boot .row button, #error-reload {
	display: inline-block;
	padding: 9px 16px;
	margin: 4px;
	border-radius: 10px;
	border: 1px solid var(--line);
	background: var(--panel-2);
	cursor: pointer;
	font-size: 14px;
}
.pick { background: var(--accent); border-color: transparent; font-weight: 600; }
.pick.alt { background: var(--panel-2); border-color: var(--line); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; }
.row { display: flex; gap: 6px; justify-content: center; align-items: center; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }

/* ---- side panel ---- */
#panel {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(440px, 100vw);
	z-index: 60;
	background: var(--panel);
	border-left: 1px solid var(--line);
	transform: translateX(100%);
	transition: transform .2s ease;
	display: flex;
	flex-direction: column;
	padding-right: var(--safe-r);
	box-shadow: -20px 0 60px rgba(0, 0, 0, .5);
}
#panel.open { transform: none; }
#panel header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: calc(10px + var(--safe-t)) 10px 10px 12px;
	border-bottom: 1px solid var(--line);
}
#panel nav { display: flex; gap: 4px; }
#panel .tab { background: none; border-color: transparent; color: var(--muted); margin: 0; padding: 7px 12px; }
#panel .tab.active { background: var(--panel-2); border-color: var(--line); color: var(--gold-2); }
#panel-close { margin: 0; }
#panel .pane { display: none; padding: 14px 16px 30px; overflow-y: auto; flex: 1; }
#panel .pane.active { display: block; }
#panel button.primary { background: var(--gold); color: #1b1030; border-color: transparent; font-weight: 600; }
#panel button.danger { color: var(--danger); }
#panel h3 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gold); }
.setting {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: center;
	gap: 4px 12px;
	padding: 9px 0;
	border-bottom: 1px solid rgba(58, 42, 92, .5);
}
.setting .name em { font-style: normal; font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 6px; margin-left: 6px; vertical-align: 2px; }
.setting small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.setting select, .setting input[type="text"] {
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 6px 8px;
	max-width: 220px;
}
.setting.text { grid-template-columns: 1fr; }
.setting.text input { max-width: none; width: 100%; }
.setting.range { grid-template-columns: 1fr auto auto; }
.setting.range small { grid-column: 1 / -1; }
.setting input[type="checkbox"] {
	appearance: none;
	width: 42px;
	height: 24px;
	border-radius: 99px;
	background: var(--panel-2);
	border: 1px solid var(--line);
	position: relative;
	cursor: pointer;
	transition: background .15s;
}
.setting input[type="checkbox"]::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--muted);
	transition: transform .15s, background .15s;
}
.setting input[type="checkbox"]:checked { background: var(--accent); }
.setting input[type="checkbox"]:checked::after { transform: translateX(18px); background: #fff; }
.setting output { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.5em; text-align: right; }
#settings-restart { margin-top: 16px; width: 100%; }

.slot { margin: 16px 0 6px; }
.slot h4 { margin: 0 0 6px; font-size: 13px; color: var(--gold); }
.slot h4 span { color: var(--text); font-weight: 400; margin-left: 8px; }
.snap {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	border: 1px solid var(--line);
	border-radius: 10px;
	margin-bottom: 6px;
	background: rgba(33, 22, 58, .5);
}
.snap.pinned { border-color: var(--gold); }
.snap .info { display: flex; flex-direction: column; min-width: 0; }
.snap .info small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snap .actions { display: flex; flex-shrink: 0; }
.snap .actions button { margin: 0 0 0 4px; padding: 5px 9px; }
.empty { color: var(--muted); }
#log-view {
	font: 11px/1.4 ui-monospace, monospace;
	white-space: pre-wrap;
	word-break: break-all;
	background: #08040f;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 8px;
	max-height: calc(100dvh - 160px);
	overflow-y: auto;
}

/* ---- on-screen keyboard ---- */
#vkbd {
	--kb-h: 38vh;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	height: var(--kb-h);
	z-index: 45;
	background: rgba(12, 7, 22, .96);
	border-top: 1px solid var(--line);
	padding: 4px calc(4px + var(--safe-r)) calc(4px + var(--safe-b)) calc(4px + var(--safe-l));
	display: none;
	flex-direction: column;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
}
#vkbd.open { display: flex; }
#vkbd.compact { --kb-h: 26vh; }
body.kb-open { --kb-h: 38vh; }
body.kb-open:has(#vkbd.compact) { --kb-h: 26vh; }
.kb-bar { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 0 2px 3px; }
.kb-bar span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.kb-bar button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 9px; cursor: pointer; }
#vkbd .rows { flex: 1; display: flex; flex-direction: column; gap: 3px; }
#vkbd .row { flex: 1; display: flex; gap: 3px; justify-content: stretch; }
#vkbd .k {
	flex: 1 1 0;
	min-width: 0;
	padding: 0;
	border-radius: 6px;
	border: 1px solid #2c2046;
	border-bottom-width: 2px;
	background: #1d1431;
	font-size: clamp(10px, 1.9vh, 16px);
	line-height: 1;
	min-height: 0;
	cursor: pointer;
	touch-action: none;
}
#vkbd .row { min-height: 0; }
#vkbd .k.fn { background: #160f27; color: var(--muted); }
#vkbd .k.mod { background: #160f27; color: var(--muted); }
#vkbd .k.hot { color: var(--gold-2); }
#vkbd .k.on { background: var(--accent); color: #fff; }
#vkbd .k.pressed { background: var(--gold); color: #1b1030; transform: translateY(1px); }

/* ---- touch controls ---- */
#touch {
	display: none;
	--t-scale: 1;
	--t-alpha: .85;
	--stick: calc(min(34vmin, 170px) * var(--t-scale));
	--fire: calc(min(19vmin, 96px) * var(--t-scale));
	--spell: calc(min(14vmin, 70px) * var(--t-scale));
}
#touch.on { display: block; }
#touch .zone, #touch .t-btn, #touch .t-top { position: fixed; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#touch .t-btn, #touch .t-top { z-index: 35; }
/* thumb zones sit under the toolbar (z 30) and the buttons, over the picture. The move zone is the lower left;
   the look zone (stick mode only) the lower right. Outside flight they step aside so menus can be tapped. */
#touch .zone { z-index: 25; bottom: 0; top: 28%; }
#touch .move-zone { left: 0; width: 46%; }
#touch .look-zone { right: 0; width: 54%; display: none; }
#touch.look-stick .look-zone { display: block; }
body:not(.flying) #touch .zone { display: none; }
#touch .stick {
	position: absolute;
	left: calc(22px + var(--safe-l) + var(--stick) / 2);
	top: calc(100% - 22px - var(--safe-b) - var(--stick) / 2);
	width: var(--stick);
	height: var(--stick);
	transform: translate(-50%, -50%) scale(.86);
	border-radius: 50%;
	pointer-events: none;
	background: radial-gradient(circle, rgba(140, 92, 255, .14), rgba(20, 12, 36, .18) 62%, rgba(255, 255, 255, .03) 71%);
	border: 2px solid rgba(255, 255, 255, .16);
	box-shadow: inset 0 0 18px rgba(0, 0, 0, .35);
	opacity: calc(var(--t-alpha) * .55);
	transition: left .22s cubic-bezier(.2, .9, .3, 1.2), top .22s cubic-bezier(.2, .9, .3, 1.2), transform .15s, opacity .15s, border-color .15s;
}
#touch .look-zone .stick { left: auto; right: calc(22px + var(--safe-r) + var(--stick) / 2 + 2.3 * var(--fire)); }
#touch .stick.active {
	transform: translate(-50%, -50%) scale(1);
	opacity: var(--t-alpha);
	border-color: rgba(242, 192, 79, .55);
	box-shadow: inset 0 0 18px rgba(0, 0, 0, .35), 0 0 24px rgba(242, 192, 79, .18);
	transition: transform .12s, opacity .1s, border-color .1s;
}
#touch .knob {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 42%;
	height: 42%;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: radial-gradient(circle at 38% 32%, rgba(255, 236, 180, .95), rgba(242, 192, 79, .75) 45%, rgba(170, 110, 30, .7));
	border: 2px solid rgba(255, 223, 138, .8);
	box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 0 0 0 rgba(242, 192, 79, 0);
	transition: transform .18s cubic-bezier(.2, .9, .3, 1.3), box-shadow .15s;
}
#touch .stick.active .knob { transition: box-shadow .15s; box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 0 22px rgba(242, 192, 79, .55); }
#touch .stick.look .knob { background: radial-gradient(circle at 38% 32%, rgba(220, 205, 255, .95), rgba(140, 92, 255, .8) 45%, rgba(80, 40, 170, .75)); border-color: rgba(200, 180, 255, .8); }
/* direction ticks light up for the keys the stick is holding */
#touch .tick { position: absolute; width: 14%; height: 5%; border-radius: 4px; background: rgba(255, 255, 255, .22); transition: background .08s, box-shadow .08s; }
#touch .tick.u { left: 43%; top: 6%; }
#touch .tick.d { left: 43%; bottom: 6%; }
#touch .tick.l { width: 5%; height: 14%; left: 6%; top: 43%; }
#touch .tick.r { width: 5%; height: 14%; right: 6%; top: 43%; }
#touch .stick.u .tick.u, #touch .stick.d .tick.d, #touch .stick.l .tick.l, #touch .stick.r .tick.r { background: var(--gold-2); box-shadow: 0 0 10px var(--gold); }
#touch .t-btn {
	position: fixed;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, .22);
	background: rgba(20, 12, 36, .45);
	color: rgba(255, 255, 255, .88);
	font-weight: 700;
	opacity: var(--t-alpha);
	transition: transform .08s, background .08s;
}
#touch .t-btn.pressed { background: rgba(242, 192, 79, .6); color: #1b1030; transform: scale(.92); }
#touch .t-btn.burst::after {
	content: "";
	position: absolute;
	inset: -2px;
	border-radius: inherit;
	border: 2px solid var(--gold-2);
	animation: t-burst .38s ease-out forwards;
	pointer-events: none;
}
@keyframes t-burst { from { transform: scale(1); opacity: .9; } to { transform: scale(1.45); opacity: 0; } }
#touch .t-right .fire { width: var(--fire); height: var(--fire); font-size: calc(22px * var(--t-scale)); }
#touch .t-right .fire.left { right: calc(26px + var(--fire) + var(--safe-r)); bottom: calc(22px + var(--safe-b)); background: rgba(80, 40, 170, .42); }
#touch .t-right .fire.right { right: calc(16px + var(--safe-r)); bottom: calc(40px + var(--fire) + var(--safe-b)); background: rgba(170, 50, 60, .42); }
#touch .t-right .fire.pressed { background: rgba(242, 192, 79, .65); }
#touch .t-right .spell { right: calc(32px + 2 * var(--fire) + var(--safe-r)); bottom: calc(30px + var(--safe-b)); width: var(--spell); height: var(--spell); font-size: 12px; }
#touch .t-top { top: calc(8px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; gap: 6px; }
#touch .t-top .t-btn { position: relative; border-radius: 10px; padding: 0 12px; height: 38px; font-size: 13px; }
body:not(.in-flight) #touch .t-right { display: none; }
body.kb-open #touch .zone, body.kb-open #touch .t-right { display: none; }
body:not(.started) #touch { display: none; }
#btn-touch.off svg { opacity: .45; }
#btn-touch.off { border-style: dashed; }

/* ---- Multiverse realm visions (js/visions.js) ---- */
#boot-vision {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 0;
}
#boot .card { position: relative; z-index: 1; background: rgba(16, 10, 30, .72); backdrop-filter: blur(10px); }
.brand h1 { font-size: 40px; letter-spacing: 1.5px; text-transform: uppercase; }
.brand .h1-small {
	display: block;
	font: 600 13px/1.4 system-ui, sans-serif;
	letter-spacing: 7px;
	text-transform: uppercase;
	color: var(--gold-2);
	-webkit-text-fill-color: var(--gold-2);
	margin-bottom: 2px;
}
.realm-line { font-style: italic; margin-top: -10px !important; opacity: .85; }

#loading-vision {
	position: fixed;
	inset: 0;
	z-index: 48;
	background: #05030a;
	opacity: 0;
	visibility: hidden;
	transition: opacity .7s ease, visibility 0s linear .7s;
	cursor: default;
	user-select: none;
	-webkit-user-select: none;
}
/* up at once (no fade-in), so the old load screen never shows through; it fades out into the realm */
#loading-vision.show { opacity: 1; visibility: visible; transition: none; }
#vision-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.lv-brand {
	position: absolute;
	top: calc(7vh + var(--safe-t));
	left: 0;
	right: 0;
	text-align: center;
	pointer-events: none;
}
.lv-small {
	display: block;
	font: 600 clamp(11px, 1.6vw, 16px)/1.2 system-ui, sans-serif;
	letter-spacing: .6em;
	text-transform: uppercase;
	color: var(--gold-2);
	text-shadow: 0 2px 10px rgba(0, 0, 0, .8);
	padding-left: .6em;
}
.lv-big {
	display: block;
	font: 700 clamp(34px, 7.5vw, 88px)/1 Georgia, "Times New Roman", serif;
	letter-spacing: .08em;
	text-transform: uppercase;
	background: linear-gradient(180deg, #fff3c4, var(--gold) 55%, #9c6512);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	filter: drop-shadow(0 4px 18px rgba(0, 0, 0, .7)) drop-shadow(0 0 22px rgba(242, 192, 79, .35));
}
.lv-realm {
	position: absolute;
	left: calc(5vw + var(--safe-l));
	bottom: calc(11vh + var(--safe-b));
	max-width: min(620px, 80vw);
	display: flex;
	flex-direction: column;
	gap: 2px;
	text-shadow: 0 2px 12px rgba(0, 0, 0, .9);
	pointer-events: none;
	animation: lv-rise 1s ease both;
}
.lv-index { font: 600 12px/1.4 system-ui, sans-serif; letter-spacing: .35em; text-transform: uppercase; color: var(--gold-2); }
.lv-name { font: 700 clamp(26px, 4.4vw, 52px)/1.05 Georgia, serif; color: #fff; }
.lv-epithet { font: italic clamp(15px, 2vw, 22px)/1.3 Georgia, serif; color: #f6e2b0; }
.lv-lore { margin-top: 10px; font-size: clamp(13px, 1.5vw, 16px); color: rgba(239, 231, 255, .85); max-width: 46ch; }
.lv-loader {
	position: absolute;
	left: 50%;
	bottom: calc(4.5vh + var(--safe-b));
	transform: translateX(-50%);
	width: min(360px, 70vw);
	text-align: center;
	font-size: 12px;
	letter-spacing: .2em;
	text-transform: uppercase;
	color: rgba(255, 236, 190, .85);
	text-shadow: 0 1px 6px #000;
}
.lv-thread {
	height: 3px;
	border-radius: 3px;
	margin-bottom: 8px;
	background: linear-gradient(90deg, transparent, var(--gold) 40%, #fff6d6 50%, var(--gold) 60%, transparent) 0 0 / 50% 100% no-repeat, rgba(255, 255, 255, .12);
	animation: lv-weave 1.4s linear infinite;
}
#loading-vision.ready .lv-thread { background: var(--gold); animation: none; box-shadow: 0 0 12px rgba(242, 192, 79, .7); }
#loading-vision.ready #lv-status { animation: lv-pulse 1.6s ease-in-out infinite; }
#loading-vision.ready { cursor: pointer; }
@keyframes lv-weave { from { background-position: -100% 0, 0 0; } to { background-position: 200% 0, 0 0; } }
@keyframes lv-pulse { 50% { opacity: .45; } }
@keyframes lv-rise { from { opacity: 0; transform: translateY(14px); } }
@media (max-height: 460px) {
	.lv-brand { top: calc(3vh + var(--safe-t)); }
	.lv-big { font-size: 34px; }
	.lv-realm { bottom: calc(14vh + var(--safe-b)); }
	.lv-lore { display: none; }
	.brand h1 { font-size: 26px; }
}

/* ---- the Waystation: company during first-time waits (js/waystation.js) ---- */
#stream-veil {
	position: fixed;
	inset: 0;
	z-index: 49;
	background: #05030a;
	opacity: 0;
	visibility: hidden;
	transition: opacity .5s ease, visibility 0s linear .5s;
}
#stream-veil.show { opacity: 1; visibility: visible; transition: opacity .25s ease, visibility 0s; }
#stream-veil.over-level { background: transparent; }
#stream-veil.over-level #stream-canvas { display: none; }
#stream-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#stream-slot {
	position: absolute;
	left: 50%;
	bottom: calc(4vh + var(--safe-b));
	transform: translateX(-50%);
	width: min(580px, calc(100vw - 32px));
}
#ws-slot { margin-top: 14px; }

.ws {
	text-align: left;
	color: var(--text);
	background: rgba(16, 10, 30, .8);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid rgba(242, 192, 79, .28);
	border-radius: 16px;
	padding: 10px 14px 12px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
	opacity: 0;
	transform: translateY(10px);
	transition: opacity .45s ease, transform .45s ease;
	max-height: calc(100dvh - 8vh - 24px);
	display: flex;
	flex-direction: column;
}
.ws.in { opacity: 1; transform: none; }
.ws.done { opacity: 0; transform: translateY(6px); pointer-events: none; }
.ws.embed { background: rgba(255, 255, 255, .035); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; border-color: rgba(242, 192, 79, .18); }
.ws.embed .ws-progress, .ws.embed .ws-min, .ws.embed .ws-restore { display: none; }
.ws.embed.done { display: none; }
.ws button { font: inherit; color: inherit; cursor: pointer; }

.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ws-tabs { display: flex; gap: 4px; }
.ws-tab {
	background: none;
	border: 1px solid transparent;
	border-radius: 999px;
	padding: 4px 11px;
	font-size: 12px !important;
	color: var(--muted) !important;
	margin: 0 !important;
}
.ws-tab.active { border-color: rgba(242, 192, 79, .4); color: var(--gold-2) !important; background: rgba(242, 192, 79, .08); }
.ws-min { background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 6px; margin: 0 !important; }

.ws-pane { display: none; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.ws-pane.active { display: block; }
.ws-card { min-height: 128px; padding: 2px 2px 4px; }
.ws-card.enter { animation: ws-in .45s ease both; }
@keyframes ws-in { from { opacity: .35; transform: translateX(8px); } }
.ws-kicker { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.ws-card.kind-world .ws-kicker { color: #f6b07a; }
.ws-card.kind-multiverse .ws-kicker { color: #c9a7ff; }
.ws-card.kind-tip .ws-kicker { color: var(--ok); }
.ws-title { margin: 3px 0 5px; font: 700 19px/1.2 Georgia, "Times New Roman", serif; color: #fff; }
.ws-body { margin: 0; font-size: 14px; line-height: 1.5; color: rgba(239, 231, 255, .88); }
.ws-keys { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ws-keys kbd { font-size: 11px; color: var(--gold-2); }
.ws-quiz { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ws-opt {
	border: 1px solid var(--line);
	background: var(--panel-2);
	border-radius: 10px;
	padding: 7px 12px;
	font-size: 13px !important;
	margin: 0 !important;
}
.ws-opt:hover:not(:disabled) { border-color: var(--gold); }
.ws-opt.right { border-color: var(--ok); background: rgba(110, 231, 168, .14); }
.ws-opt.wrong { border-color: var(--danger); background: rgba(255, 107, 122, .12); }
.ws-opt:disabled { cursor: default; }
.ws-explain { margin: 8px 0 0; font-size: 13px; color: rgba(239, 231, 255, .85); opacity: 0; transition: opacity .3s; }
.ws-explain.show { opacity: 1; }

.ws-nav { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.ws-nav > button {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: rgba(255, 255, 255, .04);
	font-size: 14px !important;
	padding: 0 !important;
	margin: 0 !important;
	display: grid;
	place-items: center;
}
.ws-pause { font-size: 9px !important; }
.ws-dots { flex: 1; display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.ws-dot { width: 7px; height: 7px; padding: 0 !important; margin: 0 !important; border-radius: 50%; border: 0 !important; background: rgba(255, 255, 255, .22) !important; }
.ws-dot.on { background: var(--gold) !important; }

.ws-intro { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.ws-group { padding: 7px 0; border-top: 1px solid rgba(58, 42, 92, .6); }
.ws-q { display: block; font-size: 13px; margin-bottom: 5px; color: #f3ecff; }
.ws-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ws-chip {
	border: 1px solid var(--line);
	background: rgba(255, 255, 255, .04);
	border-radius: 999px;
	padding: 5px 11px;
	font-size: 12px !important;
	margin: 0 !important;
	transition: background .15s, border-color .15s, color .15s;
}
.ws-chip:hover { border-color: rgba(242, 192, 79, .6); }
.ws-chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1b1030; font-weight: 600; }
.ws-chip.swatch { width: 28px; height: 28px; padding: 0 !important; background: var(--sw) !important; border: 2px solid rgba(255, 255, 255, .25); }
.ws-chip.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.ws-note { display: block; min-height: 0; font-size: 11px; color: var(--ok); opacity: 0; transition: opacity .3s; margin-top: 3px; }
.ws-note.show { opacity: 1; }

.ws-progress { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(58, 42, 92, .6); }
.ws-label { font-size: 12px; color: rgba(255, 236, 190, .9); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-pct { font-size: 12px; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.ws-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.ws-bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .25s; }
.ws.indeterminate .ws-bar > div { width: 30% !important; animation: ws-slide 1.2s ease-in-out infinite alternate; }
@keyframes ws-slide { from { transform: translateX(-10%); } to { transform: translateX(240%); } }
.ws.ready .ws-bar > div { background: var(--gold); box-shadow: 0 0 10px rgba(242, 192, 79, .7); width: 100% !important; animation: none; }
.ws-restore { align-self: flex-end; margin-top: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); border-radius: 999px; padding: 4px 12px; font-size: 12px !important; }
.ws.mini .ws-head, .ws.mini .ws-pane { display: none !important; }
.ws.mini .ws-progress { margin-top: 0; padding-top: 0; border-top: 0; }
.ws.mini { width: min(320px, 100%); margin-left: auto; margin-right: auto; }
@media (max-height: 460px) {
	#stream-slot { bottom: calc(2vh + var(--safe-b)); }
	.ws { padding: 8px 12px 10px; }
	.ws-card { min-height: 96px; }
	.ws-title { font-size: 16px; }
	.ws-body { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
	.ws-card.enter { animation: none; }
}

/* ---- small screens ---- */
@media (max-width: 560px) {
	#boot .card { padding: 20px 16px; }
	.brand h1 { font-size: 26px; }
	#toolbar { left: calc(8px + var(--safe-l)); }
}
@media (max-height: 460px) {
	#boot .card { padding: 14px 18px; }
	.sigil { width: 40px; height: 40px; }
	.brand h1 { font-size: 22px; margin-top: 4px; }
	.brand .sub { margin-bottom: 8px; }
}
/* touch mode: keep the game's minimap (top left), mana bar (top) and spells (top right) clear;
   page buttons stand in a column on the left edge, game shortcuts on the right edge */
body.touch-mode.started #toolbar {
	left: calc(6px + var(--safe-l));
	top: 50%;
	transform: translateY(-62%);
	flex-direction: column;
	gap: 5px;
}
body.touch-mode.started #toolbar button { width: 36px; height: 36px; }
body.touch-mode #touch .t-top {
	top: 50%;
	right: calc(6px + var(--safe-r));
	transform: translateY(-95%);
	flex-direction: column;
	gap: 5px;
}
body.touch-mode #touch .t-top .t-btn { height: 34px; padding: 0 8px; font-size: 12px; }
/* keyboard open: page buttons sit in the keyboard's header bar; its Esc / Tab replace Menu / Map */
body.kb-open.started #toolbar {
	top: auto;
	bottom: calc(var(--kb-h) - 31px);
	left: calc(8px + var(--safe-l));
	transform: none;
	flex-direction: row;
	gap: 5px;
	opacity: 1;
	z-index: 46;
}
body.kb-open.started #toolbar button { width: 30px; height: 26px; border-radius: 7px; }
body.kb-open.started #toolbar svg { width: 18px; height: 18px; }
body.kb-open #touch .t-top { display: none; }
body.kb-open .kb-bar { padding-left: 150px; }
/* short (landscape phone) screens: the keyboard takes half the height so all six rows fit */
@media (max-height: 520px) {
	#vkbd, body.kb-open { --kb-h: 54vh; }
	#vkbd.compact, body.kb-open:has(#vkbd.compact) { --kb-h: 42vh; }
	.kb-bar span { display: none; }
	.kb-bar { justify-content: flex-end; padding-bottom: 2px; }
	#vkbd .rows, #vkbd .row { gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
	.sigil { animation: none; }
}

/* ---- Pocket tab: talk with no bridge in reach (js/pocket.js, js/pocket-models.js) ---- */
#panel nav { overflow-x: auto; scrollbar-width: none; }
#panel nav::-webkit-scrollbar { display: none; }
#pocket-route { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
#pocket-route i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
#pocket-route.bridge i { background: var(--ok); box-shadow: 0 0 0 4px rgba(110, 231, 168, .2); }
#pocket-route.pocket i { background: var(--gold); box-shadow: 0 0 0 4px rgba(242, 192, 79, .2); }
#pocket-route.none i { background: var(--danger); }
#pocket-ready { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
#pocket-ready li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
#pocket-ready li b { flex: none; width: 1.4em; text-align: center; color: var(--muted); }
#pocket-ready li.yes b { color: var(--ok); }
#pocket-ready li span { flex: 1; min-width: 12em; }
#panel #pocket-ready button { margin: 0; padding: 5px 12px; font-size: 13px; }
#toolbar #btn-pocket.on svg { stroke: var(--gold); }
.pm { display: grid; gap: 10px; margin-top: 12px; font-size: 14px; }
#panel .pm button { margin: 0; font: inherit; color: inherit; }
#panel .pm-switch-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); text-align: left; }
.pm-switch-row b { display: block; font-size: 15px; color: var(--gold-2); }
.pm-switch-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.pm-switch-row > span:first-child { flex: 1; min-width: 0; }
.pm-sw { position: relative; flex: none; width: 46px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, .18); transition: background .2s; }
.pm-sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px #0005; }
.pm-switch-row[aria-checked="true"] .pm-sw { background: var(--ok); }
.pm-switch-row[aria-checked="true"] .pm-sw::after { transform: translateX(18px); }
.pm-note { font-size: 13px; color: var(--muted); line-height: 1.45; }
.pm-note.err { color: var(--danger); }
.pm-now { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.pm-now i { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.pm-now.ready i { background: var(--ok); box-shadow: 0 0 0 4px rgba(110, 231, 168, .25); }
.pm-now.asleep i { background: var(--accent); }
.pm-now.busy i { background: var(--gold); animation: pm-pulse 1s ease-in-out infinite alternate; }
@keyframes pm-pulse { to { opacity: .4; } }
.pm-models { display: grid; gap: 8px; }
.pm-model { padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.pm-model.use { border-color: rgba(110, 231, 168, .7); }
.pm-model.working { border-color: var(--accent); }
.pm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pm-head b { font-size: 15px; margin-right: 2px; }
.pm-chip { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: rgba(255, 255, 255, .12); white-space: nowrap; }
.pm-chip.use { background: rgba(110, 231, 168, .25); color: #b9f5dc; }
.pm-chip.mem { background: rgba(140, 92, 255, .35); color: #e2d6ff; }
.pm-chip.part { background: rgba(242, 192, 79, .2); color: var(--gold-2); }
.pm-meta { margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.pm-bar { height: 6px; margin-top: 9px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.pm-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .35s; }
.pm-bar.part i { background: rgba(242, 192, 79, .65); }
.pm-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#panel .pm-btn { padding: 7px 14px; border-radius: 10px; font-weight: 600; font-size: 13.5px; }
#panel .pm-btn.primary { background: var(--gold); color: #1b1030; border-color: transparent; }
#panel .pm-btn.danger { color: var(--danger); }
#panel .pm-btn.armed { background: var(--danger); color: #fff; border-color: transparent; }
#panel .pm-btn:disabled { opacity: .4; cursor: default; }
.pm-label { margin-top: 2px; color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.pm-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel-2); }
#panel .pm-seg button { padding: 7px 0; border: 0; border-radius: 9px; background: none; font-weight: 600; font-size: 13.5px; }
#panel .pm-seg button.on { background: rgba(255, 255, 255, .14); color: var(--gold-2); }
.pm-store { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.pm-store b { color: var(--text); font-weight: 600; }
.pm-say { display: inline-block; margin-top: 8px; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--panel-2); border: 1px solid var(--line); font-size: 14px; }
