/* 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; } }
