:root {
  --ink: #1b1324;
  --wine: #4a2233;
  --gold: #e8c36a;
  --gold-dim: #b8893a;
  --paper: #fff4e4;
  --rose: #d7767a;
  --jade: #7eb8a6;
  --mist: rgba(255, 244, 228, .72);
  --seat: #6b2f3d;
  --wood: #8a4d2f;
  --lantern: #f0a35a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(232, 195, 106, .16), transparent 55%),
    radial-gradient(800px 500px at 110% 80%, rgba(126, 184, 166, .08), transparent 50%),
    linear-gradient(180deg, #140f1c 0%, #1c1222 40%, #2a1624 100%);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.55'/></svg>");
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#app { height: 100%; position: relative; }

.view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 8px;
  gap: 12px;
  position: relative;
  z-index: 3;
}

.brand {
  display: flex;
  flex-direction: column;
  letter-spacing: .28em;
}
.brand b {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(232, 195, 106, .35);
}
.brand span { font-size: 11px; opacity: .62; letter-spacing: .42em; padding-left: 2px; }

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--mist);
  font-size: 13px;
}
.who .mini { width: 36px; height: 48px; }
.who .mini .doll-wrap, .who .mini .doll { width: 36px; height: 48px; }

.ghost, .gold, .wine {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  transition: transform .15s ease, filter .15s ease;
}
.ghost {
  background: rgba(255,244,228,.08);
  color: var(--paper);
  border: 1px solid rgba(255,244,228,.14);
}
.gold {
  background: linear-gradient(180deg, #f0d48a, #c9963d);
  color: #3a2410;
  font-weight: 700;
}
.wine {
  background: #6b2f3d;
  color: var(--paper);
}
.ghost:hover, .gold:hover, .wine:hover { transform: translateY(-1px); filter: brightness(1.06); }

/* ── auth ── */
.gate {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(46, 92, 62, .45), transparent 55%),
    radial-gradient(circle at 80% 12%, rgba(232, 195, 106, .16), transparent 28%),
    linear-gradient(180deg, #243044 0%, #1a2430 42%, #142018 100%);
}
.gate-card {
  width: min(460px, 92vw);
  background:
    linear-gradient(180deg, rgba(36, 28, 32, .92), rgba(16, 18, 22, .94));
  border: 1px solid rgba(232, 195, 106, .38);
  box-shadow: 0 28px 90px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,244,228,.08);
  border-radius: 28px;
  padding: 32px 32px 26px;
  position: relative;
  overflow: hidden;
}
.gate-mark {
  font-size: 12px;
  letter-spacing: .28em;
  color: var(--gold);
  opacity: .8;
  margin-bottom: 8px;
}
.gate-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -40px;
  top: -50px;
  background: radial-gradient(circle at 50% 40%, rgba(240, 163, 90, .55), transparent 68%);
  pointer-events: none;
}
.gate h1 {
  margin: 0 0 8px;
  font-size: 40px;
  letter-spacing: .28em;
  color: var(--gold);
}
.gate p.lead { margin: 0 0 18px; opacity: .78; font-size: 14px; line-height: 1.6; letter-spacing: .04em; max-width: 28em; }
.name-note { margin: 6px 0 0; font-size: 12px; opacity: .55; letter-spacing: .04em; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button {
  flex: 1;
  background: transparent;
  color: var(--mist);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px;
}
.tabs button.on { color: var(--gold); border-color: var(--gold); }
label { display: block; font-size: 12px; opacity: .6; margin: 10px 0 6px; }
input[type="text"], input[type="password"], select {
  width: 100%;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,244,228,.12);
  color: var(--paper);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
input[type="text"]:-webkit-autofill,
input[type="password"]:-webkit-autofill {
  -webkit-text-fill-color: var(--paper);
  caret-color: var(--paper);
  box-shadow: 0 0 0 1000px #1a1218 inset;
  transition: background-color 9999s ease-out 0s;
}
input:focus { border-color: rgba(232, 195, 106, .55); }
.err { min-height: 20px; color: #f0a0a0; font-size: 13px; margin: 10px 0 0; }
.gate .gold { width: 100%; margin-top: 14px; padding: 12px; }

/* ── atelier ── */
.atelier {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 440px);
  gap: 22px;
  padding: 8px 28px 24px;
  min-height: 0;
}
.doll-stage {
  position: relative;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 78%, rgba(110, 163, 90, .35), transparent 42%),
    linear-gradient(180deg, #c5dff0 0%, #8fb4c9 46%, #6e9a62 100%);
  border: 1px solid rgba(255, 244, 228, .18);
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
}
.doll-stage .doll-wrap, .doll-stage .doll { width: min(280px, 46vw); height: min(420px, 68vh); }
.look-panel { display: flex; flex-direction: column; }
.look-panel .gold { width: 100%; margin-top: 8px; }
.quiet { opacity: .62; letter-spacing: .12em; font-size: 13px; }
.preview-stage {
  position: relative;
  min-height: 520px;
  border-radius: 24px;
  background: #1a1020;
  border: 1px solid rgba(232,195,106,.16);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.look-preview {
  height: min(92%, 520px);
  width: auto;
  max-width: 92%;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,.45));
}
.preview-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.hint-line { margin: 0 0 14px; opacity: .65; font-size: 13px; line-height: 1.5; }
.preview-stage .doll-wrap, .preview-stage .doll { width: 260px; height: 380px; }
.preview-stage .cushion {
  position: absolute;
  width: 210px;
  height: 48px;
  bottom: 18%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #8a3d4c, #4a2230);
  box-shadow: 0 16px 30px rgba(0,0,0,.35);
}
.panel {
  background: rgba(20,12,20,.55);
  border: 1px solid rgba(255,244,228,.1);
  border-radius: 20px;
  padding: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 96px);
}
.panel h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: .16em; font-size: 14px; color: var(--gold); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip, .swatch {
  border: 1px solid rgba(255,244,228,.16);
  background: rgba(255,244,228,.05);
  color: var(--paper);
  border-radius: 999px;
  padding: 6px 12px;
}
.chip.on, .swatch.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.swatch { width: 28px; height: 28px; padding: 0; border-radius: 50%; }

/* ── lobby ── */
.lobby-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 12px 24px 36px;
}
.hall {
  width: min(520px, 92vw);
  display: grid;
  gap: 16px;
}
.room-card {
  text-align: left;
  background:
    linear-gradient(180deg, rgba(72, 36, 48, .55), rgba(24, 14, 22, .8));
  border: 1px solid rgba(232, 195, 106, .16);
  border-radius: 18px;
  padding: 16px 16px 14px;
  color: inherit;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.room-card.official::before {
  content: "高原";
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--gold);
  opacity: .8;
}
.room-card:hover { border-color: rgba(232,195,106,.5); transform: translateY(-2px); }
.room-card b { font-size: 20px; letter-spacing: .12em; }
.room-card .topic { opacity: .65; font-size: 13px; min-height: 18px; }
.counts { display: flex; gap: 10px; margin-top: auto; font-size: 12px; opacity: .85; }
.counts em { font-style: normal; color: var(--gold); }
.new-room {
  border-style: dashed;
  background: rgba(255,244,228,.03);
  align-items: center;
  justify-content: center;
  letter-spacing: .24em;
  color: var(--gold);
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8,6,10,.62);
  display: grid;
  place-items: center;
  z-index: 20;
}
.modal {
  width: min(420px, 92vw);
  background: #22141e;
  border: 1px solid rgba(232,195,106,.25);
  border-radius: 18px;
  padding: 20px;
}
.modal h3 { margin: 0 0 12px; color: var(--gold); letter-spacing: .16em; }

/* ── room ── */
.room-view { position: relative; }
.room-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr minmax(300px, 360px);
  gap: 12px;
  padding: 0 16px 16px;
}
.stage {
  position: relative;
  min-height: 56vh;
  height: 100%;
  border-radius: 28px;
  background: #07060e;
  border: 1px solid rgba(232,195,106,.18);
  box-shadow: inset 0 0 80px rgba(212, 177, 90, .06);
  overflow: hidden;
}
.stage-canvas, .preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.stage-hud { position: absolute; inset: 0; pointer-events: none; }
.live-dock {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(460px, 78%);
  pointer-events: auto;
}
.live-now {
  font-size: 12px;
  line-height: 1.45;
  color: #f6eeff;
  background: rgba(8, 6, 14, 0.78);
  border: 1px solid rgba(255, 74, 210, 0.4);
  border-radius: 999px;
  padding: 6px 12px;
}
.live-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.live-acts button {
  border: 1px solid rgba(122, 240, 255, 0.45);
  background: rgba(10, 8, 18, 0.82);
  color: #e8fbff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.minimap {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 156px;
  height: 156px;
  z-index: 5;
  border-radius: 16px;
  border: 1px solid rgba(246, 239, 226, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.yard-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 4;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #f6efe2;
  background: rgba(8, 6, 14, 0.72);
  border: 1px solid rgba(232, 195, 106, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
  pointer-events: none;
}
.stage-wait {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  color: #e8c36a;
  letter-spacing: 0.18em;
  font-size: 14px;
  pointer-events: none;
}
.hud-empty, .hud-name, .hud-bubble, .hud-mark {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  white-space: nowrap;
}
.hud-empty {
  background: rgba(107, 47, 61, .85);
  color: var(--gold);
  border: 1px solid rgba(232,195,106,.35);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.hud-name {
  color: var(--gold);
  font-size: 11px;
  pointer-events: auto;
  text-shadow: 0 1px 3px #000;
}
.hud-name.watch { opacity: .75; font-size: 11px; }
.hud-bubble {
  background: var(--paper);
  color: #3a241c;
  padding: 6px 10px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.35;
  max-width: 168px;
  white-space: normal;
  word-break: break-word;
  text-align: left;
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  pointer-events: none;
}
.hud-bubble.long {
  max-height: 3.9em;
  overflow: hidden;
}
.hud-bubble.long span {
  display: block;
  animation: rise-read 9s linear infinite;
}
@keyframes rise-read {
  0%, 16% { transform: translateY(0); }
  84%, 100% { transform: translateY(calc(-100% + 3.6em)); }
}
.hud-mark {
  transform: translate(-50%, -120%);
  pointer-events: none;
  color: #f6efe2;
  font-size: 13px;
  letter-spacing: .14em;
  text-shadow: 0 1px 2px #000;
  background: rgba(12, 16, 22, .5);
  border: 1px solid rgba(246, 239, 226, .28);
  border-radius: 999px;
  padding: 2px 8px;
}
.table {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(34vw, 280px);
  height: min(18vw, 140px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 40%, #c47a3a, #6e3a1e 72%);
  box-shadow:
    0 0 0 10px #4a2616,
    0 18px 40px rgba(0,0,0,.45);
}
.table .pot {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 42px;
  height: 36px;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #7eb8a6, #3d6b5c);
  border-radius: 40% 40% 48% 48%;
  box-shadow: inset 0 -6px 0 #2d4f46;
}
.table .pot::before {
  content: "";
  position: absolute;
  left: 14px;
  top: -8px;
  width: 14px;
  height: 10px;
  background: #2d4f46;
  border-radius: 4px;
}

.seat {
  position: absolute;
  width: 132px;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
  background: none;
  border: 0;
  color: inherit;
  padding: 0;
  overflow: visible;
}
.seat .doll-wrap { width: 118px; }
.seat .doll { width: 118px; height: 172px; filter: drop-shadow(0 10px 8px rgba(0,0,0,.35)); }
.seat.empty .pad {
  width: 72px;
  height: 26px;
  margin: 90px auto 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #7a3846, #3d1c26);
  opacity: .85;
  box-shadow: 0 0 0 2px rgba(232,195,106,.18);
}
.seat.empty { cursor: pointer; }
.seat.empty:hover .pad { box-shadow: 0 0 0 2px var(--gold); }
.seat .nm {
  font-size: 12px;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
  margin-top: -8px;
}
.seat.host .nm::after { content: " · 房主"; opacity: .7; }
.seat .bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 8px);
  transform: translateX(-50%);
  background: var(--paper);
  color: #3a241c;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  width: max-content;
  max-width: none;
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  animation: pop .2s ease;
  pointer-events: none;
  letter-spacing: .02em;
}
.seat .bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: var(--paper);
  border-bottom: 0;
}

.watch-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.watcher {
  position: absolute;
  width: 54px;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: auto;
  z-index: 1;
}
.watcher .doll { width: 46px; height: 78px; opacity: .92; }
.watcher .nm { font-size: 10px; opacity: .75; white-space: nowrap; }

.lantern {
  position: absolute;
  width: 18px;
  height: 26px;
  border-radius: 8px 8px 10px 10px;
  background: radial-gradient(circle at 50% 40%, #ffd08a, #e0893a);
  box-shadow: 0 0 24px rgba(240, 163, 90, .75);
}
.lantern::before {
  content: "";
  position: absolute;
  left: 7px;
  top: -14px;
  width: 2px;
  height: 14px;
  background: #c9a36a;
}

.board {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(28,16,24,.94), rgba(12,8,12,.96));
  border: 1px solid rgba(232,195,106,.22);
  border-radius: 18px;
  overflow: hidden;
}
.board-hd {
  padding: 10px 14px 8px;
  letter-spacing: .32em;
  color: var(--gold);
  font-size: 12px;
  border-bottom: 1px solid rgba(232,195,106,.12);
}
.board-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 8px;
  font-size: 13px;
  line-height: 1.55;
}
.board-log .line { margin: 0 0 8px; word-break: break-word; }
.board-log .who { color: var(--gold); font-weight: 700; margin-right: 6px; }
.board-log .tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .12em;
  padding: 0 5px;
  margin-right: 6px;
  border-radius: 999px;
  border: 1px solid rgba(232,195,106,.28);
  color: rgba(255,244,228,.55);
  transform: translateY(-1px);
}
.board-log .line.sit .tag { color: var(--gold); border-color: rgba(232,195,106,.45); }
.board-log .line.me .txt { color: #fff6e4; }
.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0,0,0,.28);
  border-top: 1px solid rgba(255,244,228,.08);
  padding: 8px;
}
.emoji-row { display: flex; flex-wrap: wrap; gap: 4px; }
.emo {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  background: rgba(255,244,228,.06);
  border: 1px solid rgba(255,244,228,.08);
  font-size: 16px;
  line-height: 1;
}
.say-row { display: flex; gap: 8px; align-items: center; }
.say-row input { flex: 1; border: 0; background: transparent; color: inherit; outline: none; min-width: 0; }
.board-opt {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 12px;
  opacity: .8;
  white-space: nowrap;
}
.board-opt input { width: auto; accent-color: #e8c36a; }
.hint { font-size: 11px; opacity: .45; width: 42px; text-align: right; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #3a241c;
  color: var(--paper);
  border: 1px solid var(--gold);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 30;
}

.person-menu {
  position: fixed;
  z-index: 25;
  background: #22141e;
  border: 1px solid rgba(232,195,106,.3);
  border-radius: 12px;
  padding: 6px;
  min-width: 120px;
}
.person-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--paper);
  border: 0;
  padding: 8px 10px;
  border-radius: 8px;
}
.person-menu button:hover { background: rgba(232,195,106,.12); }

.doll-wrap {
  display: inline-block;
  transform-origin: 50% 90%;
  animation: au-beat var(--beat, 2.4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform;
}
.doll-wrap.stand { transform-origin: 50% 96%; }
.doll .eyes { transform-origin: 70px 78px; animation: blink 5.4s infinite; }
@keyframes au-beat {
  0%, 100% { transform: rotate(calc(var(--tilt, 3deg) * -1)) translateY(0); }
  32% { transform: rotate(calc(var(--tilt, 3deg) * .25)) translateY(-6px); }
  68% { transform: rotate(var(--tilt, 3deg)) translateY(-2px); }
}
@keyframes blink {
  0%, 88%, 100% { transform: scaleY(1); }
  91% { transform: scaleY(.08); }
}
@keyframes pop { from { transform: translateX(-50%) scale(.86); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

@media (max-width: 860px) {
  .atelier { grid-template-columns: 1fr; }
  .preview-stage { min-height: 280px; }
  .preview-stage .doll { width: 140px; height: 240px; }
  .room-main { grid-template-columns: 1fr; }
  .board { min-height: 180px; }
  .seat { width: 96px; }
  .seat .doll { width: 86px; height: 126px; }
}
