/* ============ 基础布局（移动端优先） ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #79c96f;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; user-select: none; }
#app { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }

/* ============ HUD ============ */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud button, #hud .panel-card { pointer-events: auto; }

.panel-card {
  position: absolute; background: rgba(255,255,255,.88); backdrop-filter: blur(6px);
  border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.18); padding: 8px 10px;
}

/* 顶部信息卡（整条） */
#topCard { top: 8px; left: 8px; right: 8px; padding: 6px 10px; border-radius: 12px; }
#topCard .row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: #444; }
#topCard .row.small { font-size: 11px; font-weight: 400; color: #7a7a7a; margin-top: 2px; }
.grow { flex: 1; }
.clean-ind { font-size: 12px; font-weight: 700; color: #2e7d32; white-space: nowrap; }
.mini { border: none; background: #eceff1; border-radius: 7px; font-size: 12px; padding: 2px 7px; color: #444; cursor: pointer; }
.mini:active { background: #cfd8dc; }
#money { color: #e65100; }

/* 宠物状态卡 */
#petCard { top: 64px; left: 8px; width: 200px; max-width: 52vw; padding: 7px 9px; border-radius: 12px; }
.pet-head { display: flex; gap: 7px; align-items: center; }
.card-toggle { flex: none; border: none; background: #eceff1; color: #555; width: 24px; height: 24px;
  border-radius: 7px; font-size: 13px; line-height: 1; cursor: pointer; transition: transform .18s ease; }
.card-toggle:active { background: #cfd8dc; }
#petCard.collapsed #bars { display: none; }
#petCard.collapsed .card-toggle { transform: rotate(-90deg); }
.pet-avatar { width: 48px; height: 48px; flex: none; background: #e8f5e9; border-radius: 10px; overflow: hidden; }
#avatarCv { width: 100%; height: 100%; }
.pet-info { min-width: 0; flex: 1; }
.pet-name { font-weight: 700; font-size: 14px; color: #333; display: flex; align-items: center; gap: 5px; }
.stage-tag { font-size: 10px; background: #ffb74d; color: #fff; border-radius: 6px; padding: 1px 5px; font-weight: 600; flex: none; }
.pet-sub { font-size: 10px; color: #777; margin-top: 2px; line-height: 1.35; }
#bars { margin-top: 5px; display: flex; flex-direction: column; gap: 2px; }
.bar-row { display: flex; align-items: center; gap: 5px; font-size: 9px; color: #555; }
.bar-row .bname { width: 24px; flex: none; }
.bar-track { flex: 1; height: 6px; background: #e0e0e0; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }

/* toast 提示（底部，避免遮挡状态卡） */
#toast { position: absolute; top: calc(58px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 30;
  display: flex; flex-direction: column-reverse; gap: 6px; align-items: center; width: max-content; max-width: 88vw; }
.toast-item { background: rgba(40,40,40,.85); color: #fff; font-size: 13px; padding: 7px 14px;
  border-radius: 20px; animation: toastIn .25s ease; box-shadow: 0 3px 10px rgba(0,0,0,.25); text-align: center; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* 底部操作栏 */
#bottomBar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px); padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0,0,0,.15); }
#bottomBar button { border: none; background: none; font-size: 18px; line-height: 1.15; color: #555;
  padding: 4px 1px; border-radius: 10px; cursor: pointer; flex: 1; min-width: 0; }
#bottomBar button span { font-size: 9px; display: block; }
#bottomBar button:active { background: #eeeeee; transform: scale(.94); }
#bottomBar button.asleep { opacity: .4; filter: grayscale(.7); cursor: not-allowed; }

/* ============ 弹窗 ============ */
#panelMask { position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center; }
#panel { background: #fffdf7; width: 100%; max-width: 520px; max-height: 78vh; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; animation: panelUp .22s ease; overflow: hidden; }
@keyframes panelUp { from { transform: translateY(60px); opacity: .4; } to { transform: none; opacity: 1; } }
#panelHead { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  border-bottom: 1px solid #f0e6d2; font-size: 16px; color: #5d4037; }
#panelClose { border: none; background: #f5f0e6; width: 30px; height: 30px; border-radius: 50%; font-size: 14px; color: #8d6e63; cursor: pointer; }
#panelBody { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.item-card { background: #fff; border: 1px solid #eee2cc; border-radius: 12px; padding: 10px; text-align: center; }
.item-card .ico { font-size: 30px; }
.item-card .nm { font-size: 13px; font-weight: 700; color: #4e342e; margin: 4px 0 2px; }
.item-card .ds { font-size: 11px; color: #999; min-height: 26px; }
.item-card .pr { font-size: 13px; color: #e65100; font-weight: 700; margin: 4px 0 6px; }
.buy-btn { border: none; background: linear-gradient(180deg,#ffca28,#ffb300); color: #5d4037; font-weight: 700;
  font-size: 12px; padding: 6px 14px; border-radius: 16px; cursor: pointer; width: 100%; }
.buy-btn:active { transform: scale(.95); }
.buy-btn:disabled { background: #e0e0e0; color: #999; cursor: not-allowed; }
.owned-tag { font-size: 11px; color: #2e7d32; font-weight: 700; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: none; background: #f5f0e6; color: #8d6e63; font-size: 12px; padding: 6px 12px;
  border-radius: 14px; cursor: pointer; font-weight: 600; }
.tabs button.on { background: #ffb74d; color: #fff; }

.plot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.plot-cell { aspect-ratio: 1; border-radius: 10px; border: 2px dashed #bcaaa4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 20px; cursor: pointer; background: #efebe9; position: relative; }
.plot-cell.owned { border-style: solid; background: #d7ccc8; }
.plot-cell .pnm { font-size: 10px; color: #4e342e; font-weight: 700; }
.plot-cell .pt { font-size: 9px; color: #795548; }
.plot-cell.ripe { background: #c5e1a5; border-color: #7cb342; animation: ripeGlow 1s infinite alternate; }
@keyframes ripeGlow { from { box-shadow: 0 0 0 rgba(124,179,66,0); } to { box-shadow: 0 0 8px rgba(124,179,66,.8); } }
.plot-cell.locked { opacity: .55; }
.mini-btn { border: none; border-radius: 12px; padding: 4px 8px; font-size: 11px; font-weight: 700; cursor: pointer; color: #fff; }
.mini-btn.plant { background: #66bb6a; }
.mini-btn.harvest { background: #ffa726; }
.mini-btn:active { transform: scale(.94); }

.pet-list { display: flex; flex-direction: column; gap: 8px; }
.pet-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #eee2cc;
  border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.pet-row.active { border-color: #ffb74d; background: #fff8e1; }
.pet-row .dot { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.pet-row .pi { flex: 1; min-width: 0; }
.pet-row .pn { font-size: 13px; font-weight: 700; color: #4e342e; }
.pet-row .ps { font-size: 11px; color: #999; }
.pet-row .act { border: none; background: #f8bbd0; color: #880e4f; font-size: 11px; font-weight: 700;
  padding: 5px 9px; border-radius: 12px; cursor: pointer; flex: none; }

.stat-line { display: flex; justify-content: space-between; font-size: 13px; color: #5d4037; padding: 5px 2px;
  border-bottom: 1px dashed #eee; }
.stat-line b { color: #e65100; }
.help-p { font-size: 13px; color: #5d4037; line-height: 1.75; }
.help-p b { color: #e65100; }
.help-p .sec { font-weight: 800; color: #4e342e; margin-top: 8px; display: block; }

/* 宠物面板内的工具入口卡片（成就 / 玩法说明） */
.tool-tiles { display: flex; gap: 10px; margin-top: 14px; }
.tool-tile { flex: 1; border: none; cursor: pointer; border-radius: 14px; padding: 12px 8px;
  color: #fff; display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-weight: 800; font-size: 13px; box-shadow: 0 3px 9px rgba(0,0,0,.18); transition: transform .15s ease; }
.tool-tile .ico { font-size: 26px; line-height: 1; }
.tool-tile.achv { background: linear-gradient(160deg,#ffd54f,#ff8f00); }
.tool-tile.help { background: linear-gradient(160deg,#4fc3f7,#0288d1); }
.tool-tile.fish { background: linear-gradient(160deg,#80d8ff,#00acc1); }
.tool-tile.camp { background: linear-gradient(160deg,#aed581,#7cb342); }
.tool-tile.bag { background: linear-gradient(160deg,#bcaaa4,#8d6e63); }
.tool-tile:active { transform: scale(.95); }

/* ============ 出发动画 ============ */
#travel { position: absolute; inset: 0; z-index: 30; background: rgba(20,30,40,.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
#travelCv { width: min(86vw, 560px); height: auto; }
#travelTxt { color: #ffe082; font-size: 16px; font-weight: 700; letter-spacing: 2px; }

/* 动效场景浮层 */#anim { position: absolute; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center;
  background: rgba(20,30,40,.55); animation: fadeIn .18s ease; }
#anim .anim-box { display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: animPop .28s cubic-bezier(.2,1.4,.4,1); }
#animCv { width: min(72vw, 340px); height: auto; filter: drop-shadow(0 8px 18px rgba(0,0,0,.3)); }
#animTxt { color: #fff; font-size: 17px; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0,0,0,.5); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes animPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 屋内“出门”按钮（左下角，位于底部菜单上方） */
#btnExitHouse { position: absolute; left: 12px; bottom: 70px; z-index: 18; border: none; cursor: pointer;
  background: linear-gradient(180deg,#ffcc80,#ffa726); color: #4e342e; font-weight: 800; font-size: 14px;
  padding: 8px 14px; border-radius: 20px; box-shadow: 0 3px 8px rgba(0,0,0,.28); }
#btnExitHouse:active { transform: translateY(1px); }

/* ============ 开始界面 ============ */
#startScreen { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #aed581 0%, #4fc3f7 60%, #01579b 100%); }
.start-inner { text-align: center; color: #fff; padding: 24px; max-width: 420px; }
.start-egg { font-size: 74px; animation: eggWobble 1.6s ease-in-out infinite; }
@keyframes eggWobble { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.start-inner h1 { font-size: 27px; margin: 8px 0 12px; text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.start-inner p { font-size: 13px; opacity: .92; line-height: 1.6; }
#startBtns { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 16px; }
.big { border: none; background: #fff; color: #e65100; font-size: 16px; font-weight: 800; padding: 13px 26px;
  border-radius: 26px; cursor: pointer; box-shadow: 0 5px 16px rgba(0,0,0,.25); }
.big:active { transform: scale(.96); }
.tips { font-size: 11px; opacity: .85; line-height: 1.8; background: rgba(0,0,0,.18); border-radius: 12px; padding: 10px 14px; }

@media (min-width: 760px) {
  #topCard { right: auto; min-width: 210px; }
  #topCard .row { font-size: 14px; }
  #petCard { width: 246px; top: 10px; left: auto; right: 10px; padding: 9px 11px; }
  #topCard .row.small { font-size: 12px; }
  .pet-name { font-size: 15px; } .pet-sub { font-size: 11px; }
  #bars { margin-top: 7px; gap: 3px; } .bar-row { font-size: 10px; } .bar-track { height: 8px; }
  #bottomBar button { font-size: 21px; }
  #bottomBar button span { font-size: 11px; }
  #panelMask { align-items: center; }
  #panel { border-radius: 18px; margin-bottom: 4vh; }
}
