/* 薑糖探索地圖 — 像素羊皮紙介面。
   單一視覺世界（像素遊戲），刻意不做 light/dark 雙主題。 */
:root {
  --ink: #2b1d14;
  --parch: #f4e4c2;
  --parch-2: #e2c896;
  --parch-3: #fff7e6;
  --ginger: #f0a04b;
  --ginger-d: #c77f2e;
  --void: #141a24;
  --good: #5d9c59;
  --lock: #8a8f9c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--void);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
  touch-action: none;
  overscroll-behavior: none;
}
#game {
  position: fixed; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; display: block; cursor: pointer;
}

/* ---------- 像素羊皮紙板 ---------- */
.plate {
  background: var(--parch);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,.4), inset 0 0 0 2px var(--parch-2);
  border-radius: 2px;
}
#hud {
  position: fixed; top: 10px; left: 10px; z-index: 10;
  padding: 10px 14px 9px; max-width: min(78vw, 340px); pointer-events: none;
}
#hud .wname { font-size: 17px; font-weight: 800; letter-spacing: 1px; }
#hud .wsub { font-size: 11px; opacity: .72; margin-top: 2px; }
#hud .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 7px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--parch-3);
}
.chip.terr { background: #d8ecd2; }

/* ---------- 按鈕 ---------- */
.pxbtn {
  font-family: inherit; font-size: 13px; font-weight: 800; letter-spacing: 1px;
  color: var(--ink); background: var(--ginger);
  border: 3px solid var(--ink); border-radius: 2px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 8px 14px; cursor: pointer; user-select: none;
}
.pxbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.pxbtn:focus-visible { outline: 3px dashed var(--ginger-d); outline-offset: 2px; }
.pxbtn.ghost { background: var(--parch); }
.pxbtn.sm { font-size: 12px; padding: 6px 11px; }
.pxbtn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
#dock {
  position: fixed; left: 10px; bottom: 10px; z-index: 10;
  display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 180px);
}

/* ---------- D-pad ---------- */
#dpad {
  position: fixed; right: 14px; bottom: 14px; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px);
  gap: 4px; opacity: .92;
}
#dpad button {
  border: 3px solid var(--ink); border-radius: 2px; background: var(--parch);
  box-shadow: 0 3px 0 rgba(0,0,0,.45);
  font-size: 17px; color: var(--ink); cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#dpad button:active {
  background: var(--ginger); transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.45);
}
#dpad .blank { visibility: hidden; }
@media (min-width: 900px) and (hover: hover) {
  #dpad { opacity: .45; }
  #dpad:hover { opacity: .92; }
}

/* ---------- 地點名牌 ---------- */
.spot-label {
  position: fixed; z-index: 5; transform: translate(-50%, -100%);
  font-size: 11px; font-weight: 800; letter-spacing: 1px; white-space: nowrap;
  background: var(--parch); border: 2px solid var(--ink); border-radius: 2px;
  padding: 1px 7px; box-shadow: 0 2px 0 rgba(0,0,0,.35); pointer-events: none;
}
.spot-label .camp { color: var(--ginger-d); }
.spot-label.lockmark { background: #dfe1e6; color: #4a4f5a; }

/* ---------- 互動提示 ---------- */
#actionbar {
  position: fixed; left: 50%; bottom: 138px; transform: translateX(-50%);
  z-index: 12; display: none;
}
#actionbar.show { display: block; }
#actionbar .key { font-size: 11px; opacity: .7; margin-left: 6px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  z-index: 20; padding: 8px 16px; font-size: 13px; font-weight: 700;
  opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- overlay 面板 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(16,20,30,.62);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay[hidden] { display: none; }
.panel {
  width: min(460px, 94vw); max-height: 88vh; overflow-y: auto; padding: 20px 22px 22px;
}
.panel h1 { font-size: 21px; letter-spacing: 2px; }
.panel h2 { font-size: 15px; letter-spacing: 1px; margin-bottom: 8px; }
.panel h3 { font-size: 13px; letter-spacing: 1px; margin: 12px 0 6px; }
.panel .eyebrow {
  font-size: 10px; font-weight: 800; letter-spacing: 3px;
  color: var(--ginger-d); margin-bottom: 4px;
}
.panel .sub { font-size: 12px; opacity: .75; margin-top: 4px; line-height: 1.6; }
.panel hr { border: none; border-top: 2px dashed var(--parch-2); margin: 14px 0; }
.panel .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel .grow { flex: 1; }
.close-x {
  float: right; margin: -6px -8px 0 8px;
  background: var(--parch); border: 2px solid var(--ink); border-radius: 2px;
  font-size: 13px; font-weight: 800; padding: 2px 8px; cursor: pointer;
}

/* ---------- 貓造型 ---------- */
.avatarPrev {
  image-rendering: pixelated; border: 3px solid var(--ink);
  border-radius: 2px; background: #cfe6bd; width: 96px; height: 96px;
}
.customizer .mini {
  display: block; font-size: 11px; font-weight: 800; letter-spacing: 1px;
  opacity: .62; margin: 10px 0 4px;
}
.customizer .seg button { font-size: 11.5px; padding: 4px 9px; }
.customizer .row:first-child .mini { margin-top: 0; }
#hud .wpet { font-size: 12px; font-weight: 800; color: var(--ginger-d); margin-top: 3px; }
#hud .wpet:empty { display: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sw {
  width: 40px; height: 40px; border: 3px solid var(--ink); border-radius: 2px;
  cursor: pointer; box-shadow: 0 2px 0 rgba(0,0,0,.3); padding: 0;
}
.sw.sel { outline: 3px solid var(--ginger-d); outline-offset: 2px; }
.hue-row { margin-top: 12px; }
.hue-row label { font-size: 12px; font-weight: 700; }
.hue-row input[type=range] { width: 100%; margin-top: 6px; accent-color: var(--ginger-d); }

/* ---------- 清單 ---------- */
.dex-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.dex-list li {
  display: flex; align-items: center; gap: 8px;
  background: var(--parch-3); border: 2px solid var(--parch-2); border-radius: 2px;
  padding: 5px 9px; font-size: 13px; font-weight: 600;
}
.dex-list .cnt { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.dex-list img { image-rendering: pixelated; width: 24px; height: 24px; }
.dex-list .tag { font-size: 11px; opacity: .65; font-weight: 600; }
.tchip {
  font-size: 10px; font-weight: 800; border: 2px solid var(--ink);
  border-radius: 2px; padding: 0 5px; background: #d8ecd2;
}
.tchip.f { background: #d7e6f7; }
.tchip.q { background: #cfe3ea; }
.locked { opacity: .45; filter: grayscale(1); }
.provenance {
  font-size: 11px; line-height: 1.7; opacity: .78;
  background: var(--parch-3); border: 2px dashed var(--parch-2);
  border-radius: 2px; padding: 8px 10px; margin-top: 12px;
  word-break: break-word;
}

/* ---------- 工作台 ---------- */
.mat-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.mat {
  display: flex; align-items: center; gap: 5px;
  background: var(--parch-3); border: 2px solid var(--parch-2); border-radius: 2px;
  padding: 5px 9px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; user-select: none;
}
.mat.sel { border-color: var(--ginger-d); background: #ffeccb; box-shadow: 0 2px 0 var(--ginger-d); }
.mat[disabled], .mat.out { opacity: .4; cursor: not-allowed; }
.mat .n { font-variant-numeric: tabular-nums; opacity: .7; }
.recipe {
  font-size: 12px; padding: 4px 8px; background: var(--parch-3);
  border: 2px solid var(--parch-2); border-radius: 2px; margin-bottom: 4px;
}
.recipe .out { font-weight: 800; }
.dream { font-size: 12px; opacity: .8; line-height: 1.7; }
.txtin {
  font-family: inherit; font-size: 14px; width: 100%;
  border: 3px solid var(--ink); border-radius: 2px; background: #fff;
  padding: 7px 9px; color: var(--ink);
}
.txtin:focus-visible { outline: 3px dashed var(--ginger-d); outline-offset: 1px; }
textarea.txtin { resize: vertical; min-height: 84px; line-height: 1.6; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  font-family: inherit; font-size: 12px; font-weight: 700;
  border: 2px solid var(--ink); border-radius: 2px; background: var(--parch);
  padding: 5px 10px; cursor: pointer; color: var(--ink);
}
.seg button.on { background: var(--ginger); box-shadow: inset 0 0 0 2px var(--parch-2); }
.hint-ok { color: var(--good); font-weight: 800; font-size: 12px; }
.hint-bad { color: #b4553f; font-weight: 800; font-size: 12px; }
.lockbox {
  background: #e8eaee; border: 3px solid var(--lock); border-radius: 2px;
  padding: 10px 12px; margin-top: 10px; font-size: 12.5px; font-weight: 700; color: #4a4f5a;
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
