:root {
  --bg: #16130f; --panel: #221d16; --line: #3a3126; --text: #efe4d0; --dim: #a8977b; --accent: #e0a458; --good: #7fdc8f; --bad: #ff6a4a;
  --cell: 46px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; font-size: 14px; user-select: none; overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid var(--accent); background: #3a2a14; color: var(--text); padding: 6px 14px; border-radius: 4px; }
button:hover:not(:disabled) { background: #523a1a; }
button:disabled { opacity: .4; cursor: not-allowed; }
small, .dim { color: var(--dim); font-weight: normal; font-size: 12px; }

#game { position: fixed; inset: 0; display: block; cursor: crosshair; }
body.in-raid #game { cursor: none; }

/* ===== 基地 ===== */
#hub { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: flex; flex-direction: column; }
#hub > * { pointer-events: auto; }
#hub-panel { position: fixed; inset: 58px 0 0 0; background: rgba(10,8,5,.6); display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; }
.hub-wrap { position: relative; display: flex; flex-direction: column; max-height: calc(var(--vh, 100vh) - 80px); max-width: var(--vw, 100vw); }
.hub-wrap .cols { padding: 0 14px 14px; }
.close-btn { align-self: flex-end; margin: 0 14px 8px; }
#hub-panel .cols > .panel { display: none; }
#hub-panel[data-mode=safe] .p-equip, #hub-panel[data-mode=safe] .p-stash,
#hub-panel[data-mode=basic] .p-stash, #hub-panel[data-mode=basic] .p-trader,
#hub-panel[data-mode=arms] .p-stash, #hub-panel[data-mode=arms] .p-trader,
#hub-panel[data-mode=craft] .p-stash, #hub-panel[data-mode=craft] .p-craft,
#hub-panel[data-mode=museum] .p-stash, #hub-panel[data-mode=museum] .p-museum,
#hub-panel[data-mode=map] .p-map { display: flex; }
.p-map { width: 560px; }
.map-card { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin-bottom: 10px; background: #1a160f; }
.map-card.last { border-color: var(--accent); }
.map-card p { margin: 6px 0; line-height: 1.5; }
.map-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.risk { font-size: 12px; border: 1px solid; border-radius: 10px; padding: 1px 8px; }
.map-card button { margin-top: 8px; font-weight: bold; }
.p-stash { max-height: calc(var(--vh, 100vh) - 140px); }
.craft-row small span { margin-right: 8px; white-space: nowrap; }
.p-craft { width: 380px; }
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: #1c1813; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: 4px; color: var(--accent); text-decoration: none; }
#money { font: bold 18px monospace; color: #ffd98a; }
#stats { color: var(--dim); flex: 1; }
#btn-raid { font-size: 16px; font-weight: bold; padding: 9px 26px; background: #6b3d12; }
.ghost-btn { border-color: var(--good); background: transparent; }
.cols { display: flex; gap: 14px; padding: 14px; min-height: 0; justify-content: safe center; overflow-x: auto; }
.cols > .panel { flex: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; display: flex; flex-direction: column; min-height: 0; }
.panel h2 { margin: 0 0 10px; font-size: 15px; color: var(--accent); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.scroll { overflow-y: auto; min-height: 0; flex: 1; }
#stash-area { padding-right: 6px; }
.trader { width: 320px; }
.help { margin-top: auto; padding: 8px 20px 12px; color: var(--dim); font-size: 12px; line-height: 1.7; background: linear-gradient(transparent, rgba(10,8,5,.85)); }
.help b { color: var(--text); }
.link-btn { border: none; background: none; color: var(--dim); text-decoration: underline; padding: 0 6px; float: right; }

.sell-zone, .drop-zone { border: 2px dashed #6b5a3e; border-radius: 6px; padding: 14px; text-align: center; color: var(--dim); margin-bottom: 10px; }
.drop-zone { margin: 10px 0 0; }
.shop-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.shop-row .ic { font-size: 20px; width: 26px; text-align: center; }
.shop-row .si { flex: 1; display: flex; flex-direction: column; }
.shop-row button { padding: 4px 8px; font: 12px monospace; min-width: 78px; }

/* ===== 网格 / 物品 ===== */
.grid { position: relative; background-color: #15120d; background-image: linear-gradient(#2c251c 1px, transparent 1px), linear-gradient(90deg, #2c251c 1px, transparent 1px); background-size: var(--cell) var(--cell); border: 1px solid #4a3e2f; flex: none; }
.sub { margin-top: 10px; }
.sub h3 { margin: 0 0 4px; font-size: 12px; color: var(--dim); font-weight: normal; }
.two { display: flex; gap: 14px; }
.slots { display: flex; gap: 8px; }
.slot { position: relative; width: 64px; height: 64px; border: 1px solid #4a3e2f; background: #15120d; border-radius: 4px; margin-top: 16px; }
.slot-label { position: absolute; left: 0; right: 0; top: -16px; font-size: 11px; color: var(--dim); pointer-events: none; text-align: center; white-space: nowrap; }
.slot.hl-ok { outline: 2px solid var(--good); } .slot.hl-bad { outline: 2px solid var(--bad); }
.item { position: absolute; border: 1px solid rgba(0,0,0,.6); border-radius: 3px; overflow: hidden; cursor: grab; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.item.in-slot { position: absolute; inset: 2px; }
.item.in-slot .nm { display: none; }
.item.in-slot .ic { font-size: 26px; }
.item .ic { font-size: 20px; pointer-events: none; }
.item .nm { position: absolute; left: 3px; top: 1px; font-size: 10px; line-height: 1.1; color: #f4ead2; text-shadow: 0 1px 2px #000; pointer-events: none; max-width: 100%; white-space: nowrap; overflow: hidden; }
.item .ct { position: absolute; right: 3px; bottom: 1px; font: bold 11px monospace; color: #fff3c8; text-shadow: 0 1px 2px #000; pointer-events: none; }
.t-weapon { background: #3b3f36; } .t-ammo { background: #5b4b26; } .t-armor { background: #36464a; } .t-bag { background: #4a3a2a; }
.t-med { background: #5a2f2f; } .t-loot { background: #403a30; } .rare { background: #5e4a1c; box-shadow: inset 0 0 0 1px #d8b25a; }
.item.dragging { opacity: .3; }
.item.ghost { position: fixed; pointer-events: none; z-index: 100; opacity: .85; }
.hidden-item { background: #2a241c; cursor: default; } .hidden-item .ic { color: #6b5a3e; font-weight: bold; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.hl { position: absolute; pointer-events: none; z-index: 5; }
.hl.ok { background: rgba(127,220,143,.3); } .hl.bad { background: rgba(255,106,74,.3); }

/* ===== 局内背包 ===== */
.overlay { position: fixed; inset: 0; background: rgba(10,8,5,.72); display: flex; align-items: center; justify-content: center; z-index: 20; }
.inv-wrap { display: flex; gap: 16px; max-height: calc(var(--vh, 100vh) * .92); }
.inv-wrap .panel { overflow-y: auto; }
.search-bar { height: 4px; background: #000; margin-bottom: 8px; } .search-bar i { display: block; height: 100%; width: 0; background: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px 40px; min-width: 380px; text-align: center; }
.card h1 { margin: 0 0 14px; } .good { color: var(--good); } .bad { color: var(--bad); }

#tooltip { position: fixed; z-index: 200; max-width: 300px; background: #0f0c08ee; border: 1px solid #5a4a36; padding: 8px 10px; border-radius: 4px; pointer-events: none; line-height: 1.5; font-size: 12px; }
#tooltip b { font-size: 14px; color: var(--accent); } #tooltip .price { color: #ffd98a; }
#ctx { position: fixed; z-index: 210; background: #1a150f; border: 1px solid #5a4a36; display: flex; flex-direction: column; min-width: 150px; }
#ctx button { border: none; border-radius: 0; background: none; text-align: left; padding: 7px 12px; } #ctx button:hover { background: #3a2a14; }
#toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: #2a2116ee; border: 1px solid var(--accent); padding: 7px 16px; border-radius: 4px; }

.power { font-size: 14px; margin-bottom: 8px; padding: 6px 10px; background: #15120d; border: 1px solid var(--line); border-radius: 4px; }
.power b { font: bold 18px monospace; margin: 0 4px; }
#power { font-size: 14px; color: var(--dim); } #power b { font: bold 17px monospace; }
.rec { margin: 4px 0; font-size: 13px; } .rec b { font-family: monospace; }

.p-museum { width: 380px; }
.museum-row.got { background: rgba(127,220,143,.06); }
.rewards { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; line-height: 1.8; font-size: 13px; }

/* ===== 触屏 ===== */
#touch { display: none; position: fixed; inset: 0; z-index: 9; pointer-events: none; }
#qcfg { z-index: 60; }
body.touch #touch { display: block; }
body.touch .help { display: none; }
.tzone { position: absolute; top: 56px; bottom: 0; pointer-events: auto; touch-action: none; }
#tz-left { left: 0; width: 50%; }
.stick { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(255,240,200,.35); background: rgba(20,16,10,.25); display: none; pointer-events: none; }
.stick.on { display: block; }
.stick i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,230,170,.55); transform: translate(-50%,-50%); }
.tbtns { position: absolute; right: 8px; top: 82px; display: flex; gap: 6px; pointer-events: auto; }
.tbtns button { height: 34px; padding: 0 10px; border-radius: 9px; background: rgba(40,30,18,.72); font-size: 13px; touch-action: none; }
#fire { position: absolute; width: 92px; height: 92px; margin: -46px 0 0 -46px; border-radius: 50%; background: rgba(150,40,20,.55); border: 2px solid rgba(255,200,150,.6); display: flex; align-items: center; justify-content: center; font-weight: bold; color: #ffe9d0; pointer-events: auto; touch-action: none; }
#fire.on { background: rgba(200,60,30,.8); }
#qring button { position: absolute; width: 52px; height: 52px; margin: -26px 0 0 -26px; padding: 0; border-radius: 50%; background: rgba(40,30,18,.75); font-size: 13px; pointer-events: auto; touch-action: none; }
#qring button.active, .tbtns button.active { background: #8a5a1a; }
#qcfg label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0; }
#qcfg select { font: inherit; background: #1a150f; color: var(--text); border: 1px solid var(--accent); border-radius: 4px; padding: 4px 8px; }
.tbtns button.active { background: #8a5a1a; }
body:not(.in-raid) .tbtns { top: 64px; }
.item, .slot { touch-action: none; }
.scroll { touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.close-btn.small { padding: 2px 10px; font-size: 12px; margin: 0; }
/* ===== 竖屏手机：直接竖着玩 ===== */
body.pui .tzone { top: 42%; }
body.pui .tbtns { top: 120px; }
body.pui .topbar { padding: 6px 10px; gap: 10px; flex-wrap: wrap; } body.pui .logo { font-size: 16px; letter-spacing: 2px; } body.pui #stats { display: none; }
body.pui #btn-raid { padding: 6px 12px; font-size: 14px; margin-left: auto; }
body.pui #hub-panel { inset: 48px 0 0 0; padding-top: 4px; }
body.pui .hub-wrap { width: var(--vw, 100vw); max-height: calc(var(--vh, 100vh) - 56px); }
body.pui .hub-wrap .cols { flex-direction: column; align-items: center; overflow-y: auto; overflow-x: hidden; padding: 0 6px 12px; min-height: 0; }
body.pui .cols > .panel { width: calc(var(--vw, 100vw) - 12px) !important; max-width: 100%; }
body.pui .p-stash { max-height: calc(var(--vh, 100vh) * .46); flex: none; }
body.pui .p-stash .scroll, body.pui #stash-area { overflow-x: auto; }
body.pui .panel { padding: 8px; }
body.pui .slots { flex-wrap: wrap; } body.pui .slot { width: 46px; height: 46px; } body.pui .item.in-slot .ic { font-size: 18px; }
body.pui .two { flex-wrap: wrap; }
body.pui .overlay { align-items: flex-start; }
body.pui .inv-wrap { flex-direction: column; width: var(--vw, 100vw); max-height: var(--vh, 100vh); overflow-y: auto; padding: 6px; gap: 8px; }
body.pui .inv-wrap .panel { overflow: visible; }
body.pui .card { min-width: 0; width: calc(var(--vw, 100vw) * .92); padding: 20px; }

body.short .topbar { padding: 6px 12px; gap: 12px; } body.short .logo { font-size: 17px; } body.short #stats { display: none; }
body.short #hub-panel { inset: 46px 0 0 0; padding-top: 4px; }
body.short .panel { padding: 8px; } body.short .panel h2 { margin-bottom: 6px; font-size: 14px; }
body.short .slot { width: 50px; height: 50px; } body.short .item.in-slot .ic { font-size: 20px; }
body.short .inv-wrap { max-height: calc(var(--vh, 100vh) * .98); } body.short .p-map, body.short .p-craft, body.short .p-museum, body.short .trader { width: 300px; }

body.panel-open #touch { display: none !important; }
.touch-btn { border-color: #6b5a3e; font-size: 12px; padding: 4px 10px; }
body.pui .touch-btn { order: 10; }

/* 锁住整个页面：不滚动、不回弹、不下拉刷新、不缩放；只有列表区域能上下滑 */
html, body { position: fixed; inset: 0; width: 100%; height: 100%; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#game, #hub, #touch, .overlay { touch-action: none; }
.scroll, .inv-wrap, .hub-wrap .cols, #ctx { touch-action: pan-y; overscroll-behavior: contain; }
button { touch-action: manipulation; }

/* 旋转容器：不旋转时就是全屏；旋转时宽高互换并转 90° */
#app { position: fixed; left: 0; top: 0; width: var(--vw, 100vw); height: var(--vh, 100vh); overflow: hidden; }
body.rot #app { transform-origin: 0 0; transform: translateX(100vw) rotate(90deg); }
body.rot .scroll, body.rot .inv-wrap, body.rot .hub-wrap .cols { touch-action: pan-x pan-y; }
body.touch #st-left { display: block; opacity: .55; }
body.touch #st-left.on { opacity: 1; }
body.touch #toast { bottom: auto; top: 38%; }
