* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #888; font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; color: #2b2b2b; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

button { font: inherit; border: 0; border-radius: 12px; padding: 10px 18px; background: #f0a23b; color: #fff; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 #c97f1f; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #c97f1f; }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: 6px 12px; font-size: 14px; }
button.big { padding: 14px 34px; font-size: 20px; }
button.ghost { background: #fff; color: #c97f1f; box-shadow: 0 3px 0 #e6c79c; border: 1px solid #f0d2a6; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(40,40,40,.35); z-index: 20; padding: 14px; }
.card { background: #fffaf2; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 22px; max-width: 560px; width: 100%; max-height: 100%; overflow: auto; }
.center { text-align: center; }
h1 { font-size: 46px; margin: 4px 0 6px; color: #e0891e; letter-spacing: 6px; }
.sub { line-height: 1.7; margin: 0 0 16px; }
#pname { font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid #e2cfb0; width: 70%; margin-bottom: 14px; text-align: center; }
.howto { text-align: left; margin-top: 18px; font-size: 14px; line-height: 1.8; background: #fff; border-radius: 12px; padding: 10px 14px; }
.note { font-size: 12px; color: #8a7a66; margin-top: 10px; line-height: 1.6; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
#progress { position: absolute; top: 12px; left: 12px; background: rgba(255,250,242,.92); border-radius: 14px; padding: 10px 14px; min-width: 190px; }
.ptitle { font-weight: 700; font-size: 14px; }
.pbar { height: 10px; background: #ddd; border-radius: 6px; margin-top: 6px; overflow: hidden; }
#pfill { height: 100%; width: 0; background: linear-gradient(90deg,#f66,#fc3,#6c6,#39f,#c6f); transition: width .8s; }
#carry { font-size: 13px; margin-top: 6px; color: #b05f00; }
#scorebox { position: absolute; top: 12px; right: 12px; background: rgba(255,250,242,.92); border-radius: 14px; padding: 8px 14px; font-size: 13px; line-height: 1.6; text-align: right; }
#scorebox b { color: #e0891e; font-size: 16px; }
#btn-about { position: absolute; top: 102px; right: 12px; }
#prompt { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); background: rgba(255,250,242,.95); padding: 8px 16px; border-radius: 20px; font-weight: 700; white-space: nowrap; }
#toast { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); background: #e0891e; color: #fff; padding: 10px 18px; border-radius: 14px; font-weight: 700; text-align: center; max-width: 90%; }

#joy { position: fixed; left: 24px; bottom: 28px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.7); z-index: 11; touch-action: none; }
#joy-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,250,242,.95); }
#btn-act { position: fixed; right: 26px; bottom: 44px; width: 86px; height: 86px; border-radius: 50%; font-size: 18px; z-index: 11; }

.dlg { display: flex; flex-direction: column; gap: 10px; max-height: 92vh; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dname { font-size: 22px; font-weight: 800; }
.tag { display: inline-block; font-size: 12px; background: #fde7c6; color: #a9600c; border-radius: 10px; padding: 2px 10px; margin-top: 4px; }
.mood { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mbar { flex: 1; height: 10px; background: #e5e5e5; border-radius: 6px; overflow: hidden; }
#d-mood { height: 100%; width: 20%; background: linear-gradient(90deg,#8ab,#fc6,#f88); transition: width .6s; }
.log { flex: 1; min-height: 140px; max-height: 38vh; overflow-y: auto; background: #fff; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; line-height: 1.6; font-size: 15px; }
.msg.npc { background: #f3efe8; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.player { background: #ffd89e; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.sys { align-self: center; font-size: 13px; color: #8a7a66; background: none; }
.feedback { background: #eef7ee; border: 1px solid #cfe7cf; border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #fff; border: 1px solid #cfe7cf; }
.chip.give { background: #fff3d6; border-color: #f3d18e; }
.inputrow { display: flex; gap: 8px; }
.inputrow textarea { flex: 1; font: inherit; font-size: 16px; border-radius: 12px; border: 1px solid #e2cfb0; padding: 8px 10px; resize: none; }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #8a7a66; }
#d-extra button { width: 100%; }

.rep { text-align: center; }
.rep-kicker { font-size: 13px; letter-spacing: 4px; color: #a9600c; }
.rep h2 { font-size: 32px; margin: 6px 0 2px; color: #e0891e; }
.rname { color: #8a7a66; margin-bottom: 12px; }
.rgrid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.rstat { background: #fff; border-radius: 12px; padding: 8px; }
.rl { font-size: 13px; color: #8a7a66; }
.rv { font-size: 22px; font-weight: 800; color: #e0891e; }
.gives { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.gives span { padding: 4px 10px; border-radius: 12px; background: #eee; color: #999; font-size: 14px; }
.gives span.on { background: #ffd89e; color: #7a4300; font-weight: 700; }
.letter { text-align: left; line-height: 1.9; background: #fff; border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; }
#r-strengths { text-align: left; line-height: 1.8; }
.next { background: #eef7ee; border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.rbtns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.about p { text-align: left; line-height: 1.8; }

@media (max-width: 600px) {
  h1 { font-size: 36px; }
  #progress { min-width: 150px; padding: 8px 10px; }
  #scorebox { font-size: 12px; }
  #btn-about { top: 92px; }
  .card { padding: 16px; }
  .log { max-height: 30vh; }
}
