:root {
  --bg: #1d1a24; --panel: #27232f; --line: #3a3445; --text: #f2eee8; --muted: #a59eb0;
  --accent: #ffcf33; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 500 15px/1.4 Nunito, system-ui, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

.bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.brand small { font-weight: 700; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-left: 4px; }
.back { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.in-house .back { display: inline-block; }
.styles { margin-left: auto; display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.styles button { background: none; border: 0; border-radius: 999px; padding: 5px 12px; font-weight: 700; color: var(--muted); }
.styles button[aria-pressed="true"] { background: var(--accent); color: #2a2230; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
#stage { position: relative; overflow: hidden; min-height: 0; touch-action: manipulation; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { position: absolute; inset: 0; pointer-events: none; transition: opacity .15s; }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }

#overlay > div { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.label { pointer-events: auto; cursor: pointer; background: #fffdf7; color: #2a2230; border-radius: 10px; padding: 3px 10px 4px; text-align: center; box-shadow: 0 2px 0 rgba(0,0,0,.25); border: 2px solid var(--c); line-height: 1.15; transition: scale .12s; }
.label b { display: block; font-weight: 800; font-size: 14px; }
.label span { font-size: 11px; color: #6b6478; }
.label span::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #3fb37f; margin-right: 4px; vertical-align: 1px; }
.label.hover { scale: 1.08; }
.tag { font-size: 11px; font-weight: 700; color: #fff; background: rgba(20,16,28,.6); padding: 0 6px; border-radius: 6px; }
.tag.you { background: rgba(255,207,51,.9); color: #2a2230; }
.tag.door { background: rgba(255,255,255,.85); color: #2a2230; }
.bubble { background: #fff; color: #2a2230; font-size: 13px; padding: 5px 10px; border-radius: 12px; max-width: 220px; white-space: normal !important; width: max-content; box-shadow: 0 2px 6px rgba(0,0,0,.25); animation: pop .18s ease-out; }
.bubble::after { content: ""; position: absolute; left: var(--tail, 50%); bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble.muffled { opacity: .6; font-size: 12px; padding: 2px 8px; }
@keyframes pop { from { scale: .6; opacity: 0; } }

/* per-style overlay skins */
.style-pixel .label, .style-pixel .bubble, .style-pixel .tag { font-family: Silkscreen, monospace; border-radius: 0; box-shadow: 3px 3px 0 rgba(0,0,0,.35); }
.style-pixel .label b { font-weight: 400; font-size: 13px; }
.style-pixel .label span { font-size: 10px; }
.style-pixel .bubble { font-size: 11px; border: 2px solid #2a2230; }
.style-pixel .bubble::after { border-top-color: #2a2230; bottom: -8px; }
.style-pixel .tag { font-size: 9px; font-weight: 400; }
.style-iso .label { border-radius: 4px; }

.panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--panel); }
.panel-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.panel h1 { margin: 0; font-size: 20px; font-weight: 800; }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.sub button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.sub button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.log { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; }
.log li { word-wrap: break-word; }
.log li.me b { text-decoration: underline; text-decoration-color: var(--accent); }
.log li.sys { color: var(--muted); font-style: italic; }
.house-row button { width: 100%; display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; text-align: left; }
.house-row button:hover { border-color: var(--accent); }
.house-row i { width: 12px; height: 12px; border-radius: 3px; }
.house-row span { margin-left: auto; color: var(--muted); font-size: 13px; }
.chat { display: flex; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line); }
.chat input { min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
.chat .name { width: 84px; flex: none; color: var(--accent); }
.chat #msg { flex: 1; }
.chat input:disabled { opacity: .5; }
.chat button { background: var(--accent); color: #2a2230; border: 0; border-radius: 8px; padding: 0 14px; font-weight: 800; }
.note { margin: 0; padding: 0 16px 12px; font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 40vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .brand small { display: none; }
  .bar { gap: 8px; padding: 6px 16px; }
  .brand { font-size: 16px; }
  .styles button { padding: 4px 9px; font-size: 13px; }
  .note { display: none; }
  .bubble { max-width: 150px; font-size: 12px; padding: 4px 8px; }
  .style-pixel .bubble { font-size: 9px; }
}
@media (max-width: 420px) {
  .in-house .brand { display: none; }
  .brand { font-size: 15px; }
  .styles button { padding: 4px 7px; font-size: 12px; }
  .bar { padding: 6px 12px; }
}
