:root {
  --bg: #111418;
  --panel: rgba(16, 19, 25, 0.92);
  --panel2: #1c2129;
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef0f3;
  --dim: #9aa3ad;
  --gold: #ffcf4a;
  --red: #ff5a4a;
  --green: #5fdc7a;
  --blue: #59a8ff;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Segoe UI", "Noto Color Emoji", sans-serif; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
#game { position: fixed; inset: 0; display: block; touch-action: none; }
#hurtflash { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(255, 0, 0, 0.75); opacity: 0; }
#hurtflash.on { animation: hurt 0.5s ease-out; }
@keyframes hurt { from { opacity: 1; } to { opacity: 0; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--line); background: #2a313b;
  border-radius: 10px; padding: 9px 14px; font-weight: 600; transition: transform 0.06s, background 0.15s; }
.btn:active { transform: scale(0.96); }
.btn:hover { background: #343c48; }
.btn.primary { background: linear-gradient(180deg, #ffd86b, #f0b429); color: #1b1300; border-color: #ffd86b; }
.btn.danger { background: #4a1e1e; border-color: #7a2c2c; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn.big { padding: 13px 18px; font-size: 17px; width: 100%; }
.btn.dim { opacity: 0.45; }
.btn:disabled { opacity: 0.4; }
.btn.toggle.on { border-color: var(--green); }
.iconbtn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; }
.iconbtn.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }

/* ---------- HUD ---------- */
#hud-top { position: fixed; top: calc(var(--sat) + 6px); left: calc(var(--sal) + 6px); right: calc(var(--sar) + 6px); display: flex;
  justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 5; }
#hud-top > * { pointer-events: auto; }
#hud-left { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; width: 172px; display: flex; flex-direction: column; gap: 3px; }
#hud-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud-name b { color: var(--gold); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; border: 1px solid #fff; vertical-align: -1px; }
.bar { position: relative; height: 15px; background: rgba(255, 255, 255, 0.08); border-radius: 5px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #d8433b, #ff6b5a); transition: width 0.25s; }
.bar.paint i { background: linear-gradient(90deg, #6a5cff, #3690ea); }
.bar.xp { height: 4px; }
.bar.xp i { background: var(--gold); }
.bar span { position: relative; font-size: 11px; font-weight: 700; padding-left: 5px; line-height: 15px; text-shadow: 0 1px 2px #000; white-space: nowrap; }
#btn-spawn { margin-top: 3px; }
#hud-right { display: flex; gap: 6px; align-items: center; }
#hud-right > span { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
#loc { position: fixed; top: calc(var(--sat) + 50px); right: calc(var(--sar) + 6px); max-width: min(58vw, 420px); z-index: 4; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 4px 9px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#loc small { color: var(--dim); }
#quest { position: fixed; top: calc(var(--sat) + 104px); left: calc(var(--sal) + 6px); max-width: min(66vw, 360px); z-index: 4; background: rgba(40, 32, 8, 0.9);
  border: 1px solid rgba(255, 207, 74, 0.45); border-radius: 10px; padding: 5px 9px; font-size: 12px; cursor: pointer; }
#quest b { color: var(--gold); }
.qp { color: var(--green); font-weight: 700; }
#conn { position: fixed; top: calc(var(--sat) + 140px); left: 50%; transform: translateX(-50%); background: #5a3a00; border-radius: 10px; padding: 5px 12px; z-index: 9; }
#toasts { position: fixed; top: calc(var(--sat) + 140px); left: 50%; transform: translateX(-50%); width: min(92vw, 460px); z-index: 20; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: rgba(20, 24, 30, 0.95); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; padding: 8px 12px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); animation: tin 0.25s ease-out; pointer-events: auto; }
.toast.err { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
.toast.raid { border-left-color: var(--red); background: rgba(70, 10, 10, 0.95); font-weight: 700; }
.toast.drop { border-left-color: var(--gold); background: rgba(50, 40, 5, 0.95); font-weight: 700; }
.toast.kill { border-left-color: #b46cff; }
.toast.link { cursor: pointer; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: 0.35s; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
#sidebtns { position: fixed; right: calc(var(--sar) + 6px); top: calc(var(--sat) + 84px); display: flex; flex-direction: column; gap: 6px; z-index: 4; }

/* ---------- bottom ---------- */
#bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; flex-direction: column; align-items: stretch; pointer-events: none; }
#bottom > * { pointer-events: auto; }
#ticker { align-self: flex-start; margin: 0 0 4px calc(var(--sal) + 6px); max-width: min(80vw, 480px); font-size: 12px; background: rgba(0, 0, 0, 0.55);
  border-radius: 8px; padding: 3px 8px; opacity: 0; pointer-events: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ticker.fade { animation: tick 8s ease-out forwards; }
@keyframes tick { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
#throwbar { margin: 0 auto 6px; background: rgba(90, 30, 10, 0.95); border: 1px solid #ff8a4a; border-radius: 12px; padding: 6px 10px; display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; }
.panel { background: var(--panel); border-top: 1px solid var(--line); padding: 6px calc(var(--sar) + 6px) 4px calc(var(--sal) + 6px); }
.chips { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; align-items: center; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #262c35; border-radius: 9px; padding: 4px 8px; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.chip small { font-size: 10px; color: var(--dim); font-weight: 500; }
.chip.on { background: #3d3410; border-color: var(--gold); color: var(--gold); }
.chip.dim { opacity: 0.5; }
.sep { flex: none; width: 1px; height: 26px; background: var(--line); margin: 0 2px; }
.hint { color: var(--dim); font-size: 12px; }
.chips .hint { flex: none; padding-left: 4px; }
.pal { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; }
@media (min-width: 900px) { #bottom .pal { grid-template-columns: repeat(32, minmax(0, 1fr)); max-width: 980px; margin: 0 auto; } }
.sw { aspect-ratio: 1; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.25); padding: 0; min-width: 0; min-height: 18px; }
.sw.on { outline: 2px solid #fff; outline-offset: 1px; transform: scale(1.12); z-index: 1; }
.paintrow { display: flex; align-items: center; gap: 8px; }
.pcount { flex: none; font-size: 13px; }
#hotbar { display: flex; gap: 5px; overflow-x: auto; padding: 5px calc(var(--sar) + 6px) 5px calc(var(--sal) + 6px); scrollbar-width: none; background: linear-gradient(transparent, rgba(0, 0, 0, 0.35)); }
#hotbar::-webkit-scrollbar { display: none; }
.hot { flex: none; position: relative; width: 48px; height: 48px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; justify-content: center; }
.hot .e { font-size: 24px; }
.hot .k { position: absolute; top: 1px; left: 4px; font-size: 9px; color: var(--dim); }
.hot .c { position: absolute; bottom: 1px; right: 3px; font-size: 9px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.hot.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; background: #2b2610; }
#modebar { display: grid; grid-template-columns: repeat(7, 1fr); background: #0d1014; border-top: 1px solid var(--line); padding-bottom: var(--sab); }
#modebar button { position: relative; background: none; border: 0; padding: 5px 0 6px; font-size: 10px; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 1px; }
#modebar button span { font-size: 20px; line-height: 1.2; }
#modebar button.on { color: var(--gold); background: rgba(255, 207, 74, 0.08); }
#modebar .badge { position: absolute; top: 2px; right: 18%; background: var(--red); color: #fff; font-style: normal; font-size: 10px; border-radius: 8px; padding: 0 5px; }
@media (min-width: 700px) { #modebar { max-width: 700px; margin: 0 auto; border-radius: 14px 14px 0 0; border: 1px solid var(--line); width: 100%; } #modebar button { font-size: 12px; } }

/* ---------- sheet ---------- */
#sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; height: min(74vh, 640px); z-index: 31; background: #151a21; border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5); animation: sheetin 0.2s ease-out; padding-bottom: var(--sab); }
@keyframes sheetin { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 900px) {
  .sheet { left: auto; right: 12px; top: 60px; bottom: 12px; height: auto; width: 420px; border-radius: 16px; border: 1px solid var(--line); }
  #sheet-back { background: transparent; }
}
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 16px; border-bottom: 1px solid var(--line); }
.sheet h3 { margin: 0; font-size: 16px; }
.sheet h3 small { color: var(--dim); font-weight: 500; font-size: 12px; margin-left: 6px; }
#sheet-body { flex: 1; overflow-y: auto; padding: 10px 12px 16px; touch-action: pan-y; -webkit-overflow-scrolling: touch; user-select: text; }
#sheet-body h4 { margin: 12px 0 6px; font-size: 13px; color: var(--gold); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.cell { position: relative; aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; }
.cell .e { font-size: 24px; line-height: 1.1; }
.cell .n { position: absolute; top: 2px; right: 5px; font-size: 11px; font-weight: 700; }
.cell .nm { font-size: 9px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cell[data-sel] { border-color: var(--gold); background: #2b2610; }
.cell.eq { aspect-ratio: auto; height: 58px; width: 64px; }
.cell.empty { border-style: dashed; }
.eqrow { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.prot { margin-left: auto; font-size: 13px; color: var(--blue); font-weight: 700; }
.selbox { background: #232a33; border: 1px solid var(--gold); border-radius: 10px; padding: 8px; margin-bottom: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; border: 1px solid var(--line); background: #222831; border-radius: 9px; padding: 5px 10px; font-size: 12px; font-weight: 600; }
.tab.on { background: #3d3410; border-color: var(--gold); color: var(--gold); }
.crow { display: flex; gap: 8px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.crow > .e { font-size: 26px; width: 34px; text-align: center; flex: none; }
.crow.locked > .e { filter: grayscale(1); opacity: 0.6; }
.ci { flex: 1; min-width: 0; font-size: 13px; }
.cb { display: flex; flex-direction: column; gap: 4px; flex: none; }
.cost { display: inline-block; font-size: 12px; background: rgba(255, 255, 255, 0.06); border-radius: 6px; padding: 0 4px; margin: 2px 2px 0 0; }
.cost.lack { color: #ff8a7a; background: rgba(255, 90, 74, 0.12); }
.badge { display: inline-block; font-size: 10px; background: #24402c; color: #9fe8b0; border-radius: 6px; padding: 1px 5px; }
.badge.bad { background: #4a2020; color: #ffb0a5; }
.desc { font-size: 11px; color: var(--dim); }
.learn { background: #1e3350; border-color: #3a6aa8; }
.tcbox { background: #1d242d; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-bottom: 6px; line-height: 1.6; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #222831; font-size: 11px; padding: 3px 8px; color: var(--text); }
.seg button.on { background: var(--gold); color: #000; }
#chatlog { height: calc(100% - 92px); min-height: 200px; max-height: 52vh; overflow-y: auto; background: #10141a; border-radius: 10px; padding: 6px 8px; font-size: 13px; user-select: text; }
.cl { padding: 2px 0; word-break: break-word; }
.cl small { color: var(--dim); }
.cl.clan b { color: #8cf; }
#chatform { display: flex; gap: 6px; margin-top: 8px; }
input { width: 100%; background: #0f1318; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 16px; outline: none; }
input:focus { border-color: var(--gold); }
.form { display: flex; gap: 6px; margin-bottom: 8px; }
.rrow { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.rrow > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk { width: 24px; text-align: center; font-weight: 800; color: var(--gold); }
.rv { font-weight: 700; text-align: right; }
.rv small { display: block; color: var(--dim); font-weight: 500; font-size: 10px; }
.mystats { background: #1d242d; border-radius: 10px; padding: 6px 10px; font-size: 12px; margin-bottom: 6px; }
.qrow { display: flex; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.qrow.done { opacity: 0.55; }
.qrow.cur { background: rgba(255, 207, 74, 0.07); border-radius: 8px; }
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu .danger { grid-column: 1 / -1; }
.code { font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: 1px; color: var(--gold); user-select: all; }
.code.small { font-size: 12px; word-break: break-all; }
.help p { margin: 4px 0 10px; font-size: 13px; color: #d4d8dd; }
.hof { background: #1d242d; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.hof small { color: var(--dim); }
.hofimg { margin-top: 6px; }
.hofimg canvas { border-radius: 8px; display: block; margin-bottom: 4px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: radial-gradient(ellipse at center, rgba(10, 14, 20, 0.6), rgba(5, 7, 10, 0.92)); display: flex;
  align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
#loading { background: #0b0e12; }
.startbox { width: min(420px, 100%); background: rgba(18, 22, 28, 0.96); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); max-height: 100%; overflow-y: auto; }
.startbox.center { text-align: center; background: transparent; border: 0; box-shadow: none; }
.startbox label { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 4px; }
.startbox .btn.big { margin-top: 14px; }
.startbox .btn.ghost.sm { margin: 8px auto 0; display: flex; }
.logo { font-family: "DotGothic16", system-ui, sans-serif; font-size: 40px; margin: 0; letter-spacing: 2px; text-align: center; color: #fff; text-shadow: 3px 3px 0 #ff4500, 6px 6px 0 rgba(0, 0, 0, 0.5); }
.logo span { color: var(--gold); }
.tagline { text-align: center; margin: 6px 0 10px; font-family: "DotGothic16", system-ui; font-size: 15px; }
.feats { list-style: none; padding: 0; margin: 0 0 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 11.5px; color: #cfd5dc; }
.spbox { width: min(400px, 100%); background: rgba(18, 22, 28, 0.97); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.spbox h2 { margin: 0 0 2px; font-size: 19px; text-align: center; }
.spbox h2.dead { color: var(--red); }
#spawnui { background: rgba(5, 7, 10, 0.55); align-items: flex-end; padding-bottom: calc(var(--sab) + 70px); }
@media (min-width: 700px) { #spawnui { align-items: center; padding-bottom: 16px; } }
@media (max-width: 380px) { #hud-left { width: 150px; } #hud-right > span { padding: 5px 6px; font-size: 11px; } .logo { font-size: 34px; } }

/* ---------- icons ---------- */
.ic { width: 30px; height: 30px; display: inline-block; vertical-align: middle; image-rendering: auto; pointer-events: none; }
.ic.xs { width: 15px; height: 15px; margin: 0 1px 0 0; vertical-align: -3px; }
.ic.sm { width: 20px; height: 20px; vertical-align: -5px; }
.ic.lg { width: 36px; height: 36px; flex: none; }
.ic.emo { font-size: 24px; text-align: center; line-height: 30px; }
.cell .ic { width: 34px; height: 34px; }
.cell.eq .ic { width: 28px; height: 28px; }
.hot .ic { width: 34px; height: 34px; }
#modebar button .ic { width: 26px; height: 26px; }
#modebar button.on .ic { filter: drop-shadow(0 0 4px rgba(255, 207, 74, 0.7)); }
.chip .ic.sm { margin-bottom: 1px; }
.chip { flex-direction: column; min-width: 44px; }
.mat { display: block; width: 18px; height: 18px; border-radius: 3px; margin-bottom: 2px; border: 2px solid rgba(0, 0, 0, 0.5); }
.mat.m1 { background: #b0925f; border-style: dashed; } .mat.m2 { background: #8b5e34; } .mat.m3 { background: #808080; }
.mat.m4 { background: #606670; box-shadow: inset 0 0 0 2px #2a2d33; } .mat.m5 { background: #34383f; box-shadow: inset 0 0 0 3px #111; }
.cb { flex-direction: row !important; flex-wrap: wrap; justify-content: flex-end; max-width: 140px; }
.crow { align-items: center; }
.selbox .desc { margin: 2px 0; }
.qh { font-size: 11px; color: #e8d9a8; margin-top: 2px; }
.toast.boss { border-left-color: #b44cff; background: rgba(45, 10, 70, 0.95); font-weight: 700; }
@media (max-width: 600px) { .toast { font-size: 12px; padding: 6px 10px; } #toasts { top: calc(var(--sat) + 150px); } }
#emotes { position: fixed; right: calc(var(--sar) + 52px); top: calc(var(--sat) + 84px); z-index: 7; display: grid; grid-template-columns: repeat(4, 40px); gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
#emotes button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: #262c35; font-size: 22px; }
#emotes button:active { transform: scale(0.9); }
.help a { color: var(--gold); }

/* ---------- v3: Minecraft-style inventory ---------- */
.slots { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin-bottom: 6px; }
.slot { position: relative; aspect-ratio: 1; border-radius: 8px; background: #262d37; border: 2px solid #3a4350; box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.slot.empty { background: #1b2028; border-color: #2b323c; }
.slot .ic { width: 72%; height: 72%; }
.slot .n { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 800; text-shadow: 0 1px 2px #000, 0 0 3px #000; pointer-events: none; }
.slot .hk { position: absolute; left: 3px; top: 1px; font-size: 9px; color: #8b95a1; pointer-events: none; }
.slot.sel { border-color: var(--gold); background: #3b3414; box-shadow: 0 0 0 2px rgba(255, 207, 74, 0.35); animation: selpulse 1s ease-in-out infinite alternate; }
@keyframes selpulse { to { box-shadow: 0 0 0 4px rgba(255, 207, 74, 0.15); } }
.slot.cur { border-color: #8fd0ff; }
.slot:hover { border-color: #65707e; }
.hotrow { background: rgba(255, 255, 255, 0.04); padding: 4px; border-radius: 10px; }
.eqslot { width: 54px; height: 54px; aspect-ratio: auto; }
.eqlabel { font-size: 11px; color: #6c7682; }
.invtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.invtop .eqrow { margin: 0; }
.selbox { min-height: 44px; }
.selhead { display: flex; gap: 8px; align-items: center; }
.selbox .row .btn { padding: 6px 9px; }
#dragghost { position: fixed; z-index: 100; width: 48px; height: 48px; margin: -24px 0 0 -24px; pointer-events: none; display: flex; align-items: center; justify-content: center;
  background: rgba(30, 35, 44, 0.85); border: 2px solid var(--gold); border-radius: 10px; }
#dragghost .ic { width: 36px; height: 36px; }
#dragghost .n { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 800; text-shadow: 0 1px 2px #000; }
/* hotbar (main screen) */
#hotbar { justify-content: center; }
.hot { width: 52px; height: 52px; }
.hot.empty { opacity: 0.55; }
.hot .k { top: 2px; left: 5px; font-size: 10px; }
.hot.on { transform: translateY(-3px); }
@media (max-width: 520px) {
  #hotbar { gap: 3px; padding-left: 4px; padding-right: 4px; }
  .hot { width: calc((100vw - 40px) / 9); height: calc((100vw - 40px) / 9); border-radius: 9px; }
  .hot .ic { width: 70%; height: 70%; }
}
#helditem { align-self: center; margin-bottom: 2px; background: rgba(0, 0, 0, 0.6); border-radius: 8px; padding: 2px 10px; font-size: 13px; font-weight: 700; pointer-events: none !important; text-align: center; transition: opacity 0.4s; }
#helditem small { display: block; font-size: 10px; color: #c9d1da; font-weight: 500; }
#helditem.out { opacity: 0; }
#taskchip { align-self: center; display: flex; align-items: center; gap: 8px; background: rgba(20, 30, 20, 0.9); border: 1px solid #4b7a4b; border-radius: 12px; padding: 4px 6px 4px 12px; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
#taskchip span::before { content: '⏳ '; }
#bagcount.full { color: #ff8a7a; border-color: #ff5a4a !important; }
/* pickup feed */
#pickup { position: fixed; left: calc(var(--sal) + 8px); bottom: calc(var(--sab) + 150px); z-index: 5; display: flex; flex-direction: column; gap: 4px; pointer-events: none; max-width: 70vw; }
body.has-joy #pickup { bottom: calc(var(--sab) + 270px); }
.prow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; background: rgba(12, 15, 20, 0.78); border-left: 3px solid var(--green); border-radius: 8px; padding: 3px 9px 3px 6px; font-size: 13px; animation: pin 0.25s ease-out; transition: opacity 0.4s, transform 0.4s; }
.prow .pn { font-weight: 800; color: #b6ff8a; }
.prow.new { border-left-color: var(--gold); background: rgba(45, 38, 10, 0.9); }
.prow .ph { grid-column: 1 / -1; font-size: 11px; color: #f0e2b0; }
.prow.bump .pn { animation: bump 0.25s; }
.prow.out { opacity: 0; transform: translateX(-12px); }
.newb { color: var(--gold); font-size: 11px; }
@keyframes pin { from { opacity: 0; transform: translateX(-14px); } }
@keyframes bump { 50% { transform: scale(1.3); } }
/* context menu */
#ctxmenu { position: fixed; z-index: 60; min-width: 220px; max-width: min(320px, 92vw); max-height: 70vh; overflow-y: auto; background: rgba(20, 24, 31, 0.98); border: 1px solid #3a4350; border-radius: 12px; padding: 4px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); animation: tin 0.12s ease-out; }
#ctxmenu .mt { padding: 8px 10px 6px; font-weight: 800; font-size: 14px; border-bottom: 1px solid var(--line); margin-bottom: 3px; }
#ctxmenu .mt small { display: block; font-weight: 500; font-size: 11px; color: var(--dim); margin-top: 2px; }
#ctxmenu .mi { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 9px 10px; font-size: 14px; color: var(--text); }
#ctxmenu .mi:hover, #ctxmenu .mi:active { background: #2a323d; }
#ctxmenu .mi.primary { font-weight: 800; color: var(--gold); }
#ctxmenu .mi.danger { color: #ff8a7a; }
#ctxmenu .mi:disabled { opacity: 0.4; }
#ctxmenu .me { width: 20px; text-align: center; font-size: 15px; }
#ctxmenu kbd { margin-left: auto; font-size: 10px; color: var(--dim); }
#ctxmenu .msep { height: 1px; background: var(--line); margin: 3px 6px; }
@media (pointer: coarse) { #ctxmenu .mi { padding: 12px; font-size: 15px; } }
.stars { color: #ffd23f; letter-spacing: -1px; }
.chip .stars { font-size: 9px; color: #ffd23f; }
#build-info { font-size: 12px; padding: 2px 2px 5px; color: #e8ecf0; }
/* craft */
.tab .tb { font-style: normal; background: var(--green); color: #062; border-radius: 8px; padding: 0 5px; margin-left: 4px; font-size: 10px; font-weight: 800; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 13px; margin: 2px 0 6px; }
.chk input { width: auto; }
.crow.ok { background: rgba(95, 220, 122, 0.05); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: #2a313b; font-weight: 800; }
.stepper b { min-width: 22px; text-align: center; }
.need { font-size: 11px; color: #ffb0a5; text-align: right; }
.lackt { color: #ff8a7a; }
.row.quick { margin-bottom: 6px; }
/* printer editor */
.pgrid { display: grid; gap: 1px; background: #0c0f13; padding: 1px; border-radius: 8px; margin: 8px 0; touch-action: none; max-width: 420px; }
.pc { aspect-ratio: 1; background: #232a33; }
/* joystick */
#joy { position: fixed; left: calc(var(--sal) + 18px); bottom: calc(var(--sab) + 150px); width: 108px; height: 108px; border-radius: 50%; z-index: 6;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05)); border: 2px solid rgba(255, 255, 255, 0.22); touch-action: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); border: 2px solid rgba(255, 255, 255, 0.6); }
#joy.on { border-color: var(--gold); }
body.has-joy #ticker { margin-left: 140px; }
/* guide / modal */
#guide, #modal { z-index: 45; }
.gbox { width: min(400px, 100%); background: rgba(18, 22, 28, 0.98); border: 1px solid var(--line); border-radius: 18px; padding: 20px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.gbox.wide { width: min(460px, 100%); text-align: left; max-height: 86vh; overflow-y: auto; }
.gbox h3 { margin: 8px 0; font-size: 19px; }
.gbox p { font-size: 14px; line-height: 1.6; color: #d7dde4; }
.gbox .row { justify-content: center; margin-top: 12px; }
.ic.gic { width: 72px; height: 72px; }
.gdots { display: flex; gap: 6px; justify-content: center; }
.gdots i { width: 8px; height: 8px; border-radius: 50%; background: #39424e; }
.gdots i.on { background: var(--gold); }
.bar.exp { height: 22px; margin: 10px 0; }
.bar.exp i { background: linear-gradient(90deg, #4fa86a, #8fd14f); }
.bar.exp span { line-height: 22px; font-size: 13px; }
.mat.inl { display: inline-block; vertical-align: -4px; margin-right: 6px; }

/* ---------- v2 polish ---------- */
#tip { position: fixed; z-index: 70; max-width: 260px; background: rgba(12, 15, 20, 0.96); border: 1px solid #4a5462; border-radius: 10px; padding: 7px 10px; font-size: 12px; pointer-events: none; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
#tip b { font-size: 13px; color: #fff; }
#tip small { display: block; margin-top: 4px; color: #8f99a5; font-size: 10px; }
#pickghost { position: fixed; z-index: 80; width: 44px; height: 44px; margin: 6px 0 0 6px; pointer-events: none; display: flex; align-items: center; justify-content: center;
  background: rgba(40, 34, 10, 0.85); border: 2px solid var(--gold); border-radius: 10px; }
#pickghost .ic { width: 32px; height: 32px; }
#pickghost .n { position: absolute; right: 2px; bottom: 0; font-size: 10px; font-weight: 800; text-shadow: 0 1px 2px #000; }
#dragghost { transform: scale(1.15); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); }
.slot.lifted, .hot.lifted { opacity: 0.35; transform: scale(0.92); }
.slot.dropover, .hot.dropover { border-color: #8fd0ff !important; background: #1d3347 !important; transform: scale(1.06); }
.slot { transition: transform 0.08s; }
.pulse { animation: pulse 1.2s ease-in-out infinite; position: relative; }
.pulse::after { content: ''; position: absolute; inset: 2px 10%; border-radius: 12px; border: 2px solid var(--gold); animation: pulsering 1.2s ease-out infinite; pointer-events: none; }
@keyframes pulse { 50% { color: var(--gold); } }
@keyframes pulsering { from { opacity: 1; transform: scale(0.85); } to { opacity: 0; transform: scale(1.25); } }
#modebar .badge.new { background: var(--green); color: #052; }
.celebrate { position: fixed; inset: 0; z-index: 44; pointer-events: none; display: flex; align-items: flex-start; justify-content: center; padding-top: calc(var(--sat) + 120px); overflow: hidden; }
.celebrate .cb-in { display: flex; align-items: center; gap: 10px; max-width: min(92vw, 520px); background: linear-gradient(135deg, rgba(60, 48, 8, 0.97), rgba(30, 24, 4, 0.97)); border: 2px solid var(--gold);
  border-radius: 16px; padding: 12px 18px; font-size: 15px; font-weight: 800; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 207, 74, 0.35); animation: celeb 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); font-size: 28px; }
.celebrate .cb-in span { font-size: 15px; }
.celebrate.level .cb-in { border-color: #8fd0ff; background: linear-gradient(135deg, rgba(10, 40, 70, 0.97), rgba(6, 20, 40, 0.97)); }
@keyframes celeb { from { transform: scale(0.5) translateY(-30px); opacity: 0; } }
.conf { position: absolute; top: -10px; width: 8px; height: 12px; border-radius: 2px; animation: confall 2.6s ease-in forwards; }
@keyframes confall { to { transform: translateY(105vh) rotate(720deg); opacity: 0.8; } }
.phrases { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.phrases .chip { flex-direction: row; font-weight: 500; }
kbd { display: inline-block; background: #2a313b; border: 1px solid #4a5462; border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: 11px; font-family: inherit; }
.startlive { text-align: center; font-size: 12px; color: #c9d1da; margin: -4px 0 10px; min-height: 16px; }
.live { color: #ff5a4a; font-weight: 800; animation: pulse 1.6s infinite; }
