/* Blockforge — shared styles */
:root {
  --bg: #0f1218;
  --bg-2: #151a22;
  --panel: #1a2029;
  --panel-2: #222a35;
  --line: #2c3542;
  --text: #e8ebf0;
  --muted: #8d97a8;
  --accent: #ff7a1a;
  --accent-2: #ffa65c;
  --accent-ink: #1b1206;
  --teal: #2dd4bf;
  --blue: #38bdf8;
  --danger: #f43f5e;
  --ok: #22c55e;
  --warn: #facc15;
  --radius: 10px;
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #2a3340; border-color: #3a4556; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: #c95500; color: var(--accent-ink); font-weight: 800; box-shadow: 0 2px 0 #b34c00; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger:hover { background: #4a1b26; border-color: var(--danger); }
.btn.tiny { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.btn.icon { padding: 6px 9px; }
.btn.tiny.icon { padding: 2px 6px; }
.btn.big { padding: 10px 18px; font-size: 15px; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
input[type=color] { width: 36px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.verified {
  display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 5px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 10px; font-weight: 900; vertical-align: 1px;
}
.wordmark { font-weight: 900; letter-spacing: -0.5px; font-size: 22px; transform: rotate(-2deg); display: inline-block; }
.wordmark::first-letter { color: var(--accent); }

/* ---------- hub ---------- */
.hub-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px;
  padding: 10px 24px; background: rgba(15,18,24,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand-logo { width: 34px; height: 34px; }
.hub-nav { display: flex; gap: 4px; }
.hub-nav button { background: none; border: 0; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 700; }
.hub-nav button:hover { color: var(--text); background: var(--panel); }
.hub-nav button.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; font-weight: 700;
}
.user-chip small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.acct-dot { width: 24px; height: 24px; border-radius: 50%; background: #475569; border: 2px solid rgba(255,255,255,.25); flex: none; }

.hub { max-width: 1200px; margin: 0 auto; padding: 24px; }
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 28px; border-radius: 16px; margin-bottom: 28px;
  background: radial-gradient(circle at 85% 20%, rgba(255,122,26,.35), transparent 45%), linear-gradient(135deg, #1d2430, #141922);
  border: 1px solid var(--line);
}
.hero h1 { margin: 0 0 4px; font-size: 30px; }
.hero p { margin: 0; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 19px; }
.row-gap { display: flex; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: #3a4556; }
.card-thumb { position: relative; display: block; aspect-ratio: 16/9; padding: 0; border: 0; background: #0b0e13; cursor: pointer; overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 48px; font-weight: 900; color: rgba(255,255,255,.5); background: linear-gradient(135deg, #2b3546, #1a2029); }
.thumb-ph.big { aspect-ratio: 16/9; }
.play-badge { position: absolute; inset: auto 10px 10px auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 900; opacity: 0; transform: scale(.8); transition: .15s; }
.card:hover .play-badge { opacity: 1; transform: none; }
.card-body { padding: 10px 12px; }
.card-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { color: var(--muted); font-size: 12px; }
.card-tools { display: flex; gap: 4px; padding: 0 12px 12px; flex-wrap: wrap; }
.card-tools .btn:first-child { flex: 1; }
.empty { grid-column: 1/-1; text-align: center; padding: 40px; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); }

/* auth */
.auth { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, rgba(255,122,26,.25), transparent 40%), radial-gradient(circle at 80% 80%, rgba(45,212,191,.15), transparent 40%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-logo img { width: 64px; height: 64px; }
.auth-logo .wordmark { font-size: 36px; }
.auth-tag { color: var(--muted); margin: 6px 0 20px; }
.auth-accounts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; text-align: left; }
.auth-accounts label, .auth-form label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.acct { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; font-weight: 700; }
.acct:hover { border-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 8px; text-align: left; margin-bottom: 12px; }
.auth-form input { padding: 10px 12px; font-size: 16px; }
.err { color: var(--danger); min-height: 1em; }

/* dialogs */
.dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100% - 32px)); max-height: calc(100% - 32px); }
.dialog::backdrop { background: rgba(5,7,10,.7); }
.dialog-inner { padding: 22px; }
.dialog h2 { margin: 0 0 12px; }
.dialog h3 { margin: 20px 0 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 14px; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.template { display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; text-align: left; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg-2); cursor: pointer; }
.template.active { border-color: var(--accent); background: #261c14; }
.template .t-swatch { grid-row: span 2; width: 34px; height: 34px; border-radius: 8px; border: 2px solid rgba(0,0,0,.35); }
.template small { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.dialog-actions.left { justify-content: flex-start; }
.wd-thumb { border-radius: 12px; overflow: hidden; margin-bottom: 14px; aspect-ratio: 16/9; background: #0b0e13; }
.wd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wd-desc { white-space: pre-wrap; }

/* badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-grid.small { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding: 14px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.badge b { font-size: 13px; }
.badge small { color: var(--muted); font-size: 11.5px; }
.badge em { font-style: normal; font-size: 11px; color: var(--muted); }
.badge.locked { opacity: .45; filter: grayscale(.8); }
.badge-art { position: relative; width: 74px; height: 74px; margin-bottom: 6px; display: grid; place-items: center; }
.badge-art.platform { border-radius: 50%; background: radial-gradient(circle at 35% 30%, #3b4656, #1b222c); border: 3px solid #4a5568; font-size: 32px; }
.badge.earned .badge-art.platform { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,26,.15); }
.badge.is-verified .badge-art.platform { background: var(--blue); border-color: #bae6fd; color: #fff; font-weight: 900; }
.badge-art.game { border-radius: 50%; overflow: hidden; background: linear-gradient(135deg, #2b3546, #1a2029); border: 3px solid var(--line); }
.badge.earned .badge-art.game { border-color: var(--warn); }
.badge-art.game img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.badge-art.game span { position: relative; font-size: 28px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.7)); }

/* avatar editor & profile */
.avatar-editor { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 20px; }
.avatar-stage { height: 380px; border-radius: 16px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 30%, #2b3546, #12161d); }
.avatar-options { display: flex; flex-direction: column; gap: 18px; }
.av-group label { display: block; font-weight: 800; margin-bottom: 8px; }
.av-swatches, .av-choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 700; }
.chip.active { border-color: var(--accent); background: #2d2016; color: var(--accent-2); }
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding: 20px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.profile-avatar { width: 160px; height: 180px; border-radius: 14px; background: radial-gradient(circle at 50% 30%, #2b3546, #12161d); flex: none; }
.profile-info { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.profile-info h1 { margin: 0; font-size: 28px; display: flex; align-items: center; }
.profile-info h1 .verified { width: 22px; height: 22px; font-size: 13px; margin-left: 8px; }

.sw { width: 20px; height: 20px; border-radius: 5px; border: 2px solid rgba(0,0,0,.35); cursor: pointer; padding: 0; }
.sw:hover { transform: scale(1.12); }
.sw.big { width: 32px; height: 32px; border-radius: 8px; }
.sw.active { outline: 3px solid var(--text); outline-offset: 1px; }

/* ---------- studio ---------- */
body.studio { display: grid; grid-template-rows: 48px auto 1fr; height: 100vh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 900; font-size: 15px; }
.topbar .brand em { font-style: normal; color: var(--accent); }
.logo { width: 24px; height: 24px; background: url(../logo.svg) center/contain no-repeat; display: inline-block; }
.world-name { max-width: 260px; background: transparent !important; border-color: transparent !important; font-weight: 700; }
.world-name:hover { border-color: var(--line) !important; }
.dirty { color: var(--muted); font-size: 12px; }
.dirty.on { color: var(--warn); }
.ribbon { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.rgroup { display: flex; flex-direction: column; align-items: center; padding: 0 10px; border-right: 1px solid var(--line); }
.rgroup > label { font-size: 10.5px; color: var(--muted); padding: 2px 0 4px; text-transform: uppercase; letter-spacing: .6px; }
.rbtns { display: flex; gap: 2px; align-items: center; }
.rbtn { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 54px; padding: 4px 6px; border-radius: 6px; border: 1px solid transparent; background: none; cursor: pointer; font-size: 11.5px; color: var(--text); }
.rbtn b { font-size: 18px; line-height: 22px; }
.rbtn:hover { background: var(--panel-2); }
.rbtn.active { background: #2d2016; border-color: var(--accent); color: var(--accent-2); }
.rsnap { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; padding: 0 4px; }
.rsnap select { padding: 2px 4px; width: 66px; }
.swatches { display: grid; grid-template-columns: repeat(7, 20px); gap: 4px; padding-top: 3px; }
.swatches.small { padding: 4px 10px 8px; }

.workspace { display: grid; grid-template-columns: 230px 1fr 290px; min-height: 0; }
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); background: var(--bg-2); border-bottom: 1px solid var(--line); }
.filter { margin: 6px; width: calc(100% - 12px) !important; font-size: 12.5px; }
.tree { overflow: auto; flex: 1; padding-bottom: 12px; }
.tree-group { display: flex; align-items: center; gap: 6px; padding: 10px 10px 4px; font-weight: 800; font-size: 12px; color: var(--muted); }
.tree-group .btn { margin-left: auto; }
.count { background: var(--panel-2); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.tree-item { display: flex; align-items: center; gap: 7px; padding: 3px 10px 3px 18px; cursor: pointer; white-space: nowrap; user-select: none; }
.tree-item span { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tree-item:hover { background: var(--panel-2); }
.tree-item.selected { background: #1d3a52; box-shadow: inset 2px 0 0 var(--blue); }
.tree-item .ico { font-style: normal; width: 14px; text-align: center; font-size: 12px; }
.tree-item .ico.dot { height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.4); }
.tree-item .tag { font-style: normal; font-size: 10.5px; color: var(--muted); }
.tree-empty { padding: 4px 18px; color: var(--muted); font-size: 12px; }

.center { display: grid; grid-template-rows: 32px 1fr 150px; min-width: 0; min-height: 0; }
.tabs { display: flex; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 6px; padding: 0 12px; cursor: pointer; border-right: 1px solid var(--line); color: var(--muted); white-space: nowrap; font-size: 13px; }
.tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tab .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 2px; }
.tab .x:hover { color: var(--danger); }
.view-area { position: relative; min-height: 0; }
#viewport, #game { position: absolute; inset: 0; overflow: hidden; }
#viewport canvas, #game canvas { display: block; }
.vp-hint { position: absolute; left: 10px; bottom: 8px; font-size: 11.5px; color: rgba(255,255,255,.75); background: rgba(0,0,0,.35); padding: 3px 8px; border-radius: 6px; pointer-events: none; }

.editor { position: absolute; inset: 0; display: grid; grid-template-columns: 48px 1fr; background: #0c0f14; z-index: 2; }
.gutter, .code pre, .code textarea { font: 13.5px/1.55 var(--mono); tab-size: 2; }
.gutter { margin: 0; padding: 12px 8px 12px 0; text-align: right; color: #4b5568; white-space: pre; overflow: hidden; user-select: none; background: #0f1319; border-right: 1px solid var(--line); }
.code { position: relative; min-width: 0; }
.code pre, .code textarea { position: absolute; inset: 0; margin: 0; padding: 12px 14px; white-space: pre; overflow: auto; border: 0; }
.code pre { pointer-events: none; overflow: hidden; color: #d6dbe4; padding-bottom: 40px; }
.code textarea { background: transparent; color: transparent; caret-color: #fff; resize: none; outline: none; border-radius: 0; }
.code textarea::selection { background: rgba(56,189,248,.3); color: transparent; }
.t-com { color: #6b7a90; font-style: italic; }
.t-str { color: #a5e075; }
.t-num { color: #f5a97f; }
.t-kw { color: #ff8f50; font-weight: 600; }
.t-api { color: #5fd4f4; font-weight: 600; }
.t-fn { color: #f0d675; }

.output-panel { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); background: var(--panel); }
.output { flex: 1; overflow: auto; padding: 4px 10px; font: 12.5px/1.5 var(--mono); }
.out-line { white-space: pre-wrap; word-break: break-word; }
.out-line time { color: #4b5568; }
.out-line.error { color: #ff7a8a; }
.out-line.warn { color: var(--warn); }
.out-line.ok { color: #6ee7a0; }
.out-line.muted { color: var(--muted); }

.props { overflow: auto; flex: 1; padding-bottom: 20px; }
.prop-section { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.prop-head { padding: 9px 10px 5px; font-weight: 800; font-size: 12px; color: var(--accent-2); }
.prop { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; padding: 3px 10px; }
.prop-label { color: var(--muted); font-size: 12.5px; }
.readonly { color: var(--muted); }
.vec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ax { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ax i { font-style: normal; font-size: 10px; font-weight: 900; padding: 0 4px; align-self: stretch; display: grid; place-items: center; }
.ax-x i { background: #7f1d2d; } .ax-y i { background: #166534; } .ax-z i { background: #1e3a8a; }
.ax input { border: 0 !important; padding: 4px 3px; font-size: 12px; background: transparent; -moz-appearance: textfield; }
.ax input::-webkit-inner-spin-button { display: none; }
.color-row, .range-row { display: flex; align-items: center; gap: 8px; }
.color-row code { color: var(--muted); font-size: 12px; }
.range-val { width: 32px; text-align: right; color: var(--muted); font-size: 12px; }
.prop-actions { display: flex; gap: 6px; padding: 10px; flex-wrap: wrap; }
.prop-note { padding: 4px 10px; color: var(--muted); font-size: 12px; }
.switch { position: relative; display: inline-block; width: 34px; height: 19px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #3a4556; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(15px); }

.docs { position: fixed; top: 48px; right: 0; bottom: 0; width: min(520px, 100%); z-index: 20; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.4); }
.docs-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.docs-body { overflow: auto; padding: 4px 16px 30px; }
.docs-body h3 { margin: 18px 0 6px; font-size: 15px; }
.api-row { display: flex; flex-direction: column; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.api-row code { font: 12.5px var(--mono); color: #5fd4f4; }
.api-row span { color: var(--muted); font-size: 12.5px; }
.api-ex { margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.api-ex-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: var(--bg-2); font-weight: 700; font-size: 12.5px; }
.api-ex pre { margin: 0; padding: 10px; background: #0c0f14; font: 12.5px/1.5 var(--mono); overflow-x: auto; }

/* ---------- play ---------- */
body.play { overflow: hidden; }
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud button, .hud .hud-output { pointer-events: auto; }
.hud-top-left { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 10px; }
.hud-top-left .btn { background: rgba(15,18,24,.75); }
.world-title { font-weight: 800; padding: 6px 12px; border-radius: 8px; background: rgba(15,18,24,.6); }
.hud-label { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 18px; border-radius: 10px; background: rgba(15,18,24,.7); font-weight: 800; font-size: 17px; }
.hud-stats { position: absolute; top: 12px; right: 12px; min-width: 160px; background: rgba(15,18,24,.72); border-radius: 10px; overflow: hidden; }
.stat-head { padding: 5px 12px; background: rgba(255,122,26,.85); color: var(--accent-ink); font-weight: 900; font-size: 12.5px; }
.stat { display: flex; justify-content: space-between; gap: 14px; padding: 4px 12px; font-size: 13.5px; }
.stat span { color: #c3cad6; }
.hud-messages { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(90%, 560px); }
.toast { padding: 10px 18px; border-radius: 10px; background: rgba(15,18,24,.82); font-weight: 800; font-size: 17px; text-align: center; animation: pop .2s ease-out; transition: opacity .3s; }
.toast.error { font-size: 13px; font-weight: 600; background: rgba(90,15,30,.9); color: #ffd1d8; font-family: var(--mono); }
.toast.out { opacity: 0; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.badge-toast { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 12px 18px 12px 12px; border-radius: 14px; background: linear-gradient(135deg, #2b2112, #1a2029); border: 2px solid var(--warn); box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: slideup .35s ease-out; transition: opacity .4s; }
.badge-toast.out { opacity: 0; }
.badge-toast .badge-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: rgba(250,204,21,.15); border: 2px solid var(--warn); }
.badge-toast small { display: block; color: var(--warn); font-weight: 800; text-transform: uppercase; font-size: 11px; letter-spacing: .6px; }
.badge-toast b { display: block; font-size: 17px; }
.badge-toast span { color: var(--muted); font-size: 12.5px; }
@keyframes slideup { from { transform: translate(-50%, 30px); opacity: 0; } }
.hud-health { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 8px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.hud-health .bar { width: 200px; height: 14px; border-radius: 999px; background: rgba(0,0,0,.5); overflow: hidden; border: 2px solid rgba(255,255,255,.25); }
#healthFill { height: 100%; width: 100%; background: var(--ok); transition: width .2s; }
.hud-buttons { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.hud-btn { padding: 10px 16px; border-radius: 10px; border: 2px solid rgba(255,255,255,.2); background: rgba(15,18,24,.8); font-weight: 800; cursor: pointer; }
.hud-btn:hover { border-color: var(--accent); }
.hud-help { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 12px; color: rgba(255,255,255,.8); background: rgba(0,0,0,.35); padding: 4px 10px; border-radius: 6px; white-space: nowrap; }
.hud-output { position: absolute; left: 12px; bottom: 44px; width: min(560px, calc(100% - 24px)); max-height: 40%; overflow: auto; background: rgba(8,10,14,.88); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: 12px/1.5 var(--mono); }
.death { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: rgba(60,0,10,.3); font-size: 34px; font-weight: 900; text-shadow: 0 2px 8px #000; }
.death small { font-size: 15px; font-weight: 600; }
.fatal { height: 100vh; display: grid; place-content: center; gap: 12px; text-align: center; }

@media (max-width: 760px) {
  .hub-top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .hub-nav { order: 3; width: 100%; overflow-x: auto; }
  .hub { padding: 16px; }
  .avatar-editor { grid-template-columns: 1fr; }
  .avatar-stage { height: 300px; }
  .hud-help { display: none; }
}

/* ---------- v2: accounts, marketplace, creator, Blobux, admin ---------- */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg-2); border-radius: 10px; margin-bottom: 14px; }
.auth-tabs button { border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 800; color: var(--muted); }
.auth-tabs button.active { background: var(--panel-2); color: var(--text); }
.auth-form label { display: flex; flex-direction: column; gap: 4px; text-transform: none; letter-spacing: 0; font-size: 13px; }
.bx { color: #5eead4; font-weight: 900; }
.blobux-chip { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: #0f2a2a; border: 1px solid #1f5f5a; cursor: pointer; font-weight: 800; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.seg.small button { padding: 4px 9px; font-size: 12.5px; }
.seg .dot { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.4); }
.row-gap.end { justify-content: flex-end; margin-bottom: 12px; }
.center { text-align: center; }
.field.inline, label.inline { flex-direction: row; align-items: center; gap: 10px; display: flex; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.item-card { display: flex; flex-direction: column; gap: 3px; padding: 10px; text-align: left; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; transition: transform .12s, border-color .12s; }
.item-card:hover { transform: translateY(-2px); border-color: #3a4556; }
.item-card b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card small { color: var(--muted); font-size: 12px; }
.price { font-weight: 800; font-size: 13px; }
.owned { color: var(--ok); }
.item-art { width: 100%; aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; overflow: hidden; margin-bottom: 4px; background: #222a35; }
.item-art img { width: 78%; height: 78%; object-fit: contain; image-rendering: pixelated; }
.item-art.hat { background: radial-gradient(circle at 50% 60%, var(--c), #1a2029 75%); font-size: 46px; }
.item-art.none { color: var(--muted); font-size: 26px; }
.item-art.big { width: 200px; flex: none; }
.item-art.big.hat { font-size: 90px; }
.item-dialog { display: flex; gap: 20px; flex-wrap: wrap; }
.item-dialog > div:last-child { flex: 1; min-width: 220px; }
.dialog.narrow { width: min(560px, calc(100% - 32px)); }

.item-creator { display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.ic-left { display: flex; flex-direction: column; gap: 12px; }
.ic-left .field { margin: 0; }
.ic-right .avatar-stage { height: 380px; }
.paint-wrap { display: flex; gap: 16px; flex-wrap: wrap; }
#paint { width: 320px; max-width: 100%; aspect-ratio: 1; image-rendering: pixelated; cursor: crosshair; border-radius: 8px; border: 1px solid var(--line);
  background: conic-gradient(#2a3240 25%, #222935 0 50%, #2a3240 0 75%, #222935 0) 0 0 / 20px 20px; touch-action: none; }
.paint-tools { display: flex; flex-direction: column; gap: 10px; max-width: 260px; }

.inv-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.inv { flex: none; width: 92px; display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel); cursor: pointer; }
.inv small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.inv.active { border-color: var(--accent); background: #2d2016; }
.inv .item-art { margin: 0; }

.role-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.role { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.role.owner { background: #3a2a07; color: #fcd34d; border: 1px solid #8a6514; }
.role.admin { background: #3b0f17; color: #fda4af; border: 1px solid #7f1d2d; }
.role.ver { background: #0c2f45; color: #7dd3fc; border: 1px solid #1e6a92; }
.bio { margin: 0; white-space: pre-wrap; }
.badge-logo { width: 46px; height: 46px; display: block; }
.badge.is-blockforge .badge-art.platform { background: radial-gradient(circle at 35% 30%, #3a2a1a, #1a1208); border-color: var(--accent); }
.badge.is-admin .badge-art.platform { background: radial-gradient(circle at 35% 30%, #fb7185, #7f1d2d); border-color: #fda4af; }
.badge.is-owner .badge-art.platform { background: radial-gradient(circle at 35% 30%, #fde68a, #b45309); border-color: #fcd34d; }

.blobux-hero { background: radial-gradient(circle at 85% 20%, rgba(45,212,191,.35), transparent 45%), linear-gradient(135deg, #12302e, #141922); }
.test-banner { padding: 10px 14px; border-radius: 10px; background: #2a2410; border: 1px solid #6b5a12; color: #fde68a; margin-bottom: 16px; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.pack { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.pack-gem { font-size: 46px; color: #5eead4; text-shadow: 0 0 24px rgba(94,234,212,.5); }
.pack b { font-size: 24px; }
.pack span { color: var(--muted); margin-bottom: 8px; }
.pack .btn small { font-weight: 600; opacity: .7; margin-left: 4px; font-size: 11px; }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table th { background: var(--bg-2); font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }

.hub-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 12px 18px; border-radius: 12px; background: #1d2633; border: 1px solid var(--line); font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.hub-toast.error { background: #4a1b26; border-color: var(--danger); }

@media (max-width: 760px) {
  .item-creator { grid-template-columns: 1fr; }
  .item-art.big { width: 140px; }
}

/* ---------- multiplayer HUD ---------- */
.hud-right { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.hud-right .hud-stats { position: static; }
.player-list { min-width: 170px; max-height: 40vh; overflow: auto; background: rgba(15,18,24,.72); border-radius: 10px; font-size: 13px; pointer-events: auto; }
.pl-head { padding: 5px 12px; font-weight: 900; font-size: 12px; background: rgba(255,255,255,.08); }
.pl-row { padding: 3px 12px; white-space: nowrap; }
.pl-row.me { color: var(--accent-2); font-weight: 800; }
.chat { position: absolute; left: 12px; top: 56px; width: min(380px, calc(100% - 24px)); pointer-events: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-log { max-height: 220px; overflow: auto; padding: 6px 10px; border-radius: 10px; background: rgba(15,18,24,.55); font-size: 13.5px; line-height: 1.4; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.chat-log:empty { display: none; }
.chat-line { word-break: break-word; }
.chat-line.system { color: #a5b4c8; font-style: italic; }
.chat-line b.staff { color: #fcd34d; }
.chat-line kbd { background: rgba(255,255,255,.15); border-radius: 4px; padding: 0 5px; font-style: normal; }
.chat input { background: rgba(15,18,24,.7); border: 1px solid rgba(255,255,255,.15); border-radius: 8px; padding: 7px 10px; }
.chat .verified { width: 13px; height: 13px; font-size: 8px; margin-left: 2px; }
.disconnected { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5,7,10,.55); pointer-events: auto; }
.disc-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; text-align: center; }
.disc-card b { font-size: 20px; }
.online { color: var(--ok); font-weight: 800; }
@media (max-width: 760px) { .chat { top: auto; bottom: 46px; } .chat-log { max-height: 120px; } }

/* ---------- Esc menu + in-game admin ---------- */
.esc-menu { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(5,7,10,.6); backdrop-filter: blur(3px); pointer-events: auto; }
.esc-card { width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.esc-tabs { display: flex; gap: 2px; padding: 8px; background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; flex-wrap: wrap; }
.esc-tabs button { flex: 1; border: 0; background: none; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 800; cursor: pointer; white-space: nowrap; }
.esc-tabs button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.esc-tabs #tabAdmin.active { box-shadow: inset 0 -2px 0 var(--danger); }
.esc-page { padding: 18px; }
.esc-page h2 { margin: 0 0 14px; text-align: center; }
.esc-buttons { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 0 auto; }
.esc-help { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 16px; color: var(--muted); font-size: 13px; }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font: 12px var(--mono); color: var(--text); }
.esc-players { display: flex; flex-direction: column; gap: 6px; }
.esc-player { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--bg-2); flex-wrap: wrap; }
.esc-player.me { border: 1px solid var(--accent); }
.esc-player em { color: var(--muted); font-style: normal; font-size: 12px; }
.adm-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.set-row input[type=range] { width: 180px; margin-left: auto; }
.set-row output { width: 36px; text-align: right; color: var(--muted); }
.adm-section { margin-bottom: 18px; }
.adm-section h3 { margin: 0 0 8px; font-size: 15px; }
.adm-section form input { flex: 1; }
.announce { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(640px, calc(100% - 24px)); padding: 12px 18px; border-radius: 12px; text-align: center;
  background: linear-gradient(135deg, rgba(255,122,26,.95), rgba(225,90,0,.95)); color: var(--accent-ink); box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: pop .25s ease-out; }
.announce small { font-weight: 800; opacity: .8; }
.announce div { font-size: 19px; font-weight: 900; }
.admin-status { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); padding: 5px 12px; border-radius: 999px; background: rgba(15,18,24,.8); border: 1px solid var(--accent); font-weight: 800; font-size: 13px; }
.chat-line.ann { color: var(--accent-2); }

/* ---------- Studio app home ---------- */
.studio-tag { font-style: normal; font-weight: 900; color: var(--blue); margin-left: 4px; }
.inline-auth { margin: 40px auto; }
.big-templates { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.studio-list { display: flex; flex-direction: column; gap: 8px; }
.studio-row { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.studio-row:hover { border-color: var(--blue); }
.sr-thumb { width: 96px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; font-weight: 900; font-size: 22px; color: var(--muted); flex: none; }
.sr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sr-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sr-info small { color: var(--muted); }
.row-gap.wrap { flex-wrap: wrap; }

/* ---------- download page ---------- */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.dl-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 28px 20px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.dl-card img { width: 96px; height: 96px; }
.dl-card h2 { margin: 4px 0 0; }
.dl-card p { color: var(--muted); margin: 0 0 8px; max-width: 320px; }
.dl-card.studio .btn.primary { background: var(--blue); border-color: #0284c7; box-shadow: 0 2px 0 #0369a1; color: #04121f; }
.dl-notes { margin-top: 24px; padding: 18px 22px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.dl-notes h3 { margin-top: 0; }
.dl-notes li { margin-bottom: 6px; }

/* top bar: keep chips on one line, wrap the nav on narrower windows */
.blobux-chip, .user-chip { white-space: nowrap; flex: none; }
@media (max-width: 1000px) {
  .hub-top { flex-wrap: wrap; row-gap: 6px; padding: 8px 16px; }
  .hub-nav { order: 3; width: 100%; overflow-x: auto; }
}

/* ---------- marketplace tools, Limited U, uploads ---------- */
.market-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.market-tools input { flex: 1; min-width: 200px; padding: 9px 12px; }
.market-tools select { width: auto; padding: 8px 10px; }
.more-row { margin-top: 16px; }
.item-art { position: relative; }
.lim-badge { position: absolute; left: 6px; bottom: 6px; padding: 2px 6px; border-radius: 5px; font: 900 10px/1.3 var(--font); letter-spacing: .5px;
  color: #052e16; background: linear-gradient(135deg, #86efac, #22c55e); box-shadow: 0 1px 0 rgba(0,0,0,.4); }
.lim-badge.static { position: static; display: inline-block; vertical-align: 1px; }
.item-card.limited { border-color: #166534; }
.item-card.limited:hover { border-color: #22c55e; }
.stock { color: var(--muted); font-weight: 600; font-size: 12px; margin-left: 4px; }
.lim-box { margin: 10px 0; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid #166534; }
.lim-box h4 { margin: 12px 0 6px; font-size: 13px; }
.lim-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lim-bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin: 8px 0; }
.lim-bar div { height: 100%; background: linear-gradient(90deg, #22c55e, #86efac); }
.lim-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: var(--panel); margin-bottom: 4px; }
.lim-row span { flex: 1; }
.upload-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: #0f2a1a; border: 1px solid #166534; color: #86efac; font-size: 12.5px; }
#paint.uploaded { outline: 2px solid #22c55e; }
.limited-opts { padding: 10px 12px; border-radius: 10px; border: 1px dashed #166534; background: #0d1a12; }
.limited-opts .set-row { border: 0; padding: 4px 0; }
.tex-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
.tex-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
