/* 自由摆放：每个模块各有大小 / 透明度（JS 把 --blk-k、--blk-a 写在模块自己身上）；沉浸模式。
   选择器故意写得很重：hud.css / v117u.css 里这些元素的 scale 是带 !important 的。 */
html body #hud-tl[data-ui="date"]      { transform-origin: 50% 50% !important; scale: calc(var(--hud-scale, 1) * var(--ui-k, 1) * var(--blk-k, 1)) !important; }
html body #hotbar-wrap[data-ui="hotbar"] { left: 0 !important; right: 0 !important; margin-left: auto !important; margin-right: auto !important; width: max-content !important; transform: none !important; transform-origin: 50% 50% !important; scale: calc(var(--hud-scale, 1) * var(--ui-k, 1) * var(--blk-k, 1)) !important; }
html body #hud #hud-tr#hud-tr[data-ui="map"][class] { transform-origin: 50% 50% !important; scale: calc(var(--hud-scale, 1) * var(--blk-k, 1)) !important; }
/* 扑、互动默认比原来大 20%（滑条上仍显示 100%）；放大后互动往里收一点、扑往旁边让一点，免得出屏、互相压住 */
html body #touch-btns > .tbtn[data-ui] { scale: calc(var(--blk-k, 1) * 1.2); transform-origin: center; }
html body #touch-btns > .tbtn.big[data-ui] { margin-right: 10px; margin-bottom: 10px; }
html body #touch-btns > .tbtn.small[data-ui] { margin-right: 20px; margin-bottom: 4px; }
html body.lefty #touch-btns > .tbtn.big[data-ui] { margin-right: 0; margin-left: 10px; }
html body.lefty #touch-btns > .tbtn.small[data-ui] { margin-right: 0; margin-left: 20px; }
html body #soil182[data-ui], html body #fert-card[data-ui] { scale: var(--blk-k, 1); transform-origin: 50% 50%; }
/* 透明度：整体不透明度 × 单个模块的不透明度。触屏按键的整体不透明度原来写在容器上，现在容器不再是模块，直接用单个的 */
html body .ui-blk[data-ui] { opacity: max(.3, calc(var(--hud-alpha, 1) * var(--blk-a, 1))); }   /* 两个透明度叠起来也不低于 30% */
html body #touch-btns > .tbtn[data-ui] { opacity: min(max(.3, calc(var(--hud-alpha, 1) * var(--blk-a, 1))), .96); }   /* 默认 96%（和以前一样），最低正好 30% */

/* 编辑模式里摇杆圈也要摆出来（平时只有触屏模式才有） */
body.ui-edit #stick-base { display: block !important; }
body.ui-edit #stick-zone { display: none !important; }

/* 摆放时的小条：半透明、窄、可拖、可收起，只管当前选中的模块；缩放主要靠双指捏合 */
html body #ui-edit .bar.ue-chip { position: absolute; z-index: 3; left: 0; top: 6px; transform: none; display: block; width: 214px; max-width: 70vw; box-sizing: border-box; padding: 4px 8px 6px; gap: 0;
  background: rgba(237, 231, 213, .86); border: 1.5px solid rgba(44, 51, 49, .85); border-radius: 3px; box-shadow: 0 3px 8px rgba(18, 26, 22, .3); color: #2a2620; font-size: 12px; touch-action: none; }
#ui-edit .ue-chip .ue-hd { display: flex; align-items: center; gap: 6px; height: 26px; cursor: grab; touch-action: none; }
#ui-edit .ue-chip .ue-grip { flex: none; width: 18px; height: 12px; border-top: 2px solid #6b5a42; border-bottom: 2px solid #6b5a42; box-sizing: border-box; position: relative; }
#ui-edit .ue-chip .ue-grip::after { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 2px; background: #6b5a42; }
#ui-edit .ue-chip .ue-name { flex: 1; min-width: 0; font-size: 14px; letter-spacing: 1px; color: #a8392b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
#ui-edit .ue-chip button { min-height: 26px; padding: 0 9px; font: inherit; font-size: 12px; letter-spacing: 1px; background: rgba(246, 239, 220, .9); border: 1.5px solid #6b5a42; border-radius: 2px; color: #2a2620; }
#ui-edit .ue-chip .ue-hd button { background-image: none; padding: 0 8px; }
#ui-edit .ue-chip label { display: flex; align-items: center; gap: 5px; height: 26px; }
#ui-edit .ue-chip label input[type=range] { flex: 1; min-width: 0; width: auto; }
#ui-edit .ue-chip label span { flex: none; min-width: 2.9em; text-align: right; color: #4a4032; font-variant-numeric: tabular-nums; }
#ui-edit .ue-chip .ue-tip { white-space: normal; margin: 1px 0 3px; font-size: 11px; line-height: 1.35; color: #6b6250; }
#ui-edit .ue-chip .ue-ft { display: flex; gap: 6px; }
#ui-edit .ue-chip .ue-ft button { flex: 1; padding: 0 4px; }
html body #ui-edit .ue-chip .ue-hd .ue-done { background: #a8392b; border-color: #3a3226; color: #f6efdc; letter-spacing: 2px; }
#ui-edit .ue-chip.min .ue-bd { display: none; }
#ui-edit .ue-chip.min { width: 190px; }
#ui-edit .h.sel { border-style: solid; border-color: #fff4cf; background: rgba(168, 57, 43, .30); }
/* 编辑时背景暗幕再淡一点，免得把游戏画面盖黑 */
html body #ui-edit { background: rgba(12, 16, 15, .16); }

/* ============ 沉浸模式：主界面全隐藏，只留右上角设置键 ============
   用 visibility / opacity 藏，不用 display:none —— 镜头会读快捷栏的位置，布局框还得在；
   摇杆、扑、互动只是看不见（opacity:0），位置和触控区原样保留，照常能用。 */
body.immersive #hud-tl, body.immersive #hotbar-wrap, body.immersive #sb29, body.immersive #soil182, body.immersive #fert-card,
body.immersive #hs-coop-status, body.immersive #hs-furn-quick, body.immersive #t27-btn { visibility: hidden !important; pointer-events: none !important; }
body.immersive #hud #hud-tr#hud-tr[data-ui][class] { visibility: hidden !important; translate: none !important; scale: 1 !important; opacity: 1 !important; }
/* 沉浸模式的设置键：独立按钮，固定在屏幕右上角，层级压过游戏界面；平时不显示 */
#imm-gear32 { display: none; }
body.immersive #imm-gear32 { display: grid !important; place-items: center; position: fixed; top: calc(8px + var(--android-safe-top, 0px)); right: calc(10px + var(--android-safe-right, 0px)); width: 44px; height: 44px; padding: 0; z-index: 9000; visibility: visible !important; opacity: 1 !important; pointer-events: auto !important; touch-action: manipulation;
  color: #2f2a20; background: #f4ecd6; border: 2px solid #3a3226; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 2px 5px rgba(20,16,8,.45); cursor: pointer; }
body.immersive #imm-gear32:active { background: #e8dcc0; transform: translateY(1px); }
body.immersive.ui-edit #imm-gear32, body.immersive.imm-panel32 #imm-gear32 { display: none !important; }
body.immersive #touch-btns > .tbtn { opacity: 0 !important; }
body.immersive #stick-base, body.immersive #stick-knob { opacity: 0 !important; }
/* 在摆放界面里不要沉浸（要看得见才能摆） */
body.immersive.ui-edit #hud-tl, body.immersive.ui-edit #hotbar-wrap, body.immersive.ui-edit #soil182, body.immersive.ui-edit #fert-card { visibility: visible !important; }
body.immersive.ui-edit #hud #hud-tr#hud-tr[data-ui][class] { visibility: visible !important; }
body.immersive.ui-edit #touch-btns > .tbtn { opacity: min(max(.3, calc(var(--hud-alpha, 1) * var(--blk-a, 1))), .96) !important; }
body.immersive.ui-edit #stick-base { opacity: .75 !important; }
