/*
VOICE: 末日、冷、帶少少黑色幽默（園丁好有禮貌咁殺你）
IDEA: 主角個「深水埗翻新」山寨腦機 HUD：骨白字、安全橙、點陣數字
PICTURE: 遊戲畫面本身：黑夜霓虹九龍、視線陰影、紅眼機械人
COLOUR and TYPE: 骨白 #ece6d6、安全橙 #ff7a2a、青 #39e0c8、警示紅；Noto Sans HK + DotGothic16 數字
LAYOUT: 全螢幕遊戲；四角 HUD；右邊抽屜面板；手機雙手觸控
*/
:root {
  --ink: #ece6d6; --dim: #9a947f; --acc: #ff7a2a; --good: #39e0c8; --bad: #ff3b4a; --warn: #ffc23a;
  --panel: rgba(11, 11, 15, 0.9); --line: rgba(236, 230, 214, 0.2); --gd: #2aff8a;
  --font: "Noto Sans HK", "Microsoft JhengHei", "PingFang HK", sans-serif; --dot: "DotGothic16", "Noto Sans HK", monospace;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; background: #050608; color: var(--ink); font: 15px/1.45 var(--font); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#game { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: var(--ink); background: rgba(236, 230, 214, 0.06); border: 1px solid var(--line); padding: 8px 14px; cursor: pointer; border-radius: 2px; min-height: 40px; }
button:hover:not(:disabled) { border-color: var(--acc); color: #fff; }
button:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--acc); color: #120a04; border-color: var(--acc); font-weight: 700; }
button.primary:hover:not(:disabled) { background: #ff9550; color: #120a04; }
input { font: 16px var(--font); color: var(--ink); background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); padding: 8px 10px; }
.scan { position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; z-index: 5; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hudTL { position: absolute; left: 14px; top: 12px; width: 220px; padding: 10px 12px; background: linear-gradient(90deg, rgba(8, 8, 11, 0.78), rgba(8, 8, 11, 0.35)); border-left: 2px solid var(--acc); }
#hudTL .who { font-weight: 700; margin-bottom: 4px; } #hudTL .who small { color: var(--dim); font-weight: 400; margin-left: 6px; }
.bar { display: grid; grid-template-columns: 34px 1fr 26px; align-items: center; gap: 6px; font-size: 12px; height: 18px; }
.bar span { color: var(--dim); } .bar b { font: 13px var(--dot); text-align: right; }
.bar div { height: 7px; background: repeating-linear-gradient(90deg, rgba(236, 230, 214, 0.12) 0 3px, transparent 3px 4px); }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--ink) 0 3px, transparent 3px 4px); }
.bar.hp i { background: repeating-linear-gradient(90deg, #ff6a5a 0 3px, transparent 3px 4px); }
.bar.st i { background: repeating-linear-gradient(90deg, var(--good) 0 3px, transparent 3px 4px); }
.bar.low b, .bar.low span { color: var(--bad); animation: blink 1s steps(2) infinite; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tags span { font-size: 12px; padding: 1px 6px; border: 1px solid; }
.tags .bad { color: var(--bad); } .tags .warn { color: var(--warn); } .tags .ok { color: var(--good); }
#hudTR { position: absolute; right: 14px; top: 12px; display: flex; gap: 10px; align-items: flex-start; }
#hudTRtext { text-align: right; padding: 8px 10px; background: linear-gradient(270deg, rgba(8, 8, 11, 0.78), rgba(8, 8, 11, 0.3)); border-right: 2px solid var(--acc); font-size: 12px; color: var(--dim); }
#hudTRtext .clock { font-size: 14px; color: var(--ink); } #hudTRtext .clock b { font: 22px var(--dot); color: var(--acc); margin-left: 4px; }
#hudTRtext b.ok { color: var(--good); font-weight: 400; } #hudTRtext b.bad { color: var(--bad); font-weight: 400; }
.threat { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 3px; }
.threat div { width: 90px; height: 6px; background: rgba(255, 59, 74, 0.15); } .threat i { display: block; height: 100%; background: var(--bad); }
#minimap { width: 150px; height: 150px; background: rgba(5, 6, 9, 0.85); border: 1px solid var(--line); border-radius: 50%; }
#log { position: absolute; left: 14px; bottom: 14px; width: min(480px, 50vw); font-size: 13px; display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
#log div { padding: 1px 8px; background: rgba(5, 6, 9, 0.45); border-left: 2px solid transparent; }
#log .story { color: var(--ink); border-color: var(--ink); } #log .bad { color: #ff7a82; border-color: var(--bad); } #log .warn { color: var(--warn); }
#log .good { color: var(--good); } #log .tip { color: #ffb68a; border-color: var(--acc); } #log .gardener { color: var(--gd); border-color: var(--gd); } #log .info { color: #cfc9b8; }
#hudBC { position: absolute; right: 14px; bottom: 14px; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; max-width: 40vw; font-size: 13px; }
#hudBC > div { background: rgba(8, 8, 11, 0.75); border: 1px solid var(--line); padding: 4px 10px; }
.wslot b { color: var(--acc); font-size: 15px; } .wslot em { font: 16px var(--dot); font-style: normal; color: var(--ink); } .wslot small, .wt { color: var(--dim); }
.lslot { color: var(--dim); } .lslot.on { color: #fff3c8; border-color: #fff3c8 !important; }
.act { position: relative; color: var(--acc); overflow: hidden; } .act i { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--acc); }
.keys { width: 100%; text-align: right; color: var(--dim); font-size: 11px; background: none !important; border: 0 !important; padding: 0 !important; }
#prompt { position: absolute; transform: translate(-50%, -100%); background: rgba(8, 8, 11, 0.88); border: 1px solid var(--acc); padding: 4px 10px; font-size: 13px; white-space: nowrap; display: flex; gap: 8px; align-items: baseline; }
#prompt .lbl { color: var(--acc); } #prompt i { color: var(--bad); font-style: normal; font-size: 12px; } #prompt .more { color: var(--dim); font-size: 11px; }
#hurtFx { position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 0, 20, 0.55)); }
#hurtFx.on { animation: hurt 0.5s ease-out; }
#sleepFx { position: fixed; inset: 0; z-index: 7; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; pointer-events: none; }
#sleepFx span { font: 18px var(--font); color: var(--dim); letter-spacing: 0.1em; animation: blink 2s steps(2) infinite; }

/* ── 面板 ── */
#panel { position: fixed; right: 14px; top: 180px; bottom: 70px; width: min(440px, calc(100vw - 28px)); background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--acc); z-index: 20; display: flex; flex-direction: column; }
.ph { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ph b { color: var(--acc); } .ph span { flex: 1; color: var(--dim); font-size: 12px; display: flex; gap: 6px; } .ph button { min-height: 32px; padding: 4px 10px; }
.ph span button.on { border-color: var(--acc); color: var(--acc); }
.list { overflow-y: auto; flex: 1; padding: 4px; touch-action: pan-y; }
.item { display: grid; grid-template-columns: 26px 1fr 40px; gap: 8px; align-items: center; padding: 5px 6px; cursor: pointer; border-bottom: 1px solid rgba(236, 230, 214, 0.05); min-height: 36px; }
.item:hover, .item.sel { background: rgba(255, 122, 42, 0.12); }
.item .g { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid; font-size: 13px; }
.item span { font-size: 14px; } .item small { color: var(--dim); margin-left: 6px; font-size: 12px; } .item i { color: var(--dim); font: 12px var(--dot); text-align: right; font-style: normal; }
.item .eq { font: 10px var(--dot); color: #120a04; background: var(--acc); padding: 0 3px; margin-left: 6px; font-style: normal; }
.item.rot span { color: #8a9a6a; text-decoration: line-through; }
.c-food, .c-drink { color: #9fe07a; } .c-med { color: #ff8a8a; } .c-melee, .c-gun, .c-throw { color: var(--acc); } .c-ammo { color: #e8c86a; } .c-tool { color: var(--good); } .c-mat { color: #c8b89a; } .c-bag, .c-wear { color: #b8a0ff; } .c-misc { color: var(--dim); }
.empty { color: var(--dim); padding: 16px; text-align: center; }
.detail { border-top: 1px solid var(--line); padding: 10px; } .detail p { margin: 4px 0 8px; color: var(--dim); font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; } .btns.col { flex-direction: column; }
.cols { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; }
.cols > div { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.cols h4 { margin: 0; padding: 6px 8px; font-size: 13px; color: var(--acc); display: flex; justify-content: space-between; align-items: center; }
.cols h4 button { min-height: 28px; padding: 2px 8px; font-size: 12px; }
.recipe { display: flex; gap: 10px; align-items: center; padding: 8px; border-bottom: 1px solid rgba(236, 230, 214, 0.06); }
.recipe > div { flex: 1; } .recipe p { margin: 3px 0 0; font-size: 12px; } .recipe p.d { color: var(--dim); }
.recipe span { margin-right: 6px; } .recipe .ok { color: var(--good); } .recipe .bad { color: #ff7a82; } .recipe.no b { color: var(--dim); }
.hint { padding: 8px 10px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--line); }
.charinfo { padding: 10px 12px; overflow-y: auto; } .charinfo p { margin: 4px 0; font-size: 13px; } .charinfo h4 { color: var(--acc); margin: 12px 0 4px; }
.charinfo .d { color: var(--dim); }
.skill { display: grid; grid-template-columns: 48px 1fr; position: relative; padding: 3px 0 5px; font-size: 13px; }
.skill b { color: var(--acc); letter-spacing: 1px; font-weight: 400; font-size: 12px; } .skill i { position: absolute; left: 48px; bottom: 1px; height: 2px; background: var(--good); }
#ctx { position: fixed; z-index: 30; background: var(--panel); border: 1px solid var(--acc); min-width: 200px; display: flex; flex-direction: column; }
#ctx .ct { padding: 6px 10px; color: var(--acc); font-size: 13px; border-bottom: 1px solid var(--line); }
#ctx button { border: 0; border-bottom: 1px solid rgba(236, 230, 214, 0.06); text-align: left; background: none; display: flex; justify-content: space-between; gap: 10px; }
#ctx button:hover { background: rgba(255, 122, 42, 0.15); } #ctx button.off { color: var(--dim); } #ctx small { color: #ff7a82; font-size: 11px; }
#mapView { position: fixed; inset: 0; z-index: 40; background: rgba(3, 4, 6, 0.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
#mapView canvas { border: 1px solid var(--line); image-rendering: pixelated; } #mapView small { color: var(--dim); }
#banner { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 25; text-align: center; pointer-events: none; animation: banner 3.8s ease forwards; }
#banner div { font: 900 clamp(34px, 6vw, 56px)/1.05 var(--font); letter-spacing: 0.06em; text-shadow: 0 0 18px rgba(255, 122, 42, 0.6); }
#banner small { color: var(--dim); font-size: 15px; }
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(3, 4, 6, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mbox { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--acc); padding: 18px 20px; touch-action: pan-y; }
.mbox h3 { margin: 0 0 10px; color: var(--acc); } .mbox h4 { color: var(--acc); margin: 12px 0 4px; }
.note { font-size: 16px; line-height: 1.7; background: rgba(236, 230, 214, 0.06); padding: 12px; border-left: 2px solid var(--ink); }
.help p { font-size: 14px; margin: 6px 0; } .sliders { display: grid; gap: 8px; margin-top: 14px; } .sliders label { display: grid; grid-template-columns: 90px 1fr; align-items: center; color: var(--dim); }
.death { text-align: center; } .death p { margin: 6px 0; } .death .who { font-size: 18px; } .death .cause { color: #ff7a82; } .death .st { color: var(--dim); font-size: 13px; }
.death .gd { color: var(--gd); font-size: 13px; margin: 14px 0; } .death .btns { justify-content: center; }

/* ── 主畫面 / 建立角色 ── */
.screen { position: fixed; inset: 0; z-index: 60; overflow-y: auto; touch-action: pan-y;
  background: radial-gradient(ellipse at 20% 110%, rgba(255, 45, 149, 0.28), transparent 55%), radial-gradient(ellipse at 85% -10%, rgba(0, 229, 255, 0.2), transparent 50%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 46px), linear-gradient(#07080c, #0d0a12); }
.screen::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 34vh; pointer-events: none;
  background: linear-gradient(transparent, rgba(5, 6, 8, 0.95)), repeating-linear-gradient(90deg, #0b0c11 0 38px, #101119 38px 66px, #090a0e 66px 120px); clip-path: polygon(0 40%, 6% 40%, 6% 12%, 12% 12%, 12% 30%, 19% 30%, 19% 0, 24% 0, 24% 25%, 33% 25%, 33% 50%, 39% 50%, 39% 8%, 47% 8%, 47% 35%, 55% 35%, 55% 15%, 61% 15%, 61% 42%, 70% 42%, 70% 5%, 76% 5%, 76% 28%, 84% 28%, 84% 18%, 91% 18%, 91% 38%, 100% 38%, 100% 100%, 0 100%); }
.title-box { position: relative; z-index: 2; max-width: 720px; margin: 0 auto; padding: max(9vh, 40px) 22px 30vh; }
.glitch { position: relative; font: 900 clamp(48px, 11vw, 96px)/1.02 var(--font); letter-spacing: 0.04em; color: var(--ink); text-wrap: balance; }
.glitch::before, .glitch::after { content: attr(data-t); position: absolute; left: 0; top: 0; width: 100%; }
.glitch::before { color: #ff2d95; transform: translate(-3px, 0); clip-path: inset(0 0 62% 0); opacity: 0.8; animation: gl1 3.2s steps(1) infinite; }
.glitch::after { color: #00e5ff; transform: translate(3px, 0); clip-path: inset(58% 0 0 0); opacity: 0.8; animation: gl2 2.7s steps(1) infinite; }
.glitch.big { font-size: clamp(40px, 9vw, 72px); }
.title-box .sub { font: 15px var(--dot); color: var(--acc); letter-spacing: 0.08em; margin: 8px 0 22px; }
.title-box .tag { font-size: 17px; line-height: 1.6; border-left: 2px solid var(--gd); padding: 6px 14px; max-width: 34em; }
.title-box .tag span { display: block; color: var(--gd); font-size: 13px; margin-top: 4px; }
.title-box .menu { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; max-width: 300px; }
.title-box .menu button { min-height: 48px; font-size: 17px; text-align: left; padding-left: 16px; }
.title-box .foot { margin-top: 18px; color: var(--dim); font-size: 12px; }
.create-box { position: relative; z-index: 2; max-width: 940px; margin: 0 auto; padding: 28px 18px 40px; }
.create-box h2 { color: var(--acc); margin: 0 0 14px; font-size: 24px; } .create-box h3 { margin: 18px 0 8px; font-size: 16px; display: flex; justify-content: space-between; }
.create-box .row { display: flex; gap: 8px; align-items: center; } .create-box .row label { color: var(--dim); } .create-box .row input { width: 200px; }
.create-box .row.end { justify-content: flex-end; margin-top: 18px; position: sticky; bottom: 0; padding: 10px 0; background: linear-gradient(transparent, #0b0a10 40%); }
.occs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.occ, .trait { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: rgba(8, 8, 11, 0.7); }
.occ b, .trait b { font-size: 15px; } .occ small, .trait small { color: var(--dim); font-size: 12px; line-height: 1.4; } .occ i { color: var(--good); font-style: normal; font-size: 12px; }
.occ.on, .trait.on { border-color: var(--acc); background: rgba(255, 122, 42, 0.14); }
.occ-items { margin-top: 8px; color: var(--dim); font-size: 13px; }
.traits { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.trait em { font: 13px var(--dot); font-style: normal; color: #ff7a82; } .trait.neg em { color: var(--good); }
.pts { font: 14px var(--dot); color: var(--good); } .pts.bad { color: var(--bad); }

/* ── 手機觸控 ── */
#touch { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#joyZone { position: absolute; left: 0; top: 30%; bottom: 0; width: 50%; pointer-events: auto; }
#joyBase { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(236, 230, 214, 0.25); background: rgba(236, 230, 214, 0.05); display: none; pointer-events: none; }
#joyBase.on { display: block; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 122, 42, 0.5); border: 2px solid var(--acc); transform: translate(-50%, -50%); }
.tb { pointer-events: auto; border-radius: 50%; background: rgba(8, 8, 11, 0.6); border: 2px solid rgba(236, 230, 214, 0.3); padding: 0; font-weight: 700; touch-action: none; }
.tb.down { background: rgba(255, 122, 42, 0.5); } .tb.on { border-color: var(--acc); color: var(--acc); }
.tbtns { position: absolute; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: 74px; width: 200px; height: 190px; }
.tb.big { position: absolute; right: 0; bottom: 0; width: 92px; height: 92px; font-size: 18px; border-color: var(--acc); }
.tb.mid { position: absolute; right: 100px; bottom: 6px; width: 72px; height: 72px; font-size: 13px; }
.tb.sm2 { position: absolute; right: 18px; bottom: 104px; width: 60px; height: 60px; }
.trow { position: absolute; right: calc(10px + env(safe-area-inset-right, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 6px; }
.tb.sm { width: 44px; height: 44px; font-size: 14px; }
body.touch #hudBC { bottom: auto; top: 12px; right: auto; left: 50%; transform: translateX(-50%); justify-content: center; max-width: 34vw; }
body.touch #log { bottom: auto; top: 168px; width: min(360px, 52vw); font-size: 12px; }
body.touch #panel { top: 12px; bottom: 64px; }
body.touch #prompt .more { display: none; }

@media (max-width: 700px) {
  #hudTL { width: 168px; padding: 6px 8px; } .bar { grid-template-columns: 30px 1fr 22px; font-size: 11px; height: 15px; }
  #minimap { width: 96px; height: 96px; } #hudTRtext { font-size: 11px; padding: 5px 7px; } #hudTRtext .stat { display: none; }
  #hudTR { flex-direction: column-reverse; align-items: flex-end; }
  body.touch #log { top: 150px; width: 56vw; }
  body.touch #hudBC { left: auto; right: 12px; transform: none; top: 150px; max-width: 42vw; justify-content: flex-end; }
  .cols { grid-template-columns: 1fr; } .cols > div { max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) { .glitch::before, .glitch::after, #banner, .bar.low b { animation: none !important; } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes gl1 { 0%, 100% { transform: translate(-3px, 0); } 30% { transform: translate(2px, -1px); } 31% { transform: translate(-6px, 1px); } 60% { transform: translate(-2px, 0); } }
@keyframes gl2 { 0%, 100% { transform: translate(3px, 0); } 45% { transform: translate(-2px, 1px); } 46% { transform: translate(6px, 0); } 80% { transform: translate(2px, 0); } }
