* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1220; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* 加载页 */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1b2a44, #0b1220); transition: opacity .6s ease; }
#loading.hide { opacity: 0; pointer-events: none; }
.loader-box { text-align: center; color: #dce6f5; }
.spinner { width: 54px; height: 54px; margin: 0 auto 18px; border: 4px solid rgba(255,255,255,.15);
  border-top-color: #6fb1ff; border-radius: 50%; animation: spin 1s linear infinite; }
.loader-text { font-size: 18px; font-weight: 600; letter-spacing: 1px; }
.loader-sub { font-size: 12px; opacity: .65; margin-top: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 顶栏 */
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; background: linear-gradient(180deg, rgba(8,14,26,.78), rgba(8,14,26,0)); color: #eaf1fb; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand .logo { font-size: 22px; }
.brand .title { font-size: 18px; font-weight: 700; }
.brand .sub { font-size: 12px; opacity: .6; }
#floors { display: flex; gap: 6px; margin-left: 8px; }
#times { display: flex; gap: 6px; margin-left: 8px; }
#times button { background: rgba(255,255,255,.08); color: #dbe6f5; border: 1px solid rgba(255,255,255,.12);
  padding: 7px 10px; border-radius: 9px; font-size: 12px; cursor: pointer; transition: .15s; white-space: nowrap; }
#times button:hover { background: rgba(255,255,255,.18); }
#times button.active { background: #f59e0b; border-color: #fbbf24; color: #fff; }
#floors button, .mode-switch button { background: rgba(255,255,255,.08); color: #dbe6f5; border: 1px solid rgba(255,255,255,.12);
  padding: 7px 12px; border-radius: 9px; font-size: 13px; cursor: pointer; transition: .15s; }
#floors button:hover, .mode-switch button:hover { background: rgba(255,255,255,.18); }
#floors button.active { background: #3b82f6; border-color: #60a5fa; color: #fff; }
.mode-switch { margin-left: auto; display: flex; gap: 6px; }
.mode-switch button.active { background: #10b981; border-color: #34d399; color: #fff; }

/* 配色面板 —— 缩小 + 可折叠 */
#panel {
  position: fixed; top: 62px; right: 10px; z-index: 20; width: 186px; padding: 11px;
  background: rgba(13,20,34,.9); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.1);
  border-radius: 13px; color: #e7eefb; box-shadow: 0 10px 30px rgba(0,0,0,.42);
  max-height: calc(100vh - 130px); overflow-y: auto;
  transition: transform .22s ease, opacity .22s ease;
}
/* 折叠状态：滑出屏幕右侧 */
#panel.collapsed { transform: translateX(calc(100% + 16px)); opacity: 0; pointer-events: none; }

/* 面板开关小按钮 */
#panelToggle {
  position: fixed; top: 62px; right: 10px; z-index: 21;
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(255,255,255,.16);
  background: rgba(13,20,34,.9); color: #fff; font-size: 19px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); transition: .18s;
}
#panelToggle:hover { background: rgba(30,42,64,.96); }
#panelToggle.open { opacity: 0; pointer-events: none; }

.panel-head { font-size: 13px; font-weight: 700; margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; }
.panel-head .close { cursor: pointer; opacity: .65; font-size: 16px; line-height: 1; padding: 0 2px; }
.panel-head .close:hover { opacity: 1; }
.field { display: block; margin-bottom: 9px; }
.field > span { display: block; font-size: 11px; opacity: .7; margin-bottom: 5px; }
#roomSelect { width: 100%; padding: 7px 8px; border-radius: 8px; background: #0f1726; color: #e7eefb;
  border: 1px solid rgba(255,255,255,.14); font-size: 12px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 9px; }
.swatches .sw { width: 100%; aspect-ratio: 1; border-radius: 6px; cursor: pointer; border: 2px solid rgba(255,255,255,.15); transition: .12s; }
.swatches .sw:hover { transform: scale(1.12); border-color: #fff; }
.field.custom input[type=color] { width: 100%; height: 32px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: #0f1726; cursor: pointer; }
.panel-actions { display: flex; gap: 6px; }
.panel-actions button { flex: 1; padding: 7px; border-radius: 8px; border: none; font-size: 12px; cursor: pointer; font-weight: 600; }
#applyColor { background: #3b82f6; color: #fff; }
#applyColor:hover { background: #2f6fe0; }
#resetColor { background: rgba(255,255,255,.1); color: #dbe6f5; }
.hint { font-size: 10px; opacity: .55; margin-top: 9px; line-height: 1.45; }

/* 手机端：顶栏与面板更紧凑 */
@media (max-width: 640px) {
  #topbar { flex-wrap: wrap; gap: 6px; padding: 7px 9px; }
  .brand .sub { display: none; }
  .brand .title { font-size: 14px; }
  #floors { margin-left: 0; flex-wrap: wrap; }
  #floors button { padding: 5px 8px; font-size: 11px; border-radius: 7px; }
  #times { margin-left: 0; flex-wrap: wrap; }
  #times button { padding: 5px 7px; font-size: 11px; border-radius: 7px; }
  .mode-switch { margin-left: 0; }
  .mode-switch button { padding: 5px 8px; font-size: 11px; }
  #panel { width: 168px; top: 116px; right: 8px; padding: 9px; }
  #panelToggle { top: 116px; right: 8px; }
  #help { font-size: 11px; padding: 8px 10px; }
  .swatches { grid-template-columns: repeat(6, 1fr); gap: 4px; }
}

/* 底部帮助 */
#help { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; padding: 12px 18px; text-align: center;
  background: linear-gradient(0deg, rgba(8,14,26,.78), rgba(8,14,26,0)); color: #cdd9ec; font-size: 13px; }
#help kbd { background: rgba(255,255,255,.12); border-radius: 4px; padding: 1px 6px; margin: 0 2px; font-size: 12px; }
#help b { color: #fff; }

#crosshair { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 15; color: rgba(255,255,255,.7); font-size: 22px; pointer-events: none; }

.hidden { display: none !important; }

/* ── 手机虚拟摇杆 ── */
#joystick {
  position: fixed; left: 22px; bottom: 58px; z-index: 30;
  width: 116px; height: 116px; border-radius: 50%;
  background: rgba(10,18,32,.42); border: 2px solid rgba(255,255,255,.22);
  backdrop-filter: blur(3px); touch-action: none;
  display: none;
}
#joyKnob {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.82); box-shadow: 0 3px 12px rgba(0,0,0,.35);
  pointer-events: none;
}
#lookArea {
  position: fixed; right: 0; bottom: 0; top: 96px; width: 58%; z-index: 12;
  touch-action: none; display: none;
}
body.walk-mode #joystick,
body.walk-mode #lookArea { display: block; }

/* ── 手机 HUD（天气/时间提示）── */
#hud {
  position: fixed; left: 12px; top: 60px; z-index: 25;
  padding: 7px 12px; border-radius: 10px;
  background: rgba(13,20,34,.78); border: 1px solid rgba(255,255,255,.12);
  color: #e7eefb; font-size: 12px; backdrop-filter: blur(6px);
}

@media (max-width: 640px) {
  #toast { left: 12px; right: 12px; transform: translateY(-14px); text-align: center; }
  #toast.show { transform: translateY(0); }
}

/* ── 顶部轻提示（进入房间提示）── */
#toast {
  position: fixed; top: 74px; left: 50%; transform: translate(-50%, -14px); z-index: 40;
  padding: 9px 18px; border-radius: 11px;
  background: rgba(11,18,32,.9); border: 1px solid rgba(255,255,255,.16);
  color: #fff; font-size: 13px; letter-spacing: .3px;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  backdrop-filter: blur(8px); white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
