:root {
  --paper: #f4ecdb;
  --paper2: #efe5cf;
  --ink: #2b2733;
  --ink2: #5a5262;
  --red: #c8503f;
  --navy: #34456b;
  --shadow: 0 6px 18px rgba(43, 39, 51, 0.18);
  --font: "Noto Serif TC", "PMingLiU", "Songti TC", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9dfc9; color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font-family: var(--font); cursor: pointer; }

.panel { position: fixed; background: rgba(244, 236, 219, 0.88); border: 1.5px solid rgba(43, 39, 51, 0.55); border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(2px); }
#hud.hidden { display: none; }

#status { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); padding: 5px 14px; font-size: 14px; background: rgba(244, 236, 219, 0.82); border: 1.5px solid rgba(43, 39, 51, 0.45); border-radius: 999px; letter-spacing: 0.08em; }

#keys { left: 16px; bottom: 16px; padding: 10px 14px 9px; font-size: 13px; width: 300px; }
#keys h4 { margin: 0 0 6px; font-size: 14px; letter-spacing: 0.15em; }
#keys .kg { display: grid; grid-template-columns: 1.3fr 1fr; gap: 3px 10px; }
#keys .kg div { white-space: nowrap; }
#keys .kf { margin-top: 5px; color: var(--ink2); }
kbd { display: inline-block; min-width: 19px; padding: 0 4px; margin-right: 4px; font: 600 11px/17px var(--font); text-align: center; background: #fbf7ee; border: 1px solid var(--ink2); border-bottom-width: 2px; border-radius: 4px; }
#keys.off { display: none; }

#quests { left: 16px; top: 16px; width: 290px; padding: 10px 12px; font-size: 13px; max-height: 46vh; overflow: auto; }
#quests.off { display: none; }
#quests h3 { margin: 0 0 6px; font-size: 15px; letter-spacing: 0.1em; }
#quests ul { list-style: none; margin: 0; padding: 0; }
#quests li { display: flex; gap: 8px; padding: 6px 6px; border-radius: 8px; cursor: pointer; border: 1px dashed transparent; }
#quests li.tracked { border-color: var(--red); background: rgba(200, 80, 63, 0.07); }
#quests li.done { opacity: 0.5; }
#quests .tt { font-weight: 700; }
#quests .rw { margin-left: 6px; font-size: 11px; color: var(--red); }
#quests .st { color: var(--ink2); font-size: 12px; margin-top: 1px; }
#quests .ok { color: #4d7a4c; }
#quests .timer { color: var(--red); }
#quests .late { color: #8a8a8a; }
#quests .qfoot { margin-top: 6px; font-size: 11px; color: var(--ink2); }
.tag { flex: none; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 6px; font-size: 12px; font-weight: 700; color: #fbf7ee; border: 1px solid var(--ink); }
.t-letter { background: #b8423a; }
.t-parcel { background: #a87b4f; }
.t-bag { background: #5f7699; }

#minimap { right: 16px; top: 16px; width: 200px; height: 200px; padding: 0; overflow: hidden; }
#minimap.off { display: none; }

#cargo { right: 16px; bottom: 16px; padding: 9px 12px; font-size: 13px; min-width: 170px; }
#cargo .ch { margin-bottom: 5px; }
#cargo .slots { display: flex; gap: 6px; }
#cargo .slot { width: 32px; height: 32px; border-radius: 7px; border: 1.5px solid var(--ink); display: grid; place-items: center; color: #fbf7ee; font-weight: 700; position: relative; font-size: 13px; }
#cargo .slot em { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: 10px; background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 50%; width: 16px; height: 16px; display: grid; place-items: center; }
#cargo .slot.empty { border-style: dashed; border-color: rgba(43, 39, 51, 0.35); }
#cargo .stamps { margin-top: 6px; }
#cargo .stamps b { color: var(--red); font-size: 16px; }

#prompt { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(8px); padding: 7px 18px; font-size: 15px; background: rgba(244, 236, 219, 0.94); border: 1.5px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; text-align: center; }
#prompt.on { opacity: 1; transform: translateX(-50%); }
#prompt.dim { color: var(--ink2); border-color: rgba(43, 39, 51, 0.4); }
#prompt .bar { display: block; height: 5px; margin: 5px auto 1px; width: 160px; background: rgba(43, 39, 51, 0.15); border-radius: 3px; overflow: hidden; }
#prompt .bar b { display: block; height: 100%; background: var(--red); }

#toasts { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: min(90vw, 760px); }
.toast { padding: 6px 16px; font-size: 14px; background: rgba(251, 247, 238, 0.95); border: 1.2px solid rgba(43, 39, 51, 0.6); border-radius: 10px; box-shadow: var(--shadow); animation: tin .3s ease; transition: opacity .5s; text-align: center; }
.toast.out { opacity: 0; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

#note { position: fixed; top: 64px; left: 50%; transform: translateX(-50%) rotate(-1.2deg); max-width: min(80vw, 460px); padding: 10px 18px; background: #fbf7ee; border: 1.5px solid var(--ink); font-size: 14px; box-shadow: 3px 4px 0 rgba(43, 39, 51, 0.2); opacity: 0; transition: opacity .4s; pointer-events: none; }
#note.on { opacity: 1; }

#waypoint { position: fixed; left: 0; top: 0; pointer-events: none; display: none; }
#waypoint .pin { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; transform: rotate(45deg); background: var(--red); border: 2px solid var(--ink); box-shadow: 0 0 0 3px rgba(251, 247, 238, 0.8); }
#waypoint[data-kind="bag"] .pin { background: #f2c14e; }
#waypoint[data-kind="pickup"] .pin { background: var(--navy); }
#waypoint .lbl { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); white-space: nowrap; font-size: 12px; padding: 2px 8px; background: rgba(251, 247, 238, 0.9); border: 1px solid rgba(43, 39, 51, 0.5); border-radius: 999px; }
#waypoint .arr { position: absolute; left: -8px; top: -34px; width: 16px; text-align: center; color: var(--red); font-size: 16px; display: none; transform-origin: 8px 34px; }
#waypoint.edge .arr { display: block; }

#title { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(244, 236, 219, 0.05), rgba(244, 236, 219, 0.35)); transition: opacity .8s; }
#title.gone { opacity: 0; pointer-events: none; }
.tcard { text-align: center; padding: 30px 40px 24px; background: rgba(244, 236, 219, 0.86); border: 2px solid var(--ink); border-radius: 18px; box-shadow: 6px 8px 0 rgba(43, 39, 51, 0.18); max-width: min(92vw, 520px); }
.logo { font-size: 54px; font-weight: 700; letter-spacing: 0.22em; margin-left: 0.22em; }
.sub { font-size: 13px; letter-spacing: 0.5em; color: var(--ink2); margin-top: 2px; }
.tcard p { line-height: 1.8; font-size: 15px; margin: 16px 0 18px; }
.btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btns button, .card button { padding: 9px 22px; font-size: 16px; background: var(--ink); color: var(--paper); border: 2px solid var(--ink); border-radius: 999px; }
.btns button:hover { background: var(--red); border-color: var(--red); }
button.ghost { background: transparent !important; color: var(--ink) !important; }
.hint { margin-top: 14px; font-size: 12px; color: var(--ink2); }
.by { position: fixed; bottom: 14px; right: 18px; font-size: 12px; letter-spacing: 0.2em; color: var(--ink2); }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(43, 39, 51, 0.25); }
.overlay[hidden] { display: none; }
.card { background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; padding: 20px 26px; min-width: 300px; max-width: 92vw; box-shadow: 6px 8px 0 rgba(43, 39, 51, 0.2); }
.card h2 { margin: 0 0 12px; letter-spacing: 0.15em; }
.card label { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 8px 0; font-size: 15px; }
.card label.ck { justify-content: flex-start; }
.card input[type=range] { width: 170px; accent-color: var(--red); }
.card select { font-family: var(--font); font-size: 14px; padding: 2px 6px; background: #fbf7ee; border: 1px solid var(--ink2); border-radius: 6px; }
.card .btns { margin-top: 14px; }
.de-list { list-style: none; padding: 0; margin: 0 0 10px; min-width: 300px; }
.de-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed rgba(43, 39, 51, 0.25); }
.de-list li b { margin-left: auto; color: var(--red); }
.de-total { font-size: 16px; }
.de-total b { color: var(--red); font-size: 22px; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #f4ecdb; font-size: 18px; letter-spacing: 0.2em; transition: opacity .6s; z-index: 10; }
#loading.gone { opacity: 0; pointer-events: none; }

#touch { display: none; }
body.touch #touch { display: block; }
body.touch #keys { display: none; }
#stick { position: fixed; left: 22px; bottom: 30px; width: 128px; height: 128px; border-radius: 50%; border: 2px solid rgba(43, 39, 51, 0.5); background: rgba(244, 236, 219, 0.45); touch-action: none; }
#knob { position: absolute; left: 40px; top: 40px; width: 48px; height: 48px; border-radius: 50%; background: rgba(43, 39, 51, 0.75); border: 2px solid var(--paper); pointer-events: none; }
#tbtns { position: fixed; right: 18px; bottom: 30px; display: flex; flex-direction: column-reverse; gap: 7px; align-items: flex-end; }
#tbtns button, #tpause { height: 38px; width: 84px; border-radius: 12px; border: 1.5px solid var(--ink); background: rgba(244, 236, 219, 0.9); font-size: 14px; color: var(--ink); touch-action: none; }
#tbtns button.big { width: 84px; height: 84px; border-radius: 50%; font-size: 26px; font-weight: 700; background: var(--ink); color: var(--paper); }
#tpause { position: fixed; top: 12px; right: 146px; width: 44px; height: 44px; font-size: 20px; }
body.touch #minimap { width: 124px; height: 124px; top: 12px; right: 12px; }
body.touch #status { top: 142px; bottom: auto; left: auto; right: 12px; transform: none; font-size: 12px; padding: 4px 10px; }
body.touch #cargo { top: 176px; bottom: auto; right: 12px; min-width: 0; padding: 7px 9px; font-size: 12px; }
body.touch #cargo .slot { width: 26px; height: 26px; font-size: 12px; }
body.touch #quests { width: calc(100vw - 210px); min-width: 160px; max-height: 50vh; font-size: 12px; padding: 8px 10px; }
body.touch #quests:not(.open) li:not(.tracked) { display: none; }
body.touch #quests:not(.open) .qfoot { display: none; }
body.touch #quests h3 { font-size: 13px; }
body.touch #prompt { bottom: 236px; max-width: 92vw; white-space: normal; }
body.touch #toasts { bottom: 290px; }
body.touch .toast { font-size: 13px; }
body.touch #note { top: auto; bottom: 360px; }
@media (orientation: landscape) and (max-height: 520px) {
  body.touch #prompt { bottom: 14px; }
  body.touch #toasts { bottom: 64px; width: 50vw; }
  body.touch #note { bottom: auto; top: 12px; }
  body.touch #quests { max-height: 60vh; width: 240px; }
  #stick { width: 112px; height: 112px; bottom: 16px; }
  #knob { left: 32px; top: 32px; }
  #tbtns { bottom: 14px; flex-direction: row-reverse; align-items: flex-end; }
}

@media (max-width: 760px) {
  #quests { width: 220px; font-size: 12px; max-height: 34vh; }
  #minimap { width: 130px; height: 130px; }
  .logo { font-size: 40px; }
  #status { top: auto; bottom: 8px; font-size: 12px; }
}

.row2 { display: flex; gap: 8px; margin-top: 6px; }
.row2 button { flex: 1; padding: 6px 10px !important; font-size: 14px !important; }

/* ---------- 趣味系統 ---------- */
#quests .ev { font-size: 12px; margin: -2px 0 6px; padding: 4px 8px; background: rgba(200, 80, 63, 0.08); border-left: 3px solid var(--red); border-radius: 4px; }
#cargo .slot.fragile { box-shadow: 0 0 0 2px #f2c14e; }
#cargo .steam { height: 6px; margin-top: 7px; background: rgba(43, 39, 51, 0.12); border-radius: 3px; overflow: hidden; }
#cargo .steam i { display: block; height: 100%; width: 100%; background: #8fb3c9; transition: width .15s; }
#cargo .steam.on i { background: #f2c14e; }
#cargo .bt { margin-left: 10px; font-size: 12px; color: var(--ink2); }
#cargo { position: fixed; }
.pop { position: absolute; right: 14px; bottom: 26px; font-weight: 700; color: var(--red); font-size: 18px; pointer-events: none; animation: popup 1.2s ease-out forwards; }
@keyframes popup { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-46px); } }
#combo { position: fixed; right: 16px; bottom: 150px; padding: 6px 14px 8px; background: var(--ink); color: var(--paper); border-radius: 10px; box-shadow: var(--shadow); min-width: 110px; text-align: center; }
#combo b { font-size: 17px; letter-spacing: 0.08em; }
#combo i { display: block; height: 3px; margin-top: 4px; background: #f2c14e; border-radius: 2px; }
#combo.bump { animation: cbump .4s ease; }
@keyframes cbump { 30% { transform: scale(1.18) rotate(-3deg); } }
#combo[hidden] { display: none; }
#banner { position: fixed; top: 26%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; }
#banner.on { animation: banner 4.6s ease forwards; }
#banner .bd { font-size: 15px; letter-spacing: 0.4em; color: var(--ink2); }
#banner .bn { font-size: 40px; font-weight: 700; letter-spacing: 0.15em; text-shadow: 0 2px 0 rgba(244, 236, 219, 0.9), 0 0 18px rgba(244, 236, 219, 0.9); }
#banner .bs { font-size: 15px; margin-top: 4px; padding: 4px 14px; background: rgba(244, 236, 219, 0.88); border-radius: 999px; display: inline-block; }
@keyframes banner { 0% { opacity: 0; transform: translateX(-50%) translateY(10px); } 12% { opacity: 1; transform: translateX(-50%); } 80% { opacity: 1; } 100% { opacity: 0; } }
#letter { position: fixed; top: 22%; left: 50%; width: min(86vw, 420px); transform: translateX(-50%) rotate(1.5deg) scale(0.9); padding: 16px 22px 18px; background: #fbf7ee; border: 1.5px solid var(--ink); box-shadow: 4px 6px 0 rgba(43, 39, 51, 0.2); opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; }
#letter.on { opacity: 1; transform: translateX(-50%) rotate(1.5deg) scale(1); }
#letter .lt { font-size: 12px; color: var(--red); letter-spacing: 0.15em; margin-bottom: 6px; }
#letter .lb { font-size: 16px; line-height: 1.7; }
.ach { position: fixed; top: 70px; right: 16px; z-index: 5; padding: 9px 16px; background: var(--ink); color: var(--paper); border-radius: 12px; box-shadow: var(--shadow); display: grid; animation: tin .4s ease; transition: opacity .6s; max-width: 260px; }
.ach span { font-size: 11px; letter-spacing: 0.3em; color: #f2c14e; }
.ach b { font-size: 17px; }
.ach em { font-style: normal; font-size: 12px; opacity: 0.8; }
.ach.out { opacity: 0; }
.card.wide { width: min(94vw, 520px); max-height: 88vh; overflow: auto; }
.shop-body .have { margin-bottom: 8px; }
.shop-body .have b { color: var(--red); font-size: 20px; }
.up { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed rgba(43, 39, 51, 0.25); }
.up .dots { margin-left: 8px; }
.up .dots i { display: inline-block; width: 10px; height: 10px; margin-right: 3px; border: 1.5px solid var(--ink); border-radius: 50%; }
.up .dots i.on { background: var(--red); }
.up .ud { font-size: 12px; color: var(--ink2); }
.card .up button { padding: 6px 14px; font-size: 14px; min-width: 76px; }
.card .up button.poor { opacity: 0.45; }
.card .up button[disabled] { background: transparent; color: var(--ink2); border-style: dashed; }
.card h4 { margin: 14px 0 6px; letter-spacing: 0.1em; }
.paints { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card .paints .sw { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; background: #fbf7ee; color: var(--ink); border: 1.5px solid rgba(43, 39, 51, 0.35); border-radius: 10px; font-size: 13px; }
.card .paints .sw.cur { border-color: var(--red); box-shadow: 0 0 0 2px rgba(200, 80, 63, 0.25); }
.paints .sw i { width: 28px; height: 18px; border-radius: 4px; border: 1.5px solid var(--ink); }
.paints .sw em { font-style: normal; font-size: 11px; color: var(--ink2); }
.al-body ul { list-style: none; padding: 0; margin: 0; }
.achs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.achs li { padding: 6px 8px; border: 1px dashed rgba(43, 39, 51, 0.35); border-radius: 8px; opacity: 0.45; display: grid; font-size: 12px; }
.achs li b { font-size: 14px; }
.achs li.got { opacity: 1; border-style: solid; border-color: var(--red); background: rgba(200, 80, 63, 0.06); }
.bottles li { padding: 6px 4px; border-bottom: 1px dashed rgba(43, 39, 51, 0.2); font-size: 13px; color: var(--ink2); }
.bottles li.got { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div { display: grid; text-align: center; padding: 6px; background: #fbf7ee; border-radius: 8px; font-size: 12px; }
.stats b { font-size: 18px; }
.de-extra { font-size: 14px; margin-bottom: 4px; color: var(--ink2); }
.de-hint { font-size: 12px; color: var(--ink2); margin-top: 4px; }
#tbtns button.boost { background: #f2c14e; }
body.touch #combo { bottom: auto; top: 300px; right: 12px; min-width: 90px; }
body.touch #banner .bn { font-size: 30px; }
@media (max-width: 760px) { .achs { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2, 1fr); } }
/* 觸控按鈕：上方 2x2 小按鈕，下方 加速 + E */
#tbtns { display: grid; grid-template-columns: 84px 84px; gap: 7px; flex-direction: unset; }
#tbtns [data-k="v"] { grid-area: 1 / 1; } #tbtns [data-k="c"] { grid-area: 1 / 2; }
#tbtns [data-k="m"] { grid-area: 2 / 1; } #tbtns [data-k="j"] { grid-area: 2 / 2; }
#tbtns button.boost { grid-area: 3 / 1; height: 84px; border-radius: 50%; font-size: 17px; font-weight: 700; }
#tbtns button.big { grid-area: 3 / 2; }
@media (orientation: landscape) and (max-height: 520px) {
  #tbtns { grid-template-columns: 70px 70px 84px 84px; align-items: end; }
  #tbtns button { width: 70px; }
  #tbtns [data-k="v"] { grid-area: 1 / 1; } #tbtns [data-k="c"] { grid-area: 1 / 2; }
  #tbtns [data-k="m"] { grid-area: 2 / 1; } #tbtns [data-k="j"] { grid-area: 2 / 2; }
  #tbtns button.boost { grid-area: 1 / 3 / 3 / 4; width: 84px; } #tbtns button.big { grid-area: 1 / 4 / 3 / 5; }
}
