: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 'shelf dock side' var(--bottom, 0px) / var(--left, 196px) minmax(0, 1fr) var(--right, 300px); }
#bar { grid-area: bar; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0;
  /* too many buttons for a phone/iPad? the bar slides sideways with a finger (no visible scrollbar); Play stays pinned on the right */
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; touch-action: pan-x; }
#bar::-webkit-scrollbar { display: none; }
#bar > * { flex: none; }
#bar > .grow { flex: 1 1 0; min-width: 0; }
#bar > .play-wrap { position: sticky; right: 0; z-index: 1; box-shadow: 0 0 0 6px var(--panel), -18px 0 14px -4px var(--panel); }
#shelf { grid-area: shelf; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
#shelf-body { padding-bottom: 14px; }
#view-wrap { grid-area: view; position: relative; min-width: 0; min-height: 0; background: #000; }
#side { grid-area: side; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; min-width: 0; overflow: hidden; }
#dock { grid-area: dock; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); min-height: 0; min-width: 0; overflow: hidden; }
.region.empty { border: 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; }
/* ?play=<pub>: a published game, no editor (app.js play mode) */
body.play-mode #app { grid-template: 'view' 1fr / 1fr; }
body.play-mode #bar, body.play-mode #shelf, body.play-mode #side, body.play-mode #dock, body.play-mode #floats, body.play-mode .col-edge, body.play-mode #stage, body.play-mode #view-hint, body.play-mode #guide, body.play-mode #helper { display: none !important; }
body.play-mode #hud-top .chip { display: none; }
body.play-mode #room-bar { display: none !important; }   /* one shared room per published game: no codes or invites */
.game-card-pic { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: #1b2028; }
body.playing #bar, body.playing #shelf, body.playing #side, body.playing #dock, body.playing #floats, body.playing .col-edge, body.playing #stage { display: none !important; }

/* ---------- 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); }
/* The build tools: a strip in the top-left corner of the 3D view (Build workspace only), so the top bar fits a laptop */
.viewtools { position: absolute; left: 10px; top: 10px; z-index: 3; display: flex; flex-direction: column; gap: 6px; }
body:not([data-ws="build"]) .viewtools, body.playing .viewtools, body.play-mode .viewtools { display: none; }
.vt-grip { height: 12px; border-radius: 6px; cursor: grab; touch-action: none; background: rgba(18,21,28,.9) radial-gradient(circle, var(--faint) 1.2px, transparent 1.6px) center / 7px 6px repeat-x; border: 1px solid var(--line-2); }
.vt-grip:hover, body.dragging-ui .vt-grip { border-color: var(--accent); }
.vt-grip { position: relative; }
.vt-dock { position: absolute; right: 1px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font-size: 11px; line-height: 1; padding: 1px 3px; cursor: pointer; }
.vt-dock:hover { color: var(--accent); }
@media (pointer: coarse) { .vt-dock { font-size: 15px; padding: 2px 5px; } }
/* the build tools in the top bar (docked) */
.tool-wrap { display: none; }
body.tools-docked[data-ws="build"] .tool-wrap { display: block; }
body.tools-docked .viewtools { display: none; }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; }
.tool-btn svg { width: 15px; height: 15px; }
#tool-cur { display: inline-flex; align-items: center; gap: 6px; }
.tool-menu .tools { flex-direction: column; background: none; border: 0; padding: 0; gap: 1px; }
.tool-menu .tools button { display: flex; align-items: center; flex-direction: row; gap: 9px; width: 100%; padding: 8px 10px; font-size: 13px; color: var(--text); }
.tool-menu .tools button span { display: inline !important; }
.tool-menu .tools button svg { width: 17px; height: 17px; }
.tool-snap-title { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 2px 10px; }
.tool-menu .snap-opts { padding: 0 10px; }
.tool-menu .snap-opts label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.tool-menu .pill { display: inline-block; width: auto; min-width: 64px; text-align: center; border: 1px solid var(--line-2); background: var(--panel-2); padding: 5px 12px; }
@media (pointer: coarse) { .vt-grip { height: 20px; } }
.viewtools .tools { flex-direction: column; background: rgba(18,21,28,.9); border-color: var(--line-2); }
.viewtools .tools button, .vt-snap { flex-direction: column; justify-content: center; gap: 2px; width: 56px; padding: 6px 2px 5px; font-size: 10.5px; line-height: 1.15; }
.viewtools .tools button svg, .vt-snap svg { width: 18px; height: 18px; }
.vt-snap { display: flex; align-items: center; border: 1px solid var(--line-2); background: rgba(18,21,28,.9); border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.vt-snap:hover { color: var(--text); }
.vt-snap small { font-size: 9.5px; font-weight: 500; color: var(--faint); white-space: nowrap; }
.snap-menu { min-width: 0; padding: 10px 12px; }
.snap-menu .pill { display: inline-block; width: auto; min-width: 64px; text-align: center; border: 1px solid var(--line-2); background: var(--panel-2); padding: 5px 12px; }
.snap-menu label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
@media (pointer: coarse) { .viewtools .tools button, .vt-snap { width: 60px; padding: 8px 2px 6px; } }
@media (max-width: 700px), (max-height: 560px) { .viewtools .tools button span, .vt-snap span { display: none; } .viewtools .tools button, .vt-snap { width: 44px; } }
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); }
/* Play + ▾ (Play with friends, Join a friend's game) */
.play-wrap { display: flex; align-items: stretch; background: var(--panel); border-radius: 8px; }
.play-wrap #play { border-radius: 8px 0 0 8px; }
.play-more { padding: 7px 9px; border-radius: 0 8px 8px 0; border-left: 1px solid rgba(4,20,12,.28); font-size: 12px; }
.menu-wrap { position: relative; }
/* menus are fixed to the screen (placed by app.js placeMenu) so the sliding bar never clips them; tall menus scroll on short screens */
.dropdown { position: fixed; top: 54px; right: 8px; min-width: 210px; max-width: calc(100vw - 16px); max-height: calc(100vh - 62px); max-height: calc(100dvh - 62px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 5px; display: none; z-index: 28; 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; }
@media (pointer: coarse) { .dropdown button { padding: 11px 12px; font-size: 14px; } }
.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; }

.tree { 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); }
/* the "out of all groups" strip: only while dragging a row */
.tree-end span { display: none; }
#tree.dragging .tree-end { margin: 6px 4px 4px; min-height: 38px; border: 1px dashed var(--line-2); border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
#tree.dragging .tree-end span { display: block; pointer-events: none; }
#tree.dragging .tree-end.drop { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.props-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 10px; font-size: 12px; color: var(--muted); }
.props-group b { color: var(--text); font-weight: 600; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
@media (pointer: coarse) { .props-group .pill { padding: 8px 12px; font-size: 13px; } }
.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 { 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; }
/* folding sections (editor/folds.js): tap a section's name to fold / open it */
.fold-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; margin: -6px 0 2px; cursor: pointer; user-select: none; -webkit-user-select: none; border-radius: 6px; }
.fold-head::after { content: '▾'; font-size: 13px; color: var(--muted); transition: transform .12s; }
.fold-head:hover, .fold-head:focus-visible { color: var(--text); outline: none; }
.sec.folded:not(.fold-hit) { padding: 6px 0; }
.sec.folded:not(.fold-hit) > .fold-head { margin: 0; }
.sec.folded:not(.fold-hit) > .fold-head::after { transform: rotate(-90deg); }
.sec.folded:not(.fold-hit) > :not(.fold-head) { display: none; }
/* a heading INSIDE a section (Game → Cars, Target, Bots...): a sub-heading, not a fold bar */
.sec > .sec-name:not(.fold-head) { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--text); border-top: 1px dashed var(--line); padding-top: 10px; }
.fold-bar { display: flex; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.fold-bar .fold-find { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line-2); color: var(--text); border-radius: 7px; padding: 6px 8px; font: 500 12.5px var(--font); }
.fold-bar .fold-find:focus { outline: none; border-color: var(--accent); }
.fold-bar .fold-all { white-space: nowrap; }
.fold-none { padding: 10px 0; }
.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.wrap { flex-wrap: wrap; }
.seg.wrap .seg-btn { flex: 1 1 30%; white-space: nowrap; }   /* six moods: three per row */
.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: 1500px) { #bar .brand span { display: none; } }
@media (max-width: 1280px) { .world-name { display: none; } }
@media (max-width: 700px) {
  #app { grid-template: 'bar' 48px 'view' 1fr 'dock' var(--bottom, 0px) 'side' 40% / 1fr; }
  #shelf { display: none; }
}

/* ---------- 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-stats { position: absolute; top: 64px; left: 14px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.g-stat { display: flex; gap: 10px; justify-content: space-between; min-width: 110px; padding: 5px 10px; border-radius: 8px; background: rgba(12,14,19,.6); font-size: 13px; }
.g-stat span { color: var(--muted); }
.g-stat b { font-family: var(--mono); }
.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; text-align: center; width: max-content; max-width: calc(100vw - 32px); }
.pause-range { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.pause-range input { width: 140px; } .pause-range output { min-width: 34px; font-family: var(--mono); color: var(--text); }
.pause-range[hidden], #pause-look[hidden] { display: none; }
#pause .btn.small { font-size: 13px; padding: 7px 12px; margin-bottom: 10px; }
.pause-opt { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 12px; font-size: 14px; color: var(--muted); cursor: pointer; }
.pause-opt input { width: 16px; height: 16px; }
.pause-gfx select { font-size: 13px; padding: 3px 6px; max-width: 220px; }
.g-race { position: absolute; left: 50%; top: 58px; transform: translateX(-50%); padding: 4px 14px; border-radius: 9px; background: rgba(12,14,19,.65); font: 700 22px var(--mono); opacity: 0; transition: opacity .2s; pointer-events: none; }
.g-race.on { opacity: 1; } .g-race.ready { color: var(--muted); } .g-race.done { color: #ffd23f; }
.g-rpos { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); padding: 2px 12px; border-radius: 8px; background: rgba(12,14,19,.55); font: 700 16px var(--mono); color: #fff; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
.g-rpos.on { opacity: 1; }
.g-rrec { position: absolute; left: 50%; top: 124px; transform: translateX(-50%); padding: 1px 10px; border-radius: 8px; background: rgba(12,14,19,.45); font: 600 12px var(--mono); color: #ffe27a; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
.g-rrec.on { opacity: 1; }
.g-carhp { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: 160px; height: 8px; border-radius: 6px; background: rgba(12,14,19,.6); overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
.g-carhp.on { opacity: 1; }
.g-carhp i { display: block; height: 100%; width: 100%; background: #3ddc97; transition: width .2s; }
.g-carhp.low i { background: #ff5a4f; }
.g-ritem { position: absolute; right: 18px; top: 170px; display: flex; gap: 8px; align-items: center; padding: 6px 12px 6px 8px; border-radius: 14px; background: rgba(12,14,19,.6); border: 2px solid #ffcc33; color: #fff; opacity: 0; transform: scale(.85); transition: opacity .15s, transform .15s; pointer-events: none; }
.g-ritem.on { opacity: 1; transform: none; }
.g-ritem b { font-size: 30px; line-height: 1; }
.g-ritem span { display: flex; flex-direction: column; font: 700 14px var(--mono); }
.g-ritem small { font: 500 11px var(--mono); opacity: .75; }
.t-btn.t-useitem { background: rgba(255,204,51,.35); border-color: #ffcc33; font-size: 26px; }
.t-useitem { --base: 76px; right: calc(5vw + 96px); bottom: 22vh; }   /* (left of Fire: a race with weapons shows both) */
.g-talk { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px; background: rgba(12,14,19,.82); border: 1px solid rgba(255,255,255,.12); opacity: 0; transition: opacity .25s; pointer-events: none; }
.g-talk.on { opacity: 1; } .g-talk b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #ffd23f; margin-bottom: 4px; } .g-talk span { font-size: 16px; line-height: 1.4; }
.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; }
/* the way out on phones / tablets: a clear "❚❚ Menu" pill in the top-left corner, above the game's HUD and screens */
#touch-top { position: fixed; top: 0; left: 0; z-index: var(--z-hud); display: none; }
body.playing.touch #touch-top { display: block; }
body.playing.touch #hud-top { display: none; }
#touch-top .t-menu { position: fixed; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); width: auto; height: 40px; border-radius: 20px; padding: 0 14px 0 12px;
  display: flex; align-items: center; gap: 8px; background: rgba(12,14,19,.72); border: 1px solid rgba(255,255,255,.4); font: 700 14px var(--font); touch-action: none; }
#touch-top .t-menu b { font-size: 11px; letter-spacing: -1px; }
#touch-top .t-menu.on { background: rgba(76,194,255,.55); }
#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-credit { font-size: 11px; margin-top: 3px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.cr-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.cr-form > label { font-size: 12px; color: var(--muted); }
.cr-more { display: contents; }
.cr-form input[type=text], .cr-form input[type=url] { min-width: 160px; flex: 1 1 160px; }
.cr-form select { max-width: 260px; }
.cr-edit { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.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. --rows (touch.js layoutOwn) = as many as fit
   above Fire / ⇄ / Jump; the rest wrap into more columns to the LEFT (rtl), so they never sit on top of the built-in buttons */
.t-own { position: absolute; right: calc(5vw + 4px); top: 14vh; display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 6), auto);
  direction: rtl; gap: 10px; align-items: start; justify-items: center; }
.t-own .t-btn { --base: 60px; position: static; direction: ltr; 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: the site's universal chat box (/bk/chat.js draws it); here only where it sits + Engine colours */
#game-hud .g-chat { left: 14px; bottom: 120px; width: min(380px, 60vw); --bkc-font: 500 14.5px/1.35 var(--font); --bkc-name: #7fd4ff; --bkc-game: #c9b8ff; --bkc-round: 8px; text-shadow: none; }
body.touch #game-hud .g-chat { bottom: 48vh; --bkc-font: 500 15.5px/1.35 var(--font); }
#game-hud .hud-ui { pointer-events: auto; }              /* the HUD's own controls take taps (see SCREEN LAYERS) */
.t-chat { --base: 46px; left: calc(6vw + 112px); top: 12vh; font-size: 18px; }
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-kinds { display: flex; gap: 6px; margin: 4px 0 8px; }
.hp-kind { flex: 1; min-height: 40px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); border-radius: 8px; font: 600 13px var(--font); cursor: pointer; }
.hp-kind.on { background: rgba(255,140,66,.18); border-color: rgba(255,140,66,.7); color: #ffd0a8; }
.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); }

/* SCREENS made by scripts (game/screens-view.js): title screens, menus, update logs, counters. On the HUD layer;
   only screens that pause (and their buttons) take taps (.hud-ui), so plain text never blocks the game. */
:is(#game-hud, .sd-hud) .g-screens { position: absolute; inset: 0; pointer-events: none; }
:is(#game-hud, .sd-hud) .g-screen { position: absolute; inset: 0; display: flex; padding: 4vh 4vw; pointer-events: none; }
:is(#game-hud, .sd-hud) .g-screen.pausing { pointer-events: auto; }
:is(#game-hud, .sd-hud) .g-screen.dim { background: radial-gradient(ellipse at center, rgba(8,10,14,.55), rgba(8,10,14,.85)); }
:is(#game-hud, .sd-hud) .g-screen.place-center { align-items: center; justify-content: center; }
:is(#game-hud, .sd-hud) .g-screen.place-top { align-items: flex-start; justify-content: center; }
:is(#game-hud, .sd-hud) .g-screen.place-bottom { align-items: flex-end; justify-content: center; padding-bottom: 14vh; }
:is(#game-hud, .sd-hud) .g-screen.place-left { align-items: center; justify-content: flex-start; }
:is(#game-hud, .sd-hud) .g-screen.place-right { align-items: center; justify-content: flex-end; }
:is(#game-hud, .sd-hud) .g-screen.place-top-left { align-items: flex-start; justify-content: flex-start; padding-top: 9vh; }
:is(#game-hud, .sd-hud) .g-screen.place-top-right { align-items: flex-start; justify-content: flex-end; padding-top: 9vh; }
:is(#game-hud, .sd-hud) .g-screen.place-bottom-left { align-items: flex-end; justify-content: flex-start; padding-bottom: 12vh; }
:is(#game-hud, .sd-hud) .g-screen.place-bottom-right { align-items: flex-end; justify-content: flex-end; padding-bottom: 12vh; }
:is(#game-hud, .sd-hud) .g-sc-stack { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: min(720px, 92vw); max-height: 90vh; overflow-y: auto; }
#game-hud .place-top-left .g-sc-stack, #game-hud .place-bottom-left .g-sc-stack, #game-hud .place-left .g-sc-stack { align-items: flex-start; }
#game-hud .place-top-right .g-sc-stack, #game-hud .place-bottom-right .g-sc-stack, #game-hud .place-right .g-sc-stack { align-items: flex-end; }
:is(#game-hud, .sd-hud) .g-sc-stack.free { position: absolute; inset: 0; max-width: none; max-height: none; overflow: visible; }
:is(#game-hud, .sd-hud) .g-sc-text { white-space: pre-wrap; text-align: center; line-height: 1.35; }
:is(#game-hud, .sd-hud) .g-sc-text.sz-small { font: 500 13px var(--font); }
:is(#game-hud, .sd-hud) .g-sc-text.sz-medium { font: 600 17px var(--font); }
:is(#game-hud, .sd-hud) .g-sc-text.sz-big { font: 800 30px var(--font); letter-spacing: -.02em; }
:is(#game-hud, .sd-hud) .g-sc-text.sz-huge { font: 900 clamp(34px, 8vw, 72px) var(--font); letter-spacing: -.03em; }
:is(#game-hud, .sd-hud) .g-sc-btn { pointer-events: auto; cursor: pointer; border: 0; border-radius: 12px; background: #3d7bff; color: #fff; font: 700 17px var(--font);
  padding: 12px 28px; min-width: 200px; box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3); text-shadow: none; transition: transform .08s, filter .15s; touch-action: manipulation; }
:is(#game-hud, .sd-hud) .g-sc-btn:hover { filter: brightness(1.12); }
:is(#game-hud, .sd-hud) .g-sc-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
:is(#game-hud, .sd-hud) .g-sc-btn.sz-small { font-size: 13px; padding: 8px 16px; min-width: 120px; }
:is(#game-hud, .sd-hud) .g-sc-btn.sz-big { font-size: 22px; padding: 16px 36px; min-width: 260px; }
:is(#game-hud, .sd-hud) .g-sc-btn.sz-huge { font-size: 28px; padding: 20px 44px; min-width: 300px; }
:is(#game-hud, .sd-hud) .g-sc-box { width: 100%; min-width: 200px; border-radius: 12px; }
body.touch :is(#game-hud, .sd-hud) .g-sc-btn { min-height: 48px; }
/* backstab: a sharp red flash at the edges of the screen */
#game-hud .g-backstab { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255,40,40,.55)); transition: opacity .5s; }
#game-hud .g-backstab.on { opacity: 1; transition: none; }
#game-hud .g-feed-back { color: #ff5a4f; font-weight: 800; font-size: 11px; letter-spacing: .06em; }

/* ---------- panels + workspaces (editor/layout.js) ---------- */
.ws-tabs { display: flex; align-items: center; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.ws-tabs button { border: 0; background: none; color: var(--muted); font: 600 12.5px var(--font); padding: 5px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; min-height: 30px; }
.ws-tabs button:hover { color: var(--text); background: var(--raise); }
.ws-tabs button.on { color: #071019; background: var(--accent); }
.ws-tabs .ws-link { color: var(--muted); font: 600 12.5px var(--font); padding: 5px 10px; border-radius: 6px; white-space: nowrap; min-height: 30px; display: inline-flex; align-items: center; text-decoration: none; border-left: 1px solid var(--line); margin-left: 2px; }
.ws-tabs .ws-link:hover { color: var(--text); background: var(--raise); }
.ws-tabs .ws-out { opacity: .6; font-size: 11px; }
.ws-tabs .ws-reset { padding: 5px 8px; font-size: 14px; }

@media (max-width: 1180px) { .ws-tabs .ws-name { display: none; } }
.pnl { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.pnl.folded { flex: none !important; }
.pnl-head { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 6px 0 4px; user-select: none; -webkit-user-select: none; flex: none; }
.pnl-title { flex: 1; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pnl-fold, .pnl-pop { flex: none; width: 26px; height: 26px; border: 1px solid transparent; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; font: 700 15px/1 var(--font); padding: 0; }
.pnl-fold:hover, .pnl-pop:hover { color: var(--text); background: var(--raise); border-color: var(--line-2); }
.pnl-actions { display: flex; gap: 4px; }
.pnl-act, .pnl-actions button { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 6px; font-size: 11px; padding: 3px 8px; cursor: pointer; color: var(--text); font-weight: 600; }
.pnl-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.pnl.folded .pnl-body, .pnl-resize { display: none; }
.pnl-split { flex: none; height: 9px; margin: -4px 0; position: relative; z-index: 2; cursor: row-resize; touch-action: none; }
.pnl-split::after { content: ''; position: absolute; left: 40%; right: 40%; top: 3px; height: 3px; border-radius: 2px; background: var(--line-2); opacity: 0; transition: opacity .15s; }
.pnl-split:hover::after, body.dragging-ui .pnl-split::after { opacity: 1; }
.region.all-folded#shelf .pnl-head { flex-direction: column; padding: 6px 0; }
.region.all-folded#shelf .pnl-title { writing-mode: vertical-rl; transform: rotate(180deg); }
.region.all-folded#shelf .pnl-pop { display: none; }
#dock .pnl { flex: 1 1 0; border-bottom: 0; }
#floats { position: fixed; inset: 0; pointer-events: none; z-index: 25; }
.pnl.floating { position: fixed; pointer-events: auto; border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 18px 60px rgba(0,0,0,.55); overflow: hidden; }
.pnl.floating .pnl-head { cursor: grab; background: var(--panel-2); touch-action: none; }
.pnl.floating .pnl-resize { display: block; position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 50%, var(--line-2) 50%, var(--line-2) 60%, transparent 60%, transparent 72%, var(--line-2) 72%, var(--line-2) 82%, transparent 82%); }
.col-edge { position: absolute; z-index: 15; touch-action: none; }
.col-edge.l, .col-edge.r { top: 48px; bottom: 0; width: 12px; cursor: col-resize; }
.col-edge.l { left: calc(var(--left, 196px) - 6px); }
.col-edge.r { right: calc(var(--right, 300px) - 6px); }
.col-edge.b { height: 12px; left: var(--left, 196px); right: var(--right, 300px); bottom: calc(var(--bottom, 0px) - 6px); cursor: row-resize; }
.col-edge:hover, body.dragging-ui .col-edge { background: rgba(76,194,255,.12); }
body.dragging-ui, body.dragging-ui * { user-select: none !important; -webkit-user-select: none !important; }
@media (max-width: 700px) { .col-edge.l, .col-edge.r { display: none !important; } .col-edge.b { left: 0; right: 0; } }

/* ---------- previews (editor/preview.js) ---------- */
.pv { position: relative; width: 100%; height: 100%; min-height: 120px; background: #15181d; overflow: hidden; }
.pv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.pv-dom { position: absolute; inset: 0; display: none; }
.pv.dom .pv-dom { display: block; } .pv.dom .pv-canvas { display: none; }
.pv-label { position: absolute; left: 10px; top: 8px; font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; pointer-events: none; }
.pv-msg { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: var(--muted); font-size: 12px; pointer-events: none; }
#stage { position: absolute; inset: 0; z-index: 2; display: none; background: #15181d; }
#stage.on { display: block; }
.pv-screen { position: absolute; inset: 10%; border: 1px dashed var(--line-2); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at 50% 40%, #27406a, #12151c 70%); }
.pv-card { background: rgba(10,12,18,.9); border: 1px solid var(--line-2); border-radius: 14px; padding: 18px 26px; text-align: center; min-width: 200px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.pv-card-t { font-weight: 800; font-size: 20px; } .pv-card-s { color: var(--muted); margin: 4px 0 12px; }
.pv-card-b { display: inline-block; margin: 0 4px; padding: 7px 18px; border-radius: 8px; background: var(--good); color: #04140c; font-weight: 800; } .pv-card-b.alt { background: var(--accent); color: #071019; }

/* ---------- the Animate workspace (editor/animator.js) ---------- */
.anim-targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.anim-targets .seg-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 48px; }
.anim-targets .tg-i { font-size: 17px; line-height: 1; }
.anim-code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 11px/1.5 var(--mono); color: var(--muted); white-space: pre-wrap; word-break: break-word; margin: 0; }
.tl { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex: none; }
.tl-bar .abtn { flex: none; min-height: 32px; padding: 4px 10px; }
.tl-bar .abtn.on { border-color: var(--accent); color: var(--accent); }
.tl-bar .abtn.rec.on { border-color: #ff6b6b; color: #ff8f8f; }
.tl-bar .tl-play { min-width: 44px; font-size: 15px; }
.tl-time { margin-left: auto; font: 500 12px var(--mono); color: var(--muted); }
.tl-track { position: relative; flex: 1; min-height: 70px; overflow-x: hidden; overflow-y: auto; touch-action: none; cursor: text; user-select: none; -webkit-user-select: none; }
.tl-ruler { position: relative; height: 22px; border-bottom: 1px solid var(--line); }
.tl-tick { position: absolute; bottom: 0; width: 1px; height: 5px; background: var(--line-2); }
.tl-tick.big { height: 10px; background: var(--faint); }
.tl-tick span { position: absolute; bottom: 10px; left: 3px; font: 500 10px var(--mono); color: var(--faint); white-space: nowrap; }
.tl-row { position: relative; height: 24px; border-bottom: 1px solid rgba(255,255,255,.03); }
.tl-row.keys { height: 34px; background: rgba(255,255,255,.02); }
.tl-name { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 10.5px; color: var(--faint); pointer-events: none; white-space: nowrap; }
.tl-key { position: absolute; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 0; background: none; cursor: ew-resize; touch-action: none; padding: 0; }
.tl-key::before { content: ''; position: absolute; left: 6px; top: 6px; width: 13px; height: 13px; transform: rotate(45deg); background: #ffc83d; border: 2px solid #12151c; border-radius: 2px; }
.tl-key.snap::before { background: #ff9f43; } .tl-key.lin::before { background: #8b7bff; }
.tl-key.sel::before { background: #fff; box-shadow: 0 0 0 2px var(--accent); }
.tl-dot { position: absolute; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--accent); opacity: .7; }
.tl-more { padding: 4px 14px; font-size: 11px; color: var(--faint); }
.tl-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff6b6b; pointer-events: none; z-index: 3; }
.tl-head::before { content: ''; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: #ff6b6b; }
:is(#game-hud, .sd-hud) .g-sc-hint { font-size: 10.5px; color: rgba(255,255,255,.6); text-align: center; margin-top: 4px; pointer-events: none; text-shadow: 0 1px 2px #000; }
body.touch :is(#game-hud, .sd-hud) .g-sc-hint { display: none; }

/* the vote for the next map (between rounds) */
.g-vote { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 240px; max-width: 90vw; padding: 12px; background: rgba(15,18,24,.88); border: 1px solid var(--line); border-radius: 12px; pointer-events: auto; }
.g-vote-h { text-align: center; font-weight: 700; color: #fff; }
.g-vote-b { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px 14px; font-size: 16px; font-weight: 600; border-radius: 9px; border: 2px solid transparent; background: var(--raise); color: var(--text); cursor: pointer; }
.g-vote-b.mine { border-color: var(--accent); background: var(--accent-dim); }
.g-vote-b b { min-width: 1.5em; text-align: right; }

/* race HUD (game/racehud.js): minimap top-left under the stats, speedometer bottom-right */
.g-minimap { position: absolute; left: 12px; top: 120px; width: 150px; height: 150px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.g-minimap.on { opacity: .95; }
.g-speedo { position: absolute; right: 18px; bottom: 150px; width: 120px; text-align: center; opacity: 0; transition: opacity .3s; pointer-events: none; color: #fff; }
.g-speedo.on { opacity: 1; }
.g-speedo svg { width: 120px; height: 72px; display: block; }
.g-speedo path { fill: none; stroke-width: 9; stroke-linecap: round; }
.g-speedo .bg { stroke: rgba(12,14,19,.55); }
.g-speedo .fg { stroke: #ffd23f; stroke-dasharray: 0 200; transition: stroke-dasharray .1s; }
.g-speedo b { display: block; margin-top: -40px; font: 800 30px var(--mono); text-shadow: 0 2px 4px #000; }
.g-speedo small { font: 700 11px var(--mono); opacity: .8; }
@media (max-width: 700px) { .g-minimap { width: 110px; height: 110px; top: 96px; } .g-speedo { bottom: 190px; transform: scale(.85); transform-origin: right bottom; } }

/* THE TARGET (game/targets.js): an arrow at the top of the screen pointing to them */
.g-tarrow { position: absolute; left: 50%; top: 128px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 10px; background: rgba(12,14,19,.6); color: #ff6b5f; font: 700 15px var(--mono); opacity: 0; transition: opacity .2s; pointer-events: none; }
.g-tarrow.on { opacity: 1; }
.g-tarrow i { font-style: normal; font-size: 22px; display: inline-block; }
.g-tarrow span { color: #fff; }
/* Library: sounds (editor/library.js) */
.lib-pic.lib-sound { display: flex; align-items: center; justify-content: center; font-size: 30px; position: relative; background: linear-gradient(135deg, #2b3550, #1c2233); }
.lib-play { position: absolute; right: 4px; bottom: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #ffd23f; color: #111; font-weight: 800; cursor: pointer; }

/* ---------- 💻 Code workspace (editor/codespace.js), code gutter marks, the Debugger's stop window ---------- */
.code-lines div { cursor: pointer; position: relative; padding-left: 14px; }
.code-lines div:hover { color: #8a92a2; }
.code-lines div.bp::before { content: ''; position: absolute; left: 3px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.code-lines div.err { color: var(--danger); background: rgba(255,107,107,.12); }
.code-lines div.warn { color: #ffcc66; background: rgba(255,204,102,.10); }
.code-lines div.here { color: #04140c; background: #ffd34d; }
.code-lines { width: 52px; }
.code-sig { position: absolute; left: 52px; right: 0; bottom: 0; display: none; padding: 3px 12px; font: 12px var(--mono); color: #c9d1dc; background: #161a22; border-top: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 4; pointer-events: none; }
.code-sig.on { display: block; }
#stage.code-on { display: flex; }
.cs-center { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 8px 10px 10px; gap: 6px; background: var(--bg); }
.cs-tabs { display: flex; gap: 4px; overflow-x: auto; flex: none; scrollbar-width: thin; }
.cs-tab { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 9px; border-radius: 7px 7px 0 0; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; cursor: pointer; color: var(--muted); white-space: nowrap; font-weight: 600; font-size: 12px; }
.cs-tab.on { background: var(--panel-2); color: var(--text); border-color: var(--line-2); }
.cs-tab-lang { font: 700 10px var(--mono); color: var(--accent); }
.cs-tab-err { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 10.5px; font-weight: 800; }
.cs-tab-x { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 3px; font-size: 14px; line-height: 1; }
.cs-tab-x:hover { color: var(--text); }
.cs-tools { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; }
.cs-tools .abtn { flex: none; padding: 5px 10px; }
.cs-tools .seg { flex: none; }
.abtn.primary { background: var(--good); color: #04140c; border-color: transparent; }
.abtn.small { flex: none; padding: 3px 8px; font-size: 11px; }
.cs-name { font-size: 13px; }
.cs-gap { flex: 1; }
.cs-hint { color: var(--faint); font-size: 11px; }
.cs-ed { flex: 1; display: flex; min-height: 0; }
.cs-ed .code { flex: 1; }
.cs-list { padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cs-row { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: 1px solid transparent; background: none; border-radius: 7px; padding: 6px 8px; cursor: pointer; position: relative; }
.cs-row:hover { background: var(--raise); }
.cs-row.on { background: var(--accent-dim); border-color: rgba(76,194,255,.3); }
.cs-row-name { font-weight: 600; }
.cs-row-meta { font-size: 11px; color: var(--muted); }
.cs-row .cs-tab-err { position: absolute; right: 8px; top: 8px; }
.cs-add { margin-top: 6px; }
.cs-note { color: var(--muted); font-size: 12px; padding: 8px; line-height: 1.45; }
.cs-out { font: 12px/1.5 var(--mono); padding: 4px 0; }
.cs-out-row { display: flex; gap: 10px; padding: 1px 10px; white-space: pre-wrap; word-break: break-word; }
.cs-out-row.link { cursor: pointer; } .cs-out-row.link:hover { background: var(--raise); }
.cs-out-row.err { color: #ff8c8c; } .cs-out-row.warn { color: #ffcc66; } .cs-out-row.info { color: var(--muted); } .cs-out-row.ok { color: var(--good); }
.cs-out-t { color: var(--faint); flex: none; }
.cs-dbg, .cs-ref { padding: 6px 8px 10px; }
.cs-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; margin: 10px 0 4px; }
.cs-bp, .cs-var, .cs-frame { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 12px; min-width: 0; }
.cs-bp a, .cs-frame a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.cs-bp code { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 11px; }
.cs-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.cs-x { border: 0; background: none; color: var(--faint); cursor: pointer; margin-left: auto; font-size: 14px; }
.cs-x:hover { color: var(--danger); }
.cs-var code { color: #9cdcfe; font: 12px var(--mono); flex: none; }
.cs-val { font: 12px var(--mono); color: #e6e9ef; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; margin-left: auto; text-align: right; }
.cs-up { font-size: 10px; color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; }
.cs-frame.top a { font-weight: 700; }
.cs-watch-add { display: flex; gap: 6px; margin-top: 4px; }
.cs-watch-in { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line-2); color: var(--text); border-radius: 7px; padding: 5px 8px; font: 12px var(--mono); }
.cs-ref-top { display: flex; gap: 6px; align-items: center; position: sticky; top: 0; background: var(--panel); padding: 2px 0 6px; z-index: 1; }
.cs-ref-top .seg { flex: none; }
.cs-ref-body h3 { font-size: 13px; margin: 12px 0 2px; }
.cs-ref-body h4 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 8px 0 2px; }
.g-ref { width: 100%; border-collapse: collapse; font-size: 12px; }
.g-ref td { padding: 4px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.g-ref td:first-child { width: 48%; }
.g-ref code { font: 11.5px var(--mono); color: #9cdcfe; word-break: break-word; }
.g-ref-tag { display: inline-block; margin-left: 5px; font-size: 9.5px; color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; }
#dbg-stop { position: fixed; z-index: calc(var(--z-dialog) - 1); right: 16px; top: 64px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 90px); overflow: auto; padding: 12px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dbg-head { font-size: 14px; margin-bottom: 8px; } .dbg-head b { color: #ffd34d; } .dbg-step { color: var(--muted); font-size: 12px; }
.dbg-code { font: 12.5px/20px var(--mono); background: #0c0f14; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 0; overflow-x: auto; white-space: pre; }
.dbg-code div { padding: 0 10px 0 0; } .dbg-code i { display: inline-block; width: 40px; text-align: right; margin-right: 10px; color: #4a5260; font-style: normal; }
.dbg-code div.here { background: rgba(255,211,77,.16); } .dbg-code div.here i { color: #ffd34d; }
.dbg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dbg-note { color: var(--muted); font-size: 11.5px; margin: 8px 0; }
.dbg-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dbg-btns .abtn { flex: none; padding: 6px 12px; }
.dbg-btns .abtn:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) { .dbg-cols { grid-template-columns: 1fr; } .cs-hint { display: none; } }

/* ---------- When → Do rules (panels.js rulesEditor) ---------- */
.rules { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 2px; }
.rule { border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 8px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.rule-head { display: flex; align-items: center; gap: 6px; } .rule-head b { flex: 1; font-size: 12px; }
.rule-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rule-row select, .rule-row input[type=text] { flex: 1 1 120px; min-width: 0; }
.rule-k { font: 800 10px var(--font); letter-spacing: .08em; color: var(--accent); width: 36px; flex: none; }
.rule-pair { display: inline-flex; gap: 4px; align-items: center; flex: 1 1 120px; }
.rule-pair input[type=number] { width: 64px; }
.rule-opts { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--muted); }
.rule-opts input[type=number] { width: 52px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 4px; }
.rules input[type=text], .rule-pair input { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 6px; font: 12px var(--font); }

/* ---------- Screen designer (editor/screendesigner.js) ---------- */
.sd { display: grid; grid-template-columns: 170px minmax(0, 1fr) 280px; gap: 12px; min-height: 0; height: min(62vh, 620px); }
.sd-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.sd-row { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: none; cursor: pointer; }
.sd-row small { color: var(--muted); font-size: 11px; } .sd-row:hover { background: var(--raise); } .sd-row.on { background: var(--accent-dim); border-color: rgba(76,194,255,.3); }
.sd-mid { min-width: 0; display: flex; align-items: center; }
.sd-hud { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #6fb4e8 0%, #a9d5f2 55%, #4f7a3b 55%, #3b5e2c 100%); }
.sd-hud .g-screens { position: absolute; inset: 0; pointer-events: none; }
.sd-hud .g-screen { transform-origin: center; }
.sd-hud .sd-drag { cursor: grab; outline: 1px dashed rgba(255,255,255,.5); outline-offset: 3px; }
.sd-side { overflow: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.sd-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.sd-field > span { font-weight: 600; } .sd-field small { color: var(--faint); font-size: 11px; }
.sd-field input[type=text], .sd-field input[type=number], .sd-field textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 7px; font: 12.5px var(--font); }
.sd-field input[type=checkbox] { align-self: flex-start; }
.sd-item { display: flex; gap: 4px; align-items: center; }
.sd-item-name { flex: 1; text-align: left; border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 6px; padding: 5px 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-item.open .sd-item-name { border-color: var(--accent); }
.sd-item-edit { display: flex; flex-direction: column; gap: 5px; padding: 6px 0 8px 10px; border-left: 2px solid var(--accent-dim); margin: 4px 0 4px 4px; }
.sd-adds, .sd-dupe { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
@media (max-width: 900px) { .sd { grid-template-columns: 1fr; height: auto; } .sd-list { flex-direction: row; flex-wrap: wrap; } }

/* ---------- 👥 Build together (editor/together.js) ---------- */
.tg-btn { display: inline-flex; align-items: center; gap: 6px; }
#bar .tg-btn:not(.shared) { display: none; }
.tg-btn:not(.shared) .tg-bar { display: none; }
.tg-bar { display: inline-flex; gap: 0; }
.tg-bar:not(.on) { display: none; }
.tg-bar.on + .tg-label { display: none; }
.tg-who { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--c, #888); color: #0b0d12; font: 800 9.5px var(--font); border: 2px solid var(--panel); margin-left: -5px; }
.tg-who:first-child { margin-left: 0; }
.tg-who.you { outline: 1.5px solid #fff; }
.tg-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.tg-row b, .tg-row span:not(.tg-who):not(.tg-tag) { flex: 1; }
.tg-row .tg-who { margin-left: 0; }
.tg-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; }
.tg-here { margin: 6px 0 4px; }

/* 🎮 Keys & controller (app.js keysDialog) */
.keys-list { display: grid; gap: 4px; margin: 10px 0 14px; max-height: 52vh; overflow-y: auto; }
.keys-row { display: grid; grid-template-columns: minmax(120px, 1.3fr) 1fr 1fr; gap: 8px; align-items: center; font-size: 14px; }
.keys-row .btn.small { margin: 0; padding: 6px 10px; font-size: 13px; text-align: left; min-height: 32px; }
.keys-row .btn.waiting { outline: 2px solid var(--accent, #7cf); }
.keys-head { font-weight: 700; opacity: .7; font-size: 12px; }
.keys-stick { opacity: .7; font-size: 13px; }
@media (max-width: 520px) { .keys-row { grid-template-columns: 1fr 1fr; } .keys-row > span:first-child { grid-column: 1 / -1; } }

/* ⭐ prefabs (Properties box, World list tag, shelf) */
.props-prefab { margin: 8px 0; padding: 8px 10px; border-radius: 10px; background: rgba(255, 204, 0, .08); border: 1px solid rgba(255, 204, 0, .25); font-size: 13px; }
.props-prefab .muted { opacity: .65; }
.prefab-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.prefab-tag { font-size: 11px; margin-left: 4px; }
.shelf-item.prefab .prefab-star { font-size: 18px; line-height: 1; }
.shelf-hint { font-size: 12px; opacity: .6; padding: 4px 8px 10px; }

/* 🔀 Remix switch (publish dialog) */
.pub-remix { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 8px 0; cursor: pointer; }
.pub-remix input { margin-top: 3px; }
/* ✏️ Describe your game (Publish box) + the maker's words on the game card */
.pub-about-box { margin: 10px 0; }
.pub-about-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-size: 14px; }
.pub-about-left { color: var(--muted); font-size: 12px; }
.pub-about { width: 100%; box-sizing: border-box; resize: vertical; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font: 14px/1.4 var(--font); }
.pub-about-box .btn { margin-top: 6px; }
.game-card-about { font-size: 15px; line-height: 1.45; margin: 4px 0 8px; white-space: pre-line; overflow-wrap: anywhere; }

/* 📚 library scripts (Code workspace) */
.cs-lib { margin: 8px 4px; padding: 8px; border-radius: 8px; background: rgba(255,255,255,.04); }
.cs-lib-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.cs-lib-row { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 3px 0; }
.cs-lib-row span { flex: 1; }
.credits-list { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow: auto; margin: 10px 0; }
.credit-row { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.05); overflow-wrap: anywhere; }
.credit-row .sub { margin-top: 2px; }
.shelf-lib { width: 100%; margin-top: 6px; }
.prefab-lib-row .prefab-btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
/* 🏆 Leaderboard (game card, pause menu, Publish box) */
.board-spot:empty { display: none; }
.board-box { margin-top: 12px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,0.05); }
.board-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.board-tabs { margin-bottom: 6px; }
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 40vh; overflow: auto; }
.board-row { display: flex; gap: 8px; align-items: baseline; font-size: 14px; padding: 3px 4px; }
.board-place { width: 1.8em; text-align: center; flex: none; }
.board-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-val { flex: none; font-variant-numeric: tabular-nums; }
.board-empty { color: var(--muted); font-size: 14px; padding: 4px; }
.pub-board { margin: 8px 0; }
.pub-board .btn { margin-top: 6px; }
