* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: #1d2b24; color: #f3ecd8;
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
#app {
  height: 100%; height: 100dvh; max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; position: relative;
}

/* ---------- HUD */
#hud { flex: none; padding: 6px 10px 6px; background: #24362d; border-bottom: 2px solid #142019; }
#hud .row1 { display: flex; align-items: center; gap: 8px; }
#hClock { flex: 1; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hClock b { color: #ffd76a; }
#hMoney { text-align: right; line-height: 1.1; }
#hCash { font-weight: 700; font-size: 18px; color: #9be38a; }
#hBank { display: block; font-size: 11px; color: #c9d6c2; }
.iconbtn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: #34493e; font-size: 20px; }
.iconbtn:active { background: #46604f; }
#hud .row2 { display: flex; gap: 8px; margin-top: 5px; }
.bar { flex: 1; position: relative; height: 18px; background: #142019; border-radius: 9px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; border-radius: 9px; transition: width .35s; }
#bEnergy i { background: linear-gradient(90deg, #f0b43c, #ffd76a); }
#bHunger i { background: linear-gradient(90deg, #8fbf6a, #c0e070); }
#bHunger.bad i { background: linear-gradient(90deg, #d0553f, #f07a55); }
#bEnergy.bad i { background: linear-gradient(90deg, #d0553f, #f07a55); }
.bar .lbl, .bar b { position: absolute; top: 0; line-height: 18px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.bar .lbl { left: 8px; }
.bar b { right: 8px; }
#hud .row3 { display: flex; align-items: center; gap: 5px; margin-top: 5px; font-size: 12px; }
.chip { padding: 2px 7px; border-radius: 8px; background: #34493e; font-weight: 700; white-space: nowrap; }
.chip.up { background: #5d8a3c; }
#hJob { flex: 1; text-align: right; color: #c9d6c2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- map */
#stage { flex: none; position: relative; display: flex; justify-content: center; background: #2f5a35; }
#map { display: block; touch-action: none; }
#toasts { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 5px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(20, 28, 24, .92); color: #f3ecd8; border-radius: 10px; padding: 7px 12px;
  font-size: 13.5px; max-width: 100%; box-shadow: 0 3px 10px rgba(0,0,0,.3);
  animation: tin .2s ease-out; white-space: pre-line;
}
.toast.goal { background: #6b4fb0; color: #fff; font-weight: 600; }
.toast.good { border-left: 4px solid #9be38a; }
.toast.bad { border-left: 4px solid #f07a55; }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- action sheet */
#sheet {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #f3ecd8; color: #262622; padding: 10px 12px 18px; border-radius: 14px 14px 0 0; margin-top: -10px; position: relative; z-index: 2;
}
#placeHead { display: flex; align-items: flex-start; gap: 8px; }
#placeHead > div:first-child { flex: 1; min-width: 0; }
#pName { margin: 0; font-size: 18px; }
#pHours { font-size: 12px; color: #6d6a5e; }
#pTag { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: #d9e8cf; color: #2f5a35; white-space: nowrap; }
#pTag.closed { background: #f2d0c6; color: #8a2f1b; }
#pTag.walk { background: #fde7a6; color: #6b4b00; }
.grp { margin: 10px 0 2px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #8a8471; }
.act {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; margin: 6px 0; padding: 7px 12px;
  border: 0; border-radius: 11px; background: #fffdf6; text-align: left; color: #262622;
  box-shadow: 0 1px 0 #d8cfb5, 0 2px 6px rgba(80, 60, 20, .08);
}
.act:active:not(:disabled) { background: #fff3cc; transform: translateY(1px); }
.act .txt { flex: 1; min-width: 0; }
.act .l { display: block; font-weight: 700; }
.act .s { display: block; font-size: 12.5px; color: #6d6a5e; }
.act .why { font-size: 11.5px; font-weight: 700; color: #a0442c; white-space: nowrap; }
.act:disabled { opacity: .62; cursor: default; }
.act.info { background: transparent; box-shadow: none; min-height: 0; padding: 4px 2px; opacity: 1; }
.act.info .l { font-weight: 600; font-size: 13px; }
.act.hot { background: #fff0c2; box-shadow: 0 1px 0 #e3c46a, 0 2px 8px rgba(160, 120, 0, .2); }
#hint { margin: 10px 2px 0; font-size: 12.5px; color: #8a8471; text-align: center; }

/* ---------- layers */
.layer {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 16, 13, .62); padding: 14px;
}
.layer[hidden] { display: none; }
.card {
  width: 100%; max-width: 420px; max-height: 92%; max-height: 92dvh; overflow-y: auto;
  background: #f3ecd8; color: #262622; border-radius: 16px; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.4);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.card h1 { margin: 4px 0 8px; font-size: 30px; }
.card h2 { margin: 0 0 8px; font-size: 21px; }
.card p { margin: 8px 0; }
#mBody { white-space: pre-line; }
#mBody ul { margin: 6px 0; padding-left: 20px; white-space: normal; }
#mBtns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.big {
  display: block; width: 100%; min-height: 50px; margin: 8px 0 0; border: 0; border-radius: 12px;
  background: #2f5a35; color: #fff7e0; font-weight: 800; font-size: 17px;
}
.big:active { background: #3d7345; }
.big.alt { background: #e3d9bd; color: #262622; }
.ghost { display: block; width: 100%; min-height: 44px; margin-top: 8px; border: 2px solid #c9bd99; border-radius: 12px; background: transparent; font-weight: 700; color: #4b4738; }
#scrTitle { background: radial-gradient(ellipse at top, #3b6b45, #142019 75%); }
.titlecard { text-align: center; }
.titlecard h1 { font-size: 40px; letter-spacing: -.5px; color: #2f5a35; }
#titleArt { width: 100%; max-width: 320px; height: auto; border-radius: 12px; display: block; margin: 0 auto; }
.tag { color: #4b4738; }
.credit { font-size: 12px; color: #8a8471; }
.tip { font-size: 13.5px; }
.tip a { color: #2f5a35; font-weight: 700; }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: #e3d9bd; font-weight: 700; color: #4b4738; }
.tabs button.on { background: #2f5a35; color: #fff7e0; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed #d8cfb5; font-size: 14px; }
.kv b { font-weight: 700; }
.goal { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #d8cfb5; }
.goal .ck { width: 22px; text-align: center; }
.goal.no { opacity: .55; }
.goal small { display: block; color: #6d6a5e; }
.ladder { margin: 8px 0 12px; }
.ladder h3 { margin: 0 0 4px; font-size: 15px; }
.rung { font-size: 13px; padding: 2px 0 2px 10px; border-left: 3px solid #d8cfb5; }
.rung.cur { border-left-color: #2f5a35; font-weight: 700; }
.rung.done { color: #6d6a5e; }
.menucard .big { margin-top: 14px; }
.howto li { margin: 5px 0; }
.mini { font-size: 12.5px; color: #6d6a5e; }

/* ---------- wide screens: map left, actions right */
@media (min-width: 900px) and (min-height: 560px) {
  #app { max-width: 1120px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; }
  #hud { grid-column: 1 / 3; }
  #stage { grid-row: 2; align-items: flex-start; padding: 12px; background: #1d2b24; }
  #sheet { grid-row: 2; margin: 12px 12px 12px 0; border-radius: 14px; }
}
