:root { --gold: #f0c560; --gold2: #e0b45a; --bg: #14110f; --panel: #201812; --panel2: #2b2118; --line: #4a3828; --text: #eadfc8; --sub: #a8957a; --bad: #ff9b85; --good: #a8e07a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; -webkit-text-size-adjust: 100%; touch-action: manipulation; background: var(--bg); color: var(--text); font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; font-size: 14px; overflow: hidden; }
button { font: inherit; color: #f4e7c8; background: linear-gradient(#5a4632, #46362a); border: 1px solid #8a6a3e; border-radius: 5px; padding: 4px 9px; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,230,180,.15), 0 1px 2px rgba(0,0,0,.4); transition: transform .08s, background .15s; }
button:hover:not(:disabled) { background: linear-gradient(#6e563c, #574230); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .42; cursor: not-allowed; }
button.on { background: linear-gradient(#e0ac48, #b8862e); color: #1d150b; border-color: #f0c870; }
button.primary { background: linear-gradient(#c89a3e, #9a7028); color: #1d150b; border-color: #f0c870; font-weight: bold; }
img { image-rendering: pixelated; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
#view { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#hud { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: linear-gradient(#3e2e20, #261c14); border-bottom: 2px solid #7a5a32; box-shadow: 0 2px 8px rgba(0,0,0,.5); z-index: 5; }
.brand { font-weight: bold; font-size: 18px; color: var(--gold); letter-spacing: 2px; text-shadow: 0 2px 0 #3a2008; white-space: nowrap; }
.brand small { font-size: 11px; color: #c9a86a; margin-left: 4px; letter-spacing: 1px; }
#clock { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#clock img { width: 16px; height: 16px; }
#clock .bar { width: 96px; height: 8px; background: #1a130d; border: 1px solid #6a5232; border-radius: 4px; overflow: hidden; }
#dayBar { height: 100%; width: 0; background: linear-gradient(90deg, #f6d36b, #e07b39 75%, #3a4a8a 85%); background-size: 96px 100%; }
#res { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#res::-webkit-scrollbar { display: none; }
#res .r { display: flex; align-items: center; gap: 4px; padding: 2px 7px 2px 4px; background: rgba(20,14,10,.75); border-radius: 12px; border: 1px solid #4a3a28; white-space: nowrap; font-variant-numeric: tabular-nums; transition: border-color .3s, background .3s; }
#res .r img { width: 16px; height: 16px; }
#res .r.warn { border-color: #d0503a; color: #ffb3a0; animation: warnPulse 1.2s infinite; }
#res .r.flash { background: rgba(240,197,96,.35); }
@keyframes warnPulse { 50% { background: rgba(160,40,20,.35); } }
#ctrl { display: flex; gap: 4px; }
#ctrl button { min-width: 36px; padding: 4px 6px; }
#ctrl img { width: 16px; height: 16px; vertical-align: middle; }
main { flex: 1; display: flex; min-height: 0; position: relative; }
#viewWrap { flex: 1; position: relative; overflow: hidden; background: #0d0b0a; touch-action: none; }
#view { position: absolute; left: 0; top: 0; width: 100%; height: 100%; cursor: pointer; touch-action: none; }
#view.drag { cursor: grabbing; }
#hint { position: absolute; left: 8px; bottom: 8px; background: rgba(20,15,10,.82); padding: 4px 9px; border-radius: 4px; font-size: 12px; pointer-events: none; max-width: 68%; border: 1px solid rgba(120,90,50,.5); }
#tip { position: absolute; display: none; pointer-events: none; background: rgba(24,17,11,.95); border: 1px solid #8a6a3e; border-radius: 5px; padding: 6px 9px; font-size: 12px; line-height: 1.5; max-width: 240px; z-index: 6; box-shadow: 0 4px 12px rgba(0,0,0,.5); }
#tip b { color: var(--gold); }
#pauseMark { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.72); padding: 10px 24px; border: 1px solid #b8862e; border-radius: 6px; font-size: 18px; display: none; pointer-events: none; letter-spacing: 2px; }
#toasts { position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; pointer-events: none; align-items: center; z-index: 4; }
.toast { background: rgba(40,28,14,.94); border: 1px solid #e0b45a; color: #ffe7a6; padding: 5px 12px; border-radius: 5px; animation: fade 4s forwards; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.toast.bad { border-color: #d0503a; color: #ffc2b5; }
.toast.event { border-color: #7ab0e0; color: #d0e8ff; }
@keyframes fade { 0% { opacity: 0; transform: translateY(8px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#banner { position: absolute; top: 14px; left: 50%; transform: translate(-50%, -120%); background: linear-gradient(#5a4220, #3a2a14); border: 2px solid var(--gold); border-radius: 8px; padding: 8px 18px; text-align: center; transition: transform .45s cubic-bezier(.2,1.4,.4,1); pointer-events: none; z-index: 7; box-shadow: 0 6px 18px rgba(0,0,0,.55); }
#banner.show { transform: translate(-50%, 0); }
#banner .t { color: var(--gold); font-weight: bold; font-size: 15px; } #banner .d { font-size: 12px; color: #e8d8b0; }
#tut { position: absolute; left: 10px; top: 10px; max-width: 320px; background: rgba(34,24,14,.95); border: 2px solid var(--gold2); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.6; z-index: 5; display: none; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
#tut .step { color: var(--gold); font-size: 12px; } #tut .btns { margin-top: 6px; display: flex; gap: 6px; justify-content: flex-end; }
#zoomCtl { position: absolute; right: 52px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 3; }
#zoomCtl button { width: 34px; height: 34px; padding: 0; font-size: 16px; opacity: .85; }
#mobileBar { display: none; }
#side { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-left: 2px solid #5a4228; min-height: 0; z-index: 4; transition: width .26s cubic-bezier(.3,.7,.3,1); overflow: hidden; }
#side > * { min-width: 336px; }
#side.mini { width: 58px; }
#side.mini > * { min-width: 0; }
#side.mini #panel, #side.mini #selInfo, #side.mini #logBox { display: none; }
#side.mini #tabs { flex-direction: column; border-bottom: none; padding: 6px 5px; gap: 5px; }
#side.mini #tabs button { flex: none; height: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px 0; font-size: 10px; }
#side.mini #tabs button span { font-size: 10px; opacity: .85; }
#side.mini #tabs button.on { box-shadow: 0 0 0 1px #f0c870 inset; }
#sideToggle { flex: 0 0 26px !important; font-weight: bold; padding: 5px 0; }
#side.mini #sideToggle { height: 30px !important; font-size: 15px; }
#tabs button img { width: 16px; height: 16px; display: none; }
#side.mini #tabs button img { display: block; }
#sheetHandle { display: none; }
#tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; padding: 5px 0; font-size: 13px; min-width: 0; }
#tabs button.pulse { animation: tabPulse 1s infinite; }
@keyframes tabPulse { 50% { box-shadow: 0 0 0 3px rgba(240,197,96,.7); } }
#panel { padding: 8px; overflow-y: auto; flex: 1 1 50%; min-height: 120px; }
#selInfo { padding: 8px; border-top: 1px solid var(--line); background: #2a2017; font-size: 13px; line-height: 1.5; }
#selInfo:empty { display: none; }
#logBox { flex: 1 1 26%; min-height: 90px; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.logTitle { padding: 4px 8px; color: #c9a86a; font-size: 12px; }
#log { overflow-y: auto; padding: 0 8px 8px; font-size: 12px; line-height: 1.55; flex: 1; }
#log .good { color: var(--good); } #log .bad { color: var(--bad); } #log .loot { color: #ffd76a; } #log .event { color: #9fd0ff; } #log .ach { color: #f0a0ff; }
#log .ts { color: #7d6a52; margin-right: 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px; border-radius: 6px; margin-bottom: 4px; background: var(--panel2); border: 1px solid transparent; transition: border-color .15s, background .15s; }
.row.sel { border-color: var(--gold2); background: #3a2c1c; }
.row.click { cursor: pointer; } .row.click:hover { background: #33271c; }
.row .sub { color: var(--sub); font-size: 12px; }
.row .ico { width: 28px; height: 28px; flex: none; border-radius: 4px; border: 1px solid #5a4228; image-rendering: pixelated; }
.row .grow { flex: 1; min-width: 0; }
.mbar { height: 4px; background: #1a130d; border-radius: 2px; overflow: hidden; margin-top: 3px; }
.mbar i { display: block; height: 100%; background: linear-gradient(90deg, #d0503a, #e0b040 50%, #8fd06a); background-size: 200px 100%; }
.tag { display: inline-block; padding: 0 5px; border-radius: 3px; background: #4a3a28; color: #f0d8a8; font-size: 11px; margin-left: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
h4 { margin: 10px 0 6px; color: var(--gold); font-size: 14px; } h4:first-child { margin-top: 2px; }
p.note { color: var(--sub); font-size: 12px; margin: 4px 0 8px; line-height: 1.55; }
.goal { padding: 3px 0; font-size: 13px; } .goal.done { color: #8fc46a; } .goal.done::before { content: "✓ "; } .goal:not(.done)::before { content: "○ "; color: #7d6a52; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; }
.ach { padding: 5px; border-radius: 5px; background: #261d15; border: 1px solid #3a2c1e; font-size: 12px; color: #6d5d48; }
.ach.done { color: #f0e0b8; border-color: #b8862e; background: linear-gradient(#3e2e18, #2c2014); }
.ach small { display: block; font-size: 11px; opacity: .8; }
label.chk { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
label.chk input { margin-top: 3px; accent-color: #d8a040; }
label.chk span small { display: block; color: var(--sub); font-size: 12px; }
.seg { display: flex; gap: 4px; margin: 4px 0 8px; } .seg button { flex: 1; }
input[type=range] { width: 100%; accent-color: #d8a040; }
textarea { width: 100%; height: 80px; background: #14100c; color: var(--text); border: 1px solid #5a4228; font-size: 11px; border-radius: 4px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 20; animation: fadeIn .2s; }
#modal.show { display: flex; }
#modal .card { width: min(420px, 92vw); background: linear-gradient(#3a2a1a, #2a1e14); border: 2px solid var(--gold2); border-radius: 10px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.6); animation: pop .3s cubic-bezier(.2,1.4,.4,1); }
#modal h3 { margin: 0 0 8px; color: var(--gold); letter-spacing: 1px; }
#modal p { margin: 0 0 12px; line-height: 1.6; }
#mChoices { display: flex; flex-direction: column; gap: 6px; }
#mChoices button { text-align: left; padding: 8px 10px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } }


/* ---------- v4 机械 ---------- */
#mechBar { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); display: none; gap: 6px; align-items: center; background: rgba(24,18,12,.94); border: 1px solid #b8862e; border-radius: 22px; padding: 5px 8px 5px 14px; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.55); white-space: nowrap; }
#mechBar.show { display: flex; }
#mechBar .lbl { color: var(--gold); font-size: 13px; margin-right: 4px; }
#mechBar button { border-radius: 16px; padding: 6px 12px; }
#zoomCtl #powerBtn.on { background: linear-gradient(#5ab0e0, #2a78a8); color: #fff; border-color: #a8e0ff; }
.mtools button { flex: 1; }
h4.mcat { cursor: pointer; user-select: none; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.sbar { height: 5px; background: #14100c; border-radius: 3px; overflow: hidden; margin: 3px 0 1px; }
.sbar i { display: block; height: 100%; }
.inv { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.inv .it { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px 2px 3px; background: var(--panel2); border: 1px solid #4a3a28; border-radius: 10px; font-size: 12px; }
.inv .it img { width: 16px; height: 16px; }
.row .ico.sm { width: 22px; height: 22px; background: #2a2017; }
#res .r img[src^="data"] { image-rendering: auto; }

/* ---------- 平板 ---------- */
@media (min-width: 821px) and (max-width: 1180px) {
  #side { width: 304px; }
  #side > * { min-width: 300px; }
  #tabs button { font-size: 12px; }
  #res .r { padding: 2px 6px 2px 3px; font-size: 13px; }
  .brand small { display: none; }
  #hud { gap: 8px; }
}
@media (pointer: coarse) { button { min-height: 32px; } #zoomCtl button { width: 40px; height: 40px; } }

/* ---------- 手机 / 窄屏（含横屏手机） ---------- */
@media (max-width: 820px), (max-height: 540px) and (pointer: coarse) {
  body { font-size: 13px; }
  #hud { flex-wrap: wrap; gap: 6px 8px; padding: 5px 8px; padding-top: max(5px, env(safe-area-inset-top)); }
  .brand { font-size: 15px; } .brand small { display: none; }
  #clock .bar { width: 60px; }
  #res { order: 3; flex-basis: 100%; }
  #res .r { padding: 1px 6px 1px 3px; font-size: 12px; }
  #ctrl { margin-left: auto; } #ctrl button { min-width: 32px; padding: 3px 5px; }
  main { flex-direction: column; }
  #side > * { min-width: 0; }
  #sideToggle { display: none; }
  #tabs button img { display: none !important; }
  #side { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 48%; border-left: none; border-top: 2px solid #7a5a32; border-radius: 12px 12px 0 0; box-shadow: 0 -6px 18px rgba(0,0,0,.5); transition: height .25s; padding-bottom: env(safe-area-inset-bottom); }
  #side.collapsed { height: 46px; }
  #side.collapsed #panel, #side.collapsed #selInfo, #side.collapsed #logBox { display: none; }
  #sheetHandle { display: block; height: 14px; cursor: pointer; } #sheetHandle::after { content: ""; display: block; width: 44px; height: 4px; border-radius: 2px; background: #7a5a32; margin: 5px auto 0; }
  #tabs { padding: 2px 6px 6px; } #tabs button { font-size: 12px; padding: 6px 0; }
  #logBox { flex-basis: 22%; min-height: 60px; }
  #hint { display: none; }
  #zoomCtl { right: 40px; bottom: auto; top: 8px; }
  #zoomCtl button { width: 32px; height: 32px; }
  #mobileBar { display: flex; position: absolute; left: 8px; bottom: calc(48% + 8px); gap: 6px; z-index: 3; transition: bottom .25s; }
  #mobileBar button { padding: 7px 12px; opacity: .92; }
  body.sheet-collapsed #mobileBar { bottom: 54px; }
  #toasts { bottom: auto; top: 84px; }
  #tut { font-size: 12px; line-height: 1.5; padding: 8px 10px; }
  #tut { left: 8px; right: 8px; max-width: none; top: auto; bottom: calc(48% + 52px); }
  body.sheet-collapsed #tut { bottom: 98px; }
  .row { padding: 7px 6px; }
}

@media (max-width: 820px), (max-height: 540px) and (pointer: coarse) {
  #mechBar { bottom: calc(48% + 52px); left: 50%; max-width: 96vw; overflow-x: auto; }
  body.sheet-collapsed #mechBar { bottom: 98px; }
  #zoomCtl button { width: 36px; height: 36px; }
}
/* 横屏手机：侧栏改为右侧抽屉 */
@media (max-height: 540px) and (pointer: coarse) and (orientation: landscape) {
  #hud { flex-wrap: nowrap; padding-top: 4px; }
  #res { order: 0; flex-basis: auto; }
  #clock .bar { display: none; }
  #side { left: auto; top: 0; bottom: 0; width: min(380px, 46%); height: auto; border-top: none; border-left: 2px solid #7a5a32; border-radius: 12px 0 0 12px; }
  #side.collapsed { top: auto; height: 46px; width: min(380px, 46%); }
  #mobileBar { bottom: 8px; }
  body.sheet-collapsed #mobileBar { bottom: 8px; }
  #mechBar, body.sheet-collapsed #mechBar { bottom: 54px; left: 30%; }
  #tut, body.sheet-collapsed #tut { bottom: auto; top: 8px; right: 50%; }
  #zoomCtl { right: calc(min(380px, 46%) + 8px); }
  body.sheet-collapsed #zoomCtl { right: 8px; }
}
