/* 造化仙府 — 视觉样式 */
:root {
  --ink: #07141c;
  --ink2: #0d2430;
  --jade: #35b39a;
  --jade-deep: #1d7a68;
  --gold: #e9c46a;
  --gold-deep: #b98a35;
  --ice: #8fd8ff;
  --rose: #ff9fb2;
  --paper: #f2ead6;
  --glass: rgba(10, 32, 42, 0.72);
  --glass-2: rgba(16, 44, 56, 0.86);
  --line: rgba(143, 216, 255, 0.22);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --font-title: "Songti SC", "STSong", "Noto Serif SC", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #050c12;
  color: var(--paper);
  font-family: var(--font-body);
  user-select: none;
}

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

/* ---------- 顶栏 ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: stretch; gap: 10px;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 20;
}
#resbar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px;
  background: linear-gradient(180deg, rgba(10, 34, 45, .88), rgba(6, 20, 28, .78));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}
.res {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 7px 3px 3px;
  border-radius: 11px;
  font-size: 13px;
  background: rgba(255, 255, 255, .04);
  min-width: 74px;
}
.res img { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.res .num { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .3px; }
.res .name { opacity: .62; font-size: 11px; }
.res.rate { font-size: 10px; color: var(--jade); opacity: .9; }

#realmbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(120deg, rgba(233, 196, 106, .16), rgba(10, 34, 45, .82));
  border: 1px solid rgba(233, 196, 106, .35);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}
#realmName {
  font-family: var(--font-title); font-size: 17px; font-weight: 700;
  color: var(--gold); text-shadow: 0 0 14px rgba(233, 196, 106, .55);
  letter-spacing: 2px;
}
#powerVal { font-size: 12px; color: var(--ice); opacity: .85; font-variant-numeric: tabular-nums; }

/* ---------- 左侧功能键 ---------- */
#dock {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px;
  z-index: 20;
}
.dockbtn {
  width: 62px; height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: linear-gradient(180deg, rgba(16, 48, 60, .9), rgba(8, 24, 32, .9));
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--paper);
  font-size: 12px; font-family: var(--font-title); letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.dockbtn:hover { border-color: rgba(143, 216, 255, .55); transform: translateX(2px); }
.dockbtn.active { border-color: var(--gold); box-shadow: 0 0 18px rgba(233, 196, 106, .35); }
.dockbtn .glyph { font-size: 20px; line-height: 1; }
.dockbtn .badge {
  position: absolute; transform: translate(22px, -18px);
  background: var(--rose); color: #3a0a13; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
}

/* ---------- 侧面板 ---------- */
#sidepanel {
  position: absolute; right: 12px; top: 74px; bottom: 12px;
  width: 372px;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(12, 34, 45, .94), rgba(6, 18, 25, .96));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  z-index: 30;
  overflow: hidden;
}
#sidepanel.hidden { display: none; }
#sidepanel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(143, 216, 255, .14);
}
#sidepanel h2 {
  margin: 0; font-family: var(--font-title); font-size: 17px; letter-spacing: 3px;
  color: var(--gold);
}
#panelBody { padding: 12px; overflow-y: auto; flex: 1; }
#panelBody::-webkit-scrollbar { width: 6px; }
#panelBody::-webkit-scrollbar-thumb { background: rgba(143,216,255,.25); border-radius: 3px; }

.iconbtn {
  width: 28px; height: 28px; border-radius: 9px;
  background: rgba(255,255,255,.06); color: var(--paper);
  border: 1px solid var(--line); cursor: pointer; font-size: 13px;
}

/* 卡片 */
.card {
  display: flex; gap: 10px; align-items: center;
  padding: 9px; margin-bottom: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(143, 216, 255, .13);
  border-radius: 13px;
}
.card .thumb { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 10px; background: rgba(0,0,0,.25); display: grid; place-items: center; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-family: var(--font-title); font-size: 14px; letter-spacing: 1px; }
.card .sub { font-size: 11px; opacity: .65; margin-top: 2px; line-height: 1.45; }
.card .meta { font-size: 11px; color: var(--jade); margin-top: 3px; font-variant-numeric: tabular-nums; }
.card button { flex: 0 0 auto; }

.btn {
  padding: 7px 12px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, rgba(53, 179, 154, .9), rgba(29, 122, 104, .9));
  border: 1px solid rgba(143, 216, 255, .35);
  color: #032018; font-weight: 700; font-size: 12px;
  font-family: var(--font-title); letter-spacing: 1px;
  white-space: nowrap;
}
.btn:disabled { background: rgba(120, 130, 140, .25); color: rgba(255,255,255,.4); border-color: rgba(255,255,255,.1); cursor: not-allowed; }
.btn.gold { background: linear-gradient(180deg, rgba(233, 196, 106, .95), rgba(185, 138, 53, .95)); color: #2a1d05; }
.btn.ghost { background: rgba(255,255,255,.06); color: var(--paper); border: 1px solid var(--line); }

.section-title {
  font-family: var(--font-title); font-size: 13px; letter-spacing: 2px;
  color: var(--ice); opacity: .75; margin: 14px 0 8px;
}
.empty { font-size: 12px; opacity: .5; padding: 10px 4px; line-height: 1.6; }

/* 境界进度 */
.realm-progress { margin-bottom: 12px; }
.bar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .2s linear; }

/* ---------- 建造条 ---------- */
#buildbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 14px 14px;
  background: linear-gradient(0deg, rgba(6, 18, 25, .97), rgba(6, 18, 25, .55) 70%, rgba(6, 18, 25, 0));
  z-index: 25;
}
#buildbar.hidden { display: none; }
.buildbar-title { font-family: var(--font-title); font-size: 13px; letter-spacing: 2px; color: var(--gold); margin-bottom: 8px; }
#buildlist { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 4px; }
.buildcard {
  flex: 0 0 108px; padding: 7px 6px 8px; border-radius: 13px; cursor: pointer;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(143,216,255,.15);
  text-align: center;
  transition: border-color .12s, transform .12s;
}
.buildcard:hover { border-color: rgba(143,216,255,.5); transform: translateY(-3px); }
.buildcard.sel { border-color: var(--gold); box-shadow: 0 0 16px rgba(233,196,106,.3); }
.buildcard.off { opacity: .38; }
.buildcard img { height: 52px; object-fit: contain; }
.buildcard .bn { font-family: var(--font-title); font-size: 12px; letter-spacing: 1px; margin-top: 2px; }
.buildcard .bp { font-size: 10px; color: var(--gold); margin-top: 1px; }

/* ---------- 提示 ---------- */
#hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: rgba(242, 234, 214, .75);
  background: rgba(6, 18, 25, .7); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 12px;
  z-index: 15; pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
#hint.show { opacity: 1; }

/* ---------- toast ---------- */
#toasts {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  z-index: 40; pointer-events: none;
}
.toast {
  padding: 7px 16px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(233,196,106,.95), rgba(185,138,53,.9));
  color: #241804; font-size: 12px; font-weight: 700;
  font-family: var(--font-title); letter-spacing: 1px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  animation: toastIn .28s ease, toastOut .5s ease 2.1s forwards;
  white-space: nowrap;
}
.toast.good { background: linear-gradient(180deg, rgba(53,179,154,.95), rgba(29,122,104,.9)); color: #032018; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- modal ---------- */
#modal {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(3, 10, 15, .72); backdrop-filter: blur(6px);
}
#modal.hidden { display: none; }
.modal-box {
  width: min(520px, 86vw); padding: 20px 22px;
  background: linear-gradient(180deg, rgba(14, 40, 52, .98), rgba(6, 18, 25, .98));
  border: 1px solid rgba(233,196,106,.4);
  border-radius: 20px; box-shadow: var(--shadow);
  text-align: center;
}
.modal-box h3 { margin: 0 0 10px; font-family: var(--font-title); font-size: 18px; color: var(--gold); letter-spacing: 3px; }
#modalBody { font-size: 13px; line-height: 1.7; opacity: .88; }
.modal-box button { margin-top: 16px; }

/* 移动端适配 */
@media (max-width: 760px) {
  #sidepanel { width: auto; left: 8px; right: 8px; top: 128px; bottom: 8px; }
  #topbar { flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px 6px 6px 70px; }
  #resbar { padding: 4px 6px; gap: 4px; }
  .res { min-width: 0; font-size: 11px; padding: 2px 5px 2px 2px; }
  .res img { width: 17px; height: 17px; }
  .res .name { display: none; }
  #realmbar { padding: 4px 10px; gap: 8px; }
  #realmName { font-size: 13px; letter-spacing: 1px; }
  #powerVal { font-size: 10px; }
  #dock { left: 6px; top: 50%; gap: 6px; }
  .dockbtn { width: 46px; height: 44px; border-radius: 12px; font-size: 9px; letter-spacing: 0; }
  .dockbtn .glyph { font-size: 16px; }
  #toasts { top: 128px; }
  .buildcard { flex: 0 0 96px; }
  .buildcard img { height: 44px; }
}
