/* Kampung Hoomey — gaya. iPad dulu (1180×820 / 820×1180), telefon guna media query di bawah. */
:root { --kg-alat: 88px; --kg-hud-l: calc(118px + var(--safe-l)); }
body { background: #9BD86A; }
#game { position: fixed; inset: 0; }
.kg-view { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.kg-view.pan { cursor: grabbing; }
.kg-dunia { position: absolute; left: 0; top: 0; width: 2700px; height: 1200px; transform-origin: 0 0; will-change: transform; background: var(--langit, #C9ECFF); }
.kg-dunia.lancar { transition: transform .6s cubic-bezier(.3,.8,.3,1); }
.kg-dunia > div { position: absolute; inset: 0; }
.kg-langit-obj { z-index: 0; pointer-events: none; }
.kg-latar { z-index: 1; pointer-events: none; }
.kg-latar svg { width: 100%; height: 100%; display: block; }
.kg-obj { z-index: 2; }
.kg-malam { z-index: 3; pointer-events: none; }
.kg-malam::before, .kg-malam::after { content: ''; position: absolute; inset: 0; }
.kg-malam::before { background: #24286E; opacity: calc(var(--gelap, 0) * .5); mix-blend-mode: multiply; }
.kg-malam::after { background: #FF9A6A; opacity: calc(var(--senja, 0) * .16); mix-blend-mode: soft-light; }
.kg-cahaya { z-index: 4; pointer-events: none; }
.kg-cahaya i { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(255,226,140,.95) 0, rgba(255,200,90,.45) 38%, rgba(255,190,80,0) 70%);
  opacity: var(--gelap, 0); mix-blend-mode: screen; animation: kg-kelip 2.6s ease-in-out infinite; }
.kg-fx { z-index: 5; pointer-events: none; }
.kg-atas { z-index: 6; pointer-events: none; }
.kg-atas > * { pointer-events: auto; }
.awan-latar { animation: kg-awan 60s linear infinite alternate; }
@keyframes kg-awan { to { transform: translateX(120px); } }

/* langit */
.kg-matahari, .kg-bulan { position: absolute; left: -75px; top: -75px; width: 150px; height: 150px; transition: opacity 1s; }
.kg-bulan { left: -60px; top: -60px; width: 120px; height: 120px; }
.kg-matahari svg, .kg-bulan svg { width: 100%; height: 100%; display: block; }
.kg-matahari .rays { transform-origin: center; transform-box: fill-box; animation: kg-putar 30s linear infinite; }
@keyframes kg-putar { to { transform: rotate(360deg); } }
.kg-bintang i { position: absolute; width: 26px; height: 26px; opacity: var(--gelap, 0); animation: kg-kelip 2s ease-in-out infinite; }
.kg-bintang i svg { width: 100%; height: 100%; }
@keyframes kg-kelip { 0%,100% { filter: brightness(1); scale: 1 } 50% { filter: brightness(1.15); scale: .88 } }

/* objek dunia */
.kg-tempat, .kg-petak, .kg-haiwan, .kg-penduduk, .kg-hiasan, .kg-avatar, .kg-gelembung, .kg-tidur-b, .kg-pagar-kandang { position: absolute; }
.kg-tempat, .kg-petak, .kg-haiwan, .kg-penduduk, .kg-hiasan, .kg-avatar, .kg-gelembung, .kg-tidur-b { cursor: pointer; }
.kg-pagar-kandang { pointer-events: none; }
.kg-tempat > svg, .kg-petak > svg, .kg-haiwan > svg, .kg-hiasan > svg, .kg-avatar > svg, .kg-pagar-kandang > svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kg-tempat, .kg-petak, .kg-haiwan, .kg-hiasan, .kg-avatar { transform-origin: 50% 100%; }
.lantun { animation: kg-lantun .55s cubic-bezier(.3,1.5,.5,1); }
@keyframes kg-lantun { 0% { transform: scale(1) } 25% { transform: scale(1.1,.88) } 55% { transform: scale(.94,1.08) } 80% { transform: scale(1.02,.98) } 100% { transform: scale(1) } }
.kedip { transform-box: fill-box; transform-origin: center; animation: tma-blink 4.6s infinite; }
.kg-label { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); padding: 0 16px; border: 4px solid var(--ink); border-radius: 999px; background: #FFF8EC;
  font-size: 24px; font-weight: 800; line-height: 1.35; white-space: nowrap; pointer-events: none; box-shadow: 0 4px 0 rgba(51,38,43,.2); }
.kg-label-kebun { bottom: auto; transform: none; background: #FFE58A; }
.kg-rumah .kg-label { bottom: -4px; left: 26%; }
.kg-pokok .kg-label { bottom: 4px; }
.kg-kolam .kg-label { bottom: auto; top: -2px; left: 22%; }
.kg-pagar-kandang .kg-label { bottom: 14px; left: 30%; }

/* rumah & avatar */
.kg-avatar svg { filter: drop-shadow(0 6px 0 rgba(51,38,43,.12)); }
.kg-tidur-b { display: flex; align-items: center; gap: 8px; padding: 6px 26px 6px 10px; border: 5px solid var(--ink); border-radius: 999px; background: #3D4A8C; color: #fff;
  font-size: 34px; font-weight: 800; box-shadow: 0 7px 0 rgba(51,38,43,.3); animation: kg-apung 1.6s ease-in-out infinite; }
.kg-tidur-b svg { width: 70px; height: 70px; }
.kg-tidur-b[hidden] { display: none; }
@keyframes kg-apung { 0%,100% { translate: 0 0 } 50% { translate: 0 -10px } }

/* papan misi */
.kg-seru { position: absolute; right: -8px; top: -14px; width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--ink); background: var(--pink); color: #fff;
  font-style: normal; font-weight: 800; font-size: 38px; line-height: 42px; text-align: center; display: none; animation: kg-apung 1s ease-in-out infinite; }
.kg-papan.ada .kg-seru { display: block; }

/* petak kebun */
.kg-petak.masak .kg-pokok-g { transform-box: fill-box; transform-origin: 50% 100%; animation: kg-goyang-pokok 1.8s ease-in-out infinite; }
@keyframes kg-goyang-pokok { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(2deg) scale(1.02) } }
.kg-titis { position: absolute; right: 14px; top: 46%; width: 30px; height: 40px; animation: kg-apung 1.2s ease-in-out infinite; }
.kg-titis svg { width: 100%; height: 100%; }
.kg-kilau { position: absolute; left: 50%; top: 18%; width: 30px; height: 30px; margin-left: -15px; background: var(--yellow); clip-path: polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%);
  animation: kg-kilau 1.6s ease-in-out infinite; }
@keyframes kg-kilau { 0%,100% { transform: scale(.3) rotate(0); opacity: 0 } 50% { transform: scale(1.2) rotate(45deg); opacity: 1 } }
.kg-petak { pointer-events: none; }
.kg-petak .kg-hit { position: absolute; left: 4%; right: 4%; bottom: 0; height: 58%; pointer-events: auto; border-radius: 40% 40% 50% 50%; }
.kg-petak.masak .kg-hit { height: 64%; }
.kg-petak.kunci { opacity: .9; }
.kg-petak.kunci:not(.boleh) { opacity: .45; pointer-events: none; }
.kg-kunci-tanda { position: absolute; left: 50%; bottom: 0; width: 56px; height: 56px; margin-left: -28px; border-radius: 50%; border: 5px solid var(--ink); background: var(--green);
  color: #fff; font-size: 44px; font-weight: 800; line-height: 40px; text-align: center; }

/* haiwan */
.kg-haiwan .hw-badan { transform-box: fill-box; transform-origin: 50% 100%; animation: kg-nafas 2.2s ease-in-out infinite; }
.kg-haiwan.jalan .hw-badan { animation: kg-kedek .42s ease-in-out infinite; }
.kg-haiwan.kiri > svg { transform: scaleX(-1); }
@keyframes kg-nafas { 0%,100% { transform: scale(1) } 50% { transform: scale(1.03,.97) } }
@keyframes kg-kedek { 0%,100% { transform: rotate(-6deg) translateY(0) } 50% { transform: rotate(6deg) translateY(-6px) } }

/* semasa memegang benih/penyiram: penduduk & hiasan tidak menghalang petak */
.kg-view[data-mod="benih"] :is(.kg-penduduk, .kg-hiasan, .kg-haiwan), .kg-view[data-mod="penyiram"] :is(.kg-penduduk, .kg-hiasan, .kg-haiwan) { pointer-events: none; }
/* penduduk */
.kg-penduduk { width: 110px; height: 140px; transition: opacity .8s; }
.kg-penduduk.tidur { opacity: 0; pointer-events: none; }
.kg-pd-seni svg { width: 100%; height: auto; display: block; }
.kg-penduduk.kiri .kg-pd-seni { transform: scaleX(-1); }
.kg-penduduk.jalan .kg-pd-seni { animation: kg-kedek .5s ease-in-out infinite; transform-origin: 50% 100%; }
.kg-penduduk.kiri.jalan .kg-pd-seni { animation-name: kg-kedek-kiri; }
@keyframes kg-kedek-kiri { 0%,100% { transform: scaleX(-1) rotate(-5deg) } 50% { transform: scaleX(-1) rotate(5deg) translateY(-6px) } }
.kg-mahu { position: absolute; left: 50%; top: -76px; width: 84px; padding: 6px 6px 2px; margin-left: -42px; border: 4px solid var(--ink); border-radius: 22px; background: #fff;
  box-shadow: 0 4px 0 rgba(51,38,43,.2); animation: kg-apung 1.4s ease-in-out infinite; }
.kg-mahu::after { content: ''; position: absolute; left: 50%; bottom: -14px; margin-left: -10px; border: 10px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
.kg-mahu[hidden] { display: none; }
.kg-mahu svg { width: 64px; height: 64px; display: block; margin: 0 auto; }
.kg-titik-k { display: flex; justify-content: center; }
.kg-hati-n { position: absolute; right: -6px; bottom: 6px; display: flex; align-items: center; }
.kg-hati-n svg { width: 30px; height: 30px; }
.kg-hati-n b { font-size: 20px; font-weight: 800; margin-left: -2px; -webkit-text-stroke: 0; }

/* gelembung hasil (telur/susu) */
.kg-gelembung { display: flex; flex-direction: column; align-items: center; width: 96px; padding: 6px 6px 4px; border: 5px solid var(--ink); border-radius: 26px; background: #fff;
  box-shadow: 0 5px 0 rgba(51,38,43,.2); animation: kg-apung 1.3s ease-in-out infinite; }
.kg-gelembung[hidden] { display: none; }
.kg-gelembung svg { width: 70px; height: 70px; }

/* hiasan */
.kg-hiasan.angkat { scale: 1.12; filter: drop-shadow(0 16px 0 rgba(51,38,43,.2)); z-index: 1400 !important; cursor: grabbing; }
.kg-hiasan .api { transform-box: fill-box; transform-origin: 50% 100%; animation: kg-api .5s ease-in-out infinite alternate; }
@keyframes kg-api { to { transform: scale(.9, 1.12) rotate(4deg); } }
.kg-hiasan .wau-goyang { transform-box: fill-box; transform-origin: 50% 90%; animation: kg-goyang-pokok 2.4s ease-in-out infinite; }
.kg-hiasan .ayun { transform-box: view-box; transform-origin: 60px 22px; animation: kg-ayun 2.6s ease-in-out infinite; }
@keyframes kg-ayun { 0%,100% { transform: rotate(-12deg) } 50% { transform: rotate(12deg) } }

/* pokok buah & kolam */
.kg-pokok .buah { transform-box: fill-box; transform-origin: 50% 0; animation: kg-goyang-pokok 2s ease-in-out infinite; }
.kg-kolam .riak { animation: kg-riak 3s ease-in-out infinite; }
@keyframes kg-riak { 0%,100% { opacity: .9; transform: translateX(0) } 50% { opacity: .4; transform: translateX(10px) } }
.kg-ikan-bayang { position: absolute; inset: 0; pointer-events: none; }
.kg-ikan-bayang i { position: absolute; width: 46px; height: 18px; border-radius: 50%; background: #3E8FD0; opacity: .45; top: 54%; left: 20%; animation: kg-renang 7s ease-in-out infinite; }
.kg-ikan-bayang i:nth-child(2) { top: 70%; left: 62%; animation-delay: -2.5s; animation-duration: 9s; }
.kg-ikan-bayang i:nth-child(3) { top: 40%; left: 70%; animation-delay: -5s; }
.kg-kolam:not(.ada) .kg-ikan-bayang { display: none; }
@keyframes kg-renang { 0%,100% { translate: 0 0 } 50% { translate: 70px 10px } }

/* kelip-kelip & rama-rama */
.kg-kelip { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #FFF6A0; box-shadow: 0 0 12px 6px rgba(255,240,120,.8);
  opacity: calc(var(--gelap, 0) * 1); animation: kg-kelip-terbang 6s ease-in-out infinite; }
@keyframes kg-kelip-terbang { 0%,100% { transform: translate(0,0); filter: brightness(1) } 25% { transform: translate(40px,-30px); filter: brightness(.4) } 50% { transform: translate(70px,10px); filter: brightness(1.2) } 75% { transform: translate(20px,30px); filter: brightness(.5) } }
.kg-rama { position: absolute; width: 56px; height: 46px; z-index: 1250; pointer-events: none; animation: kg-rama 14s ease-in-out infinite; transition: opacity 1s; }
.malam .kg-rama { opacity: 0; }
.kg-rama svg { width: 100%; height: 100%; }
.kg-rama .wing-l, .kg-rama .wing-r { transform-box: fill-box; animation: kg-kepak .25s ease-in-out infinite alternate; }
.kg-rama .wing-l { transform-origin: 100% 50%; } .kg-rama .wing-r { transform-origin: 0 50%; }
@keyframes kg-kepak { to { transform: scaleX(.35); } }
@keyframes kg-rama { 0%,100% { translate: 0 0 } 20% { translate: 120px -60px } 40% { translate: 220px 20px } 60% { translate: 120px 80px } 80% { translate: -40px 30px } }
.kg-h-ayam:not(.jalan) .hw-badan, .kg-h-itik:not(.jalan) .hw-badan { animation: kg-patuk 3.4s ease-in-out infinite; }
@keyframes kg-patuk { 0%,70%,100% { transform: rotate(0) } 76% { transform: rotate(14deg) translateY(4px) } 82% { transform: rotate(0) } 88% { transform: rotate(14deg) translateY(4px) } }

/* kesan */
.kg-kilau-p { position: absolute; width: 34px; height: 34px; margin: -17px; animation: kg-pecah .85s ease-out forwards; }
.kg-kilau-p.skrin { position: fixed; z-index: 99; pointer-events: none; }
.kg-kilau-p svg, .kg-hati-p svg { width: 100%; height: 100%; display: block; }
@keyframes kg-pecah { 0% { transform: translate(0,0) scale(.3) } 60% { opacity: 1 } 100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(90deg); opacity: 0 } }
.kg-hati-p { position: absolute; width: 46px; height: 46px; margin: -23px; opacity: 0; animation: kg-hati 1.4s ease-out forwards; }
@keyframes kg-hati { 0% { transform: translateY(0) scale(.3); opacity: 0 } 20% { transform: translateY(-20px) scale(1.15); opacity: 1 } 100% { transform: translateY(-120px) scale(.8); opacity: 0 } }
.kg-air-p { position: absolute; width: 14px; height: 20px; border: 3px solid var(--ink); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #6EC6FF; opacity: 0;
  animation: kg-air .7s ease-in forwards; }
@keyframes kg-air { 0% { transform: translateY(0); opacity: 1 } 100% { transform: translateY(70px); opacity: 0 } }
.kg-terbang { position: fixed; z-index: 98; width: 76px; height: 76px; margin: -38px 0 0 -38px; pointer-events: none;
  transition: transform .7s cubic-bezier(.45,-0.35,.7,1), opacity .7s ease-in; }
.kg-terbang.syiling { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
.kg-terbang svg { width: 100%; height: 100%; display: block; }
.kg-ghost { position: fixed; left: 0; top: 0; z-index: 97; width: 130px; height: 110px; margin: -70px 0 0 -40px; pointer-events: none; }
.kg-ghost.tanam { width: 90px; height: 112px; margin: -100px 0 0 -45px; }
.kg-ghost svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 10px 0 rgba(51,38,43,.2)); }
.kg-ghost.siram svg { animation: kg-condong .5s ease-in-out infinite alternate; transform-origin: 70% 60%; }
@keyframes kg-condong { from { transform: rotate(-8deg) } to { transform: rotate(-22deg) } }
.kg-ghost[hidden] { display: none; }

/* HUD */
.kg-hud { position: fixed; z-index: 20; top: calc(14px + var(--safe-t)); left: var(--kg-hud-l); display: flex; gap: 10px; pointer-events: none; }
.kg-masa, .kg-syiling { pointer-events: auto; display: flex; align-items: center; gap: 8px; min-height: 76px; padding: 4px 20px 4px 8px; border: 5px solid var(--ink); border-radius: 999px;
  background: #fff; box-shadow: 0 6px 0 rgba(51,38,43,.2); }
.kg-masa { cursor: pointer; }
.kg-masa-ikon, .kg-syiling-ikon { width: 58px; height: 58px; flex: none; }
.kg-masa-ikon svg, .kg-syiling-ikon svg { width: 100%; height: 100%; display: block; }
.kg-masa-teks { display: flex; flex-direction: column; line-height: 1; text-align: left; }
.kg-masa-teks b { font-size: 24px; font-weight: 800; }
.kg-masa-teks small { font-size: 17px; font-weight: 700; color: var(--muted); margin-top: 3px; }
.kg-syiling b { font-size: 34px; font-weight: 800; min-width: 1.2em; }

/* alat */
/* Landskap: dok alat mendatar di kanan ATAS (jalur langit) — dulu menegak di kanan & menutup Reban/Rambutan pada pandangan pembukaan. */
.kg-alat { position: fixed; z-index: 20; right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(12px + var(--safe-t)); display: flex; flex-direction: row; gap: 10px;
  padding: 8px; border: 5px solid var(--ink); border-radius: 34px; background: rgba(255,248,236,.94); box-shadow: 0 8px 0 rgba(51,38,43,.2); }
.kg-alat-b { position: relative; width: var(--kg-alat); height: var(--kg-alat); padding: 4px 0 0; border: 5px solid var(--ink); border-radius: 26px; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 5px 0 rgba(51,38,43,.2); touch-action: none; }
.kg-alat-b.aktif { background: var(--yellow); transform: translateY(-2px); box-shadow: 0 0 0 5px #fff, 0 0 0 9px var(--pink); }
.kg-alat-seni { width: 62px; height: 54px; display: flex; align-items: center; justify-content: center; }
.kg-alat-seni svg { max-width: 100%; max-height: 100%; }
.kg-alat-l { font-size: 18px; font-weight: 800; line-height: 1; margin-top: 2px; }
.kg-lencana { position: absolute; top: -12px; right: -12px; min-width: 36px; height: 36px; padding: 0 6px; border: 4px solid var(--ink); border-radius: 999px; background: var(--pink);
  color: #fff; font-style: normal; font-size: 19px; font-weight: 800; line-height: 28px; text-align: center; }
.kg-lencana[hidden] { display: none; }

/* dulang (benih / bakul) */
.kg-dulang { position: fixed; z-index: 19; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100vw - 48px);
  display: flex; gap: 10px; padding: 10px 12px; overflow-x: auto; border: 5px solid var(--ink); border-radius: 30px; background: #FFF8EC; box-shadow: 0 8px 0 rgba(51,38,43,.2);
  animation: kg-naik .3s cubic-bezier(.3,1.5,.5,1); touch-action: pan-x; }
.kg-dulang[hidden] { display: none; }
@keyframes kg-naik { from { transform: translateX(-50%) translateY(30px); opacity: 0 } }
.kg-dl-i, .kg-dl-kosong { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100px; min-height: 120px; padding: 6px 4px; border: 4px solid var(--ink);
  border-radius: 22px; background: #fff; cursor: pointer; touch-action: none; }
.kg-dl-i svg { width: 64px; height: 64px; }
.kg-dl-i.pilih { background: var(--yellow); box-shadow: 0 0 0 4px var(--pink); }
.kg-dl-kosong { width: 140px; background: var(--green); color: #fff; font-size: 20px; font-weight: 800; }
.kg-dl-kosong.kecil { width: 100px; background: var(--yellow); color: var(--ink); }
.kg-dl-kosong svg { width: 72px; height: 72px; }
.kg-dl-teks { display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 22px; font-weight: 800; color: var(--muted); }
.kg-dl-teks svg { width: 80px; }
.kg-dl-n { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.kg-nom { font-size: 22px; font-weight: 800; }
.kg-titik { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 76px; }
.kg-titik i { width: 9px; height: 9px; border-radius: 50%; background: var(--pink); border: 2px solid var(--ink); }

/* panel */
.kg-panel { position: fixed; inset: 0; z-index: 65; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(51,38,43,.35); }
.kg-panel[hidden] { display: none; }
.kg-pn-kad { width: min(900px, 100%); max-height: calc(100dvh - 32px); overflow: auto; border: 6px solid var(--ink); border-radius: 36px; background: #FFF8EC; padding: 16px 20px 22px;
  box-shadow: 0 12px 0 rgba(51,38,43,.25); animation: tma-pop-in .35s cubic-bezier(.3,1.5,.5,1); touch-action: pan-y; overscroll-behavior: contain; }
.kg-pn-kepala { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.kg-pn-kepala h2 { margin: 0; flex: 1; font-size: 34px; font-weight: 800; line-height: 1; }
.kg-pn-ikon { width: 74px; height: 74px; flex: none; }
.kg-pn-ikon svg { width: 100%; height: 100%; }
.kg-pn-syiling { display: flex; align-items: center; gap: 6px; padding: 2px 16px 2px 6px; border: 4px solid var(--ink); border-radius: 999px; background: #fff; }
.kg-pn-syiling svg { width: 44px; height: 44px; }
.kg-pn-syiling b { font-size: 28px; font-weight: 800; }
.kg-pn-tutup { flex: none; width: 72px; height: 72px; border-radius: 50%; border: 5px solid var(--ink); background: var(--pink); cursor: pointer; box-shadow: 0 5px 0 rgba(51,38,43,.25); }
.kg-pn-tutup svg { width: 38px; height: 38px; }
.kg-tab { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.kg-tab button { display: flex; align-items: center; gap: 8px; min-height: 76px; padding: 4px 18px 4px 8px; border: 4px solid var(--ink); border-radius: 22px; background: #fff;
  font-size: 22px; font-weight: 800; cursor: pointer; }
.kg-tab button svg { width: 60px; height: 60px; }
.kg-tab button.on { background: var(--yellow); box-shadow: 0 0 0 4px var(--pink); }
.kg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.kg-kad { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 196px; padding: 10px 8px; border: 5px solid var(--ink); border-radius: 26px;
  background: #fff; cursor: pointer; box-shadow: 0 6px 0 rgba(51,38,43,.18); }
.kg-kad:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(51,38,43,.18); }
.kg-kad-seni { width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; }
.kg-kad-seni svg { max-width: 100%; max-height: 100%; }
.kg-kad-nama { font-size: 20px; font-weight: 800; line-height: 1.1; text-align: center; }
.kg-kad-ada { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; align-items: center; font-size: 18px; font-weight: 800; color: var(--muted); }
.kg-kad.penuh { opacity: .55; }
.kg-harga { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 2px 12px 2px 4px; border-radius: 999px; background: #FFF3C4; }
.kg-harga svg { width: 32px; height: 32px; }
.kg-harga b { font-size: 24px; font-weight: 800; }
.kg-harga .kg-titik { max-width: 60px; }
.kg-harga .kg-titik i { background: var(--yellow); }
.kg-jual-semua { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 92px; margin-top: 16px; border: 5px solid var(--ink); border-radius: 999px;
  background: var(--green); color: #fff; font-size: 32px; font-weight: 800; cursor: pointer; box-shadow: 0 7px 0 rgba(51,38,43,.25); }
.kg-jual-semua[hidden] { display: none; }
.kg-js-ikon svg { width: 60px; height: 60px; display: block; }
.kg-jual-semua b { padding: 0 16px; border-radius: 999px; background: var(--yellow); color: var(--ink); }
.kg-kosong { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; padding: 10px; color: var(--muted); font-size: 24px; font-weight: 800; }
.kg-kosong svg { width: 160px; }
.kg-kosong p { margin: 4px 0 0; }
/* misi */
.kg-misi-senarai { display: flex; flex-direction: column; gap: 14px; }
.kg-misi { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border: 5px solid var(--ink); border-radius: 28px; background: #fff; }
.kg-misi.ok { background: #E4F8EC; }
.kg-misi-muka { width: 110px; height: 120px; flex: none; padding: 0; border: 0; background: none; cursor: pointer; }
.kg-misi-muka svg { width: 100%; height: 100%; }
.kg-misi-tengah { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.kg-misi-mahu { display: flex; gap: 8px; flex-wrap: wrap; }
.kg-misi-i { width: 72px; height: 72px; padding: 4px; border: 4px dashed #C9B8A8; border-radius: 20px; opacity: .55; }
.kg-misi-i.dapat { border: 4px solid var(--green); background: #E4F8EC; opacity: 1; }
.kg-misi-i svg { width: 100%; height: 100%; }
.kg-misi-upah { display: flex; align-items: center; gap: 8px; }
.kg-misi-hati svg, .kg-misi-pelekat svg { width: 36px; height: 36px; display: block; }
.kg-beri { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 116px; min-height: 108px; border: 5px solid var(--ink); border-radius: 28px;
  background: var(--green); color: #fff; font-size: 24px; font-weight: 800; cursor: pointer; box-shadow: 0 6px 0 rgba(51,38,43,.25); animation: kg-apung 1.2s ease-in-out infinite; }
.kg-beri svg { width: 50px; height: 50px; }
.kg-beri.belum { background: #EFE6DA; color: var(--ink); animation: none; }
/* kolam */
.kg-kolam-main { position: relative; width: 100%; aspect-ratio: 540 / 280; }
.kg-kolam-latar { position: absolute; inset: 0; width: 100%; height: 100%; }
.kg-ikan-l { position: absolute; inset: 0; }
.kg-ikan-lompat { position: absolute; width: 120px; height: 120px; margin: -60px; padding: 0; border: 0; background: none; cursor: pointer; }
.kg-ikan-seni { position: absolute; inset: 14px; animation: kg-lompat 1.5s ease-in-out infinite; }
.kg-ikan-seni svg { width: 100%; height: 100%; }
.kg-riak { position: absolute; left: 10px; right: 10px; bottom: 16px; height: 30px; border: 5px solid #fff; border-radius: 50%; opacity: .8; animation: kg-riak-b 1.5s ease-out infinite; }
@keyframes kg-lompat { 0%,100% { transform: translateY(20px) rotate(20deg) } 50% { transform: translateY(-40px) rotate(-20deg) } }
@keyframes kg-riak-b { from { transform: scale(.5); opacity: .9 } to { transform: scale(1.3); opacity: 0 } }
.kg-ikan-lompat.dapat { animation: kg-hilang .4s forwards; }
@keyframes kg-hilang { to { transform: scale(1.4); opacity: 0 } }
.kg-kolam-baki { position: absolute; right: 12px; top: 10px; display: flex; gap: 4px; padding: 4px 10px; border: 4px solid var(--ink); border-radius: 999px; background: #fff; }
.kg-kolam-baki i { width: 44px; height: 44px; }
.kg-kolam-baki i.habis { opacity: .25; filter: grayscale(1); }
.kg-kolam-baki svg { width: 100%; height: 100%; }

/* tirai tidur */
.kg-tirai { position: fixed; inset: 0; z-index: 64; display: flex; align-items: center; justify-content: center; background: #2E3470; opacity: 0; transition: opacity .9s, background .9s; }
.kg-tirai[hidden] { display: none; }
.kg-tirai.gelap { opacity: 1; }
.kg-tirai.pagi { background: #FFE2B8; }
.kg-tirai.hilang { opacity: 0; }
.kg-tirai-bintang { position: absolute; width: 30px; height: 30px; animation: kg-kelip 1.6s ease-in-out infinite; }
.kg-tirai-bintang svg { width: 100%; height: 100%; }
.kg-tirai.pagi .kg-tirai-bintang { display: none; }
.kg-tirai-isi { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.kg-tirai-bulan { width: 140px; animation: kg-apung 2s ease-in-out infinite; }
.kg-tirai-kawan { position: relative; width: 220px; }
.kg-tirai-kawan svg, .kg-tirai-bulan svg, .kg-tirai-mentari svg { width: 100%; height: auto; display: block; }
.kg-zzz { position: absolute; right: -30px; top: 0; }
.kg-zzz i { position: absolute; color: #fff; font-style: normal; font-weight: 800; font-size: 40px; opacity: 0; animation: kg-zzz 1.8s ease-out infinite; }
.kg-zzz i:nth-child(2) { animation-delay: .6s; } .kg-zzz i:nth-child(3) { animation-delay: 1.2s; }
@keyframes kg-zzz { 0% { transform: translate(0,0) scale(.5); opacity: 0 } 30% { opacity: 1 } 100% { transform: translate(40px,-90px) scale(1.3); opacity: 0 } }
.kg-tirai-mentari { width: 200px; animation: kg-terbit 1.4s cubic-bezier(.3,1.4,.5,1); }
@keyframes kg-terbit { from { transform: translateY(120px) scale(.6) } }
.kg-tirai-hari { font-size: 48px; font-weight: 800; padding: 0 30px; border: 5px solid var(--ink); border-radius: 999px; background: #fff; }

/* ---------- landskap: dulang benih/bakul jatuh dari dok alat (kanan atas) — tidak menutup kebun ---------- */
@media (orientation: landscape) {
  .kg-dulang { left: auto; right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(var(--kg-alat) + 52px + var(--safe-t)); bottom: auto; transform: none;
    max-width: calc(100vw - var(--kg-hud-l) - 24px); animation: kg-turun .3s cubic-bezier(.3,1.5,.5,1); }
}
@keyframes kg-turun { from { transform: translateY(-24px); opacity: 0 } }

/* ---------- iPad potret: alat di bawah ---------- */
@media (orientation: portrait) {
  .kg-alat { top: auto; right: auto; left: 50%; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); flex-direction: row; }
  .kg-dulang { left: 50%; bottom: calc(64px + 140px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); }
}

/* ---------- telefon (sisi pendek < 600px) ---------- */
@media (max-width: 599px), (max-height: 599px) {
  :root { --kg-alat: 58px; --kg-hud-l: calc(84px + var(--safe-l)); }
  .kg-hud { top: calc(10px + var(--safe-t)); gap: 6px; }
  .kg-masa, .kg-syiling { min-height: 54px; padding: 2px 12px 2px 4px; border-width: 4px; gap: 4px; }
  .kg-masa-ikon, .kg-syiling-ikon { width: 40px; height: 40px; }
  .kg-masa-teks b { font-size: 17px; } .kg-masa-teks small { font-size: 13px; }
  .kg-syiling b { font-size: 24px; }
  .kg-alat { gap: 6px; padding: 5px; border-width: 4px; border-radius: 24px; right: calc(8px + env(safe-area-inset-right, 0px)); }
  .kg-alat-b { border-width: 4px; border-radius: 18px; padding-top: 2px; }
  .kg-alat-seni { width: 38px; height: 32px; }
  .kg-alat-l { font-size: 12px; }
  .kg-lencana { min-width: 26px; height: 26px; font-size: 14px; line-height: 19px; border-width: 3px; top: -9px; right: -9px; }
  .kg-dulang { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); left: 50%; max-width: calc(100vw - 32px); padding: 6px 8px; border-width: 4px; gap: 6px; }
  .kg-dl-i, .kg-dl-kosong { width: 70px; min-height: 84px; border-width: 3px; border-radius: 16px; }
  .kg-dl-i svg { width: 44px; height: 44px; }
  .kg-dl-kosong { width: 96px; font-size: 15px; } .kg-dl-kosong svg { width: 48px; height: 48px; }
  .kg-nom { font-size: 17px; }
  .kg-titik i { width: 7px; height: 7px; border-width: 1.5px; }
  .kg-panel { padding: 8px; }
  .kg-pn-kad { padding: 10px 12px 14px; border-width: 5px; border-radius: 26px; max-height: calc(100dvh - 16px); }
  .kg-pn-kepala h2 { font-size: 24px; }
  .kg-pn-ikon { width: 48px; height: 48px; }
  .kg-pn-tutup { width: 56px; height: 56px; border-width: 4px; }
  .kg-tab button { min-height: 56px; font-size: 16px; padding: 2px 12px 2px 4px; }
  .kg-tab button svg { width: 42px; height: 42px; }
  .kg-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
  .kg-kad { min-height: 150px; border-width: 4px; padding: 6px; border-radius: 20px; }
  .kg-kad-seni { width: 68px; height: 68px; }
  .kg-kad-nama { font-size: 16px; }
  .kg-harga svg { width: 24px; height: 24px; } .kg-harga b { font-size: 19px; }
  .kg-jual-semua { min-height: 64px; font-size: 22px; margin-top: 10px; }
  .kg-js-ikon svg { width: 40px; height: 40px; }
  .kg-misi { padding: 6px 8px; gap: 8px; border-width: 4px; }
  .kg-misi-muka { width: 72px; height: 80px; }
  .kg-misi-i { width: 52px; height: 52px; }
  .kg-beri { width: 84px; min-height: 76px; font-size: 18px; }
  .kg-beri svg { width: 36px; height: 36px; }
  .kg-tirai-kawan { width: 150px; } .kg-tirai-mentari { width: 140px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .kg-pn-kad { width: min(760px, 100%); }
}
@media (prefers-reduced-motion: reduce) {
  .kg-haiwan .hw-badan, .kg-mahu, .kg-gelembung, .kg-tidur-b, .kg-beri, .awan-latar, .kg-petak.masak .kg-pokok-g { animation: none; }
}
@media (orientation: portrait) and (max-width: 599px) {
  .kg-alat { right: auto; }
  .kg-dulang { left: 50%; bottom: calc(64px + 90px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 24px); }
}
@media (orientation: landscape) and (max-height: 599px) {
  .kg-panel { padding-left: calc(84px + var(--safe-l)); }
  .kg-kad-ada { font-size: 14px; top: 4px; right: 6px; }
}

/* Audit UI Okt 2026: kamera kini boleh geser melepasi tepi kanan dunia (selebar bar alat) supaya Pasar/Kedai/label tidak tertutup bar alat.
   Jalur luar dunia: sambung langit (ikut masa) + gelap malam supaya tiada sempadan tajam. */
.kg-dunia::before { content: ''; position: absolute; left: 100%; top: 0; width: 600px; height: 262px; background: var(--langit, #C9ECFF); }
.kg-dunia > .kg-malam { right: -600px; }

/* Latar/langit bukan sasaran tekan — supaya Langkau (ui.js letakSkip) nampak ruang langit kosong di tengah atas dan tidak menindih dok alat */
.kg-latar, .kg-langit-obj { cursor: default; }

/* Tutorial kali pertama: sentuhan anak diabaikan semasa tangan menunjuk contoh */
body.tutorial .kg-view, body.tutorial .kg-dulang, body.tutorial .kg-hud { pointer-events: none; }
/* (.kg-alat disekat dalam JS — kekal 'boleh tekan' supaya Langkau ui.js tidak memilih tempat di atas dok) */

/* telefon landskap: dulang di bawah dok alat kanan atas (selepas peraturan telefon umum supaya menang) */
@media (orientation: landscape) and (max-height: 599px) {
  .kg-dulang { right: calc(8px + env(safe-area-inset-right, 0px)); top: calc(var(--kg-alat) + 36px + var(--safe-t)); bottom: auto; left: auto; max-width: calc(100vw - var(--kg-hud-l) - 16px); }
}
