* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: #e8dcc0;
  font: 13px/1.45 "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-user-select: none; user-select: none;
  touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; display: block; image-rendering: pixelated; }
.hidden { display: none !important; }
button { font: inherit; color: #f4e6c4; background: linear-gradient(#5b4426, #3a2a16); border: 1px solid #8a6a3a;
  border-radius: 4px; padding: 4px 10px; cursor: pointer; }
button:active { filter: brightness(1.3); }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(#2a1d10, #000); z-index: 50; }
#loading .box { width: min(360px, 92vw); text-align: center; }
#loading h1 { font-size: 28px; letter-spacing: 4px; color: #ffcf6b; text-shadow: 0 0 12px #a0520e; }
#loading input[type=password], #loading input[name=name] { width: 100%; padding: 8px; margin: 8px 0; font: inherit;
  background: #1b130a; color: #f4e6c4; border: 1px solid #8a6a3a; border-radius: 4px; }
#loading .row { margin: 10px 0; }
#loading .choice label { margin: 0 10px; }
.err { color: #ff7b7b; min-height: 20px; }

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: auto; }
.hud { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end;
  padding: 6px calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: linear-gradient(transparent, rgba(0,0,0,.75) 35%); }
.bars { flex: 1 1 220px; min-width: 200px; display: flex; flex-direction: column; gap: 3px; }
.bar { position: relative; height: 16px; background: rgba(0,0,0,.6); border: 1px solid #5c4526; border-radius: 3px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; }
.bar.hp .fill { background: linear-gradient(#e0473b, #8e1a12); }
.bar.mp .fill { background: linear-gradient(#3b78e0, #12348e); }
.bar.exp .fill { background: linear-gradient(#e0c33b, #8e6f12); }
.bar span { position: relative; font-size: 11px; padding-left: 6px; text-shadow: 0 1px 1px #000; }
.belt, .skillbar { display: flex; gap: 3px; }
.slot { position: relative; width: 38px; height: 38px; background: rgba(20,14,8,.85); border: 1px solid #6b5230;
  border-radius: 3px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.slot .key { position: absolute; left: 2px; top: 0; font-size: 10px; color: #c9b386; text-shadow: 0 1px 1px #000; pointer-events: none; }
.slot .label { position: absolute; bottom: 0; font-size: 10px; color: #8d7a58; pointer-events: none; }
.slot .icon { pointer-events: none; }
.buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.log { position: absolute; left: 8px; bottom: 110px; max-width: min(460px, 70vw); pointer-events: none !important; }
.msg { text-shadow: 0 1px 2px #000; transition: opacity 1s; }
.msg.fade { opacity: 0; }
.msg.good { color: #9cff8a; } .msg.bad { color: #ff8a8a; } .msg.item { color: #ffe08a; } .msg.system { color: #e8dcc0; }

.panel { position: absolute; right: 8px; top: 8px; width: min(640px, calc(100vw - 16px)); max-height: calc(100vh - 130px);
  overflow: auto; background: rgba(24,17,9,.95); border: 1px solid #8a6a3a; border-radius: 6px; padding: 8px; }
.panel .head { display: flex; justify-content: space-between; align-items: center; color: #ffcf6b; font-size: 15px; margin-bottom: 6px; }
.panel .close { padding: 0 8px; }
.cols { display: flex; gap: 10px; flex-wrap: wrap; }
.col { flex: 1 1 280px; }
.equip { display: grid; grid-template-columns: repeat(4, 42px); gap: 4px; margin-bottom: 8px; }
.slot.eq { width: 42px; height: 42px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, 40px); gap: 3px; }
.stats div { font-size: 12px; margin: 1px 0; }
.foot, .hint, .sub { margin-top: 6px; color: #c9b386; font-size: 12px; }
.title { color: #ffcf6b; } .dim { color: #9b8a6a; } .good { color: #9cff8a; } .bad { color: #ff8a8a; } .gold { color: #ffe08a; }
.goods { display: flex; flex-direction: column; gap: 2px; }
.good { display: flex; align-items: center; gap: 8px; padding: 2px 4px; cursor: pointer; border-radius: 3px; color: #e8dcc0; }
.good:hover { background: rgba(255,207,107,.12); }
.good .name { flex: 1; } .good .price { color: #ffe08a; }
.skill { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid #3a2a16; }
.skill .desc { flex: 1; }
.setting { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.setting input[type=number] { width: 60px; background: #1b130a; color: #f4e6c4; border: 1px solid #8a6a3a; }
select { background: #1b130a; color: #f4e6c4; border: 1px solid #8a6a3a; }
.tip { position: absolute; z-index: 30; max-width: 340px; background: rgba(10,7,3,.96); border: 1px solid #8a6a3a;
  border-radius: 4px; padding: 6px 8px; font-size: 12px; pointer-events: auto; }
.tip .act { display: block; width: 100%; margin-top: 4px; }
.death { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; font-size: 20px;
  color: #ff8a8a; background: rgba(0,0,0,.8); padding: 16px 24px; border: 1px solid #8a2a2a; border-radius: 6px; }
.death button { margin-top: 10px; font-size: 15px; }
@media (max-width: 700px) {
  .slot { width: 34px; height: 34px; }
  .log { bottom: 150px; font-size: 12px; }
}
