/* Minicraft - 外层 UI
   ---------------------------------------------------------------------------
   这一层是「原版界面的 HTML 复刻」：坐标、配色、大小全部照抄 160x120 里的像素布局，
   区别只是文字用系统字体渲染（清晰）而且能点。
   --u = 一个游戏像素的尺寸，所有位置写成 calc(var(--u) * N)，N 就是原版里的像素坐标。 */

:root {
	--u: 3px;
	/* 只用系统自带字体，不引外链：思源黑体 = Source Han Sans，多数系统里
	   和 Noto Sans SC 是同一套字形。后面的都是各平台的等价物。 */
	--font: "Source Han Sans SC", "Source Han Sans CN", "Noto Sans SC", "Noto Sans CJK SC",
		"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
	/* 原版调色板里的几档灰/蓝，运行时由 UI.palette() 换成真实 RGB */
	--c-ink: #e8e8e8;
	--c-dim: #6a6a6a;
	--c-dark: #3a3a3a;
	--c-mute: #666666;
	--c-win: #0a0f18;
	--c-edge: #8d9aa8;
	--c-hud: #000000;
	/* TUI 层用的几档灰，比原版调色板干净 */
	--t-bg: #050505;
	--t-ink: #ededed;
	--t-sub: #9a9a9a;
	--t-dim: #5c5c5c;
	--t-line: #242424;
	--t-sel: #ffffff;
	--t-fill: rgba(255, 255, 255, 0.08);
}

/* 像素风硬约束：项目里任何 UI 都不允许圆角，包括以后 JS 动态塞进来的内联样式。 */
#stage * {
	border-radius: 0 !important;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	background: #000;
	overflow: hidden;
	overscroll-behavior: none;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
	font-family: var(--font);
	/* 不让系统替换成用户装的花体：合成关闭，平滑打开 */
	font-synthesis: none;
	-webkit-font-smoothing: antialiased;
	color: var(--c-ink);
}

/* ------------------------------------------------------------------ stage */
/* 竖屏时整块旋转 90°，物理上永远横屏。 */

#stage {
	position: fixed;
	left: 0;
	top: 0;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	background: #000;
}

/* 不做伪横屏：竖屏时舞台整体隐藏（帧循环也停了，纯省性能），
   由 #rotate-hint 弹窗接管整个屏幕。 */
@media (orientation: portrait) {
	#stage {
		display: none;
	}
}

/* ---------------------------------------------------------------- 竖屏拦截弹窗
   挂在 body 直下（舞台外），竖屏时永远以手机原生竖向显示，
   不被任何游戏坐标/旋转影响。点一下请求全屏+方向锁定自动横屏。 */
#rotate-hint {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 10000;
	background: #000;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	color: #fff;
	font-family: var(--font);
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	cursor: pointer;
}

@media (orientation: portrait) {
	#rotate-hint {
		display: flex;
	}
}

#rotate-hint .rh-title {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: 2px;
}

#rotate-hint .rh-sub {
	font-size: 14px;
	color: #999;
	letter-spacing: 1px;
}

canvas#game {
	position: absolute;
	left: 0;
	top: 0;
	display: block;
	outline: none;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	cursor: default;
	touch-action: none;
}

/* --------------------------------------------------------------------- UI */

#ui {
	position: absolute;
	left: 0;
	top: 0;
	width: 160px;
	height: 120px;
	pointer-events: none;
	overflow: hidden;
	/* 压在 .touch-layer(z-index:1) 之上：图标按钮不能被摇杆的触摸区挡住。
	   其余部分 pointer-events:none，事件照样穿透到摇杆或 canvas。 */
	z-index: 2;
}

/* 千万别写成 `#ui > * { pointer-events: none }`：ID 选择器会压过
   `.overlay.is-on { pointer-events: auto }`，把整个菜单层的点击全部吃掉，
   真实指针会直接落到下面的 canvas 上。只把「不需要点」的层单独关掉。 */
.hud,
.screen,
.overlay,
.touch-layer {
	pointer-events: none;
}

/* -------------------------------------------------------------------- HUD */
/* 原版 HUD 就是底部 160x16 的黑条：上一行 10 颗心，下一行 10 格体力，
   (80,104) 放手上的东西。这里用同一套精灵、同一套配色还原。 */

.hud {
	position: absolute;
	left: 0;
	top: calc(var(--u) * 104);
	width: 100%;
	height: calc(var(--u) * 16);
	background: var(--c-hud);
	opacity: 1;
}

.hud.is-hidden {
	opacity: 0;
}

.hud canvas {
	position: absolute;
	width: calc(var(--u) * 8);
	height: calc(var(--u) * 8);
	image-rendering: pixelated;
}

/* ---------------------------------------------------------------- overlay */
/* 原版菜单打开时 screen.clear(0)：整屏纯黑，世界看不见。照做。 */

.overlay {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background: transparent;
	opacity: 0;
	visibility: hidden;
}

.overlay.is-solid {
	background: #000;
}

.overlay.is-on {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* -------------------------------------------------------------- 文字基元 */

.t {
	position: absolute;
	font-family: var(--font);
	font-size: calc(var(--u) * 8);
	line-height: calc(var(--u) * 8);
	white-space: pre;
	letter-spacing: 0;
}

.hit,
.opt {
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.hit:active {
	filter: brightness(1.4);
}

/* ------------------------------------------------------------------ 标题 */
/* 原版：logo 在 (28,24)，13x2 个 tile；三个选项居中在 y=64/72/80；
   底部提示在 (0,112)。全部照抄。 */

.screen {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
}

.screen .logo {
	position: absolute;
	left: calc(var(--u) * 28);
	top: calc(var(--u) * 24);
	width: calc(var(--u) * 104);
	height: calc(var(--u) * 16);
	image-rendering: pixelated;
}

/* ------------------------------------------------------------------ 窗口 */
/* 原版 Font.renderFrame：深色底 + 一圈亮边。位置按原版的格数换算。 */

.win {
	position: absolute;
	background: var(--c-win);
	/* 原版窗口是一圈 8px 的边框贴图：外面深、中间一道亮线 */
	border: max(2px, calc(var(--u) * 1)) solid var(--c-edge);
	box-shadow: 0 0 0 max(1px, calc(var(--u) * 0.34)) rgb(11, 11, 35);
}

.win-title {
	position: absolute;
	font-family: var(--font);
	font-size: calc(var(--u) * 8);
	line-height: calc(var(--u) * 8);
	color: var(--c-ink);
	white-space: pre;
	pointer-events: none;
}

.list {
	position: absolute;
	overflow: hidden;
	pointer-events: none;
}

/* 列表窗口的「手势命中层」：窗口空白处也能接住手指，事件再冒泡到 .screen
   由 UI.bindScroll 统一处理。放在所有窗口元素之前，行 / 关闭叉自然压在它上面。 */
.list-hit {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background: transparent;
	pointer-events: auto;
	touch-action: none;
}

.item {
	position: absolute;
	height: calc(var(--u) * 8);
	cursor: pointer;
	pointer-events: auto;
}

.item .icon {
	position: absolute;
	left: 0;
	top: 0;
	width: calc(var(--u) * 8);
	height: calc(var(--u) * 8);
	image-rendering: pixelated;
}

.item .label {
	position: absolute;
	left: calc(var(--u) * 8);
	top: 0;
	font-family: var(--font);
	font-size: calc(var(--u) * 8);
	line-height: calc(var(--u) * 8);
	color: var(--c-ink);
	white-space: pre;
	overflow: hidden;
}

.item .num {
	position: absolute;
	left: 0;
	top: 0;
	font-family: var(--font);
	font-size: calc(var(--u) * 4);
	line-height: calc(var(--u) * 4);
	color: var(--c-dim);
	white-space: pre;
}

.item.is-off .label {
	color: var(--c-mute);
}

/* 背包行右侧的「丢到地上」按钮：手心向下图标。点一下丢 1 个，连点两下丢整堆。
   图标是 Font Awesome hand-point-down（CC BY 4.0），填色走 currentColor。 */
.item-discard {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--c-ink);
	pointer-events: auto;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.item-discard svg {
	display: block;
	height: 80%;
	width: auto;
	fill: currentColor;
	stroke: none;
}

.cursor {
	position: absolute;
	font-family: var(--font);
	font-size: calc(var(--u) * 8);
	line-height: calc(var(--u) * 8);
	color: #ffffff;
	pointer-events: none;
}

.prose {
	position: absolute;
	font-family: var(--font);
	font-size: calc(var(--u) * 8);
	line-height: calc(var(--u) * 8);
	white-space: pre;
	color: var(--c-dim);
}

.prose .lead {
	color: var(--c-ink);
}

/* ------------------------------------------------------------- 触屏控件 */
/* 方形像素按键：黑底、白边、白字，跟游戏本身一个语言。 */

.touch-layer {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	pointer-events: none;
	touch-action: none;
}

.touch-zone {
	position: absolute;
	left: 0;
	top: 0;
	width: 46%;
	height: 100%;
	pointer-events: auto;
	touch-action: none;
}

.touch-stick,
.touch-knob {
	position: absolute;
	/* 像素风直角：方形摇杆底座和方形滑块 */
	border-radius: 0;
	pointer-events: none;
	will-change: left, top;
	transition: opacity 0.12s linear;
}

.touch-stick {
	border: 2px solid rgba(255, 255, 255, 0.22);
	background: rgba(0, 0, 0, 0.35);
}

.touch-layer.stick-active .touch-stick {
	border-color: rgba(255, 255, 255, 0.5);
	background: rgba(0, 0, 0, 0.5);
}

.touch-knob {
	background: rgba(255, 255, 255, 0.28);
	border: 2px solid rgba(255, 255, 255, 0.55);
}

.touch-layer.stick-active .touch-knob {
	background: rgba(255, 255, 255, 0.5);
}

/* ------------------------------------------------------- 图标按钮（自绘 SVG） */
/* 齿轮 / 背包 / 返回 / 关闭，全部是内联 SVG，不用 emoji、不写字母。
   方形、半透明黑底、白色线条，和像素画面一个语言。 */

.ingame-controls {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.corner-btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: calc(var(--u) * 1.5);
	background: rgba(0, 0, 0, 0.45);
	color: #ffffff;
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	-webkit-user-select: none;
	user-select: none;
}

.corner-btn svg {
	display: block;
	width: 100%;
	height: 100%;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.corner-btn:active {
	background: rgba(255, 255, 255, 0.28);
}

/* ------------------------------------------------- About / How to play 正文 */
/* 一整段自然文本，统一字号，浏览器自动换行，不再逐行拆字定坐标。 */

.prose-natural {
	position: absolute;
	text-align: center;
	font-family: var(--font);
	font-size: calc(var(--u) * 7);
	line-height: calc(var(--u) * 8);
	/* pre-wrap：既保留段落之间的空行，又照样按宽度自动换行 */
	white-space: pre-wrap;
	overflow-wrap: break-word;
	color: var(--c-ink);
	/* 允许滚动；手指/滚轮的滚动由 UI.bindScroll 自己接管（全局 body 是
	   touch-action:none，浏览器不会替子元素做原生滚动，只靠拖滚动条能动能滚） */
	overflow-y: auto;
	pointer-events: auto;
	touch-action: none;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: auto;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.prose-natural::-webkit-scrollbar {
	width: calc(var(--u) * 3);
}

.prose-natural::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.45);
}

/* 语言菜单：选中项 > xxx < 白字，其余灰字，居中排列 */
.prose-head {
	font-size: calc(var(--u) * 7);
	line-height: calc(var(--u) * 8);
	white-space: pre;
}

noscript {
	color: #888;
	font: 14px monospace;
	padding: 24px;
	display: block;
}

/* ---------------------------------------------------------------- 联机延迟角标
   贴在 #stage 的右上角。stage 铺满整屏并负责竖屏旋转，所以它永远在屏幕角落，
   不受 160x120 游戏分辨率和 4:3 画面的限制。pointer-events: none 保证
   它不吃任何点击，触摸摇杆和攻击都不受影响。 */
.net-latency {
	position: absolute;
	top: 6px;
	right: 8px;
	display: none;
	align-items: center;
	gap: 4px;
	padding: 3px 7px;
	background: rgba(0, 0, 0, 0.45);
	font: 600 12px/1 ui-monospace, Menlo, Consolas, monospace;
	color: #63b3ff;
	pointer-events: none;
	z-index: 40;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.net-latency.is-on {
	display: flex;
}
.net-latency i {
	width: 6px;
	height: 6px;
	background: currentColor;
	box-shadow: 0 0 6px currentColor;
}
.net-latency b {
	font-weight: 600;
	min-width: 18px;
	text-align: right;
}
.net-latency span {
	opacity: 0.7;
	font-size: 10px;
}
.net-latency.good {
	color: #63b3ff;
}
.net-latency.mid {
	color: #ffd166;
}
.net-latency.bad {
	color: #ff6b6b;
}

/* 玩家头顶的名字。用 DOM 而不是 canvas：原版像素字体只有 ASCII，
   中文和表情在画布上根本画不出来。坐标由 NetWorld.drawNames 每帧递进来。 */
.net-names {
	position: absolute;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	pointer-events: none;
	/* 必须压在 #ui（z-index: 2）下面：名字只在局内出现，
	   一开菜单就被盖住，不然暂停面板上还飘着一堆名字。 */
	z-index: 1;
	overflow: hidden;
}
.net-names span {
	position: absolute;
	left: 0;
	top: 0;
	white-space: nowrap;
	font: 600 11px/1.2 var(--font);
	color: #ffffff;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 3px rgba(0, 0, 0, 0.9);
	will-change: transform;
}
.net-names span.is-dead {
	color: #ff9a9a;
}
.net-names span.is-ghost {
	opacity: 0.55;
}

/* ================================================================== TUI 层
   所有整屏界面共用一套骨架：左上角 ← 返回、标题、一条细规则线、中间内容、
   底部一行提示。坐标集中在这里和 UI.shell 里，保证每个界面的返回键位置
   一模一样，不用逐个界面去对。 */

.tui {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background: var(--t-bg);
	color: var(--t-ink);
	font-family: var(--font);
}

.tui-back {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	/* 返回键只是一个字，不要框。触摸热区靠 width/height 撑住，和视觉无关。 */
	background: none;
	border: 0;
	color: var(--t-ink);
	font-size: calc(var(--u) * 9);
	line-height: 1;
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	opacity: 0.85;
}

.tui-back:active {
	opacity: 1;
	background: rgba(255, 255, 255, 0.14);
}

.tui-title {
	position: absolute;
	left: 0;
	width: 100%;
	text-align: center;
	font-size: calc(var(--u) * 8);
	line-height: calc(var(--u) * 10);
	letter-spacing: calc(var(--u) * 0.6);
	color: var(--t-ink);
	white-space: nowrap;
	text-transform: uppercase;
}

/* 顶栏右上角那行状态改成标题下面的一行小字，居中。
   标题居中了，右边再挂一坨信息就会压上去。 */
.tui-right {
	position: absolute;
	font-size: calc(var(--u) * 5);
	line-height: calc(var(--u) * 7);
	text-align: center;
	color: var(--t-dim);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tui-rule {
	position: absolute;
	background: var(--t-line);
}

.tui-row {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 calc(var(--u) * 4);
	font-size: calc(var(--u) * 7);
	line-height: 1;
	color: var(--t-sub);
	white-space: nowrap;
	text-align: center;
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.tui-row:active {
	background: rgba(255, 255, 255, 0.16);
}

.tui-row.is-sel {
	background: var(--t-fill);
	color: var(--t-sel);
}

.tui-row.is-off {
	color: var(--t-dim);
}

/* 值跟着标题一起居中，不再被 margin-left:auto 顶到最右边 */
.tui-row .v {
	margin-left: calc(var(--u) * 4);
	color: var(--t-dim);
	font-size: calc(var(--u) * 6);
}

.tui-row.is-sel .v {
	color: var(--t-sel);
}

.tui-label {
	position: absolute;
	font-size: calc(var(--u) * 5);
	line-height: calc(var(--u) * 7);
	color: var(--t-dim);
	letter-spacing: calc(var(--u) * 0.4);
	white-space: pre;
	text-align: center;
}

/* 死亡删档警告：可换行的小字，居中，中文长句也能完整显示。 */
.tui-warn {
	position: absolute;
	font-size: calc(var(--u) * 4);
	line-height: calc(var(--u) * 5.5);
	color: var(--t-sel);
	text-align: center;
	white-space: normal;
	overflow: hidden;
}

.tui-foot {
	position: absolute;
	font-size: calc(var(--u) * 5);
	line-height: calc(var(--u) * 7);
	color: var(--t-dim);
	text-align: center;
	white-space: normal;
}

/* 长说明（建房页那段房号规则）：字小一号、行距收一点，
   三行也放得下，不挤到上面的按钮。 */
.tui-foot.is-long {
	font-size: calc(var(--u) * 4);
	line-height: calc(var(--u) * 6);
	padding: 0 calc(var(--u) * 3);
}

.tui-key {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid var(--t-line);
	color: var(--t-ink);
	font-size: calc(var(--u) * 7);
	line-height: 1;
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.tui-key:active {
	background: rgba(255, 255, 255, 0.3);
}

.tui-key.is-fn {
	color: var(--t-sub);
	font-size: calc(var(--u) * 6);
}

.tui-code {
	position: absolute;
	display: flex;
	gap: calc(var(--u) * 3);
	justify-content: center;
}

.tui-code i {
	width: calc(var(--u) * 11);
	height: calc(var(--u) * 14);
	display: flex;
	align-items: center;
	justify-content: center;
	border-bottom: 2px solid var(--t-line);
	font-style: normal;
	font-size: calc(var(--u) * 9);
	color: var(--t-ink);
}

.tui-code i.on {
	border-bottom-color: var(--t-sel);
}

.tui-chip {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--t-line);
	color: var(--t-sub);
	font-size: calc(var(--u) * 6);
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.tui-chip:active {
	background: rgba(255, 255, 255, 0.18);
}

.tui-chip.is-on {
	color: #0b0b0b;
	background: #dedede;
}

.tui-line {
	position: absolute;
	text-align: center;
	font-size: calc(var(--u) * 6);
	line-height: calc(var(--u) * 8);
	color: var(--t-sub);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tui-line.is-me {
	color: var(--t-ink);
}

.tui-line.is-off {
	color: var(--t-dim);
}

/* ============================================================== 状态弹窗
   房间相关的状态（正在创建、正在加入、房间不存在…）一律走这一层。
   极简：纯黑背景 + 一个白色直角框 + 白字，和 TUI 同一套黑白语言，
   没有灰色卡片、没有阴影、没有圆角、没有渐变。两种形态：
     - 阻断型：没有按钮，盖住整屏，防止用户在过程中点别的；
     - 提示型：一个"确定"，点掉才继续。
   挂在 #ui 里面，所以 --u 和竖屏旋转都跟着走。 */
.net-modal {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	display: none;
	align-items: center;
	justify-content: center;
	background: #000;
	z-index: 60;
	pointer-events: auto;
	font-family: var(--font);
}

.net-modal.is-on {
	display: flex;
}

.net-modal .box {
	min-width: calc(var(--u) * 104);
	max-width: calc(var(--u) * 132);
	padding: calc(var(--u) * 8) calc(var(--u) * 9);
	background: #000;
	border: max(2px, calc(var(--u) * 0.7)) solid #fff;
	text-align: center;
	box-sizing: border-box;
}

.net-modal .title {
	font-size: calc(var(--u) * 6);
	line-height: calc(var(--u) * 8);
	color: #fff;
	margin-bottom: calc(var(--u) * 4);
}

.net-modal .msg {
	font-size: calc(var(--u) * 6);
	line-height: calc(var(--u) * 8);
	color: #fff;
	white-space: pre-wrap;
	word-break: break-word;
}

/* 阻断型：白色方块在黑轨道里跑，只表示"还在跑"，没有呼吸、没有渐变 */
.net-modal .pulse {
	height: calc(var(--u) * 2);
	margin: calc(var(--u) * 7) auto 0;
	width: calc(var(--u) * 46);
	background: #000;
	border: 1px solid #fff;
	overflow: hidden;
	position: relative;
}

.net-modal .pulse::after {
	content: "";
	position: absolute;
	left: -25%;
	top: 0;
	width: 25%;
	height: 100%;
	background: #fff;
	animation: net-modal-run 1.1s linear infinite;
}

@keyframes net-modal-run {
	from { left: -25%; }
	to { left: 100%; }
}

.net-modal .ok {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: calc(var(--u) * 7);
	min-width: calc(var(--u) * 52);
	height: calc(var(--u) * 11);
	padding: 0 calc(var(--u) * 6);
	border: max(2px, calc(var(--u) * 0.7)) solid #fff;
	background: #000;
	font-size: calc(var(--u) * 6);
	color: #fff;
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.net-modal .ok:active {
	background: #fff;
	color: #000;
}

/* ---------------------------------------------------------------- 死亡遮罩
   客人本地不 tick，死了只表现为"定住+血条清零"。盖一层黑底白字说明情况，
   倒计时由快照里的 rs 字段驱动，复活即撤。 */
.net-dead {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	padding: calc(var(--u) * 10) calc(var(--u) * 16);
	background: rgba(0, 0, 0, 0.82);
	border: max(2px, calc(var(--u) * 0.7)) solid #fff;
	color: #fff;
	font: 700 calc(var(--u) * 9) / 1 var(--font);
	letter-spacing: 1px;
	pointer-events: none;
	z-index: 41;
	text-align: center;
	white-space: nowrap;
}

/* ---------------------------------------------------------------- 轻提示
   底部居中叠放的公告条：谁死了/谁加入了/存档导入导出结果。自动消失，
   pointer-events: none 不挡任何操作。 */
.ui-toasts {
	position: absolute;
	left: 50%;
	bottom: calc(var(--u) * 14);
	transform: translateX(-50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: calc(var(--u) * 2);
	pointer-events: none;
	z-index: 42;
	width: max-content;
	max-width: 90%;
}
.ui-toast {
	padding: calc(var(--u) * 3) calc(var(--u) * 8);
	background: rgba(0, 0, 0, 0.8);
	border: max(2px, calc(var(--u) * 0.5)) solid #fff;
	color: #fff;
	font: 600 calc(var(--u) * 6) / 1.3 var(--font);
	text-align: center;
	white-space: nowrap;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	opacity: 1;
	transition: opacity 0.4s ease;
}
.ui-toast.is-out {
	opacity: 0;
}

/* ---------------------------------------------------------------- 确认弹窗双按钮
   UI.confirm 用的确认/取消并排。.ok 原样式带 margin-top，排里归零。 */
.net-modal .btn-row {
	display: flex;
	gap: calc(var(--u) * 5);
	margin-top: calc(var(--u) * 7);
	justify-content: center;
}
.net-modal .btn-row .ok {
	margin-top: 0;
	min-width: calc(var(--u) * 40);
}

/* ---------------------------------------------------------------- 文档弹窗
   关于游戏 / 更新日志 / 版本公告共用 UI.documentModal：白框里一段可滚动正文
   + 底部关闭按钮。更新日志多一排版本切换 chip。外观和状态弹窗完全一致。 */
.net-modal .doc-box {
	min-width: calc(var(--u) * 100);
	max-width: min(calc(var(--u) * 210), 82vw);
}
.net-modal .doc-body {
	max-height: calc(var(--u) * 78);
	font-family: var(--font);
	font-size: calc(var(--u) * 6);
	line-height: calc(var(--u) * 8);
	color: #fff;
	text-align: left;
	white-space: pre-wrap;
	overflow-wrap: break-word;
	overflow-y: auto;
	pointer-events: auto;
	touch-action: none;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: auto;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}
.net-modal .doc-body::-webkit-scrollbar { width: calc(var(--u) * 3); }
.net-modal .doc-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.45); }
.net-modal .doc-chips {
	display: flex;
	gap: calc(var(--u) * 5);
	justify-content: center;
	margin-top: calc(var(--u) * 6);
}
.net-modal .doc-chip {
	min-width: calc(var(--u) * 30);
	padding: 0 calc(var(--u) * 5);
	height: calc(var(--u) * 11);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: max(2px, calc(var(--u) * 0.7)) solid #fff;
	background: #000;
	font-size: calc(var(--u) * 6);
	color: #fff;
	cursor: pointer;
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
.net-modal .doc-chip.is-on { background: #fff; color: #000; }
.net-modal .doc-chip:active { background: #fff; color: #000; }

/* 主菜单左下角的业务版本号 */
.title-version {
	position: absolute;
	font-family: var(--font);
	font-size: calc(var(--u) * 5);
	line-height: calc(var(--u) * 8);
	color: var(--c-ink);
	opacity: 0.65;
	white-space: nowrap;
	pointer-events: none;
}

/* ---------------------------------------------------------------- 面板右上角关闭键
   背包/合成/箱子的 ✕。是 .win 的子元素，absolute 跟着面板边框走，绝不超界。
   语义是「关闭」，与左上角的 ←「返回」区分。 */
.win-close {
	position: absolute;
	right: calc(var(--u) * 2);
	top: calc(var(--u) * 1);
	width: calc(var(--u) * 10);
	height: calc(var(--u) * 10);
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font);
	font-size: calc(var(--u) * 8);
	color: var(--c-ink);
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	z-index: 3;
}
.win-close:active {
	color: var(--c-dim);
}

/* ---------------------------------------------------------------- 自绘文本输入框
   真框 + 透明 <input> 覆盖：显示走自绘层，键盘/输入法走原生，两不耽误。
   input 字号 ≥16px，避开 iOS 聚焦自动放大。 */
.tui-inputbox {
	position: absolute;
	background: #000;
	border: max(2px, calc(var(--u) * 0.7)) solid #fff;
	box-sizing: border-box;
}
.tui-inputbox.is-focus {
	border-color: var(--c-ink);
	box-shadow: 0 0 0 max(1px, calc(var(--u) * 0.34)) rgba(255, 255, 255, 0.35);
}
.tui-inputtext {
	position: absolute;
	left: calc(var(--u) * 3);
	top: 0;
	right: calc(var(--u) * 3);
	bottom: 0;
	display: flex;
	align-items: center;
	font-family: var(--font);
	font-size: calc(var(--u) * 7);
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
}
.tui-inputtext:empty::before {
	content: attr(data-ph);
	color: #777;
}
.tui-inputbox.is-focus .tui-inputtext:not(:empty)::after {
	content: "_";
	margin-left: calc(var(--u) * 1);
	animation: tui-cursor 1s steps(1) infinite;
}
@keyframes tui-cursor {
	50% {
		opacity: 0;
	}
}
.tui-inputreal {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	border: 0;
	padding: 0;
	margin: 0;
	background: transparent;
	color: transparent;
	caret-color: transparent;
	font-size: 16px;
	z-index: 2;
}

/* ---------------------------------------------------------------- 存档列表滚动容器
   存档不限 5 个：列表区超出高度自己滚，触摸拖动/滚轮都行，滚动条藏掉。 */
.tui-scrollrows {
	position: absolute;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}
.tui-scrollrows::-webkit-scrollbar {
	display: none;
}

/* ---------------------------------------------------------------- 输入框可点击
   .screen 是 pointer-events:none 的，框不带 auto 的话点不到透明 input ——
   这就是"点输入框呼不出键盘"的根因。 */
.tui-inputbox {
	pointer-events: auto;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------- 进度条弹窗
   UI.progress：导入/导出大文件时的可见进展。
   填充用 transform: scaleX 而不是 width：width 每帧改会触发布局，配上
   transition 还会被反复重置 —— 真机上看着就是"条不动、只有数字在跳"。
   scaleX 走合成层，逐帧更新也跟得上。 */
.net-modal .progress {
	width: 70%;
	height: calc(var(--u) * 6);
	margin: calc(var(--u) * 7) auto 0;
	border: max(2px, calc(var(--u) * 0.7)) solid #fff;
	background: #000;
	overflow: hidden;
}
.net-modal .progress-bar {
	height: 100%;
	width: 100%;
	background: #fff;
	transform: scaleX(0);
	transform-origin: left center;
	will-change: transform;
}

/* 进度条下面的一行小字：坑位提示 / 兜底说明。
   比正文小一号，不抢主信息的注意力。 */
.net-modal .note {
	margin-top: calc(var(--u) * 5);
	font-size: calc(var(--u) * 5);
	line-height: calc(var(--u) * 7);
	color: var(--t-sub);
	white-space: pre-wrap;
	word-break: break-word;
}
