* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0f12; }
body { font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; color: #e8e2d4; user-select: none; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 顶栏 */
#topbar {
  position: absolute; top: 8px; left: 10px; z-index: 10;
  display: flex; gap: 12px; align-items: center;
  background: rgba(10,14,18,.82); border: 1px solid #2b3640; border-radius: 8px;
  padding: 7px 12px; backdrop-filter: blur(8px); font-size: 13px;
}
#topbar .pname { color: #e8d9a8; font-weight: 600; }
#topbar .prealm { color: #7fd1a8; margin-left: 6px; font-size: 12px; }
#topbar .pcoord { color: #6d7d8a; margin-left: 8px; font-size: 11px; }
#topbar .bars { display: flex; gap: 5px; }
.bar { position: relative; width: 92px; height: 13px; border-radius: 7px; background: #131b21; border: 1px solid #26313a; overflow: hidden; }
.bar i { position: absolute; inset: 0; transform-origin: left; transition: transform .18s; }
.bar.hp i { background: linear-gradient(90deg,#7d2626,#cf5a4a); }
.bar.sp i { background: linear-gradient(90deg,#1e4f7a,#4aa3d8); }
.bar.st i { background: linear-gradient(90deg,#5e4f21,#c9a94a); }
.bar.exp i { background: linear-gradient(90deg,#2e5e3e,#5ac98a); }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #fff; text-shadow: 0 0 3px #000; }
#topbar .currency { color: #e8d9a8; font-size: 12px; }
#topbar .currency b { color: #f0d878; }

/* 侧栏 */
#side { position: absolute; left: 10px; top: 76px; z-index: 10; display: flex; flex-direction: column; gap: 5px; }
#side button {
  width: 50px; height: 40px; border-radius: 7px; cursor: pointer; font-size: 11px;
  background: rgba(10,14,18,.8); border: 1px solid #2b3640; color: #cfc7ae; transition: all .12s;
}
#side button:hover { border-color: #c9a94a; color: #e8d9a8; }
#side button.active { border-color: #c9a94a; background: rgba(58,48,18,.8); color: #f0d878; }

/* 面板 */
#panel {
  position: absolute; left: 70px; top: 76px; z-index: 20;
  width: min(620px, calc(100vw - 90px)); max-height: calc(100vh - 190px);
  background: #0a0e12; border: 1px solid #33414d; border-radius: 10px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 50px rgba(0,0,0,.9);
}
#panel.hidden { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-bottom: 1px solid #22303a; color: #e8d9a8; font-size: 14px; }
#panel-close { background: none; border: none; color: #8697a3; font-size: 20px; cursor: pointer; line-height: 1; }
#panel-body { padding: 12px 14px; overflow: auto; font-size: 13px; line-height: 1.65; }

/* 通用 */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: #8fa3b2; font-weight: 500; padding: 5px 6px; border-bottom: 1px solid #22303a; position: sticky; top: 0; background: #0a0e12; }
td { padding: 5px 6px; border-bottom: 1px solid #141d25; }
tr:hover td { background: rgba(255,255,255,.03); }
.up { color: #e05a5a; } .down { color: #55c98a; }
.btn {
  padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 11px;
  background: #1b252d; border: 1px solid #2f3d47; color: #cfc7ae;
}
.btn:hover { border-color: #c9a94a; color: #f0d878; }
.btn.primary { background: #3a2f10; border-color: #c9a94a; color: #f0d878; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; background: #1b252d; color: #8fa3b2; }
.tag.gold { background: #3a2f10; color: #f0d878; }
.tag.green { background: #14301f; color: #6fd39a; }
.tag.red { background: #301414; color: #e07a7a; }
.row { display: flex; gap: 10px; }
.col { flex: 1; }
h4 { color: #c9a94a; font-size: 13px; margin: 10px 0 6px; font-weight: 500; }
h4:first-child { margin-top: 0; }
.muted { color: #7d8b96; font-size: 11px; }
input.fld {
  background: #131b21; border: 1px solid #2f3d47; color: #e8e2d4;
  border-radius: 4px; padding: 3px 6px; font-size: 12px;
}

/* 快捷栏 */
#hotbar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; z-index: 10; }
.slot {
  width: 44px; height: 44px; border-radius: 7px; cursor: pointer;
  background: rgba(10,14,18,.85); border: 1px solid #2b3640;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10px; color: #cfc7ae; position: relative;
}
.slot:hover { border-color: #c9a94a; }
.slot.cooling { opacity: .45; }
.slot .key { position: absolute; top: 1px; left: 3px; font-size: 8px; color: #6d7d8a; }
.slot .nm { margin-top: 10px; font-size: 9px; }

/* 聊天 */
#chat { position: absolute; left: 10px; bottom: 12px; z-index: 10; width: min(330px, 44vw); }
#chat-log { height: 92px; overflow: auto; font-size: 11px; line-height: 1.5; color: #b9c6cf; margin-bottom: 3px; }
#chat-log .who { color: #c9a94a; }
#chat-input { width: 100%; height: 24px; border-radius: 5px; padding: 0 8px; background: rgba(10,14,18,.85); border: 1px solid #2b3640; color: #e8e2d4; font-size: 11px; }
#chat-input:focus { outline: none; border-color: #c9a94a; }

/* 事件 + 时钟 */
#events { position: absolute; right: 12px; top: 192px; z-index: 10; width: 210px; font-size: 10px; line-height: 1.55; color: #8b9ba6; text-align: right; }
#clock { position: absolute; right: 12px; top: 178px; z-index: 10; font-size: 10px; color: #7d8b96; text-align: right; }

/* 小地图 */
#minimap { position: absolute; right: 12px; top: 10px; z-index: 10; border: 1px solid #33414d; border-radius: 8px; background: rgba(10,14,18,.8); }

/* 秘境条 */
#ruinbar {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 15;
  display: flex; gap: 10px; align-items: center;
  background: rgba(20,16,8,.92); border: 1px solid #c9a94a; border-radius: 8px;
  padding: 6px 14px; font-size: 12px;
}
#ruinbar.hidden { display: none; }
#ruin-timer { color: #e07a7a; font-weight: 600; }

/* 死亡 */
#death {
  position: absolute; inset: 0; z-index: 90; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(6,8,10,.86);
}
#death.hidden { display: none; }
#death h2 { color: #c05a4a; font-size: 28px; letter-spacing: 6px; font-weight: 300; }
#death p { color: #8b9ba6; font-size: 13px; }
#death button { padding: 8px 30px; border-radius: 6px; background: #3a2f10; border: 1px solid #c9a94a; color: #f0d878; cursor: pointer; font-size: 14px; }

/* 开场 */
#intro {
  position: absolute; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 38%, #17242c, #05080a 72%);
}
#intro.hidden { display: none; }
#intro h1 { font-size: 40px; letter-spacing: 14px; color: #e8d9a8; font-weight: 300; text-shadow: 0 0 34px rgba(201,169,74,.35); }
#intro .sub { color: #7d8b96; font-size: 12px; text-align: center; line-height: 1.8; margin-bottom: 6px; }
#intro input { width: 200px; height: 32px; text-align: center; border-radius: 6px; background: rgba(12,16,20,.9); border: 1px solid #33414d; color: #e8e2d4; font-size: 13px; }
#intro .openings { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 4px; }
#intro button {
  width: 150px; height: 36px; border-radius: 6px; cursor: pointer; font-size: 12px;
  background: rgba(20,28,34,.9); border: 1px solid #33414d; color: #cfc7ae; transition: all .14s;
}
#intro button:hover { border-color: #c9a94a; color: #e8d9a8; background: rgba(50,42,18,.6); }

/* toast */
#toast { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 5px; pointer-events: none; align-items: center; }
#toast div { background: rgba(8,12,16,.94); border: 1px solid #33414d; color: #e8d9a8; padding: 5px 13px; border-radius: 6px; font-size: 12px; animation: tin .16s ease, tout .3s ease 1.7s forwards; }
@keyframes tin { from { opacity: 0; transform: translateY(-5px); } }
@keyframes tout { to { opacity: 0; transform: translateY(-5px); } }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #2b3640; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) {
  #events, #clock { display: none; }
  #panel { left: 6px; width: calc(100vw - 12px); max-height: 70vh; }
  #chat { width: 44vw; }
  #chat-log { height: 64px; }
  #topbar .bars .bar { width: 64px; }
  #side button { width: 44px; height: 36px; font-size: 10px; }
}
