* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1020; color: #fff;
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#3b6fb6, #0d1020); z-index: 50; }
#loading .box { text-align: center; }
#loading .title { font-size: 34px; font-weight: 800; letter-spacing: 4px; margin-bottom: 12px;
  text-shadow: 3px 3px 0 #000; }
#loadmsg { opacity: .85; max-width: 80vw; line-height: 1.6; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#topbar { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 8px; display: flex; gap: 6px; align-items: center; }
#online { background: #0008; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.ib { background: #0008; border: 2px solid #fff3; border-radius: 8px; width: 40px; height: 36px; font-size: 18px; }

#chatlog { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; max-width: min(60vw, 420px);
  font-size: 13px; pointer-events: none !important; display: flex; flex-direction: column; gap: 3px; }
#chatlog div { background: #0009; padding: 3px 8px; border-radius: 6px; transition: opacity 1s; word-break: break-all; }
#chatlog b { color: #ffd76a; }
#chatlog .sys { color: #9fd3ff; }

#hotbar { position: absolute; bottom: calc(10px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; background: #0008; padding: 4px; border-radius: 10px; max-width: 96vw; overflow-x: auto; }
.slot { position: relative; width: 44px; height: 44px; border: 2px solid #fff3; border-radius: 6px; background: #0006;
  display: flex; align-items: center; justify-content: center; flex: none; }
.slot.sel { border-color: #ffd76a; background: #ffd76a33; transform: translateY(-3px); }
.slot canvas { width: 28px; height: 28px; image-rendering: pixelated; }
.slot .n { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 700; text-shadow: 1px 1px 0 #000; }

#touch { position: absolute; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); display: none;
  justify-content: space-between; padding: 0 12px; pointer-events: none !important; }
#touch > div { display: flex; gap: 10px; pointer-events: auto; }
.tb { width: 64px; height: 64px; border-radius: 50%; background: #0007; border: 2px solid #fff4; font-size: 26px; touch-action: none; }
.tb.on { background: #ffffff44; }
.tb.act { width: 80px; height: 80px; background: #ffb3c799; border-color: #fff8; }
.tb.act canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.tb.act.on { background: #ff8fa8cc; }
body.touch #touch { display: flex; }
body.touch #help { display: none; }
#help { position: absolute; bottom: calc(66px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: 12px; opacity: .6; white-space: nowrap; pointer-events: none !important; }

.panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 30; background: #1b2033f2;
  border: 2px solid #fff3; border-radius: 12px; padding: 12px; min-width: 260px; max-width: 92vw; max-height: 80vh; overflow: auto; }
.ph { font-weight: 700; font-size: 17px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.close { background: none; border: none; font-size: 18px; }
.recipe { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; background: #0003; margin-bottom: 6px; }
.recipe .need { flex: 1; font-size: 13px; opacity: .9; }
.recipe button, .wide { background: #3a7d3a; border: none; border-radius: 6px; padding: 6px 10px; }
.recipe button:disabled { background: #555; opacity: .6; }
.recipe .need .bad { color: #ff8f8f; }
.recipe .need .ok { color: #9be89b; }
.wide { width: 100%; padding: 10px; margin-bottom: 8px; }
.small { font-size: 12px; opacity: .6; }

#chatBox { position: fixed; left: 8px; right: 8px; top: calc(50px + env(safe-area-inset-top)); z-index: 40; display: flex; gap: 6px; }
#chatBox input { flex: 1; font-size: 16px; padding: 8px 10px; border-radius: 8px; border: 2px solid #fff4; background: #000c; color: #fff; }
#chatBox button { background: #3a7d3a; border: none; border-radius: 8px; padding: 0 14px; }
