/* 赛博扫墓 · 界面样式 */
:root {
  --accent: #e6b06a;
  --accent-soft: rgba(230, 176, 106, 0.16);
  --ink: #ece7de;
  --ink-dim: #a09a91;
  --glass: rgba(13, 16, 23, 0.62);
  --glass-2: rgba(16, 19, 27, 0.86);
  --line: rgba(255, 255, 255, 0.10);
  --serif: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "SimSun", "Noto Serif SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: #04060b;
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

/* 留言弹幕：压在场景之上、界面之下，不拦鼠标事件 */
#danmaku {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  pointer-events: none;
}
body.hide-ui #danmaku { display: none !important; }

.hud { position: fixed; z-index: 6; }

/* ---------- 顶部 ---------- */
.top {
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  color: var(--accent);
  background: linear-gradient(155deg, var(--accent-soft), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(230, 176, 106, 0.32);
  box-shadow: inset 0 0 22px rgba(230, 176, 106, 0.14);
  transition: color .4s, border-color .4s;
}
.brand-mark svg { width: 24px; height: 24px; }

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.22em;
  font-family: var(--serif);
}
.brand-text p {
  margin: 3px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}

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

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform .18s, border-color .25s, color .25s;
}
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { transform: translateY(-1px); border-color: rgba(230, 176, 106, 0.5); color: var(--accent); }
.icon-btn:active { transform: translateY(0) scale(0.96); }

#btnSound .ico-on { display: none; }
#btnSound.on { color: var(--accent); border-color: rgba(230, 176, 106, 0.5); }
#btnSound.on .ico-on { display: block; }
#btnSound.on .ico-off { display: none; }

/* 弹幕开关：关掉时整颗按钮变暗 */
#btnDanmaku:not(.on) { opacity: .5; }
#btnDanmaku.on { color: var(--accent); border-color: rgba(230, 176, 106, 0.5); }

/* ---------- 底部供奉栏 ---------- */
.bottom {
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 8px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  max-width: calc(100vw - 20px);
}

.offer {
  min-width: 74px;
  padding: 9px 8px 7px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: transform .18s, background .2s, border-color .2s, color .2s;
}
.offer svg { width: 22px; height: 22px; opacity: 0.8; transition: color .2s, opacity .2s, transform .3s; }
.offer:hover { background: rgba(255, 255, 255, 0.055); border-color: var(--line); transform: translateY(-2px); }
.offer:hover svg { opacity: 1; color: var(--accent); transform: scale(1.06); }
.offer:active { transform: translateY(0) scale(0.96); }

.offer.primary {
  color: #21160a;
  background: linear-gradient(160deg, var(--accent), #c68f48);
  box-shadow: 0 8px 22px rgba(230, 176, 106, 0.24);
  margin-left: 2px;
}
.offer.primary svg { opacity: 0.95; color: inherit; }
.offer.primary:hover { background: linear-gradient(160deg, #f0bd79, #cf9850); }
.offer.primary:hover svg { color: inherit; }

/* ---------- 侧栏 ---------- */
.panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: 352px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: var(--glass-2);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  z-index: 20;
  transform: translateX(103%);
  transition: transform .42s cubic-bezier(.22, .8, .24, 1);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
}
body.panel-open .panel { transform: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--accent);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 30px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 3px; }

.sec { padding: 16px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: none; }
.sec h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.26em;
  color: var(--accent);
  opacity: 0.9;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field span { font-size: 11.5px; letter-spacing: 0.1em; color: var(--ink-dim); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row + .row { margin-top: 8px; }

input:not([type=range]):not([type=file]), textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  margin-bottom: 10px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus {
  border-color: rgba(230, 176, 106, 0.55);
  box-shadow: 0 0 0 3px rgba(230, 176, 106, 0.10);
}
input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, 0.22); }

.btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .2s, color .2s, transform .15s, border-color .2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.2); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--ink-dim); }
.btn.ghost:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .2s;
}
.chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.22); }
.chip.on {
  color: #21160a;
  font-weight: 600;
  border-color: transparent;
  background: linear-gradient(160deg, var(--accent), #c68f48);
}

.drop {
  position: relative;
  height: 138px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.26);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop:hover { border-color: rgba(230, 176, 106, 0.6); }
.drop.over { border-color: var(--accent); background: rgba(230, 176, 106, 0.10); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.drop.has img { display: block; }
.drop.has .drop-hint { display: none; }
.drop-hint { display: flex; flex-direction: column; gap: 5px; text-align: center; }
.drop-hint strong { font-size: 13px; font-weight: 500; color: var(--ink); letter-spacing: 0.06em; }
.drop-hint span { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.12em; }

.slider {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(230, 176, 106, 0.5);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

.stat {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
  line-height: 1.6;
}
.tip {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.32);
  letter-spacing: 0.04em;
}

/* ---------- 提示 / 鞠躬 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 108px;
  z-index: 30;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(9, 11, 17, 0.88);
  border: 1px solid rgba(230, 176, 106, 0.32);
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity .35s, transform .35s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.bow-layer {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 44%, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.74) 100%);
  transition: opacity .7s;
}
.bow-layer.show { opacity: 1; }
.bow-text {
  font-family: var(--serif);
  font-size: clamp(26px, 5.4vw, 52px);
  letter-spacing: 0.32em;
  color: rgba(255, 241, 217, 0.95);
  text-shadow: 0 0 46px rgba(230, 176, 106, 0.55);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .55s, transform .9s;
  padding-left: 0.32em;
}
.bow-text.show { opacity: 1; transform: none; }

.hint {
  position: fixed;
  left: 18px;
  bottom: 22px;
  z-index: 6;
  max-width: 46vw;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
  background: rgba(10, 12, 18, 0.5);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 13px;
  backdrop-filter: blur(10px);
  transition: opacity .8s;
}
.hint.hide { opacity: 0; }

/* ---------- 隐藏界面 ---------- */
body.hide-ui .hud,
body.hide-ui .panel,
body.hide-ui .hint { opacity: 0; pointer-events: none; transition: opacity .6s; }
body.hide-ui { cursor: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 15px; letter-spacing: 0.18em; }

  .bottom {
    left: 0; right: 0;
    bottom: 0;
    transform: none;
    max-width: none;
    border-radius: 18px 18px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    overflow-x: hidden;
    justify-content: space-between;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    scrollbar-width: none;
  }
  .bottom::-webkit-scrollbar { display: none; }
  .offer { flex: 1 1 0; min-width: 0; font-size: 11px; letter-spacing: 0.02em; padding: 7px 2px 6px; }
  .offer svg { width: 20px; height: 20px; }

  .panel {
    top: auto; bottom: 0;
    width: 100%; max-width: none;
    height: auto;
    max-height: 84vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    transform: translateY(103%);
  }
  body.panel-open .panel { transform: none; }

  .hint { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); max-width: 70vw; font-size: 11px; }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); font-size: 12px; }
}

/* ---------- 留言簿 ---------- */
/* .row / .field 自带 display:flex，会盖掉 [hidden] 的 display:none，这里兜住 */
[hidden] { display: none !important; }

#btnGuest { position: relative; }

.badge {
  position: absolute;
  top: -3px; right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #1b1206;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  letter-spacing: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.badge[hidden] { display: none; }

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(3, 6, 11, 0.6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s;
}
body.guest-open .sheet-mask { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%; top: 50%;
  z-index: 31;
  width: 540px;
  max-width: 92vw;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.97);
  transition: opacity .28s, transform .34s cubic-bezier(.22, .8, .24, 1);
}
body.guest-open .sheet {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.sheet-stat {
  margin-left: auto;
  margin-right: 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-form { padding-top: 16px; }
.msg-form #msgName { flex: 1; }
.msg-form .btn { flex: 0 0 auto; min-width: 100px; }
.msg-form textarea { margin-top: 8px; resize: vertical; min-height: 68px; }
.msg-form .chips { margin-top: 10px; }
.msg-form .tip { margin: 10px 0 0; }

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-bottom: 6px;
}

.msg {
  position: relative;
  padding: 10px 13px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.032);
}
.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-dim);
}
.msg-head strong {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.msg-head time { margin-left: auto; font-size: 10.5px; opacity: 0.75; }
.msg-tag {
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(230, 176, 106, 0.14);
  border: 1px solid rgba(230, 176, 106, 0.26);
}
.msg p {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-del {
  position: absolute;
  right: 9px;
  bottom: 7px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-dim);
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity .2s, color .2s;
}
.msg-del:hover { opacity: 1; color: #e08a7a; }
.msg-del:disabled { opacity: 0.25; cursor: default; }
.msg-empty {
  margin: 0;
  padding: 30px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-dim);
}

@media (max-width: 820px) {
  .sheet {
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%;
    max-width: none;
    max-height: 86vh;
    border-radius: 20px 20px 0 0;
    opacity: 1;
    transform: translateY(104%);
  }
  body.guest-open .sheet { transform: none; }
  .sheet-stat { display: none; }
}

/* 系统开了「减弱动态效果」就不做过渡 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
