/* Matte Studio Editorial UI — zero emoji, zero purple glassmorphism, zero neon gradients */
:root {
  --bg-outer: #0b0a0a;
  --bg-stage: #111010;
  --surface: rgba(20, 19, 18, 0.86);
  --surface-solid: #191817;
  --border: rgba(242, 236, 228, 0.13);
  --border-strong: rgba(242, 236, 228, 0.24);
  --ink: #f2ece4;
  --ink-muted: #9e968c;
  --accent: #d85a2a;
  --accent-ink: #ffffff;
  --live: #48b878;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-outer);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage-frame {
  position: relative;
  height: 100dvh;
  width: min(100vw, calc(100dvh * 9 / 16));
  max-width: 100vw;
  aspect-ratio: 9 / 16;
  background: var(--bg-stage);
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

@media (max-aspect-ratio: 9/16) {
  #stage-frame {
    width: 100vw;
    height: 100dvh;
    border: none;
  }
}

#unity-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------------
   Minimal Studio Loading Screen
------------------------------------------------------------------ */
#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #100f0e;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 36px 28px;
  transition: opacity 0.42s ease;
}

#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-wrap {
  text-align: center;
}

.loader-kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #d88a5a;
  padding: 4px 12px;
  border: 1px solid rgba(216, 138, 90, 0.38);
  border-radius: 3px;
  margin-bottom: 18px;
}

.loader-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--ink);
  line-height: 1.2;
}

.loader-divider {
  width: 28px;
  height: 2px;
  background: var(--accent);
  margin: 16px auto 14px;
}

.loader-sub {
  font-size: 12.5px;
  letter-spacing: 1.5px;
  color: var(--ink-muted);
}

.loader-bottom {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: max(36px, env(safe-area-inset-bottom));
}

.loader-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--ink-muted);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.loader-bar-track {
  width: 100%;
  height: 2px;
  background: rgba(242, 236, 228, 0.14);
  overflow: hidden;
}

#loader-bar-fill {
  width: 4%;
  height: 100%;
  background: var(--ink);
  transition: width 0.2s ease;
}

.hud-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   WeChat Built-in Browser Subtle Hint
------------------------------------------------------------------ */
#wx-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: #221d19;
  border-bottom: 1px solid rgba(216, 138, 90, 0.32);
  color: #ebd6c3;
  font-size: 11px;
  line-height: 1.35;
}

#wx-banner.wx-hidden {
  display: none;
}

#wx-close-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  padding: 2px;
  cursor: pointer;
  display: flex;
}

/* ------------------------------------------------------------------
   Top Watermark, Live Readout & Sound Toggle
------------------------------------------------------------------ */
#hud-top {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  transition: opacity 0.35s ease, top 0.2s ease;
}

#hud-top.wx-shifted {
  top: 40px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--ink);
}

.brand-sep {
  font-size: 11px;
  color: rgba(242, 236, 228, 0.32);
}

.brand-edition {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: #e09a6c;
}

.track-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-muted);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.track-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(242, 236, 228, 0.35);
}

.track-line.track-live {
  color: #b7e4c7;
}

.track-line.track-live .track-dot {
  background: var(--live);
}

.top-right-group {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.state-readout {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: rgba(242, 236, 228, 0.86);
  padding: 4px 9px;
  background: rgba(16, 15, 14, 0.64);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.icon-chip {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(16, 15, 14, 0.64);
  color: rgba(242, 236, 228, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-chip.muted {
  color: var(--ink-muted);
}

.svg-hidden {
  display: none;
}

/* ------------------------------------------------------------------
   Recallable Mirrored Webcam Selfie PIP
------------------------------------------------------------------ */
#pip-wrap {
  position: absolute;
  top: 52px;
  right: 14px;
  width: 82px;
  height: 110px;
  border-radius: 6px;
  overflow: hidden;
  z-index: 16;
  background: #151413;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.22s ease, opacity 0.22s ease;
}

#pip-wrap.pip-hidden {
  opacity: 0;
  transform: scale(0.88);
  pointer-events: none;
}

#webcam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#pip-ring {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  pointer-events: none;
}

#pip-wrap.locked #pip-ring {
  border: 1.5px solid var(--live);
}

#pip-hide-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: none;
  background: rgba(16, 15, 14, 0.72);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#pip-recall-btn {
  position: absolute;
  top: 52px;
  right: 14px;
  z-index: 16;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: rgba(16, 15, 14, 0.76);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

#pip-recall-btn.pip-recall-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   Tactile Comic Speech Tag
------------------------------------------------------------------ */
#speech-bubble {
  position: absolute;
  top: 78px;
  left: 14px;
  max-width: 60%;
  z-index: 14;
  padding: 7px 11px;
  border-radius: 8px 8px 8px 2px;
  background: #f5efe6;
  border: 1.5px solid #2b211b;
  color: #241b15;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.32);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#speech-bubble.bubble-hidden {
  opacity: 0;
  transform: translateY(6px);
}

/* Toast */
#clear-toast {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  padding: 7px 16px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: #1c1a19;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#clear-toast.toast-hidden {
  opacity: 0;
}

/* ------------------------------------------------------------------
   Clean Primary Camera Prompt
------------------------------------------------------------------ */
#cam-cta-wrap {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 126px;
  z-index: 18;
  display: flex;
  justify-content: center;
  transition: opacity 0.22s ease;
}

#cam-cta-wrap.cta-hidden {
  opacity: 0;
  pointer-events: none;
}

.cam-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 6px;
  border: none;
  background: #f2ece4;
  color: #161412;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.cam-cta-btn:active {
  transform: scale(0.97);
  background: #e2dad0;
}

/* ------------------------------------------------------------------
   Compact Preset Expression Grid
------------------------------------------------------------------ */
#preset-drawer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 124px;
  z-index: 19;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#preset-drawer.drawer-hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.preset-chip {
  padding: 8px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(242, 236, 228, 0.04);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.preset-chip:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ------------------------------------------------------------------
   Bottom Studio Control Area (5-Control Balanced Dock)
------------------------------------------------------------------ */
#hud-bottom {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity 0.35s ease;
}

.taunt-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.taunt-btn {
  padding: 8px 4px;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: rgba(242, 236, 228, 0.82);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.taunt-btn:last-child {
  border-right: none;
}

.taunt-btn:active {
  background: rgba(242, 236, 228, 0.08);
}

.taunt-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.tool-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 2px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(242, 236, 228, 0.85);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tool-btn:active {
  background: rgba(242, 236, 228, 0.08);
}

.tool-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.tool-btn .lbl {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ------------------------------------------------------------------
   Clean Matte Snapshot Modal
------------------------------------------------------------------ */
#snap-modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(10, 9, 9, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

#snap-modal.modal-hidden {
  display: none;
}

.snap-card {
  width: 86%;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.snap-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.snap-tip {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-muted);
}

#snap-img {
  width: 100%;
  border-radius: 4px;
  display: block;
  border: 1px solid var(--border);
  -webkit-touch-callout: default;
  user-select: auto;
}

.snap-actions {
  display: flex;
  gap: 8px;
}

.snap-btn-primary, .snap-btn-secondary {
  flex: 1;
  text-align: center;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 5px;
  border: none;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.snap-btn-primary {
  background: var(--ink);
  color: #161412;
}

.snap-btn-secondary {
  background: rgba(242, 236, 228, 0.08);
  border: 1px solid var(--border);
  color: var(--ink);
}
