:root {
  /* SCREEN LAYERS while playing, bottom to top. A tap goes to the TOP layer that wants it: the HUD lets taps through
     (pointer-events: none) except its own controls (chat box, future menus/shops: give them .hud-ui), then the touch
     layer (buttons, then the move stick / look drag anywhere else), then the 3D view. Dialogs sit above everything. */
  --z-touch: 3; --z-hud: 4; --z-pause: 5; --z-dialog: 30;
  --bg: #0b0d12; --panel: #12151c; --panel-2: #171b23; --raise: #1d222c; --line: rgba(255, 255, 255, 0.07); --line-2: rgba(255, 255, 255, 0.12);
  --text: #e6e9ef; --muted: #8a92a2; --faint: #5c6473; --accent: #4cc2ff; --accent-dim: rgba(76, 194, 255, 0.14); --accent-2: #8b7bff;
  --good: #3ddc97; --danger: #ff6b6b; --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
svg { display: block; }

/* ---------- layout ---------- */
#app { position: fixed; inset: 0; display: grid; grid-template: 'bar bar bar' 48px 'shelf view side' 1fr / 196px 1fr 300px; }
#bar { grid-area: bar; display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
#shelf { grid-area: shelf; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding-bottom: 14px; }
#view-wrap { grid-area: view; position: relative; min-width: 0; min-height: 0; background: #000; }
#side { grid-area: side; display: grid; grid-template-rows: minmax(140px, 38%) 1fr; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
canvas#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.playing #app { grid-template: 'view' 1fr / 1fr; }
body.playing #bar, body.playing #shelf, body.playing #side { display: none; }

/* ---------- top bar ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.02em; font-size: 14px; white-space: nowrap; }
.brand i { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: inline-block; }
.world-name { color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 14px; border-left: 1px solid var(--line); }
.tools { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.tools button { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 5px 9px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.tools button svg { width: 16px; height: 16px; }
.tools button:hover { color: var(--text); background: var(--raise); }
.tools button.on { color: #071019; background: var(--accent); }
.snaps { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.snaps label { display: flex; align-items: center; gap: 6px; }
select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 7px; padding: 4px 6px; font: 500 12px var(--font); }
.pill { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 7px; padding: 5px 10px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--text); }
.pill:hover { background: var(--raise); }
.hist { display: flex; gap: 2px; }
.hist button { border: 0; background: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.hist button svg { width: 17px; height: 17px; }
.hist button:hover:not(:disabled) { color: var(--text); background: var(--raise); }
.hist button:disabled { opacity: .35; cursor: default; }
.grow { flex: 1; }
.play { display: flex; align-items: center; gap: 7px; border: 0; cursor: pointer; background: var(--good); color: #04140c; font-weight: 800; padding: 7px 16px; border-radius: 8px; font-size: 13px; }
.play svg { width: 13px; height: 13px; }
.play:hover { filter: brightness(1.08); }
.menu-wrap { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 5px; display: none; z-index: 20; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.dropdown.open { display: block; }
.dropdown button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.dropdown button:hover { background: var(--raise); }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }

/* ---------- panels ---------- */
.panel-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 12px 8px; }
.panel-actions button { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 6px; font-size: 11px; padding: 2px 8px; cursor: pointer; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 600; }
.shelf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 10px; }
.shelf-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.shelf-item svg { width: 28px; height: 28px; color: var(--text); }
.shelf-item:hover { border-color: var(--accent); color: var(--text); background: var(--raise); }
.shelf-item.spawn svg { color: var(--good); }
.soon { margin: 16px 10px 0; padding: 10px; border: 1px dashed var(--line-2); border-radius: 9px; }
.soon-title { font-size: 11px; font-weight: 700; color: var(--faint); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .06em; }
.soon-list { display: flex; flex-wrap: wrap; gap: 4px; }
.soon-list span { font-size: 11px; color: var(--faint); background: rgba(255,255,255,.03); padding: 2px 7px; border-radius: 5px; }

#list-panel { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--line); }
.tree { overflow-y: auto; flex: 1; padding: 0 6px 6px; }
.tree-row { display: flex; align-items: center; gap: 5px; height: 26px; border-radius: 6px; cursor: pointer; color: var(--text); white-space: nowrap; user-select: none; }
.tree-row:hover { background: var(--raise); }
.tree-row.sel { background: var(--accent-dim); box-shadow: inset 2px 0 0 var(--accent); }
.tree-row.sel-in { background: rgba(76,194,255,.06); }
.tree-row.drop { outline: 1px dashed var(--accent); }
.tree-row .caret { width: 14px; height: 14px; color: var(--faint); flex: none; transition: transform .12s; }
.tree-row .caret.open { transform: rotate(90deg); }
.tree-row .caret.none { visibility: hidden; }
.tree-row .ico { width: 15px; height: 15px; color: var(--muted); flex: none; }
.tree-row .ico svg { width: 15px; height: 15px; }
.tree-row .name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tree-row .count { font: 500 10.5px var(--mono); color: var(--faint); padding-right: 6px; }
.tree-row .lock { color: var(--faint); width: 13px; height: 13px; margin-right: 6px; }
.tree-row .lock svg { width: 13px; height: 13px; }
.tree-row input.rename { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--accent); color: var(--text); border-radius: 4px; padding: 2px 5px; font: inherit; }
.tree-end { min-height: 40px; }

#props-panel { overflow-y: auto; min-height: 0; }
.props { padding: 4px 12px 20px; }
.props-head { padding: 10px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.props-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.props-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.props-world { float: right; margin-left: 8px; padding: 3px 8px; font: 600 11px var(--font); color: var(--muted); background: var(--raise); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
.props-world:hover { color: var(--accent); border-color: var(--accent); }
.sec { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sec-name { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
.props input[type=text], .props input[type=number] { width: 100%; background: var(--bg); border: 1px solid var(--line-2); color: var(--text); border-radius: 7px; padding: 6px 8px; font: 500 12.5px var(--font); }
.props input[type=number] { font-family: var(--mono); font-size: 11.5px; padding: 5px 4px 5px 18px; -moz-appearance: textfield; }
.props input::-webkit-outer-spin-button, .props input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.props input:focus { outline: none; border-color: var(--accent); }
.vec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.axis { position: relative; }
.axis i { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font: 700 10px var(--font); font-style: normal; pointer-events: none; }
.axis.a0 i { color: #ff6b6b; } .axis.a1 i { color: #3ddc97; } .axis.a2 i { color: #4c9dff; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.prow label { color: var(--muted); }
.prow .ctl { display: flex; align-items: center; gap: 8px; }
.prow output { font: 500 11px var(--mono); min-width: 44px; text-align: right; color: var(--text); }
.props input[type=range] { width: 120px; accent-color: var(--accent); }
.props input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.props input[type=color] { width: 38px; height: 26px; border: 1px solid var(--line-2); border-radius: 6px; background: none; padding: 1px; cursor: pointer; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.seg-btn { flex: 1; border: 0; background: none; border-radius: 5px; padding: 5px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.seg-btn svg { width: 18px; height: 18px; }
.seg.text .seg-btn { font-size: 12px; font-weight: 600; }
.seg-btn:hover { color: var(--text); background: var(--raise); }
.seg-btn.on { background: var(--accent-dim); color: var(--accent); }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 6px; }
.sw { aspect-ratio: 1; border: 1px solid rgba(255,255,255,.12); border-radius: 5px; cursor: pointer; padding: 0; }
.sw:hover { transform: scale(1.1); }
.sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.mats { display: flex; flex-wrap: wrap; gap: 4px; }
.mat { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 6px; padding: 4px 8px; font-size: 11.5px; cursor: pointer; color: var(--muted); }
.mat:hover { color: var(--text); border-color: var(--line-2); background: var(--raise); }
.mat.on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.actions { display: flex; gap: 6px; padding-top: 14px; }
.abtn { flex: 1; border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 7px; padding: 7px 4px; cursor: pointer; font-weight: 600; font-size: 12px; }
.abtn:hover { background: var(--raise); }
.abtn.danger { color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; padding-top: 14px; line-height: 1.5; }

/* ---------- viewport overlays ---------- */
#toast { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(10px); background: rgba(16,19,26,.92); border: 1px solid var(--line-2); padding: 7px 14px; border-radius: 8px; font-weight: 600; opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#view-hint { position: absolute; left: 12px; bottom: 12px; color: rgba(255,255,255,.55); font-size: 11.5px; text-shadow: 0 1px 2px rgba(0,0,0,.8); pointer-events: none; }
body.playing #view-hint, body.playing #toast { display: none; }

/* ---------- play HUD ---------- */
#play-hud { display: none; }
body.playing #play-hud { display: block; }
.glass { background: rgba(16, 19, 26, 0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 12px; }
#hud-top { position: fixed; top: 14px; left: 14px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; pointer-events: none; z-index: 3; }
.mark { font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.mark i { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: inline-block; }
.sep { width: 1px; height: 16px; background: var(--line-2); }
.chip { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--good); background: rgba(61, 220, 151, 0.12); padding: 3px 7px; border-radius: 6px; }
#stats { position: fixed; top: 14px; right: 14px; padding: 8px 12px; font: 500 11.5px/1.55 var(--mono); color: var(--muted); white-space: pre; display: none; pointer-events: none; z-index: 3; }
#stats b { color: var(--text); font-weight: 500; }
#cross { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; z-index: 3; }
#cross::before, #cross::after { content: ''; position: absolute; background: #fff; box-shadow: 0 0 2px rgba(0,0,0,.8); }
#cross::before { left: 10px; top: 4px; width: 2px; height: 14px; } #cross::after { top: 10px; left: 4px; height: 2px; width: 14px; }
#cross.on { opacity: .85; }
#keys { position: fixed; left: 14px; bottom: 14px; padding: 10px 12px; font-size: 12px; color: var(--muted); display: grid; grid-template-columns: auto auto; gap: 4px 12px; pointer-events: none; transition: opacity .4s; z-index: 3; }
kbd { font: 600 11px var(--font); color: var(--text); background: rgba(255,255,255,.08); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
#pause { position: fixed; inset: 0; display: none; place-items: center; background: rgba(11,13,18,.6); z-index: var(--z-pause); padding: 16px; }
#pause.on { display: grid; }

/* ---------- cards / dialogs ---------- */
.card { width: min(440px, 100%); padding: 24px; }
.card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.03em; font-weight: 800; }
.card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; line-height: 1.5; }
.btn { width: 100%; border: 0; cursor: pointer; font: 700 14px var(--font); color: #071019; padding: 12px 16px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #6fd3ff); margin-top: 8px; }
.btn.secondary { background: var(--raise); color: var(--text); border: 1px solid var(--line-2); }
.btn:hover { filter: brightness(1.08); }
.dialog-bg { position: fixed; inset: 0; display: none; place-items: center; background: rgba(5,7,10,.6); z-index: var(--z-dialog); padding: 16px; }
.dialog-bg.on { display: grid; }
.dialog-bg .card { background: var(--panel-2); max-height: 86vh; overflow-y: auto; }
.keys-table { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.keys-table b { color: var(--text); font-weight: 600; white-space: nowrap; }
.row2 { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); }
.row2 label { color: var(--muted); }
.row2 input[type=range] { width: 150px; accent-color: var(--accent); }
.row2 output { font: 500 12px var(--mono); min-width: 38px; text-align: right; }

/* ---------- boot ---------- */
#boot { position: fixed; inset: 0; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 14px; z-index: 50; }
body:not(.loading) #boot { display: none; }
.brand.big { font-size: 22px; } .brand.big i { width: 26px; height: 26px; border-radius: 7px; }
#boot-msg { color: var(--muted); }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) { .tools button span { display: none; } .world-name { display: none; } }
@media (max-width: 920px) {
  #app { grid-template-columns: 150px 1fr 250px; }
  .snaps label { font-size: 0; gap: 0; } .snaps label select { font-size: 12px; }
  .brand span { display: none; }
}
@media (max-width: 700px) {
  #app { grid-template: 'bar' 48px 'view' 1fr 'side' 42% / 1fr; }
  #shelf { display: none; } #bar { overflow-x: auto; }
}

/* ---------- saving + world pickers ---------- */
.save-wrap { display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.save-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.save-state.ok::before { background: var(--good); } .save-state.busy::before { background: var(--accent); animation: pulse 1s infinite; }
.save-state.warn::before { background: #ffb547; } .save-state.bad::before { background: var(--danger); }
.save-state a { color: var(--accent); }
@keyframes pulse { 50% { opacity: .3; } }
#save.attn { border-color: var(--accent); color: var(--accent); }
.dialog-bg .card.wide { width: min(860px, 100%); }
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 4px; }
.wcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column; }
.wcard:hover { border-color: var(--accent); }
.wcard .pic { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #1b2230, #252c3a); background-size: cover; background-position: center; display: grid; place-items: center; color: var(--faint); }
.wcard .pic svg { width: 34px; height: 34px; }
.wcard .info { padding: 9px 11px 10px; }
.wcard .wname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard .wsub { color: var(--muted); font-size: 11.5px; margin-top: 2px; line-height: 1.4; }
.wcard .wdel { margin-top: 6px; background: none; border: 0; color: var(--faint); font-size: 11.5px; cursor: pointer; padding: 0; }
.wcard .wdel:hover { color: var(--danger); }
.wcard.current { box-shadow: inset 0 0 0 1px var(--accent); }
.tpl-pic { aspect-ratio: 16 / 9; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .04em; color: rgba(255,255,255,.85); text-transform: uppercase; }
.vlist { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.vrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.vrow span { color: var(--muted); font-size: 12px; }
.vrow button { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-weight: 600; font-size: 12px; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
@media (max-width: 1180px) { .save-state { display: none; } }

/* ---------- game HUD ---------- */
#game-hud { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-hud); font-family: var(--font); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.55); }
#game-hud.hangout .g-health, #game-hud.hangout .g-weapon, #game-hud.hangout .g-cross { display: none; }
.g-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.g-timer { font: 700 18px var(--mono); letter-spacing: .02em; }
.g-timer:empty { display: none; }
.g-scores { display: flex; gap: 8px; }
.g-team { display: flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 8px; background: rgba(12,14,19,.6); border-bottom: 3px solid var(--c); }
.g-team b { font-size: 20px; } .g-team span { font-size: 11px; color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .06em; }
.g-team.mine { box-shadow: 0 0 0 1px var(--c); }
.g-ffa { padding: 5px 12px; border-radius: 8px; background: rgba(12,14,19,.6); font-weight: 700; font-size: 13px; }
.g-feed { position: absolute; top: 64px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.g-feed-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 7px; background: rgba(12,14,19,.62); font-size: 12.5px; transition: opacity .5s; }
.g-feed-row.fade { opacity: 0; }
.g-feed-w { color: rgba(255,255,255,.65); font-size: 11px; }
.g-feed-head { color: #ffd23f; font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.g-cross { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --gap: 6px; }
.g-cross i { position: absolute; background: #fff; box-shadow: 0 0 2px rgba(0,0,0,.9); }
.g-cross i:nth-child(1) { width: 2px; height: 8px; left: -1px; bottom: var(--gap); }
.g-cross i:nth-child(2) { width: 2px; height: 8px; left: -1px; top: var(--gap); }
.g-cross i:nth-child(3) { height: 2px; width: 8px; top: -1px; right: var(--gap); }
.g-cross i:nth-child(4) { height: 2px; width: 8px; top: -1px; left: var(--gap); }
.g-cross b { position: absolute; width: 2px; height: 2px; left: -1px; top: -1px; background: #fff; }
.g-cross.aim i { opacity: .5; }
.g-hit { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%,-50%) rotate(45deg); opacity: 0; }
.g-hit::before, .g-hit::after { content: ''; position: absolute; background: #fff; box-shadow: 0 0 3px rgba(0,0,0,.8); }
.g-hit::before { left: 10px; top: 0; width: 2px; height: 22px; clip-path: polygon(0 0,100% 0,100% 35%,0 35%,0 65%,100% 65%,100% 100%,0 100%); }
.g-hit::after { top: 10px; left: 0; height: 2px; width: 22px; clip-path: polygon(0 0,35% 0,35% 100%,0 100%,0 0,65% 0,100% 0,100% 100%,65% 100%); }
.g-hit.on { opacity: 1; }
.g-hit.head::before, .g-hit.head::after { background: #ffd23f; }
.g-hit.ko::before, .g-hit.ko::after { background: #ff4f6b; }
.g-hit.ko { transform: translate(-50%,-50%) rotate(45deg) scale(1.4); }
.g-dmgdir { position: absolute; left: 50%; top: 50%; }
.g-dir { position: absolute; left: -120px; top: -120px; width: 240px; height: 240px; border-radius: 50%; border-top: 6px solid rgba(255,70,70,.85); animation: dirfade .9s forwards; filter: blur(.5px); }
@keyframes dirfade { to { opacity: 0; } }
.g-scope { position: absolute; inset: 0; display: none; background: radial-gradient(circle at center, transparent 0 34vmin, rgba(0,0,0,.92) 34.4vmin); }
.g-scope::before, .g-scope::after { content: ''; position: absolute; background: rgba(0,0,0,.85); }
.g-scope::before { left: 50%; top: 16vh; bottom: 16vh; width: 1px; } .g-scope::after { top: 50%; left: 20vw; right: 20vw; height: 1px; }
.g-scope.on { display: block; }
.g-health { position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(12,14,19,.62); min-width: 230px; }
.g-hp-num { font: 800 26px var(--font); min-width: 46px; }
.g-hp-bar { flex: 1; height: 8px; border-radius: 5px; background: rgba(255,255,255,.12); overflow: hidden; }
.g-hp-bar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #3ddc97, #6ff0b6); transition: width .15s; }
.g-health.low .g-hp-bar span { background: linear-gradient(90deg, #ff4f6b, #ff8a5b); }
.g-health.low .g-hp-num { color: #ff7a7a; }
.g-health.hurt { animation: hurt .35s; }
@keyframes hurt { 30% { background: rgba(160,30,40,.6); } }
.g-weapon { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.g-ammo { padding: 8px 14px; border-radius: 12px; background: rgba(12,14,19,.62); }
.g-ammo b { font: 800 28px var(--font); } .g-ammo b.empty { color: #ff7a7a; }
.g-ammo span { font: 600 15px var(--font); color: rgba(255,255,255,.65); margin-left: 4px; }
.g-wname { font-weight: 700; font-size: 13px; }
.g-slots { display: flex; gap: 5px; }
.g-slot { display: flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 7px; background: rgba(12,14,19,.5); font-size: 11.5px; color: rgba(255,255,255,.65); border-bottom: 2px solid transparent; }
.g-slot.on { color: #fff; background: rgba(12,14,19,.75); border-bottom-color: var(--c); }
.g-slot kbd { font-size: 10px; padding: 0 4px; }
.g-reload { width: 120px; height: 4px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; display: none; }
.g-reload span { display: block; height: 100%; background: #fff; }
.g-toast { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 7px 14px; border-radius: 9px; background: rgba(12,14,19,.7); font-weight: 600; opacity: 0; transition: opacity .2s; }
.g-toast.on { opacity: 1; }
.g-banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font: 800 28px var(--font); letter-spacing: -.02em; opacity: 0; transition: opacity .3s; white-space: nowrap; }
.g-banner.on { opacity: 1; }
.g-dead { position: absolute; inset: 0; display: none; place-content: center; text-align: center; background: radial-gradient(ellipse at center, rgba(10,12,18,.2), rgba(10,12,18,.65)); }
.g-dead.on { display: grid; }
.g-dead-title { font: 800 34px var(--font); letter-spacing: -.02em; }
.g-dead-sub { font-size: 15px; color: rgba(255,255,255,.8); margin-top: 6px; }
.g-round, .g-board { position: absolute; inset: 0; display: none; place-items: center; background: rgba(8,10,14,.55); }
.g-round.on, .g-board.on { display: grid; }
.g-round-card, .g-board-card { min-width: min(520px, 92vw); max-height: 80vh; overflow: auto; padding: 22px 24px; border-radius: 14px; background: rgba(16,19,26,.94); border: 1px solid rgba(255,255,255,.08); text-shadow: none; }
.g-round-title { font: 800 30px var(--font); letter-spacing: -.02em; text-align: center; }
.g-round-sub { text-align: center; color: var(--muted); margin: 4px 0 16px; }
.g-table { display: flex; flex-direction: column; gap: 14px; }
.g-thead { border-left: 4px solid var(--c); padding-left: 8px; margin-bottom: 4px; }
.g-trow { display: grid; grid-template-columns: 1fr 60px 60px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.g-trow span:not(:first-child) { text-align: right; font-family: var(--mono); }
.g-trow.hdr { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.g-trow.me { background: rgba(76,194,255,.12); }
.g-nums { position: absolute; inset: 0; overflow: hidden; }
.dmgnum { position: absolute; left: 0; top: 0; font: 800 18px var(--font); color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.7); will-change: transform; }
.dmgnum.head { color: #ffd23f; font-size: 22px; } .dmgnum.ko { color: #ff6b8a; }
#room-bar { position: fixed; top: 14px; right: 14px; display: none; align-items: center; gap: 10px; padding: 7px 12px; z-index: 4; font-size: 12.5px; pointer-events: auto; }
body.playing.online #room-bar { display: flex; }
#room-bar b { font: 700 14px var(--mono); letter-spacing: .1em; color: var(--accent); }
#room-bar button { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12px; }
.code-big { font: 800 34px var(--mono); letter-spacing: .18em; color: var(--accent); text-align: center; margin: 6px 0 4px; }
.join-in { width: 100%; font: 700 26px var(--mono); letter-spacing: .2em; text-align: center; text-transform: uppercase; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 9px; padding: 10px; }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: var(--z-touch); display: none; touch-action: none; }
body.playing.touch #touch { display: block; }
body.touch #keys { display: none; }
.t-stick { position: absolute; left: 6vw; bottom: 8vh; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); }
.t-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255,255,255,.35); }
.t-btn { --base: 64px; position: absolute; width: calc(var(--base) * var(--k, 1)); height: calc(var(--base) * var(--k, 1)); border-radius: 50%; background: rgba(12,14,19,.5); border: 1px solid rgba(255,255,255,.3); color: #fff; font: 700 12px var(--font); display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
.t-btn.on { background: rgba(76,194,255,.5); }
.t-fire { --base: 84px; right: 5vw; bottom: 22vh; font-size: 14px; background: rgba(255,80,90,.45); }
.t-aim { right: calc(5vw + 96px); bottom: 30vh; } .t-jump { right: 5vw; bottom: 8vh; }
.t-crouch { right: calc(5vw + 80px); bottom: 6vh; } .t-reload { --base: 52px; right: calc(5vw + 100px); bottom: 17vh; }
.t-sprint { --base: 56px; left: calc(6vw + 140px); bottom: 10vh; font-size: 10px; } .t-stick.edge { border-color: rgba(76,194,255,.8); box-shadow: 0 0 18px rgba(76,194,255,.45); }
.t-swap { --base: 52px; right: 5vw; bottom: calc(22vh + 96px); } .t-cam { --base: 46px; left: 6vw; top: 12vh; } .t-menu { --base: 46px; left: calc(6vw + 56px); top: 12vh; }
#game-hud .g-health { bottom: 16px; } body.touch #game-hud .g-health { left: 50%; transform: translateX(-50%); bottom: 10px; min-width: 180px; padding: 6px 10px; }
body.touch #game-hud .g-weapon { right: 50%; transform: translateX(50%); bottom: 64px; align-items: center; }
body.touch #game-hud .g-slots { display: none; }

/* ---------- decals + painter ---------- */
.decals { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 6px; }
.decal { aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; background: #0e1116 center / contain no-repeat; image-rendering: pixelated; color: var(--muted); padding: 0; display: grid; place-items: center; }
.decal.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.decal.add svg { width: 18px; height: 18px; }
.decal.none { font-size: 15px; }
.pt-main { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; }
.pt-wrap { position: relative; width: min(384px, 80vw); aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: crosshair; touch-action: none;
  background: repeating-conic-gradient(#20252e 0 25%, #171b22 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line-2); }
.pt-canvas, .pt-grid { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.pt-grid { pointer-events: none; }
.pt-side { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }
.pt-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pt-tool, .pt-size { border: 1px solid var(--line-2); background: var(--panel); border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.pt-tool.on, .pt-size.on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.pt-pal { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.pt-sw { aspect-ratio: 1; border: 1px solid rgba(255,255,255,.15); border-radius: 5px; cursor: pointer; padding: 0; }
.pt-sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.pt-label { color: var(--muted); font-size: 12px; }
.pt-side input[type=color] { width: 44px; height: 28px; border: 1px solid var(--line-2); border-radius: 6px; background: none; padding: 1px; }

.g-console { position: absolute; left: 16px; bottom: 86px; width: min(520px, 60vw); display: flex; flex-direction: column; gap: 3px; font: 500 12px var(--mono); text-shadow: none; }
.g-con-row { padding: 4px 9px; border-radius: 6px; background: rgba(10,12,16,.78); color: #d7dbe2; transition: opacity .5s; white-space: pre-wrap; word-break: break-word; }
.g-con-row.err { color: #ffb3b3; border-left: 3px solid #ff5a5a; } .g-con-row.warn { color: #ffd9a0; } .g-con-row.info { color: #9fd8ff; }
.g-con-row.fade { opacity: 0; }

/* ---------- script editor ---------- */
.dialog-bg .card.script-card { width: min(1100px, 100%); }
.script-head { display: flex; align-items: center; gap: 12px; }
.script-main { display: flex; gap: 14px; height: min(62vh, 620px); margin-bottom: 12px; }
.script-btns { display: flex; gap: 8px; } .script-btns .btn { width: auto; flex: 1; margin-top: 0; }
.code { position: relative; flex: 1; display: flex; background: #0c0f14; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; font: 13px/20px var(--mono); }
.code-lines { width: 42px; padding: 10px 8px 10px 0; text-align: right; color: #4a5260; background: #0a0d11; overflow: hidden; user-select: none; flex: none; }
.code-body { position: relative; flex: 1; overflow: hidden; }
.code-hl, .code textarea { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font: inherit; white-space: pre; tab-size: 4; overflow: auto; }
.code-hl { color: #d6dbe4; pointer-events: none; }
.code textarea { color: transparent; caret-color: #fff; background: transparent; border: 0; outline: none; resize: none; }
.code textarea::selection { background: rgba(76,194,255,.3); color: transparent; }
.c-kw { color: #c792ea; } .c-str { color: #c3e88d; } .c-com { color: #5f6b7d; font-style: italic; } .c-num { color: #f78c6c; } .c-dec { color: #82aaff; } .c-bi { color: #4cc2ff; }
.code-pop { position: absolute; display: none; z-index: 5; width: 270px; max-height: 220px; overflow-y: auto; background: #161a22; border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); font-family: var(--font); }
.code-pop.on { display: block; }
.code-pop div { padding: 5px 9px; cursor: pointer; display: flex; flex-direction: column; }
.code-pop div b { font: 600 12px var(--mono); color: #e6e9ef; } .code-pop div span { font-size: 11px; color: var(--muted); }
.code-pop div.on { background: var(--accent-dim); }
.ex-side { width: 250px; flex: none; display: flex; flex-direction: column; min-height: 0; }
.ex-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ex { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.ex:hover { border-color: var(--accent); } .ex b { font-size: 12.5px; } .ex span { font-size: 11.5px; color: var(--muted); }
.script-btn { width: 100%; flex: none; }
.py-tag { font: 700 9.5px var(--mono); color: #c792ea; background: rgba(199,146,234,.12); padding: 1px 5px; border-radius: 4px; margin-right: 6px; }
@media (max-width: 800px) { .script-main { flex-direction: column; height: auto; } .code { height: 50vh; flex: none; } .ex-side { width: auto; max-height: 30vh; } }

/* ---------- the Guide ---------- */
#guide { position: fixed; top: 48px; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--panel); border-left: 1px solid var(--line-2); z-index: 15;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease; box-shadow: -16px 0 40px rgba(0,0,0,.35); }
body.guide-open #guide { transform: none; }
body.playing #guide { display: none; }
#guide-btn { border-color: rgba(76,194,255,.35); }
body.guide-open #guide-btn { background: var(--accent-dim); color: var(--accent); }
.gd-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.gd-head button { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 7px; width: 32px; cursor: pointer; font-size: 16px; color: var(--text); }
.gd-search { flex: 1; background: var(--bg); border: 1px solid var(--line-2); border-radius: 7px; color: var(--text); padding: 6px 10px; font: 500 13px var(--font); }
.gd-body { overflow-y: auto; padding: 6px 18px 30px; font-size: 13.5px; line-height: 1.6; color: #cfd4dd; }
.gd-body h2 { color: var(--text); font-size: 20px; letter-spacing: -.02em; margin: 14px 0 8px; }
.gd-body h3 { color: var(--text); font-size: 14px; margin: 18px 0 6px; }
.gd-body p, .gd-body li { margin: 6px 0; } .gd-body ol, .gd-body ul { padding-left: 20px; }
.gd-body b { color: var(--text); }
.gd-body a { color: var(--accent); cursor: pointer; text-decoration: none; } .gd-body a:hover { text-decoration: underline; }
.gd-body code { font: 500 12px var(--mono); background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; color: #e6e9ef; }
.gd-body pre { position: relative; background: #0c0f14; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; font: 12.5px/19px var(--mono); overflow-x: auto; color: #d6dbe4; white-space: pre; }
.gd-body pre.out { color: #ffb3b3; white-space: pre-wrap; }
.gd-copy { position: absolute; top: 6px; right: 6px; font: 600 11px var(--font); background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 8px; cursor: pointer; }
.gd-body table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
.gd-body td, .gd-body th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.gd-body th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.gd-body kbd { font-size: 10.5px; }
.g-tip { background: var(--accent-dim); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 6px; margin: 12px 0; color: var(--text); }
.gd-lead { color: var(--muted); }
.gd-sec { margin: 14px 0; } .gd-sec-name { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 12px 0 6px; }
.gd-link { display: block; padding: 7px 10px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 5px; color: var(--text) !important; }
.gd-link:hover { border-color: var(--accent); text-decoration: none !important; }
.gd-next { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line); }
.gd-body .btn { width: auto; padding: 9px 18px; }

/* ---------- tour ---------- */
.tour { position: fixed; inset: 0; z-index: 60; }
.tour-hole { position: absolute; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(5,7,10,.66); border: 2px solid var(--accent); transition: all .25s ease; pointer-events: none; }
.tour-card { position: absolute; width: 320px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 16px 18px; box-shadow: 0 16px 50px rgba(0,0,0,.5); transition: left .25s, top .25s; }
.tour-step { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.tour-card h3 { margin: 4px 0 6px; font-size: 16px; } .tour-card p { margin: 0 0 12px; color: #cfd4dd; font-size: 13px; line-height: 1.5; }
.tour-btns { display: flex; gap: 8px; justify-content: flex-end; } .tour-btns .btn { width: auto; margin: 0; padding: 8px 16px; }
.tour-skip { background: none; border: 0; color: var(--muted); cursor: pointer; }
.sw.natural { box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); position: relative; }
.sw.natural::after { content: 'Real'; position: absolute; inset: 0; display: grid; place-items: center; font: 700 7px var(--font); color: #333; letter-spacing: .02em; }

/* ---------- uploads + library (Phase 4) */
.sub-label { color: var(--faint); font-size: 11px; margin: 9px 0 5px; }
.decal.upl { image-rendering: auto; background-size: cover; font-size: 11px; }
.lib-tabs { margin: 6px 0 10px; }
.lib-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.lib-up { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lib-up select { max-width: 280px; }
.lib-used { color: var(--faint); font-size: 11.5px; margin-left: auto; }
.lib-progress { color: var(--accent); font-size: 12px; min-height: 0; }
.lib-progress:empty { display: none; }
.lib-search { width: 100%; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.lib-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.lib-pic { aspect-ratio: 1; background: #0e1116 center / cover no-repeat; }
.lib-info { padding: 8px 10px 4px; }
.lib-status { font-size: 11px; margin-top: 4px; line-height: 1.35; color: var(--muted); }
.lib-status.good { color: var(--good); } .lib-status.bad { color: var(--danger); } .lib-status.wait { color: #e2c541; }
.lib-btns { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 10px 10px; margin-top: auto; }
.lib-btns .btn { padding: 5px 12px; font-size: 12px; }
.lib-btns .abtn { flex: none; padding: 4px 8px; font-size: 11.5px; text-decoration: none; }
.abtn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- touch screens in the editor (iPad) */
#view-hint-touch { display: none; position: absolute; left: 12px; bottom: 12px; right: 12px; color: rgba(255,255,255,.6); font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.8); pointer-events: none; }
body.touch #view-hint { display: none; } body.touch #view-hint-touch { display: block; }
#sel-bar { display: none; position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); gap: 6px; padding: 6px; border-radius: 12px; background: rgba(18,21,28,.88); border: 1px solid var(--line-2); z-index: 3; }
body.touch.has-sel:not(.playing) #sel-bar { display: flex; }
#sel-bar button { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 9px 14px; font: 600 13px var(--font); cursor: pointer; }
#sel-bar button[data-sel="del"]:active { color: var(--danger); }
/* the world's own buttons (World settings → Controls): a column on the right */
.t-own { position: absolute; right: calc(5vw + 4px); top: 14vh; display: flex; flex-direction: column; gap: 10px; }
.t-own .t-btn { --base: 60px; position: static; font-size: calc(10px * var(--k, 1)); background: rgba(167,123,255,.4); }
#game-hud .g-own { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
#game-hud .g-own div { background: rgba(12,14,19,.55); border: 1px solid rgba(255,255,255,.15); border-radius: 8px; padding: 4px 8px; font: 600 12px var(--font); color: #fff; }
#game-hud .g-own kbd { background: rgba(255,255,255,.15); border-radius: 4px; padding: 0 5px; margin-right: 6px; font: 700 11px var(--mono); }
body.touch #game-hud .g-own { display: none; }
.gd-lang { position: absolute; top: 7px; right: 62px; font: 700 10px var(--font); letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.lang-seg { margin-left: 14px; }

/* ---------- the ✨ Helper chat */
#helper { position: fixed; top: 48px; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--panel); border-left: 1px solid var(--line-2); z-index: 16; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .18s ease; }
body.helper-open #helper { transform: none; }
body.playing #helper { display: none; }
#helper-btn { border-color: rgba(167,123,255,.45); }
body.helper-open #helper-btn { background: rgba(167,123,255,.18); color: #c9b8ff; }
.hp-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.hp-sub { color: var(--muted); font-size: 12px; flex: 1; }
.hp-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.hp-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.hp-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.hp-msg p { margin: 0 0 6px; } .hp-msg p:last-child { margin: 0; } .hp-msg ul { margin: 4px 0; padding-left: 18px; }
.hp-msg.me { align-self: flex-end; background: var(--accent-dim); color: var(--text); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.hp-msg.helper { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.hp-msg code { font: 12px var(--mono); background: rgba(255,255,255,.07); padding: 1px 4px; border-radius: 4px; }
.hp-msg pre, .hp-card pre { position: relative; background: #0c0f14; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font: 12px/18px var(--mono); overflow-x: auto; white-space: pre; margin: 6px 0; color: #d6dbe4; }
.hp-msg a { color: var(--accent); }
.hp-dots::after { content: '…'; animation: pulse 1s infinite; }
.hp-card { align-self: stretch; border: 1px solid rgba(167,123,255,.45); background: rgba(167,123,255,.08); border-radius: 10px; padding: 10px 12px; }
.hp-card-t { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.hp-card-b { display: flex; gap: 8px; } .hp-card-b .btn { padding: 6px 14px; font-size: 12.5px; }
.hp-card-m { color: var(--muted); font-size: 12px; margin-top: 6px; } .hp-card-m:empty { display: none; }
.hp-ask { display: flex; gap: 8px; padding: 10px 14px 6px; border-top: 1px solid var(--line); }
.hp-ask textarea { flex: 1; resize: none; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font: 13px var(--font); }
.hp-note { color: var(--faint); font-size: 10.5px; padding: 0 14px 10px; line-height: 1.4; }
/* ---------- chat while playing */
#game-hud .g-chat { position: absolute; left: 14px; bottom: 120px; width: min(380px, 60vw); pointer-events: none; font: 13px var(--font); }
#game-hud .g-chat.off { display: none; }
.g-chat-line { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9); padding: 2px 0; transition: opacity 1.5s; overflow-wrap: anywhere; }
.g-chat-line.old { opacity: 0; } .g-chat.typing .g-chat-line.old { opacity: .85; }
.g-chat-line.game b { color: #c9b8ff; }
.g-chat-form { display: none; margin-top: 6px; }
#game-hud .hud-ui { pointer-events: auto; }              /* the HUD's own controls take taps (see SCREEN LAYERS) */
.g-chat.typing .g-chat-form { display: block; }
.g-chat-form input { width: 100%; background: rgba(10,12,16,.82); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 8px 10px; font: 13px var(--font); }
.t-chat { --base: 46px; left: calc(6vw + 112px); top: 12vh; font-size: 18px; }
body.touch #game-hud .g-chat { bottom: 48vh; }
details.adv { margin-top: 10px; } details.adv summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 4px 0; }
details.adv .prow label { font-size: 11.5px; line-height: 1.3; }
/* ---------- batch 2026-11-02: world button sizes, bind button, chat above the touch layer, Helper ask box */
.hint.warn { color: #ffcf6b; }
.bind-btn.on { border-color: var(--accent); color: var(--accent); }
.hp-ask { flex-direction: column; align-items: stretch; }
.hp-ask textarea { width: 100%; min-height: 64px; max-height: 160px; resize: vertical; line-height: 1.45; }
.hp-ask .btn { width: auto; align-self: flex-end; margin-top: 0; padding: 7px 18px; font-size: 13px; }
#toast.ask { pointer-events: auto; white-space: normal; max-width: min(560px, 92vw); text-align: center; }
.toast-btn { margin-left: 8px; background: var(--accent); color: #071019; border: 0; border-radius: 6px; padding: 5px 12px; font: 700 12.5px var(--font); cursor: pointer; }
.beh { border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px 8px; margin: 6px 0; background: rgba(255,255,255,.02); }
.beh-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; } .beh-head b { flex: 1; } .beh-head .ico { width: 16px; height: 16px; }
.beh-del { flex: none; padding: 2px 7px; }
.beh-add { width: 100%; margin-top: 6px; }
.hp-card pre.hp-old { border-color: rgba(255,90,90,.5); background: rgba(255,60,60,.08); text-decoration: line-through; text-decoration-color: rgba(255,120,120,.6); }
.hp-card pre.hp-new { border-color: rgba(61,220,151,.5); background: rgba(61,220,151,.08); }
.hp-del { color: #ff8a8a; font-size: 12.5px; margin: 4px 0 6px; }
.ctl-row { align-items: center; padding: 2px 0; } .ctl-row .seg-btn { padding: 3px 0; }
.hp-bug { background: rgba(255,140,66,.12); border: 1px solid rgba(255,140,66,.45); color: #ffb37a; border-radius: 7px; font: 600 11.5px var(--font); padding: 4px 8px; cursor: pointer; white-space: nowrap; }
.hp-bugform textarea { width: 100%; resize: vertical; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font: 13px var(--font); }
