/* 毛哥石器牧场：伪 3D 等距牧场（底图/前景由客户端图档合成），宠物用 8 方向动作图集走动。
   场景按 1280×860 设计，JS 按容器宽度缩放；手机上场景比屏幕宽时可左右拖动。 */
.ranch-main { padding-top: 14px; }
.ranch-page .fun-main { width: min(100% - 16px, 1320px); }

/* ---------- 顶部状态 ---------- */
.ranch-hud { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.hud-lv {
  display: flex; align-items: center; gap: 8px; min-width: 210px; padding: 5px 14px 5px 5px;
  background: rgba(255, 255, 255, .92); border: 3px solid #fff; border-radius: 999px; box-shadow: var(--shadow);
}
.lv-badge {
  display: grid; place-items: center; width: 40px; height: 40px; color: #5a2c05; font-family: var(--font-title);
  font-size: 18px; background: radial-gradient(circle at 35% 30%, #fff5c2, #ffc53a 70%); border: 3px solid #fff;
  border-radius: 50%; box-shadow: 0 3px 0 #d8701b;
}
.lv-badge::before { content: "Lv"; font-size: 10px; margin-right: 1px; }
.lv-info { flex: 1; min-width: 0; }
.lv-info b { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.exp-bar { position: relative; height: 12px; margin-top: 2px; overflow: hidden; background: #efe6f7; border-radius: 999px; }
.exp-bar i { display: block; width: var(--p, 0%); height: 100%; background: linear-gradient(90deg, #7fe0a5, #22c3a3); border-radius: 999px; transition: width .6s var(--out); }
.exp-bar span { position: absolute; inset: 0; color: #245; font-size: 9.5px; font-weight: 800; line-height: 12px; text-align: center; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 14px 0 6px; color: var(--ink);
  background: rgba(255, 255, 255, .92); border: 3px solid #fff; border-radius: 999px; box-shadow: var(--shadow);
  font-size: 15px; font-weight: 800; cursor: pointer;
}
.hud-pill img { width: 30px; height: 30px; object-fit: contain; }
.hud-pill.bump { animation: fun-pop .5s var(--jelly); }
.hud-visit {
  display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 5px 6px 5px 14px; color: #fff;
  background: linear-gradient(135deg, #ff9b2f, #ff6fa5); border: 3px solid #fff; border-radius: 999px; font-weight: 800;
}

/* ---------- 场景 ---------- */
.ranch-wrap { position: relative; }
.ranch-viewport {
  position: relative; overflow-x: auto; overflow-y: hidden; border: 4px solid #fff; border-radius: 26px;
  box-shadow: var(--shadow-lg); background: #7fbf66; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
.ranch-viewport::-webkit-scrollbar { display: none; }
.ranch-stage { position: relative; }
.ranch-scene { position: absolute; top: 0; left: 0; width: 1280px; height: 860px; transform-origin: 0 0; user-select: none; -webkit-user-select: none; }
.ranch-ground, .ranch-front { position: absolute; top: 0; left: 0; width: 1280px; height: 860px; pointer-events: none; }
.ranch-front { z-index: 2000; }
.ranch-layer { position: absolute; inset: 0; }
#tags { z-index: 2100; pointer-events: none; }
.ranch-clouds { position: absolute; inset: 0 0 auto; height: 150px; overflow: hidden; z-index: 5; pointer-events: none; }
.ranch-clouds i {
  position: absolute; top: var(--y, 20px); left: -200px; width: 120px; height: 36px; background: rgba(255, 255, 255, .85);
  border-radius: 999px; animation: ranch-cloud 90s linear infinite;
}
.ranch-clouds i::before { content: ""; position: absolute; left: 22px; top: -22px; width: 52px; height: 52px; background: inherit; border-radius: 50%; }
.ranch-clouds i:nth-child(1) { --y: 22px; animation-delay: -20s; }
.ranch-clouds i:nth-child(2) { --y: 58px; animation-duration: 120s; animation-delay: -70s; transform: scale(.7); }
.ranch-clouds i:nth-child(3) { --y: 8px; animation-duration: 150s; animation-delay: -110s; transform: scale(.55); }
@keyframes ranch-cloud { to { left: 1400px; } }

/* 可交互建筑：图集切片 + 悬停发光 */
.ra-prop {
  position: absolute; padding: 0; border: 0; background-color: transparent; background-image: url("/static/ranch-props.png?v=20260927-1"); background-repeat: no-repeat;
  cursor: pointer; transition: filter .2s ease, transform .3s var(--jelly); transform-origin: 50% 100%;
}
.ra-prop:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .ra-prop:hover { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 10px #ffe37d); transform: scale(1.03); }
}
.ra-tag {
  position: absolute; transform: translate(-50%, -100%) scale(var(--inv, 1)); transform-origin: 50% 100%; padding: 3px 10px; color: #5a2c05; background: #fff;
  border: 2px solid #ffc53a; border-radius: 999px; box-shadow: 0 3px 0 rgba(90, 50, 20, .25); font-size: 13px; font-weight: 800;
  white-space: nowrap;
}
.ra-tag.hot { color: #fff; background: #ff6f55; border-color: #fff; animation: ranch-bob 1.2s ease-in-out infinite; }
.trough-meter {
  position: absolute; transform: translate(-50%, -100%) scale(var(--inv, 1)); transform-origin: 50% 100%; display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px;
  background: rgba(255, 255, 255, .95); border: 2px solid #9fd97b; border-radius: 999px; font-size: 12px; font-weight: 800; pointer-events: auto;
  cursor: pointer; z-index: 2100;
}
.trough-meter img { width: 22px; height: 22px; object-fit: contain; }
.trough-meter.low { border-color: #ff6f55; color: #d0413b; animation: ranch-bob 1.2s ease-in-out infinite; }

/* 宠物 */
.ra-actor { position: absolute; left: 0; top: 0; will-change: transform; cursor: pointer; }
.ra-sprite { position: absolute; background-repeat: no-repeat; pointer-events: none; }
.ra-gif { position: absolute; pointer-events: none; image-rendering: pixelated; }
/* 石器原作里宠物相对建筑偏小，牧场里整体放大 1.4 倍更醒目；幼崽保持原大 */
.ra-body { position: absolute; left: 0; top: 0; transform: scale(1.4); transform-origin: 0 0; }
.ra-actor.baby .ra-body { transform: scale(1); }
.ra-actor.old .ra-body { filter: grayscale(.6) brightness(.95); }
.ra-actor.flip .ra-gif { transform: scaleX(-1); }
.ra-bubble {
  position: absolute; left: 0; bottom: 100%; display: flex; align-items: center; gap: 2px; padding: 3px 7px 3px 3px;
  transform: translate(-50%, -4px) scale(var(--inv, 1)); transform-origin: 50% 100%; background: #fff; border: 3px solid #ffc53a; border-radius: 16px;
  box-shadow: 0 4px 0 rgba(160, 90, 20, .3), 0 0 14px rgba(255, 214, 90, .9); font-weight: 800; font-size: 14px;
  color: #b3581b; animation: ranch-bob 1.4s ease-in-out infinite; white-space: nowrap; width: max-content;
}
.ra-bubble::after { content: ""; position: absolute; left: 50%; bottom: -9px; border: 7px solid transparent; border-top-color: #ffc53a; transform: translateX(-50%); }
.ra-bubble img { width: 30px; height: 30px; object-fit: contain; }
.ra-bubble.steal { border-color: #ff6fa5; color: #d4437a; box-shadow: 0 4px 0 rgba(160, 40, 90, .3), 0 0 14px rgba(255, 111, 165, .8); }
.ra-bubble.steal::after { border-top-color: #ff6fa5; }
.ra-bubble.done { opacity: .55; filter: grayscale(.6); animation: none; }
.ra-mood {
  position: absolute; left: 0; bottom: 100%; transform: translate(-50%, -2px) scale(var(--inv, 1)); transform-origin: 50% 100%; padding: 1px 7px; color: #fff; font-size: 12px;
  font-weight: 800; border-radius: 999px; white-space: nowrap; width: max-content; animation: ranch-bob 1.6s ease-in-out infinite;
}
.ra-mood.hungry { background: #ff6f55; }
.ra-mood.old { background: #9aa6b8; animation: none; }
.ra-mood.baby { background: #22c3a3; animation: none; }

/* 便便（CSS 绘制）与苍蝇 */
.ra-poop { position: absolute; width: 30px; height: 26px; margin: -24px 0 0 -15px; padding: 0; border: 0; background: none; cursor: pointer; transform: scale(1.3); }
.ra-poop i {
  position: absolute; left: 50%; border-radius: 50%; transform: translateX(-50%);
  background: radial-gradient(circle at 35% 30%, #b9854a, #7a4a1c 70%); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.ra-poop i:nth-child(1) { bottom: 0; width: 28px; height: 11px; }
.ra-poop i:nth-child(2) { bottom: 8px; width: 20px; height: 10px; }
.ra-poop i:nth-child(3) { bottom: 15px; width: 11px; height: 9px; border-radius: 50% 50% 40% 40%; }
.ra-poop b {
  position: absolute; left: 50%; top: -8px; width: 4px; height: 4px; background: #333; border-radius: 50%;
  animation: ranch-fly 1.8s linear infinite;
}
.ra-poop b + b { animation-duration: 2.4s; animation-direction: reverse; }
.ra-poop.bye { animation: ranch-poof .4s ease forwards; pointer-events: none; }
@keyframes ranch-fly { 0% { transform: rotate(0) translateX(12px) rotate(0); } 100% { transform: rotate(360deg) translateX(12px) rotate(-360deg); } }
@keyframes ranch-poof { to { opacity: 0; transform: scale(1.6) translateY(-10px); } }
@keyframes ranch-bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -6px; } }

/* 开垦牧场引导 */
.ranch-open {
  position: absolute; left: 50%; top: 50%; z-index: 30; width: 460px; padding: 22px 26px; text-align: center;
  background: rgba(255, 253, 248, .96); border: 4px solid #fff; border-radius: 28px; box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%);
}
.ranch-open h2 { margin: 0 0 8px; font-family: var(--font-title); font-size: 28px; letter-spacing: 2px; }
.ranch-open p { margin: 0 0 16px; color: var(--muted); font-size: 15px; }

/* ---------- 底部操作栏 ---------- */
.ranch-bar {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; margin-top: 10px; padding: 8px;
  background: rgba(255, 255, 255, .85); border: 3px solid #fff; border-radius: 22px; box-shadow: var(--shadow);
}
.ranch-bar button {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 2px; color: var(--ink);
  background: linear-gradient(180deg, #fff, #fff4e0); border: 2px solid #ffe2b0; border-radius: 16px;
  box-shadow: 0 3px 0 #f0c27a; font-size: 12.5px; font-weight: 800; cursor: pointer; transition: transform .25s var(--jelly);
}
.ranch-bar button:active { transform: translateY(2px); box-shadow: 0 1px 0 #f0c27a; }
.ranch-bar button img { width: 36px; height: 36px; object-fit: contain; }
.ranch-bar button:disabled { filter: grayscale(.8); opacity: .6; }
.ranch-bar em {
  position: absolute; top: -6px; right: -4px; min-width: 20px; padding: 0 6px; color: #fff; background: #ff4d6d;
  border: 2px solid #fff; border-radius: 999px; font-size: 11px; font-style: normal; line-height: 16px;
}
.ranch-below { margin-top: 16px; }
.ranch-below .mt { margin-top: 16px; }

/* ---------- 弹窗里的列表 ---------- */
.rc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; text-align: left; }
.rc-card {
  position: relative; display: grid; gap: 4px; padding: 10px; background: #fff; border: 2px solid #f1e6f5; border-radius: 16px;
}
.rc-card.locked { opacity: .6; }
.rc-card .pic { display: grid; place-items: center; height: 76px; background: radial-gradient(circle, #fff7e0, #ffeccb); border-radius: 12px; }
.rc-card .pic img { max-width: 90%; max-height: 72px; image-rendering: pixelated; }
.rc-card b { font-size: 14px; }
.rc-card small { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.rc-card .cost { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; font-weight: 800; color: var(--orange-deep); }
.rc-card .cost img { width: 22px; height: 22px; object-fit: contain; }
.rc-card .btn { width: 100%; height: 34px; margin-top: 4px; }
.rc-card .lock { position: absolute; top: 8px; right: 8px; padding: 0 8px; color: #fff; background: #9aa6b8; border-radius: 999px; font-size: 11px; }
.rc-list { display: grid; gap: 6px; max-height: 60vh; margin: 0; padding: 0; overflow: auto; list-style: none; text-align: left; }
.rc-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border-radius: 12px; font-size: 13.5px; }
.rc-list li img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.rc-list li .grow { flex: 1; min-width: 0; }
.rc-list li small { display: block; color: var(--muted); font-size: 11.5px; }
.rc-list li .btn { flex: none; }
.rc-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
.rc-meter { height: 16px; margin: 8px 0; overflow: hidden; background: #efe6f7; border-radius: 999px; }
.rc-meter i { display: block; width: var(--p, 0%); height: 100%; background: linear-gradient(90deg, #b8f08a, #5cc24a); border-radius: 999px; }
.rc-tip { color: var(--muted); font-size: 12.5px; }
.rc-ripe { padding: 0 8px; color: #fff; background: #ff6fa5; border-radius: 999px; font-size: 11.5px; font-weight: 800; }
.modal-card.wide { width: min(100%, 720px); }

/* ---------- 飘字 ---------- */
.ranch-float {
  position: fixed; z-index: 85; display: flex; align-items: center; gap: 4px; padding: 3px 10px; color: #b3581b;
  background: #fff; border: 2px solid #ffc53a; border-radius: 999px; font-weight: 800; pointer-events: none;
  animation: fun-float-up 1.3s var(--out) forwards;
}
.ranch-float img { width: 26px; height: 26px; object-fit: contain; }

@media (max-width: 760px) {
  .ranch-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hud-lv { min-width: 0; flex: 1 1 100%; }
  .hud-pill { flex: 1; justify-content: center; }
  .hud-visit { flex: 1 1 100%; justify-content: space-between; margin-left: 0; }
  .ranch-open { width: 300px; padding: 16px; }
  .ranch-open h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .ranch-clouds i, .ra-bubble, .ra-mood, .ra-poop b, .ra-tag.hot { animation: none !important; }
}
