* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #viewport { width: 100%; height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f3eee8; }
#viewport { position: fixed; inset: 0; z-index: 1; }
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-panel, .action-dock, #join-overlay, .studio-modal { pointer-events: auto; }

.hud-panel {
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  color: #f8fafc;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.minimap-card { position: fixed; top: 14px; left: 14px; width: 226px; padding-bottom: 8px; }
#minimap-canvas { display: block; margin: 8px auto; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); }
.zone-pill { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; padding: 2px 8px; border-radius: 999px; font-size: 10px; }
.zone-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px; }
.zone-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: #cbd5e1;
  background: rgba(30, 41, 59, 0.9); border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px; padding: 3px 7px; cursor: pointer;
}
.zone-chip.active { border-color: #38bdf8; color: #ffffff; }
.zone-dot { width: 6px; height: 6px; border-radius: 50%; }

.roster-card { position: fixed; top: 14px; right: 14px; width: 255px; max-height: 290px; display: flex; flex-direction: column; }
.status-select { background: #1e293b; color: #f8fafc; border: 1px solid #475569; border-radius: 6px; font-size: 11px; padding: 2px 6px; }
.roster-list { overflow-y: auto; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.roster-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-radius: 8px; background: rgba(30, 41, 59, 0.65); }
.roster-row.self { border: 1px solid rgba(56, 189, 248, 0.4); }
.roster-info { display: flex; align-items: center; gap: 8px; }
.roster-swatch { width: 10px; height: 24px; border-radius: 4px; }
.roster-name { font-size: 12px; font-weight: 700; }
.roster-sub { font-size: 10px; color: #94a3b8; }
.roster-actions { display: flex; gap: 4px; }

#video-strip {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 12;
}
.rtc-card {
  width: 110px; padding: 8px; border-radius: 12px; background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.45); color: #f8fafc; text-align: center;
}
.rtc-avatar-badge {
  width: 36px; height: 36px; border-radius: 50%; margin: 0 auto 4px;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; background: #38bdf8;
}
.rtc-label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-card { position: fixed; bottom: 16px; left: 14px; width: 310px; height: 195px; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.chat-line { line-height: 1.35; }
.scope-tag { font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 4px; margin-right: 4px; }
.scope-tag.prox { background: #0284c7; }
.scope-tag.global { background: #7c3aed; }
.chat-form { display: flex; gap: 4px; padding: 6px; border-top: 1px solid rgba(148,163,184,0.2); }
.chat-form select, .chat-form input { background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: 6px; padding: 5px 6px; font-size: 12px; }
.chat-form input { flex: 1; min-width: 0; }
.chat-form button { background: #2563eb; color: #fff; border: none; border-radius: 6px; padding: 0 10px; font-weight: 700; cursor: pointer; }

.action-dock {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.88); backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.3); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}
.dock-btn {
  background: #1e293b; color: #f8fafc; border: 1px solid #334155; border-radius: 999px;
  padding: 8px 14px; font-size: 12px; font-weight: 700; cursor: pointer; transition: 0.15s;
}
.dock-btn:hover { background: #334155; }
.dock-btn.active { background: #16a34a; border-color: #4ade80; }
.dock-btn.accent-purple { background: #6d28d9; border-color: #a78bfa; }
.dock-btn.accent-pink { background: #be185d; border-color: #f472b6; }

#interact-prompt {
  display: none; position: fixed; bottom: 82px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); color: #fde047; border: 1px solid #fbbf24;
  border-radius: 999px; padding: 7px 18px; font-size: 13px; font-weight: 700;
}

#toast-area { position: fixed; top: 82px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; }
.toast-pill { background: #0f172a; color: #fef08a; border: 1px solid #38bdf8; border-radius: 999px; padding: 7px 16px; font-size: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }

#join-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, 0.72); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.join-card {
  width: 100%; max-width: 470px; background: #0f172a; color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.4); border-radius: 18px; padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.join-badge { display: inline-block; font-size: 11px; font-weight: 700; color: #38bdf8; background: rgba(56,189,248,0.12); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.join-card h1 { font-size: 22px; margin-bottom: 8px; }
.join-card p { font-size: 13px; color: #94a3b8; margin-bottom: 18px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #cbd5e1; }
.form-grid input, .form-grid select { background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.btn-primary, .btn-primary-sm { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; border: none; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn-primary { width: 100%; padding: 11px; font-size: 14px; }
.btn-primary-sm { padding: 8px 16px; font-size: 13px; }

.studio-modal {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 16px;
}
.studio-modal.open { display: flex; }
.modal-box {
  background: #0f172a; color: #f8fafc; border: 1px solid rgba(148,163,184,0.3);
  border-radius: 16px; padding: 20px; max-width: 96vw; box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.wb-box { width: 960px; }
.text3d-box { width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.btn-close { background: #334155; color: #fff; border: none; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-weight: 700; }
.btn-xs { background: #334155; color: #fff; border: none; border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; }
.btn-mini-danger { background: #991b1b; color: #fff; border: none; border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; }

.wb-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; cursor: pointer; }
.wb-body { display: grid; grid-template-columns: 1fr 220px; gap: 12px; }
#wb-canvas { width: 100%; border-radius: 8px; cursor: crosshair; background: #fff; }
.wb-sidebar { display: flex; flex-direction: column; gap: 8px; }
.wb-note-form { display: flex; gap: 4px; }
.wb-note-form input { flex: 1; background: #1e293b; border: 1px solid #334155; color: #fff; border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.wb-notes { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow-y: auto; }
.wb-sticky { color: #0f172a; padding: 8px; border-radius: 8px; font-size: 12px; }
.wb-sticky-author { font-size: 10px; opacity: 0.7; margin-top: 4px; }

.studio-sub { font-size: 13px; color: #94a3b8; margin-bottom: 10px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.preset-chip { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 999px; padding: 4px 10px; font-size: 11px; cursor: pointer; }
.text3d-controls { display: flex; gap: 8px; margin-bottom: 8px; }
.text3d-controls input { flex: 1; background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.studio-status { font-size: 12px; color: #7dd3fc; margin-bottom: 10px; }
.text3d-stage { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
#text3d-preview { border-radius: 10px; border: 1px solid #334155; }
.text3d-side h3 { font-size: 12px; color: #94a3b8; margin: 12px 0 6px; text-transform: uppercase; }
.prop-list { max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.prop-item { display: flex; justify-content: space-between; align-items: center; background: #1e293b; padding: 6px 8px; border-radius: 8px; font-size: 12px; }
.prop-meta { font-size: 10px; color: #94a3b8; }

@media (max-width: 800px) {
  .minimap-card, .roster-card, .chat-card { display: none; }
  .wb-body, .text3d-stage { grid-template-columns: 1fr; }
}
