/* 月儿的世界 v2 · UI 样式（P0：加载屏 + 调试 HUD；P3~P5 扩展对话通栏/背包/小店） */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { width: 100%; height: 100%; overflow: hidden; background: #dfeff8; }

#game { display: block; width: 100%; height: 100%; }

#loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #dff1e4, #cfe8ff);
  color: #3a5a40; font-family: "Microsoft YaHei", sans-serif;
  transition: opacity 0.5s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
#loading .title { font-size: 34px; font-weight: 700; letter-spacing: 2px; }
#loading .sub { margin-top: 12px; font-size: 17px; opacity: 0.75; }

/* 调试 HUD：S4 起默认隐藏（左上角数据面板已删），仅 ?selftest=1 自测模式由 JS 显示 */
#hud {
  display: none;
  position: fixed; left: 12px; top: 12px; z-index: 50;
  padding: 10px 14px; border-radius: 12px;
  background: rgba(20, 40, 60, 0.55); color: #eaf6ff;
  font-family: Consolas, monospace; font-size: 13px; line-height: 1.7;
  pointer-events: none; white-space: pre;
}

/* S4 版本号：右下角固定显示 */
#version-tag {
  position: fixed; right: 10px; bottom: 8px; z-index: 55;
  color: rgba(255, 255, 255, 0.78); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  font-family: "Microsoft YaHei", sans-serif; font-size: 12px;
  pointer-events: none; user-select: none;
}

#hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50;
  padding: 8px 18px; border-radius: 999px;
  background: rgba(20, 40, 60, 0.45); color: #fff;
  font-family: "Microsoft YaHei", sans-serif; font-size: 14px;
  pointer-events: none;
}

/* ==== S2 史莱姆王国风格左上控制面板（完全参考 castle-island.html #ui 排版逻辑） ==== */
#ui {
  position: fixed; top: 14px; left: 14px; z-index: 60;
  color: #fff; user-select: none;
  background: rgba(10, 16, 28, 0.42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px;
  padding: 14px 16px 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  min-width: 232px; max-width: 340px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
#ui h1 { font-size: 15px; margin: 0 0 2px; letter-spacing: 0.5px; font-weight: 600; }
#ui .sub { font-size: 10.5px; opacity: 0.62; margin-bottom: 10px; }

.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.wbtn {
  flex: 1 1 auto; min-width: 72px; padding: 7px 4px; font-size: 12.5px; border-radius: 9px; cursor: pointer;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.07); color: #eef4fb;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  transition: background .18s, border-color .18s, transform .12s;
}
.wbtn:hover { background: rgba(255, 255, 255, 0.16); }
.wbtn:active { transform: scale(0.96); }
.wbtn.on, .wbtn.active { background: rgba(120, 208, 220, 0.30); border-color: rgba(160, 230, 240, 0.75); }
.wbtn.locked {
  opacity: 0.45; filter: grayscale(0.85); cursor: not-allowed;
}
.wbtn.locked:hover { background: rgba(255, 255, 255, 0.07); }
.wbtn small { display: block; opacity: 0.6; font-size: 10px; margin-top: 1px; }

.section-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: 1px;
  opacity: 0.75; margin: 2px 0 6px;
}
.section-label small { font-weight: 400; opacity: 0.7; font-size: 10.5px; }

.slider-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; opacity: 0.92; }
.slider-row .slabel { flex: none; }
.slider-row input[type=range] { flex: 1; min-width: 90px; accent-color: #7ad0dc; cursor: pointer; }
#hour-label { width: 42px; text-align: right; font-variant-numeric: tabular-nums; opacity: 0.85; }
.chk-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; margin: -4px 0 10px; opacity: 0.92; cursor: pointer; }
.chk-row input { accent-color: #7ad0dc; cursor: pointer; }

/* 吐司提示（interaction.js toast） */
#toast-box {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 9px 18px; border-radius: 999px;
  background: rgba(40, 30, 70, 0.82); color: #fff;
  font-family: "Microsoft YaHei", sans-serif; font-size: 15px;
  opacity: 0; transform: translateY(-8px); transition: all 0.35s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* 对话通栏（P3：方案 7.2 —— 底部半透明深色通栏 + 头像/名字标签 + 打字机正文 + 圆角选项按钮） */
#dialogue-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px 22px;
  background: rgba(16, 10, 24, 0.55);
  transform: translateY(110%); transition: transform 0.28s ease;
}
#dialogue-bar.show { transform: translateY(0); }
#dialogue-bar .dlg-avatar {
  flex: none; width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.14); font-size: 40px;
}
#dialogue-bar .dlg-body { flex: 1; min-width: 0; }
#dialogue-bar .dlg-name {
  color: #ffd98a; font-family: "Microsoft YaHei", sans-serif;
  font-size: 17px; font-weight: 700; margin-bottom: 4px;
}
#dialogue-bar .dlg-text {
  color: #fff; font-family: "Microsoft YaHei", sans-serif;
  font-size: 27px; line-height: 1.6; min-height: 1.6em;
}
#dialogue-bar .dlg-choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#dialogue-bar .dlg-choices button {
  padding: 10px 20px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.14); color: #fff;
  font-family: "Microsoft YaHei", sans-serif; font-size: 16px; cursor: pointer;
  transition: all 0.18s ease;
}
#dialogue-bar .dlg-choices button:hover { background: #ffb35c; color: #4a2c00; border-color: #fff; }

/* 旅行包/成就/云备份按钮（S2 起已迁入 #ui 面板，统一走 .wbtn 样式，旧胶囊样式已删） */

/* 蛋仔式旅行包面板（P4：五分类竖排 + 中央 3D 预览 + 格子列表 + 月亮币） */
#pack-panel {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center;
  background: rgba(16, 10, 24, 0.5);
  font-family: "Microsoft YaHei", sans-serif;
}
#pack-panel.show { display: flex; }
.pack-window {
  display: flex; flex-direction: column;
  width: min(1080px, 94vw); height: min(680px, 88vh);
  background: linear-gradient(165deg, #fff7ec, #fdeed8);
  border: 3px solid rgba(255, 255, 255, 0.8); border-radius: 22px;
  box-shadow: 0 18px 50px rgba(40, 24, 8, 0.35);
  overflow: hidden;
}
.pack-top {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px 10px;
}
.pack-title { font-size: 22px; font-weight: 700; color: #7a4a12; }
.pack-coin {
  margin-left: auto; padding: 6px 14px; border-radius: 999px;
  background: #ffe9b8; color: #7a4a12; font-size: 15px;
}
.pack-close {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: #f3d9b8; color: #7a4a12; font-size: 17px; cursor: pointer;
}
.pack-close:hover { background: #ffb35c; }
.pack-main { flex: 1; display: flex; gap: 14px; padding: 6px 20px 18px; min-height: 0; }

.pack-cats { flex: none; width: 96px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.pack-cat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 6px; border-radius: 16px; border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.65); color: #7a4a12;
  font-family: "Microsoft YaHei", sans-serif; font-size: 15px; cursor: pointer;
  transition: all 0.18s ease;
}
.pack-cat .pack-cat-ic { font-size: 24px; }
.pack-cat:hover { background: #ffe4bd; }
.pack-cat.on { background: #ffb35c; border-color: #fff; color: #4a2c00; font-weight: 700; }

.pack-preview {
  flex: 1.15; min-width: 0; display: flex; flex-direction: column; align-items: center;
  padding: 12px 14px; border-radius: 18px;
  background: radial-gradient(120% 90% at 50% 18%, #fffdf6 0%, #f7e6c8 100%);
}
.pack-canvas { width: 100%; flex: 1; min-height: 0; display: block; cursor: grab; }
.pack-pv-icon {
  width: 100%; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  font-size: 96px;
}
.pack-pv-icon img { width: 110px; height: 110px; }
.pack-pv-name { margin-top: 6px; font-size: 20px; font-weight: 700; color: #5c3a10; }
.pack-pv-desc {
  margin-top: 6px; font-size: 14px; line-height: 1.55; color: #8a6a42;
  max-height: 74px; overflow-y: auto; text-align: center;
}
.pack-pv-desc .pack-usable { color: #b07d2f; font-size: 13px; }
.pack-pv-actions { display: flex; gap: 10px; margin-top: 10px; }
.pack-act {
  padding: 9px 22px; border-radius: 999px; border: 2px solid #fff;
  background: #ffb35c; color: #4a2c00;
  font-family: "Microsoft YaHei", sans-serif; font-size: 16px; font-weight: 700; cursor: pointer;
}
.pack-act:hover { background: #ff9d3d; }

.pack-right { flex: 1.25; min-width: 0; display: flex; flex-direction: column; }
.pack-subs { display: flex; gap: 8px; margin-bottom: 10px; }
.pack-sub {
  padding: 6px 16px; border-radius: 999px; border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.65); color: #7a4a12;
  font-family: "Microsoft YaHei", sans-serif; font-size: 14px; cursor: pointer;
}
.pack-sub.on { background: #ffb35c; border-color: #fff; color: #4a2c00; font-weight: 700; }
.pack-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px;
  align-content: start; padding-right: 4px;
}
.pack-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px 8px; border-radius: 14px; border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.72); color: #5c3a10;
  font-family: "Microsoft YaHei", sans-serif; cursor: pointer;
  transition: all 0.15s ease;
}
.pack-cell:hover { transform: translateY(-2px); background: #fff; }
.pack-cell.on { border-color: #ffb35c; background: #fff; }
.pack-cell.owned-none { opacity: 0.45; }
.pack-cell-ic { font-size: 30px; line-height: 1.2; }
.pack-cell-ic img { width: 30px; height: 30px; }
.pack-cell-name { font-size: 13px; font-weight: 700; }
.pack-cell-n { font-size: 12px; color: #a2763c; }
.pack-empty {
  grid-column: 1 / -1; padding: 30px 10px; text-align: center;
  color: #a2763c; font-size: 15px; line-height: 1.8;
}

/* ---- P5 美食小摊面板（购买美食 / 兑换装饰） ---- */
#foodshop-panel, #museum-panel {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center;
  background: rgba(16, 10, 24, 0.5);
  font-family: "Microsoft YaHei", sans-serif;
}
#foodshop-panel.show, #museum-panel.show { display: flex; }
.shop-window { height: auto; max-height: min(680px, 88vh); }
.shop-body { padding: 6px 22px 20px; overflow-y: auto; }
.shop-section h3 { font-size: 17px; color: #7a4a12; margin: 10px 0 6px; }
.shop-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 14px; margin: 6px 0;
  background: rgba(255, 255, 255, 0.65);
}
.shop-row .shop-ic { font-size: 28px; flex: none; }
.shop-row .shop-info { flex: 1; min-width: 0; }
.shop-row .shop-name { font-size: 15px; font-weight: 700; color: #5c3a10; }
.shop-row .shop-desc { font-size: 12px; color: #a2763c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-row .shop-price { font-size: 14px; font-weight: 700; color: #b07d2f; flex: none; }
.shop-row .shop-owned { font-size: 13px; color: #a2763c; flex: none; min-width: 34px; text-align: right; }
.shop-row .shop-buy { padding: 7px 16px; font-size: 14px; flex: none; }
.shop-tip {
  margin-top: 12px; padding: 9px 14px; border-radius: 12px;
  background: #ffe9b8; color: #7a4a12; font-size: 13px;
}

/* ---- P5 图鉴博物馆（灰色剪影未收集态） ---- */
.museum-grid .pack-cell.locked .pack-cell-ic { filter: grayscale(1); opacity: 0.5; }
.museum-grid .pack-cell.locked .pack-cell-name { color: #b6a488; }

/* ---- P6 成就奖励 / 云备份面板（复用 shop-window 口径） ---- */
#reward-panel, #save-panel {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center;
  background: rgba(16, 10, 24, 0.5);
  font-family: "Microsoft YaHei", sans-serif;
}
#reward-panel.show, #save-panel.show { display: flex; }
.reward-list { display: flex; flex-direction: column; }
.voucher-code {
  margin-top: 4px; padding: 6px 10px; border-radius: 10px;
  background: #fff2cf; color: #7a4a12; font-size: 13px;
}
.voucher-code b { font-size: 16px; letter-spacing: 1px; }
.save-code {
  flex: none; width: 170px; padding: 8px 12px; border-radius: 12px;
  border: 2px solid #e8c890; background: #fff; color: #5c3a10;
  font-family: "Microsoft YaHei", sans-serif; font-size: 15px;
}
.save-status { margin: 8px 2px 2px; font-size: 14px; line-height: 1.6; color: #8a6a42; }
.save-status.save-ok { color: #3a7d44; }
.save-status.save-err { color: #c2554a; }
.save-status.save-busy { color: #4a90d9; }

/* ---- 移动端专项排版（P6 总验收补 + S2 UI 重排适配）：标题不折行、面板收窄、隐藏键盘提示 ---- */
@media (max-width: 640px) {
  .pack-title { font-size: 18px; white-space: nowrap; }
  .pack-top { padding: 10px 12px; }
  .pack-coin { font-size: 11px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pack-window { max-height: 92vh; }
  #ui { left: 8px; top: 8px; min-width: 200px; max-width: calc(100vw - 16px); padding: 10px 12px 8px; }
  #ui h1 { font-size: 14px; }
  .wbtn { min-width: 64px; padding: 6px 3px; font-size: 11.5px; }
  #hint { display: none; }   /* 移动端无键盘，按键提示无意义且与底栏重叠 */
  #version-tag { right: 6px; bottom: 5px; font-size: 10.5px; }
}

/* ==== S5 R 键道具轮盘 + 已装备徽标（js/ui/item-wheel.js） ==== */
#item-wheel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 75;
  display: none; padding: 18px 22px 14px; border-radius: 16px;
  background: rgba(12, 20, 34, 0.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.16); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif; user-select: none;
}
#item-wheel.show { display: block; }
#item-wheel .iw-title {
  font-size: 14px; font-weight: 700; color: #ffe08a; letter-spacing: 2px;
  text-align: center; margin-bottom: 12px;
}
#item-wheel .iw-grid { display: flex; gap: 12px; justify-content: center; }
#item-wheel .iw-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 108px; padding: 14px 8px 10px; border-radius: 12px; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.06); color: #fff8ee;
  font-family: inherit;
  transition: transform .12s, border-color .12s, background .12s;
}
#item-wheel .iw-cell:hover { transform: scale(1.05); border-color: #ffd98a; background: rgba(255, 214, 120, 0.12); }
#item-wheel .iw-cell.iw-held { border-color: #6fff00; background: rgba(111, 255, 0, 0.12); }
#item-wheel .iw-key {
  position: absolute; top: 5px; left: 8px; font-size: 10px; opacity: 0.65;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 5px; padding: 0 5px;
}
#item-wheel .iw-emoji { font-size: 30px; }
#item-wheel .iw-name { font-size: 13px; font-weight: 700; }
#item-wheel .iw-kind { font-size: 10.5px; opacity: 0.62; }
#item-wheel .iw-hint {
  font-size: 10.5px; color: rgba(255, 235, 200, 0.55); margin-top: 12px;
  text-align: center; letter-spacing: 0.5px;
}

/* 已装备徽标（右下角、版本号上方；装备/切换时闪一下） */
#equip-badge {
  position: fixed; right: 10px; bottom: 34px; z-index: 56;
  display: none; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: rgba(20, 40, 60, 0.62); border: 1px solid rgba(255, 216, 138, 0.5);
  color: #fff; font-family: "Microsoft YaHei", sans-serif; font-size: 12.5px;
  pointer-events: none; user-select: none;
}
#equip-badge.show { display: flex; }
#equip-badge.flash { animation: eb-flash .5s ease; }
#equip-badge .eb-emoji { font-size: 18px; }
#equip-badge small { display: block; opacity: 0.68; font-size: 10px; }
@keyframes eb-flash {
  0% { transform: scale(1.12); background: rgba(255, 216, 138, 0.5); }
  100% { transform: scale(1); background: rgba(20, 40, 60, 0.62); }
}
@media (max-width: 640px) {
  #item-wheel { padding: 12px 12px 10px; }
  #item-wheel .iw-cell { width: 82px; padding: 12px 4px 8px; }
  #item-wheel .iw-emoji { font-size: 24px; }
  #equip-badge { right: 6px; bottom: 26px; font-size: 11px; }
}
