:root {
  --ink: #0b0714;
  --bg: #140d2b;
  --y: #ffd23f;
  --p: #ff4fa3;
  --c: #2fe0d0;
  --v: #a66bff;
  --muted: #6a5a9a;
  --font: 'Noto Sans TC', system-ui, sans-serif;
  --display: 'Bungee', 'Noto Sans TC', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #07050f; color: #fff; font-family: var(--font); overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { font-family: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }
img.emoji { height: 1em; width: 1em; margin: 0 .05em 0 .1em; vertical-align: -0.12em; pointer-events: none; filter: drop-shadow(1px 1px 0 #0b0714aa); }

#app { position: relative; width: 100%; max-width: 520px; height: 100dvh; margin: 0 auto; overflow: hidden; background: var(--bg); transform-origin: top center; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* 按鈕：貼紙風 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 14px; font-weight: 900; font-size: 15px; background: #fff; color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); transform: rotate(-1deg); }
.btn:active { transform: translate(2px, 2px) rotate(-1deg); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--y); }
.btn.teal { background: var(--c); }
.btn.pink { background: var(--p); color: #fff; text-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(1) brightness(.8); pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: #fff; color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); font-size: 20px; font-weight: 900; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: #fff; color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); font-size: 13px; font-weight: 900; white-space: nowrap; }
.chip b { font-family: var(--display); font-size: 12px; }

/* HUD */
.hud { position: absolute; left: 0; right: 0; top: 0; padding: 8px 8px 0; padding-top: max(8px, env(safe-area-inset-top)); pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }
.res-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.res { background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); padding: 3px 6px; font-weight: 900; line-height: 1.1; min-width: 0; }
.res .top { display: flex; align-items: center; gap: 3px; font-size: 14px; }
.res .top b { font-family: var(--display); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.res .bar { height: 5px; border-radius: 9px; background: #e6e0f5; margin-top: 3px; overflow: hidden; }
.res .bar i { display: block; height: 100%; background: var(--c); }
.res.full .bar i { background: var(--p); }
.res .rate { font-size: 10px; color: var(--muted); }
.res .rate.neg { color: #d8203f; }
.hud-row2 { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.title-tag { margin-left: auto; font-weight: 900; font-size: 15px; color: var(--y); -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; text-shadow: 2px 2px 0 var(--p), 3px 3px 0 var(--ink); transform: rotate(-3deg); pointer-events: none; }

.zoom-btns { position: absolute; right: 8px; top: 50%; display: flex; flex-direction: column; gap: 8px; z-index: 5; transform: translateY(-50%); }

.bottom-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 8px; padding-bottom: max(10px, env(safe-area-inset-bottom)); z-index: 5; }
.btn.nav { flex: 1; flex-direction: column; gap: 0; padding: 6px 4px; font-size: 22px; }
.btn.nav small { font-size: 12px; }
.btn.nav:nth-child(even) { transform: rotate(1deg); }

/* 底部面板（建築資訊、建造選單等） */
.sheet { position: absolute; left: 6px; right: 6px; bottom: 76px; max-height: 58%; overflow-y: auto; overflow-x: hidden; z-index: 8; background: #1d1438 url('../assets/ui/brick.webp'); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); padding: 12px; animation: up .25s cubic-bezier(.2, 1.3, .5, 1); }
@keyframes up { from { transform: translateY(30%); opacity: 0; } }
.sh-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sh-head .ic { font-size: 34px; }
.sh-head .nm { font-size: 20px; font-weight: 900; }
.sh-head .lv { font-family: var(--display); font-size: 13px; color: var(--y); }
.sh-head .x { margin-left: auto; }
.card { background: #ffffffeb; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; box-shadow: 2px 2px 0 var(--ink); margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
.card b.t { display: block; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cost { display: inline-flex; gap: 6px; flex-wrap: wrap; font-weight: 900; }
.cost span.no { color: #d8203f; }
.avatars { display: flex; gap: 6px; flex-wrap: wrap; }
.av { position: relative; width: 54px; height: 62px; border-radius: 12px; background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; overflow: hidden; }
.av img { height: 48px; }
.av small { font-size: 10px; font-weight: 900; color: var(--ink); }
.av.empty { background: #ffffff55; border-style: dashed; color: var(--ink); font-size: 22px; justify-content: center; }
.av.skill::after { content: '★'; position: absolute; top: 1px; right: 3px; color: #e0a100; font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { text-align: left; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); padding: 8px; font-size: 12px; }
.opt .o-nm { font-size: 15px; font-weight: 900; }
.opt:disabled { opacity: .45; }
.vl { display: flex; gap: 8px; align-items: center; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); padding: 6px 8px; margin-bottom: 6px; }
.vl img { height: 52px; }
.vl .vb { flex: 1; min-width: 0; font-size: 12px; }
.vl .vn { font-size: 15px; font-weight: 900; }
.vl.locked img { filter: brightness(0) opacity(.35); }

/* 覆蓋彈窗 */
.overlay { position: absolute; inset: 0; z-index: 20; background: #07041ad9 url('../assets/ui/splat.webp'); display: flex; flex-direction: column; align-items: center; justify-content: safe center; padding: 20px 14px; overflow-y: auto; overflow-x: hidden; }
.ov-title { font-size: 26px; font-weight: 900; color: var(--y); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--p), 5px 5px 0 var(--ink); transform: rotate(-2deg); margin-bottom: 10px; text-align: center; }
.ov-card { width: 100%; max-width: 360px; background: #1d1438 url('../assets/ui/brick.webp'); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); padding: 14px; }
.ov-actions { display: flex; gap: 10px; margin-top: 14px; justify-content: center; }
.gain { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.toast { position: absolute; left: 50%; top: 110px; z-index: 30; transform: translate(-50%, -10px); background: #fff; color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 8px 14px; border-radius: 99px; font-weight: 900; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.pw-input { width: 100%; padding: 10px; border-radius: 10px; border: 3px solid var(--ink); font-size: 16px; font-weight: 700; }
.ver { text-align: center; font-size: 11px; color: #c9bff0; margin-top: 10px; }
