/* KSF Farm Café — giao diện CHIBI dễ thương 🍓
   Màu pastel, bo tròn, nút kẹo ngọt. Chỉ animate transform/opacity. */
:root {
  --pink: #e8598b; --pink-lt: #fbd9e4; --cream: #fff8ea; --mint: #b5ead7;
  --sun: #ffc53d; --sky: #4aa8de; --ink: #432818; --muted: #8a6f56;
  --green: #58a63c; --green-d: #3e7a28; --soil: #b07a45; --wood: #8f5a2e;
  --card: #fffdf8; --card-bd: #ead9b8; --red: #e4572e; --orange: #e8912d;
  --tabbar-h: 66px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI Rounded", "Hiragino Maru Gothic ProN", sans-serif;
  background: linear-gradient(180deg, #a8dcf5 0%, #cdeecb 45%, var(--cream) 100%);
  background-attachment: fixed;
  color: var(--ink); min-height: 100vh; min-height: 100dvh;
  touch-action: manipulation; overscroll-behavior-y: contain;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; position: relative; }

/* ---- thanh trên: kẹo dẻo ---- */
#hud {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, #a06a35, var(--wood)); color: #fff;
  position: sticky; top: 0; z-index: 20;
  border-bottom-left-radius: 22px; border-bottom-right-radius: 22px;
  box-shadow: 0 3px 0 rgba(90,55,20,.35);
}
.hud-item {
  display: flex; align-items: center; gap: 5px; font-size: 15px;
  background: rgba(255,255,255,.35); border-radius: 999px; padding: 5px 12px;
  text-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.hud-item b { font-size: 16px; }
.xpbar { width: 70px; height: 9px; background: rgba(255,255,255,.4); border-radius: 99px; overflow: hidden; }
.xpbar div { height: 100%; background: var(--sun); border-radius: 99px; transition: width .4s; }
#hud-xp-text { font-size: 10px; opacity: .95; }
#hud-cloud { margin-left: auto; font-size: 19px; background: rgba(255,255,255,.35); border-radius: 50%; padding: 5px; }

/* ---- màn hình ---- */
#screen { flex: 1; padding: 12px 12px 24px; }
.screen-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 4px 10px; }
.screen-head h2 { margin: 0; font-size: 21px; letter-spacing: .5px; }
.screen-head h2::before { content: "🌸 "; } .screen-head h2::after { content: " 🌸"; }

/* ---- thẻ kẹo ---- */
.card {
  background: var(--card); border-radius: 22px; padding: 14px; margin: 10px 0;
  border: 3px solid var(--card-bd);
  box-shadow: 0 4px 0 rgba(190,150,90,.35);
}
.card h3 { margin: 0 0 8px; font-size: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 0; border-bottom: 2px dotted var(--card-bd); }
.row:last-child { border-bottom: none; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0; line-height: 1.5; }
.good { color: var(--green-d); } .bad { color: var(--red); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; align-items: center; }
.btnrow.center { justify-content: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { background: #fff7d6; border: 2px solid var(--sun); border-radius: 999px; padding: 6px 12px; font-size: 14px; }

/* ---- nút kẹo ngọt ---- */
.btn {
  min-height: 48px; padding: 10px 18px; font-size: 16px; border: none; border-radius: 999px;
  background: #fff; color: var(--ink); font-weight: 700; cursor: pointer; font-family: inherit;
  border: 3px solid var(--pink-lt);
  box-shadow: 0 3px 0 var(--pink-lt);
  transition: transform .08s;
}
.btn:active { transform: scale(.94); box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, #6fc24a, var(--green)); color: #fff; border-color: var(--green-d); box-shadow: 0 3px 0 var(--green-d); text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn.danger { background: #ffe3e3; color: var(--red); border-color: #ffc9c9; box-shadow: 0 3px 0 #ffc9c9; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.wide { width: 100%; margin: 6px 0; display: block; }
.btn.big { font-size: 20px; padding: 14px; }
.btn.sm { min-height: 42px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; }
.btn.pick { text-align: left; border-radius: 18px; }

/* ---- luống đất chibi ---- */
.plots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.plot {
  border: 3px solid var(--soil); border-radius: 18px; background: #f7e3c3;
  padding: 6px 4px; min-height: 112px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-family: inherit;
  box-shadow: 0 3px 0 #e0b883;
  transition: transform .08s;
}
.plot:active { transform: scale(.93); }
.plot .mini { display: grid; grid-template-columns: repeat(3, 1fr); font-size: 19px; line-height: 1.3; }
.plot .mini span { display: inline-block; animation: sway 2.4s ease-in-out infinite; }
.plot .mini span:nth-child(2n) { animation-delay: .4s; } .plot .mini span:nth-child(3n) { animation-delay: .8s; }
@keyframes sway { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.plot.empty { background: #fdf3e3; border-style: dashed; border-color: #e8cfa8; box-shadow: none; }
.plot-empty { font-size: 30px; opacity: .55; }
.plot-name { font-size: 12px; font-weight: 700; }
.plot-sub { font-size: 11px; color: var(--muted); }
.plot-sub.ripe { color: var(--green-d); font-weight: 700; }
.plot.ripe { border-color: var(--sun); background: #fffbe8; animation: bounce 1.2s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.03); } }
.plot.withered { filter: grayscale(.7); }
@media (prefers-reduced-motion: reduce) { .plot.ripe, .plot .mini span { animation: none; } * { transition: none !important; } }

/* ---- nhà chibi ---- */
.house-scene {
  background: linear-gradient(180deg, #bfe9ff 0%, #e8f9e8 60%, #d8f3c8 100%);
  border-radius: 18px; padding: 14px; text-align: center; font-size: 40px; line-height: 1.5;
  border: 3px dashed var(--mint); margin: 8px 0; min-height: 130px;
}
.house-main { font-size: 64px; display: block; animation: sway 3s ease-in-out infinite; }

/* ---- thanh tiến độ kẹo ---- */
.bar { height: 12px; background: #f7ecd4; border-radius: 99px; overflow: hidden; margin: 6px 0; width: 100%; border: 2px solid var(--card-bd); }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--mint), var(--green)); border-radius: 99px; transition: width 1s linear; }
.bar.thin { height: 8px; }
.bar .fill.low { background: var(--red); }
.bar.pour { height: 18px; }

/* ---- khách chibi ---- */
.cust {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-bottom: 2px dotted var(--card-bd); background: #fffdf6; border-radius: 14px; margin-bottom: 6px;
}
.cust-face { font-size: 38px; animation: sway 2s ease-in-out infinite; }
.cust-info { flex: 1; }

/* ---- bước pha chế ---- */
.brew-step {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: #fff; border: 3px solid var(--pink-lt); border-radius: 18px;
  padding: 14px; margin: 8px 0; font-size: 17px; font-weight: 700; color: var(--ink);
  font-family: inherit; cursor: pointer; box-shadow: 0 3px 0 var(--pink-lt);
}
.brew-step:active { transform: scale(.96); }
.brew-step.done { background: var(--mint); border-color: var(--green); box-shadow: none; opacity: .75; }
.brew-step .n {
  width: 34px; height: 34px; border-radius: 50%; background: var(--pink); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brew-step.done .n { background: var(--green-d); }
.brew-dots { text-align: center; font-size: 22px; letter-spacing: 6px; margin: 4px 0; }

/* ---- tab dưới ---- */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 1080px; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #fff; z-index: 20;
  border-top: 3px solid var(--card-bd); border-top-left-radius: 22px; border-top-right-radius: 22px;
  box-shadow: 0 -3px 12px rgba(150,110,60,.18);
}
#tabbar button {
  flex: 1; border: none; background: none; font-size: 24px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: var(--muted); min-height: 48px; font-family: inherit;
}
#tabbar button span { font-size: 10px; font-weight: 700; }
#tabbar button.on { color: var(--green-d); transform: translateY(-4px); }
#tabbar button.on span { color: var(--ink); }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translate(-50%, 20px);
  background: rgba(107,79,58,.96); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 15px; max-width: 92%; text-align: center; z-index: 60;
  border: 3px solid #fff;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- popup ---- */
#modal, #welcome {
  position: fixed; inset: 0; background: rgba(255,182,200,.35); backdrop-filter: blur(2px); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
#modal.show, #welcome.show { display: flex; }
.modal-card, .welcome-card {
  background: var(--cream); border-radius: 26px; padding: 20px; width: 100%; max-width: 420px;
  max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  border: 4px solid #fff; box-shadow: 0 8px 0 rgba(150,110,60,.25);
  animation: pop .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-card h3 { margin-top: 0; }

/* ---- chào mừng ---- */
.welcome-card { text-align: center; }
.w-emoji { font-size: 76px; animation: bounce 1.6s ease-in-out infinite; }
.welcome-card h2 { margin: 8px 0; color: var(--pink); }
.welcome-card p { color: var(--muted); line-height: 1.55; }
.dots { margin: 12px 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--card-bd); margin: 0 4px; }
.dot.on { background: var(--pink); transform: scale(1.3); }

/* ---- form ---- */
.textinput {
  width: 100%; min-height: 50px; font-size: 17px; padding: 10px 16px;
  border: 3px solid var(--pink-lt); border-radius: 999px; margin: 6px 0; font-family: inherit;
  background: #fff; color: var(--ink); text-align: center;
}
.textinput:focus { outline: none; border-color: var(--pink); }
.textinput.num { width: 110px; }
select.textinput { text-align: left; }
.btnrow label { font-size: 14px; font-weight: 700; }
.neighbor { width: 100%; text-align: left; background: #fff; border: 3px solid var(--card-bd);
  border-radius: 16px; font-size: 15px; cursor: pointer; font-family: inherit; color: var(--ink);
  margin-bottom: 8px; box-shadow: 0 2px 0 rgba(190,150,90,.35); }
.neighbor:active { transform: scale(.98); }

/* ---- nhật ký ---- */
.log { max-height: 260px; overflow-y: auto; }
.logrow { padding: 8px 10px; margin-bottom: 6px; background: #fffdf6; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.lvl { font-size: 12px; background: #fff7d6; border: 2px solid var(--sun); border-radius: 999px; padding: 2px 10px; font-weight: 700; }

/* ---- đồng hồ ngày ---- */
.day-clock {
  text-align: center; background: linear-gradient(180deg, #fff7d6, #ffefa8);
  border: 3px solid var(--sun); border-radius: 18px; padding: 10px; margin: 8px 0;
}
.day-clock .time { font-size: 34px; font-weight: 800; letter-spacing: 2px; }
.day-clock .dayno { font-size: 14px; font-weight: 700; color: var(--muted); }

/* ---- đợt 2: mưa, mèo thần tài, món hot, giờ cao điểm, avatar ---- */
.rain { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.rain i {
  position: absolute; top: -20px; width: 3px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, transparent, #7ec8f7);
  animation: rainfall 1.1s linear infinite;
}
.rain i:nth-child(1) { left: 8%; animation-delay: 0s; }
.rain i:nth-child(2) { left: 22%; animation-delay: .3s; }
.rain i:nth-child(3) { left: 38%; animation-delay: .6s; }
.rain i:nth-child(4) { left: 52%; animation-delay: .15s; }
.rain i:nth-child(5) { left: 66%; animation-delay: .45s; }
.rain i:nth-child(6) { left: 80%; animation-delay: .75s; }
.rain i:nth-child(7) { left: 92%; animation-delay: .9s; }
.rain i:nth-child(8) { left: 15%; animation-delay: 1s; }
@keyframes rainfall { to { transform: translateY(110vh); } }

.cat-card { display: flex; align-items: center; gap: 12px; }
.cat-mascot { display: flex; align-items: center; gap: 8px; }
.cat-face { font-size: 44px; animation: sway 2.2s ease-in-out infinite; display: inline-block; }
.cat-name { font-weight: 800; font-size: 14px; }

.hot-banner {
  background: linear-gradient(90deg, #ff9a3d, #ff6b6b); color: #fff;
  border-radius: 16px; padding: 10px 14px; margin: 8px 0; font-size: 14px;
  border: 3px solid #fff; box-shadow: 0 3px 0 rgba(255,107,107,.3);
  text-shadow: 0 1px 0 rgba(0,0,0,.12);
  animation: hotglow 1.6s ease-in-out infinite;
}
@keyframes hotglow { 0%,100% { transform: scale(1); } 50% { transform: scale(1.015); } }

.rush-timer {
  background: linear-gradient(180deg, #fff7d6, #ffefa8); border: 3px solid var(--sun);
  border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 15px;
  animation: hotglow 1s ease-in-out infinite;
}

.story { font-size: 16px; line-height: 1.7; background: #fff; border-radius: 16px; padding: 14px;
  border: 3px dashed var(--pink-lt); margin: 10px 0; }

.avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.avatar-pick {
  border: 3px solid var(--pink-lt); border-radius: 18px; background: #fff;
  padding: 8px 4px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink);
}
.avatar-pick.on { border-color: var(--pink); background: #fff0f4; box-shadow: 0 3px 0 var(--pink-lt); }
.avatar-pick img { width: 64px; height: 64px; object-fit: contain; }
.avatar-pick:active { transform: scale(.94); }
.hud-avatar svg { width: 30px; height: 30px; display: block; }
#hud-avatar { padding: 2px 6px !important; }
.cust-face svg { display: block; }
@media (prefers-reduced-motion: reduce) { .rain, .hot-banner, .rush-timer { animation: none; } .rain { display: none; } }

/* ============ CẢNH QUÁN 2.5D + NÔNG TRẠI ISO (đợt 6) ============ */
.scene-wrap { position: relative; width: 100%; aspect-ratio: 1000 / 620;
  border-radius: 22px; overflow: hidden; border: 4px solid #fff;
  box-shadow: 0 4px 0 rgba(190,150,90,.35); margin: 8px 0; }
.scene { position: absolute; inset: 0; }
/* quán: tường + sàn gỗ */
.cafe-bg-wall { position: absolute; inset: 0 0 58% 0;
  background: linear-gradient(180deg, #fff3da 0%, #ffe9c4 70%, #f7d9a8 100%); }
.cafe-bg-floor { position: absolute; inset: 42% 0 0 0;
  background: repeating-linear-gradient(90deg, #e8b98a 0 46px, #dfae7f 46px 92px),
              linear-gradient(180deg, #eec08e, #e0a878);
  border-top: 4px solid #c98f5f; }
.cafe-counter { position: absolute; left: 6%; right: 6%; top: 30%; height: 13%;
  background: linear-gradient(180deg, #b0713e, #8f5a2e); border-radius: 14px;
  border: 3px solid #6f4522; box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.cafe-counter .machines { position: absolute; top: -52px; left: 12px; font-size: 40px;
  display: flex; gap: 6px; }
.cafe-door { position: absolute; right: 2%; top: 8%; font-size: 54px; }
.cafe-sign { position: absolute; left: 4%; top: 3%; font-size: 30px;
  background: #fff8; border-radius: 12px; padding: 2px 10px; border: 2px solid #fff; }
.table { position: absolute; width: 120px; height: 60px; margin: -30px 0 0 -60px;
  background: radial-gradient(ellipse at center, #fff 0 30%, #f7d9b0 31% 100%);
  border: 3px solid #c98f5f; border-radius: 50%; }
.table .chairs { position: absolute; inset: -14px; font-size: 26px;
  display: flex; justify-content: space-between; align-items: center; }
/* nhân vật chibi đi lại */
.chibi { position: absolute; left: 0; top: 0; width: 70px; margin: -64px 0 0 -35px;
  text-align: center; transition: transform 1.1s ease-in-out; z-index: 5; }
.chibi .sprite { font-size: 46px; display: inline-block; }
.chibi svg { width: 52px; height: 52px; }
.chibi.walk .sprite, .chibi.walk svg { animation: bob .45s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.chibi.flip .sprite, .chibi.flip svg { transform: scaleX(-1); }
.chibi.happy .sprite { animation: jump .5s ease-in-out 2; }
@keyframes jump { 0%,100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-16px) scale(1.08); } }
.bubble { background: #fff; border: 3px solid var(--pink-lt); border-radius: 14px;
  padding: 3px 8px; font-size: 22px; margin-bottom: 2px; display: inline-block;
  box-shadow: 0 2px 0 rgba(0,0,0,.08); white-space: nowrap; }
.bubble .patbar { height: 6px; background: #ffeef3; border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bubble .patbar div { height: 100%; background: var(--green); border-radius: 99px; }
.bubble .patbar div.low { background: var(--red); }
.chibi.tappable { cursor: pointer; }
.chibi.tappable .bubble { animation: hotglow 1.4s ease-in-out infinite; }
/* nông trại iso */
.iso-wrap { position: relative; width: 100%; aspect-ratio: 1000 / 640;
  border-radius: 22px; overflow: hidden; border: 4px solid #fff;
  box-shadow: 0 4px 0 rgba(255,211,224,.5); margin: 8px 0;
  background: linear-gradient(180deg, #bfe9a8 0%, #a5dd8a 55%, #8fd07a 100%); }
.iso-plot { position: absolute; width: 150px; height: 150px; }
.iso-diamond { position: absolute; inset: 18px; transform: rotate(45deg);
  border-radius: 22px; background: linear-gradient(135deg, #e0aa6e, #c98f5f);
  border: 4px solid #a9764b; box-shadow: inset 0 0 0 4px #d9a066; cursor: pointer; }
.iso-plot.empty .iso-diamond { background: linear-gradient(135deg, #cfe8b8, #b5d99a);
  border-style: dashed; }
.iso-crop { position: absolute; left: 50%; top: 6%; transform: translateX(-50%);
  font-size: 54px; pointer-events: none; }
.iso-crop.grow1 { font-size: 34px; top: 22%; }
.iso-crop.grow2 { font-size: 46px; top: 12%; }
.iso-crop.ripe { animation: bounce 1.2s ease-in-out infinite; }
.iso-label { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  font-size: 11px; font-weight: 800; background: #fff9; border-radius: 99px;
  padding: 1px 8px; white-space: nowrap; pointer-events: none; }
.iso-farmer { position: absolute; left: 0; top: 0; font-size: 44px; z-index: 6;
  animation: patrol 14s ease-in-out infinite; }
@keyframes patrol {
  0% { transform: translate(60px, 480px); } 25% { transform: translate(880px, 480px) scaleX(-1); }
  50% { transform: translate(880px, 200px) scaleX(-1); } 75% { transform: translate(60px, 200px); }
  100% { transform: translate(60px, 480px); } }
.iso-deco { position: absolute; font-size: 44px; }
/* layout ngang cho desktop, dọc cho điện thoại (mobile-first) */
@media (min-width: 920px) {
  #app { max-width: 1080px; }
  .scene-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
  .scene-layout .scene-wrap, .scene-layout .iso-wrap { margin: 0; position: sticky; top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .chibi, .iso-farmer { transition: none !important; animation: none !important; }
  .iso-crop.ripe, .chibi.walk .sprite { animation: none !important; }
}

/* ================= NỘI THẤT ================= */
.furn-room { position: relative; width: 100%; aspect-ratio: 1000/620; border-radius: 12px; overflow: hidden;
  background: linear-gradient(#fff8ec 0 62%, #e8c98f 62% 100%); border: 2px solid #d9b06a; cursor: crosshair; touch-action: manipulation; }
.furn-hint { position: absolute; left: 8px; right: 8px; bottom: 8px; text-align: center; font-size: 12px;
  background: rgba(255,255,255,.85); border-radius: 8px; padding: 4px 8px; pointer-events: none; }
.furn-item { position: absolute; font-size: 44px; transform: translate(-50%,-80%); cursor: grab; user-select: none;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); touch-action: none; z-index: 2; }
.furn-item.moving { animation: furn-spin 1s linear infinite; z-index: 5; }
@keyframes furn-spin { from { filter: drop-shadow(0 0 0 #ffd93d); } 50% { filter: drop-shadow(0 0 12px #ffd93d); } to { filter: drop-shadow(0 0 0 #ffd93d); } }
#furn-store-btn { position: absolute; top: 8px; right: 8px; z-index: 6; }
.furn-pick.primary { outline: 2px solid #ff9f1c; }
/* chip album mờ */
.chip.dim { opacity: .45; filter: grayscale(.6); }
/* pan camera: màn nhỏ thì kéo ngang xem cảnh */
@media (max-width: 919px) {
  .iso-pan, .cafe-pan { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 22px; }
  .iso-pan .iso-wrap, .cafe-pan .scene-wrap { min-width: 620px; }
}

/* ============ BẢN ĐỒ NÔNG TRẠI THỐNG NHẤT (kiểu Hay Day) ============ */
.map-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 2px 8px; }
.map-scroll { overflow: hidden; -webkit-overflow-scrolling: touch; border-radius: 22px;
  border: 3px solid var(--card-bd); box-shadow: 0 4px 0 rgba(190,150,90,.35);
  background: #7cc24a; }
.map-world { position: relative;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.08) 0 60px, transparent 61px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.04) 0 80px, transparent 81px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,.06) 0 50px, transparent 51px),
    linear-gradient(160deg, #8fd15a 0%, #7cc24a 40%, #6fb344 100%);
  overflow: hidden; }
.map-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(255,253,248,.92); border-radius: 999px; padding: 6px 16px; font-size: 13px;
  color: var(--muted); white-space: nowrap; border: 2px solid var(--card-bd); }
/* đường đất */
.map-path { position: absolute; background: #d9b47c; border-radius: 999px;
  box-shadow: inset 0 2px 0 rgba(120,80,30,.25); opacity: .9; }
/* ao */
.map-pond { position: absolute; left: 400px; top: 1820px; width: 280px; height: 160px;
  background: radial-gradient(ellipse at center, #7ec8e8 0%, #4aa8de 70%, #3a8fc4 100%);
  border-radius: 50%; border: 4px solid #a8d8b9; display: flex; align-items: center; justify-content: center;
  font-size: 40px; box-shadow: inset 0 -6px 12px rgba(0,60,120,.25); }
/* tòa nhà */
.map-bld { position: absolute; text-align: center; cursor: pointer; transition: transform .15s; z-index: 5; }
.map-bld:active { transform: scale(.96); }
.map-bld .bld-label { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  background: rgba(67,40,24,.85); color: #fff; white-space: nowrap;
  font-size: 13px; padding: 3px 12px; border-radius: 999px; z-index: 6; }
.map-bld .bld-sign { display: inline-block; background: #8f5a2e; color: #ffe9b8; font-size: 15px; font-weight: bold;
  padding: 4px 16px; border-radius: 10px; border: 3px solid #6b421f; margin-bottom: 4px;
  box-shadow: 0 3px 0 rgba(60,35,10,.4); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bld-badge { position: absolute; top: -8px; right: 6px; z-index: 6; background: #e4572e; color: #fff;
  min-width: 26px; height: 26px; border-radius: 999px; font-size: 15px; font-weight: bold;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
  animation: badge-pop 1s infinite; }
@keyframes badge-pop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
/* luống */
.map-plot { position: absolute; width: 220px; min-height: 104px; cursor: pointer;
  background: linear-gradient(180deg, #a06a35 0%, #8f5a2e 100%); border-radius: 18px;
  border: 3px solid #6b421f; box-shadow: 0 4px 0 rgba(60,35,10,.35), inset 0 3px 0 rgba(255,255,255,.15);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 4px;
  transition: transform .12s; }
.map-plot:active { transform: scale(.95); }
.map-plot.empty { background: linear-gradient(180deg, #b9834e 0%, #a06a35 100%); border-style: dashed; }
.map-plot.ripe { border-color: #ffc53d; box-shadow: 0 4px 0 rgba(60,35,10,.35), 0 0 14px rgba(255,197,61,.8); }
.map-plot.buy { background: rgba(255,253,248,.35); }
.mp-crop { font-size: 40px; line-height: 1.1; }
.mp-label { font-size: 12px; color: #ffe9b8; text-align: center; margin-top: 2px; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.map-plot.buy .mp-label { color: var(--ink); text-shadow: none; }
.map-plot.empty .mp-label { color: #ffe9b8; }
.mp-bar { width: 80%; height: 8px; background: rgba(0,0,0,.3); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.mp-bar div { height: 100%; background: #8fd15a; border-radius: 99px; transition: width .5s; }
/* máy xưởng */
.mc-platform { position: absolute; left: 20px; top: 630px; width: 740px; height: 350px;
  background: linear-gradient(180deg, #c99a5e, #b9834e); border-radius: 24px;
  border: 4px solid #8f5a2e; box-shadow: 0 5px 0 rgba(60,35,10,.35); }
.map-mc { position: absolute; width: 200px; text-align: center; cursor: pointer; z-index: 5;
  background: rgba(255,253,248,.85); border-radius: 18px; padding: 8px 4px; border: 3px solid var(--card-bd); }
.map-mc:active { transform: scale(.95); }
.mc-label { font-size: 13px; font-weight: bold; margin-top: 2px; }
.mc-lock, .mc-done, .mc-work, .mc-idle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mc-done { color: var(--green-d); font-weight: bold; }
/* trang trí */
.map-deco { position: absolute; z-index: 2; pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0,0,0,.15)); }
/* nông dân đi dạo */
.map-farmer { position: absolute; left: 0; top: 560px; z-index: 4; pointer-events: none;
  width: 84px; height: 84px;
  animation: farmer-walk 20s linear infinite; }
@keyframes farmer-walk {
  0% { left: 30px; transform: scaleX(1); } 48% { left: 660px; transform: scaleX(1); }
  50% { left: 660px; transform: scaleX(-1); } 98% { left: 30px; transform: scaleX(-1); }
  100% { left: 30px; transform: scaleX(1); } }
/* thanh điều hướng dưới HUD */
#navbar { display: flex; gap: 6px; padding: 8px 10px; background: rgba(255,248,234,.95);
  border-bottom: 2px solid var(--card-bd); overflow-x: auto; position: sticky; top: 0; z-index: 19; }
#navbar button { flex: 1 0 auto; border: 2px solid var(--card-bd); background: var(--card); border-radius: 14px;
  padding: 7px 10px; font-size: 14px; font-family: inherit; color: var(--ink); cursor: pointer; white-space: nowrap; }
#navbar button:active { transform: scale(.95); }
/* nút quay lại trong các màn phủ */
.backbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.backbar button { border: 2px solid var(--card-bd); background: var(--card); border-radius: 12px;
  padding: 8px 14px; font-size: 15px; font-family: inherit; cursor: pointer; }
.backbar h2 { margin: 0; font-size: 20px; }
/* nút đám mây bấm được */
#hud-cloud { cursor: pointer; border: none; font-size: 19px; background: rgba(255,255,255,.35);
  border-radius: 50%; padding: 5px; margin-left: auto; line-height: 1; }
#hud-cloud:disabled { opacity: .55; cursor: default; }
#hud-cloud .cd { font-size: 10px; display: block; }

/* ============ QUÁN CAFÉ 3D ============ */
.cafe3d-wrap { border-radius: 22px; overflow: hidden; border: 3px solid var(--card-bd);
  box-shadow: 0 4px 0 rgba(190,150,90,.35); }
.cafe3d { position: relative; width: 100%; aspect-ratio: 16/10; background: #d9b47c; }
.cafe3d-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* khách ngồi ghế */
.cafe3d-cust { position: absolute; transform: translate(-50%, -92%); z-index: 3; cursor: pointer;
  transition: opacity .8s; }
.cafe3d-cust .sprite img { object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(60,30,0,.3)); }
.cafe3d-cust .shadow { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  width: 70%; height: 14px; background: radial-gradient(ellipse, rgba(40,20,0,.35), transparent 70%);
  border-radius: 50%; }
.cafe3d-cust .bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.96); border: 2px solid var(--card-bd); border-radius: 12px;
  padding: 3px 8px; font-size: 19px; white-space: nowrap; margin-bottom: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,.15); }
.cafe3d-cust .patbar { width: 46px; height: 6px; background: #f0e6d2; border-radius: 99px;
  overflow: hidden; margin: 2px auto 0; }
.cafe3d-cust .patbar div { height: 100%; background: #8fd15a; border-radius: 99px; }
.cafe3d-cust .patbar div.low { background: #e4572e; }
.cafe3d-cust.tappable .sprite img { filter: drop-shadow(0 0 8px #ffc53d) drop-shadow(0 4px 4px rgba(60,30,0,.35)); }
.cafe3d-cust.leaving { opacity: 0; }
/* nhân viên đi lại (bob như đang bước) */
.cafe3d-staff { position: absolute; z-index: 4; animation: staff-walk 9s ease-in-out infinite; }
.cafe3d-staff img { width: 70px; height: 70px; object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(60,30,0,.35));
  animation: walk-bob .45s ease-in-out infinite; }
@keyframes staff-walk {
  0%, 100% { left: 52%; top: 48%; }
  25% { left: 22%; top: 60%; }
  50% { left: 68%; top: 68%; }
  75% { left: 40%; top: 58%; } }
@keyframes walk-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
/* mèo thần tài */
.cafe3d-cat { position: absolute; right: 3%; bottom: 4%; font-size: 44px; z-index: 5;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); animation: cat-sway 3s ease-in-out infinite; }
@keyframes cat-sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
/* chữ +xu bay */
.cafe3d-coin { position: absolute; transform: translate(-50%, -50%); z-index: 6;
  font-weight: bold; color: #b8860b; font-size: 17px; text-shadow: 0 1px 0 #fff;
  animation: coin-fly 1.6s ease-out forwards; pointer-events: none; white-space: nowrap; }
@keyframes coin-fly { 0% { opacity: 0; margin-top: 10px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -56px; } }
.cafe3d-extra { position: absolute; right: 3%; top: 4%; z-index: 6; background: rgba(67,40,24,.85);
  color: #fff; font-size: 13px; padding: 4px 12px; border-radius: 999px; }
/* nông dân đi bộ (bob + nghiêng) */
.map-farmer img { animation: walk-bob .5s ease-in-out infinite; }
/* ============ SẠP TRƯỚC CỬA ============ */
.map-stall { position: absolute; left: 500px; top: 680px; z-index: 5; text-align: center; cursor: pointer;
  background: rgba(255,253,248,.55); border-radius: 20px; padding: 8px 14px;
  border: 3px dashed #b8860b; animation: stall-pulse 2s ease-in-out infinite; }
@keyframes stall-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.map-stall .bld-badge { position: absolute; top: -8px; right: -8px; }
.stall-booth { font-size: 76px; filter: drop-shadow(0 4px 4px rgba(60,40,10,.3)); }
.stall-npcs { display: flex; gap: 4px; justify-content: center; margin-top: 2px; }
.stall-npc { position: relative; }
.stall-npc img { width: 52px; height: 52px; object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); animation: walk-bob 1.2s ease-in-out infinite; }
.stall-npc.sold { opacity: .35; filter: grayscale(1); }
.stall-npc.sold img { animation: none; }
.stall-want { position: absolute; top: -6px; right: -6px; background: #fff; border-radius: 50%;
  width: 24px; height: 24px; font-size: 15px; border: 2px solid var(--card-bd); }
.stall-label { display: inline-block; margin-top: 2px; background: rgba(67,40,24,.82); color: #fff;
  font-size: 13px; padding: 3px 12px; border-radius: 999px; }
/* ============ TUTORIAL ============ */
#tut-overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#tut-ring { position: absolute; border: 4px solid #ffc53d; border-radius: 18px;
  box-shadow: 0 0 18px #ffc53d, 0 0 0 4px rgba(255,197,61,.35);
  animation: tut-pulse 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes tut-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
#tut-bubble { position: absolute; background: #fffdf8; border: 3px solid #ffc53d; border-radius: 16px;
  padding: 12px 16px; max-width: 280px; font-size: 15px; color: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,.25); pointer-events: auto; }
#tut-bubble b { color: #b8860b; }
#tut-next { margin-top: 8px; }
/* ============ NỀN 3D CÁC GIAN ============ */
.room3d { position: relative; border-radius: 22px; overflow: hidden; border: 3px solid var(--card-bd);
  box-shadow: 0 4px 0 rgba(190,150,90,.35); margin-bottom: 12px; }
.room3d > img.bg { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.room3d .room-ui { position: absolute; inset: 0; padding: 10px; display: flex; flex-direction: column;
  justify-content: flex-end; }
.room3d .room-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.room-chip { background: rgba(255,253,248,.94); border: 2px solid var(--card-bd); border-radius: 14px;
  padding: 6px 10px; font-size: 14px; }
.room-chip button { margin-left: 6px; }
/* ============ ĐIỆN THOẠI XOAY NGANG: full width ============ */
@media (orientation: landscape) and (max-width: 999px) {
  #app { max-width: 100%; }
  body { background: #bfe3c0; }
}
/* ============ DESKTOP: bung full chiều ngang ============ */
@media (min-width: 1000px) {
  #app { max-width: 100%; padding: 0 24px; }
  .map-scroll { border-radius: 26px; }
}
/* avatar grid ở màn tạo nhân vật */
.avatar-grid.welcome-av { max-height: 220px; overflow-y: auto; margin: 8px 0; }
/* bàn café 3D riêng (khách ngồi vào thật) */
.cafe3d-table { position: absolute; transform: translate(-50%, -70%); z-index: 2;
  filter: drop-shadow(0 6px 6px rgba(60,30,0,.3)); }
/* khách đang đi: transition mượt + nhún */
.cafe3d-cust.walking { transition: left 2s ease-in-out, top 2s ease-in-out; }
.cafe3d-cust.walking .sprite img { animation: walk-bob .4s ease-in-out infinite; }
.cafe3d-cust.seated .sprite img { animation: none; }
/* ---- chợ + xóm: banner đẹp ---- */
.screen-head { background: linear-gradient(135deg, #8fd694, #5cb85c); border-radius: 18px;
  padding: 14px 16px; margin-bottom: 12px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.2);
  box-shadow: 0 3px 8px rgba(92,184,92,.3); }
.screen-head h2 { margin: 0; font-size: 20px; }
.listing-card { background: #fffdf8; border: 2px solid #f0e6d2; border-radius: 14px;
  padding: 10px 12px; margin-bottom: 8px; display: flex; justify-content: space-between;
  align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,.06); }
.cafe3d-counter { position: absolute; left: 50%; top: 2%; transform: translateX(-50%);
  width: 60%; z-index: 3; filter: drop-shadow(0 4px 4px rgba(60,30,0,.25)); }
.room-animal { position: absolute; transform: translate(-50%, -80%); z-index: 4; cursor: pointer;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.25)); animation: animal-idle 3s ease-in-out infinite; }
@keyframes animal-idle { 0%, 100% { transform: translate(-50%, -80%); } 50% { transform: translate(-50%, -82%); } }
.animal-badge { position: absolute; top: -8px; right: -8px; font-size: 20px;
  background: #fff; border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,.2); animation: bounce 1s infinite; }
.install-popup { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.install-card { background: #fffdf8; border-radius: 20px; padding: 24px; max-width: 340px;
  text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.install-card h3 { margin: 8px 0; }

/* ================= KSF: trang chào có logo, vừa mọi màn hình ================= */
#app { max-width: none; padding: 0; }
#hud, #navbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
#screen { padding: 12px max(12px, env(safe-area-inset-right)) 24px max(12px, env(safe-area-inset-left)); }
@media (min-width: 1000px) { #screen { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); } }
#welcome { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
/* điện thoại xoay ngang: thanh trên gọn lại để nhường chỗ cho game */
@media (orientation: landscape) and (max-height: 520px) {
  #hud { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; gap: 6px; border-radius: 0 0 16px 16px; }
  .hud-item { font-size: 13px; padding: 3px 10px; } .hud-item b { font-size: 14px; }
  #hud-cloud { font-size: 16px; padding: 4px; }
  #navbar { padding-top: 5px; padding-bottom: 5px; }
  #navbar button { padding: 4px 10px; font-size: 13px; }
  #screen { padding-top: 6px; padding-bottom: 12px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .welcome-card { padding: 14px 18px; } .w-emoji { font-size: 52px; } .welcome-card h2 { margin: 4px 0; } .dots { margin: 8px 0; }
}

/* logo KSF nhỏ ở góc trái trên của trang chào */
.ksf-badge { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); z-index: 1;
  display: flex; align-items: center; gap: 9px; padding: 6px 14px 6px 8px; border-radius: 16px; background: #0a0f2e; color: #fff;
  box-shadow: 0 3px 0 rgba(10,15,46,.25), 0 6px 16px rgba(20,60,180,.25); border: 2px solid #fff; max-width: calc(100vw - 24px); }
.ksf-badge img { width: 40px; height: auto; display: block; flex: none; }
.ksf-badge b { display: block; font-size: 14px; line-height: 1.15; }
.ksf-badge span { display: block; font-size: 10.5px; line-height: 1.25; color: #6fd2ff; }
.ksf-badge small { display: block; font-size: 10px; line-height: 1.25; color: #aab4e8; }
@media (max-width: 420px), (max-height: 520px) { .ksf-badge span { display: none; } .ksf-badge img { width: 32px; } .ksf-badge { padding: 4px 11px 4px 6px; } }
@media (orientation: landscape) and (max-height: 520px) and (max-width: 740px) { .ksf-badge div { display: none; } .ksf-badge { padding: 4px 6px; } }

/* ---- Đợt 0: màn đầu 2 nút + vòng tròn nhân vật ---- */
.avatar-circle { position: relative; display: block; margin: 10px auto 2px; width: 132px; height: 132px; border-radius: 50%; border: 4px solid var(--pink); background: #fff0f4; padding: 8px; cursor: pointer; box-shadow: 0 4px 0 var(--pink-lt); }
.avatar-circle img { width: 100%; height: 100%; object-fit: contain; display: block; }
.avatar-circle i { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); font-style: normal; font-size: 11px; background: var(--pink); color: #fff; border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.avatar-circle:active { transform: scale(.96); }
.av-name { font-weight: 700; margin: 12px 0 6px; }
.avatar-grid[hidden] { display: none; }
#welcome[data-step="tao"] .textinput { margin: 6px 0 10px; }
@media (max-height: 520px) { .avatar-circle { width: 84px; height: 84px; margin-top: 4px; } .av-name { margin: 8px 0 2px; } .avatar-grid.welcome-av { max-height: 110px; } }

/* ================= ĐỢT 1: khung vừa màn hình, menu dưới/cạnh, nông trại kéo-chụm ================= */
html, body { height: 100%; overflow: hidden; }
body { min-height: 0; height: 100vh; height: 100dvh; background-attachment: scroll; }
#app { height: 100vh; height: 100dvh; min-height: 0; display: grid; overflow: hidden;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
#hud { grid-row: 1; grid-column: 1 / -1; position: relative; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; gap: 6px; border-radius: 0 0 18px 18px; }
#hud .hud-item { font-size: 13px; padding: 3px 9px; } #hud .hud-item b { font-size: 14px; }
#hud .xpbar { width: 48px; height: 8px; }
#screen { grid-row: 2; grid-column: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 0; }
#screen:not(.scr-map) { padding: 8px max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right)); }
.pane-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: 14px; }
.backbar { flex: none; }
.pane-body .screen-head { margin-top: 0; }

/* menu: ở dưới cùng khi điện thoại dọc */
#navbar { grid-row: 3; grid-column: 1 / -1; position: relative; z-index: 19; overflow: visible; gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-bottom: none; border-top: 3px solid var(--card-bd); border-radius: 18px 18px 0 0; box-shadow: 0 -3px 10px rgba(150,110,60,.18); }
#navbar button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 5px 2px; min-height: 46px; font-size: 11px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
#navbar button i { font-style: normal; font-size: 21px; line-height: 1; }
#navbar button span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* điện thoại xoay ngang: menu ở cạnh phải */
@media (orientation: landscape) and (max-height: 560px) {
  #app { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); }
  #screen { grid-row: 2; grid-column: 1; }
  #navbar { grid-row: 2; grid-column: 2; flex-direction: column; justify-content: space-around; overflow-y: auto;
    padding: 4px max(6px, env(safe-area-inset-right)) 4px 6px; border-top: none; border-left: 3px solid var(--card-bd); border-radius: 18px 0 0 18px; box-shadow: -3px 0 10px rgba(150,110,60,.18); }
  #navbar button { flex: 1 1 0; min-height: 36px; min-width: 58px; padding: 2px 4px; font-size: 10px; }
  #navbar button i { font-size: 18px; }
  #hud { padding-top: calc(3px + env(safe-area-inset-top)); padding-bottom: 3px; border-radius: 0; }
  #screen:not(.scr-map) { padding-top: 4px; }
  .backbar { margin: 0 0 4px; } .backbar button { padding: 4px 10px; font-size: 14px; } .backbar h2 { font-size: 17px; }
  /* hai cột cho các màn danh sách */
  .scr-market .pane-body, .scr-neighbors .pane-body, .scr-house .pane-body, .scr-barn .pane-body, .scr-coop .pane-body, .scr-goat .pane-body {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-content: start; align-items: start; }
  .pane-body > .screen-head, .pane-body > .note, .pane-body > .room3d { grid-column: 1 / -1; }
}

/* ---- bản đồ nông trại ---- */
.map-view { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  background: #7cc24a; cursor: grab; }
.map-view:active { cursor: grabbing; }
.map-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; overflow: hidden; }
.map-plot { width: 170px; min-height: 108px; }
.mp-crop { font-size: 42px; } .mp-label { font-size: 15px; }
.map-bld .bld-label { font-size: 18px; padding: 3px 14px; }
.map-bld .bld-sign { font-size: 19px; }
.bld-badge { min-width: 32px; height: 32px; font-size: 18px; }
.mc-platform { left: 1180px; top: 362px; width: 480px; height: 572px; }
.map-mc { width: 210px; padding: 10px 4px; }
.mc-label { font-size: 17px; } .mc-lock, .mc-done, .mc-work, .mc-idle { font-size: 15px; }
.stall-label { font-size: 16px; }
.map-stall { left: 1220px; top: 70px; }
.map-farmer { top: 280px; animation: farmer-walk 46s linear infinite; }
@keyframes farmer-walk {
  0% { left: 30px; transform: scaleX(1); } 48% { left: 1560px; transform: scaleX(1); }
  50% { left: 1560px; transform: scaleX(-1); } 98% { left: 30px; transform: scaleX(-1); }
  100% { left: 30px; transform: scaleX(1); } }
.map-fab { position: absolute; left: max(8px, env(safe-area-inset-left)); bottom: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 8; }
.map-fab .btn { min-height: 40px; padding: 4px 12px; font-size: 13px; text-align: left; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.map-fab .btn span { margin-left: 2px; }
.map-wx { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap; z-index: 8; font-size: 13px; padding: 6px 12px; animation: none; pointer-events: none; }
.map-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 8; font-size: 12px; pointer-events: none; animation: hint-fade 8s forwards; }
@keyframes hint-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@media (max-width: 460px) { .map-fab .btn span { display: none; } .map-fab .btn { padding: 4px 10px; min-width: 46px; } }
@media (orientation: landscape) and (max-height: 560px) { .map-fab { flex-direction: row; } .map-fab .btn { min-height: 34px; } .map-fab .btn span { display: inline; } .map-hint { display: none; } }
#update-bar { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 10px;
  background: #432818; color: #fff; padding: 6px 8px 6px 16px; border-radius: 999px; font-size: 14px; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.3); white-space: nowrap; }

/* ================= ĐỢT 2: quán café dựng từ mảnh, cả phòng trong một màn hình ================= */
.cafe-view { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: #6b4a2b; cursor: grab; }
.cafe-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; overflow: hidden; background: #6b4a2b; }
.cafe-wall { position: absolute; left: 0; top: 0; right: 0;
  background: linear-gradient(180deg, #fff3da 0%, #ffe6b8 62%, #f3cf98 62%, #f3cf98 64%, #b9834e 64%, #a06a35 100%); border-bottom: 8px solid #7b4f27; }
.cafe-win { position: absolute; top: 34px; width: 120px; height: 104px; border-radius: 14px 14px 6px 6px; border: 8px solid #8f5a2e;
  background: linear-gradient(180deg, #bfe9ff 0%, #e9f8ff 70%, #bfe6a8 70%); box-shadow: inset 0 0 0 3px #fff8; }
.cafe-win::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: #8f5a2e; }
.cafe-sign { position: absolute; top: 12px; transform: translateX(-50%); background: #5a3a1c; color: #ffe9b8; font-weight: bold; font-size: 22px; padding: 6px 18px; border-radius: 12px; border: 4px solid #8f5a2e; white-space: nowrap; max-width: 330px; overflow: hidden; text-overflow: ellipsis; }
.cafe-counter { position: absolute; z-index: 2; filter: drop-shadow(0 6px 5px rgba(40,20,0,.3)); }
.cafe-floor { position: absolute; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(90deg, #e8b98a 0 46px, #dfae7f 46px 92px), linear-gradient(180deg, #eec08e, #e0a878);
  box-shadow: inset 0 14px 18px -8px rgba(60,30,0,.35); }
.cafe-door { position: absolute; left: 0; width: 56px; height: 90px; font-size: 62px; line-height: 90px; text-align: center; background: #8f5a2e; border-radius: 0 28px 0 0; border: 4px solid #5a3a1c; border-left: none; z-index: 1; }
.cafe-table { position: absolute; filter: drop-shadow(0 6px 5px rgba(60,30,0,.28)); pointer-events: none; }
.cafe3d-cust { transform: translate(-50%, -100%); transition: opacity .8s; }
.cafe3d-cust .bubble { font-size: 26px; padding: 4px 10px; }
.cafe3d-cust .patbar { width: 58px; height: 7px; }
.cafe3d-staff { animation: staff-walk2 14s ease-in-out infinite alternate; z-index: 3; }
.cafe3d-staff img { width: 54px; height: auto; }
@keyframes staff-walk2 { from { left: 6%; } to { left: 78%; } }
.cafe3d-coin { font-size: 26px; }
.cafe3d-cat { font-size: 54px; }
.cafe-top { position: absolute; left: max(8px, env(safe-area-inset-left)); top: 8px; z-index: 9; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: calc(100% - 16px); }
.cafe-chip { background: rgba(255,253,248,.94); border: 2px solid var(--card-bd); border-radius: 999px; padding: 4px 12px; font-size: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.cafe-hot { background: rgba(255,154,61,.92); color: #fff; border-radius: 999px; padding: 3px 12px; font-size: 12px; text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.cafe-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cafe-btns .btn { min-height: 38px; padding: 4px 12px; font-size: 13px; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.cafe-btns .btn.ghost { background: rgba(255,253,248,.85); border: 2px solid var(--card-bd); }
.cafe-btns .btn.big { font-size: 16px; padding: 8px 18px; }
.cafe-dock { position: absolute; left: 0; right: 0; bottom: 6px; z-index: 9; display: flex; gap: 6px; justify-content: center; padding: 0 8px; pointer-events: none; }
.cafe-dock button { pointer-events: auto; position: relative; flex: 0 1 92px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 4px 4px;
  background: rgba(255,253,248,.95); border: 3px solid var(--card-bd); border-radius: 16px; box-shadow: 0 3px 0 rgba(150,110,60,.4); font-family: inherit; color: var(--ink); cursor: pointer; font-size: 11px; font-weight: 700; line-height: 1.1; }
.cafe-dock button em { font-style: normal; font-size: 22px; line-height: 1; }
.cafe-dock button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cafe-dock button i { position: absolute; top: -8px; right: -4px; font-style: normal; background: #e4572e; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; border: 2px solid #fff; }
.cafe-dock button:active { transform: scale(.94); }
.drawer-body { max-height: 70vh; max-height: 70dvh; overflow-y: auto; }
.cafe-view .rain { position: absolute; z-index: 8; }
@media (orientation: landscape) and (max-height: 560px) {
  .cafe-chip { font-size: 11px; padding: 2px 10px; } .cafe-hot { display: none; }
  .cafe-btns .btn { min-height: 32px; font-size: 12px; padding: 2px 10px; }
  .cafe-dock { left: auto; right: 6px; bottom: 6px; top: 6px; flex-direction: column; justify-content: center; width: 70px; }
  .cafe-dock button { flex: 0 0 auto; padding: 3px 2px; font-size: 9.5px; } .cafe-dock button em { font-size: 18px; }
  .drawer-body { max-height: 56vh; }
}

.cafe-peak { background: rgba(255,253,248,.94); border: 2px solid var(--card-bd); border-radius: 999px; padding: 4px 12px; font-size: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.cafe-peak.on { background: linear-gradient(90deg, #ff9a3d, #ff6b6b); color: #fff; border-color: #fff; font-weight: bold; animation: hotglow 1.2s ease-in-out infinite; }

/* ================= NÔNG TRẠI CHIBI (dễ thương) ================= */
.art { display: block; width: 100%; height: auto; overflow: visible; }
.map-deco { position: absolute; z-index: 2; pointer-events: none; }
.map-deco .tree, .map-deco .pine { transform-origin: 50% 95%; animation: tree-sway 4.5s ease-in-out infinite; }
.map-deco .flower { transform-origin: 50% 95%; animation: tree-sway 3.2s ease-in-out infinite; }
@keyframes tree-sway { 0%, 100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2.2deg); } }
.map-deco .duck { animation: duck-bob 2.8s ease-in-out infinite; }
@keyframes duck-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.bfly { position: absolute; left: var(--x); top: var(--y); width: 34px; z-index: 6; pointer-events: none; animation: bfly-fly var(--d) ease-in-out infinite; }
.bfly .wing { transform-origin: 50% 50%; animation: wing-flap .35s ease-in-out infinite alternate; }
@keyframes bfly-fly { 0% { transform: translate(0, 0); } 25% { transform: translate(90px, -40px); } 50% { transform: translate(180px, 20px); } 75% { transform: translate(80px, 50px); } 100% { transform: translate(0, 0); } }
@keyframes wing-flap { from { transform: scaleX(1); } to { transform: scaleX(.55); } }
.bld-shadow { position: absolute; left: 50%; bottom: 14px; height: 26px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, rgba(40,70,20,.32), transparent 70%); z-index: -1; }
.map-mc .mc-img { position: relative; }
.map-bld:hover { transform: translateY(-4px); }
.map-bld .bld-label, .mc-label { background: #fff8e8; color: #6b421f; border: 3px solid #fff; box-shadow: 0 3px 0 rgba(107,66,31,.45); font-weight: bold; }
.map-bld .bld-label { bottom: -14px; font-size: 18px; padding: 2px 16px; }
.map-bld .bld-sign { background: linear-gradient(180deg, #b9834e, #8f5a2e); border: 3px solid #fff; border-radius: 14px; }
/* đường đất chibi */
.map-path { background: #ecc98c; border: 4px dashed #fff7dd; border-radius: 999px; box-shadow: 0 3px 0 rgba(154,104,50,.35); opacity: 1; }
.map-path.v { border-radius: 22px; }
/* luống đất chibi: gò đất tròn, viền cỏ phía trên */
.map-plot { width: 170px; min-height: 108px; border-radius: 30px; border: 4px solid #7a4a24;
  background: radial-gradient(ellipse at 50% 18%, rgba(255,255,255,.22) 0 28%, transparent 60%),
    repeating-linear-gradient(180deg, #b27640 0 14px, #a06a36 14px 20px);
  box-shadow: 0 6px 0 #6b421f, 0 12px 14px rgba(60,40,10,.22); overflow: hidden; }
.map-plot::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 16px; background: radial-gradient(circle at 14px 16px, #86d65f 0 12px, transparent 13px) 0 0 / 28px 16px repeat-x; }
.map-plot.empty { background: radial-gradient(ellipse at 50% 18%, rgba(255,255,255,.18) 0 28%, transparent 60%), repeating-linear-gradient(180deg, #c18a52 0 14px, #b27c46 14px 20px); border-style: solid; }
.map-plot.empty::after { content: "🌱"; position: absolute; font-size: 34px; opacity: .35; bottom: 24px; }
.map-plot.ripe { border-color: #ffc53d; box-shadow: 0 6px 0 #6b421f, 0 0 18px rgba(255,197,61,.95); }
.map-plot.ripe .mp-crop { animation: bounce 1.2s ease-in-out infinite; }
.map-plot.buy { background: rgba(255,248,232,.55); border: 4px dashed #fff; box-shadow: 0 4px 0 rgba(107,66,31,.25); }
.map-plot.buy::before { display: none; }
.mp-label { background: #fff8e8; color: #6b421f !important; border-radius: 999px; padding: 1px 12px; margin-top: 4px; text-shadow: none !important; font-weight: bold; border: 2px solid #fff; font-size: 15px; }
.mp-bar { background: rgba(255,255,255,.55); border: 2px solid #fff; }
/* sàn gỗ cho khu máy */
.mc-platform { background: repeating-linear-gradient(90deg, #d8a566 0 46px, #cf9a58 46px 50px); border: 5px solid #8f5a2e; border-radius: 34px; box-shadow: 0 8px 0 #6b421f, 0 14px 16px rgba(60,40,10,.25); }
.map-mc { background: #fff8e8; border: 4px solid #fff; border-radius: 24px; box-shadow: 0 5px 0 rgba(107,66,31,.4); }
.map-mc:hover { transform: translateY(-3px); }
.map-mc .mc-img { display: flex; justify-content: center; }
.stall-booth { filter: none; }
.map-stall { background: #fff8e8; border: 4px solid #fff; border-radius: 26px; box-shadow: 0 5px 0 rgba(107,66,31,.4); }
.stall-label { background: #8f5a2e; border: 2px solid #fff; }
@media (prefers-reduced-motion: reduce) { .map-deco .tree, .map-deco .pine, .map-deco .flower, .map-deco .duck, .bfly, .bfly .wing { animation: none; } }
.map-mc { padding: 6px 4px 8px; width: 210px; }
.map-mc .mc-img { height: 96px; align-items: flex-end; }
.mc-label { font-size: 16px; margin-top: 2px; } .mc-lock, .mc-done, .mc-work, .mc-idle { font-size: 14px; margin-top: 0; }

#hud-cloud.pulse { animation: cloud-pulse 1s ease-in-out infinite; box-shadow: 0 0 0 4px rgba(255,197,61,.9), 0 0 16px #ffc53d; }
@keyframes cloud-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* ---- chuồng dê (vẽ bằng CSS, không dùng ảnh) ---- */
.room3d > .goat-bg { width: 100%; aspect-ratio: 16/10;
  background: radial-gradient(ellipse at 50% 85%, #e9cf8c 0 38%, transparent 39%), linear-gradient(#cfe9b5 0 55%, #9ccf70 55% 100%); position: relative; }
.room3d > .goat-bg::before { content: ""; position: absolute; left: 0; right: 0; top: 18%; height: 8px; background: #b9824f; box-shadow: 0 34px 0 #b9824f, 0 -2px 0 #8a5a2c; border-radius: 4px; }
.room-animal .ic { width: 1em; height: 1em; }
/* ---- khung nội thất: hai cột khi điện thoại ngang, danh sách mua gọn ---- */
.furn-tier { position: absolute; right: -4px; bottom: -4px; font-size: 11px; background: #ffd166; border: 1.5px solid #5a3a2a; border-radius: 8px; padding: 0 4px; line-height: 14px; }
.furn-right .row { flex-wrap: wrap; }
.furn-right .row .btnrow { margin: 0; justify-content: flex-end; }
@media (orientation: landscape) and (max-height: 560px) {
  .furn-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
  .furn-right { max-height: calc(100vh - 150px); overflow-y: auto; padding-right: 4px; }
  .furn-room { font-size: 70%; }
  .furn-item { font-size: 30px; }
  .scr-goat .pane-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-content: start; align-items: start; }
}

/* ===== ảnh 3D nội thất / trang trí ===== */
.fimg { height: 38px; width: auto; max-width: 52px; vertical-align: middle; object-fit: contain; }
.fimg.s { height: 28px; max-width: 40px; }
.fimg.dec { height: 40px; max-width: 56px; }
.furn-item { font-size: inherit; filter: none; }
.furn-item .fimg-room { display: block; width: 100%; height: auto; pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0,0,0,.28)); }
.furn-item.moving .fimg-room { animation: furn-spin 1s linear infinite; }
.furn-item { transform: translate(-50%, -88%); }

/* ===== nền xiên (isometric): luống là ô thoi nổi có độ dày ===== */
.map-world .map-plot, .map-world .map-plot.empty, .map-world .map-plot.ripe, .map-world .map-plot.buy,
.map-world .map-plot.growing, .map-world .map-plot.withered {
  overflow: visible; border: none; background: none; box-shadow: none; border-radius: 0; z-index: 3; padding-top: 14px; }
.map-world .map-plot::after { content: ""; position: absolute; left: 0; right: 0; top: 26px; bottom: auto; height: 84px; z-index: 0;
  font-size: 0; opacity: 1; background: #6b421f; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.map-world .map-plot::before { content: ""; position: absolute; left: 0; right: 0; top: 14px; height: 84px; z-index: 1; display: block;
  background: repeating-linear-gradient(-26deg, #b9804a 0 11px, #a76e3b 11px 17px);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.map-world .map-plot > * { position: relative; z-index: 2; }
.map-world .map-plot.empty::before { background: repeating-linear-gradient(-26deg, #c9965f 0 11px, #bb8750 11px 17px); }
.map-world .map-plot.empty::after { background: #7a4a24; font-size: 0; opacity: 1; }
.map-world .map-plot.ripe { filter: drop-shadow(0 0 10px rgba(255,197,61,.95)); }
.map-world .map-plot.buy::before { background: rgba(255,255,255,.5); }
.map-world .map-plot.buy::after { background: rgba(255,255,255,.28); }
.map-world .map-plot .mp-crop { margin-top: -2px; }

/* ===== sân vườn dưới nông trại + nhà quán to dần ===== */
.map-yard { position: absolute; left: 14px; right: 14px; top: 940px; height: 126px; border-radius: 28px; z-index: 1;
  border: 4px dashed rgba(255,255,255,.7); background: rgba(255,255,255,.14); }
.map-yard .yard-label { position: absolute; left: 18px; top: 6px; font-size: 15px; font-weight: bold; color: #4b7a2e;
  background: rgba(255,255,255,.78); border-radius: 999px; padding: 1px 12px; }
.map-yard .yard-item { position: absolute; }
.map-yard .yard-img { display: block; width: 100%; height: auto; position: relative; }
.map-bld .bld-label { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-warn { border: 2px solid #ffc53d; background: #fff8e0; }
