:root {
  color-scheme: dark;
  font-family: "Yuanti SC", "YouYuan", "STYuanti", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #0d1710;
  color: #fff7df;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow: hidden; background: #0d1710; }
body { min-height: 100dvh; touch-action: none; overscroll-behavior: none; }
button { font: inherit; }
.game-shell { min-height: 100dvh; display: grid; place-items: center; }
.game-frame {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16), 520px);
  height: auto;
  max-height: 100dvh;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #26351f;
  isolation: isolate;
  box-shadow: 0 0 50px rgba(0, 0, 0, .65);
}
#game { width: 100%; height: 100%; display: block; }

/* 加载提示：素材解析在主线程同步跑，低端机有 1-2s 白屏期 */
.boot-loading {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: #26351f;
  color: #ffe08a;
  font-size: 17px;
  letter-spacing: .35em;
  text-indent: .35em;
}

/* HUD 与操作按钮在开始前隐藏，开局淡入 */
.hud, .controls { opacity: 0; pointer-events: none; transition: opacity .35s ease; }
body.playing .hud, body.playing .controls { opacity: 1; pointer-events: auto; }

.hud {
  position: absolute;
  z-index: 4;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  padding: 11px 14px 9px;
  border: 1px solid rgba(255, 241, 183, .34);
  border-radius: 17px;
  background: linear-gradient(180deg, rgba(26, 28, 19, .86), rgba(28, 28, 18, .68));
  box-shadow: 0 5px 18px rgba(0, 0, 0, .27);
  backdrop-filter: blur(6px);
}
.hud-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hud-line strong { font-size: 15px; letter-spacing: .08em; }
.hud-line span { font-size: 13px; color: #ffe083; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.status-line { margin-top: 8px; }
.hearts { color: #ff746b; font-size: 21px; letter-spacing: 2px; filter: drop-shadow(0 2px 0 #4e1c1a); }
.hearts .empty { opacity: .24; filter: grayscale(.6); }
.hearts.danger { animation: heartbeat .5s infinite alternate; }
.mini-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 244, 200, .4);
  border-radius: 9px;
  color: #fff3c9;
  background: rgba(20, 24, 16, .55);
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.mini-btn:disabled { opacity: .38; }
.mini-btn.muted { opacity: .45; text-decoration: line-through; }

/* 声音开关：嵌入 HUD 第一行右侧，与血量/进度解耦，不再压血条 */
.sound-btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 14px;
}
.sound-btn:hover { background: rgba(30, 34, 22, .72); }

/* 妈妈库存：右上角状态行内紧凑胶囊，语义靠近"还能叫几次" */
.mama-meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid rgba(255, 214, 130, .42);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(46, 30, 18, .82), rgba(30, 20, 14, .72));
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
  backdrop-filter: blur(5px);
  margin-left: auto;
}
.mama-meter .mm-label { font-size: 12px; color: #ffdf9e; font-weight: 800; letter-spacing: .05em; }
.mama-meter b { color: #ffe171; font-size: 14px; letter-spacing: 3px; font-variant-numeric: tabular-nums; }
.mama-meter.warn { border-color: rgba(255, 143, 96, .75); }
.mama-meter.warn b { color: #ff9f6e; }
.mama-meter.hungry { animation: mama-ready .8s infinite alternate; }
.mini-btn.active { background: rgba(255, 226, 117, .85); color: #3a2410; border-color: #ffe275; }
.progress { height: 5px; margin-top: 7px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.18); }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #fb7c5e, #ffe275); }

.controls {
  position: absolute;
  z-index: 5;
  left: 16px;
  right: 16px;
  bottom: max(17px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: .78fr 1.35fr;
  gap: 12px;
  align-items: end;
}
.game-button {
  min-height: 76px;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 24px;
  color: #241b16;
  box-shadow: 0 7px 0 #773b32, 0 10px 25px rgba(0,0,0,.3);
  transform: translateY(0);
  transition: transform .08s, filter .12s, opacity .12s;
  user-select: none;
}
.game-button:active { transform: translateY(6px); box-shadow: 0 1px 0 #773b32; }
.game-button:disabled { filter: grayscale(.8); opacity: .55; }
.game-button span { display: block; font-size: 28px; font-weight: 1000; line-height: 1.1; }
.game-button small { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; opacity: .68; }
/* 跳＝阳光黄；叫妈妈＝晚霞红粉。紧急时刻靠色相区分，不靠读字 */
.jump-button { background: linear-gradient(180deg, #ffe078, #ee9a49); }
.mama-button { min-height: 88px; background: linear-gradient(180deg, #ffc2a1, #ef7a58); }
.mama-button.ready { animation: mama-ready .75s infinite alternate; }
.mama-button.memory { background: linear-gradient(180deg, #dab8ff, #9378d4); color: #1f1830; }
.toast {
  position: absolute;
  z-index: 7;
  top: 27%;
  left: 50%;
  transform: translate(-50%, 8px) scale(.92);
  min-width: 120px;
  padding: 11px 18px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 999px;
  background: rgba(24, 22, 17, .82);
  color: #fff3c7;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.crisis {
  position: absolute;
  z-index: 7;
  top: 37%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(48px, 15vw, 72px);
  font-weight: 1000;
  color: #fff2bc;
  text-shadow: 0 5px 0 #7a271f, 0 0 28px #ff3429;
  opacity: 0;
  transform: scale(.5) rotate(-4deg);
  pointer-events: none;
}
.crisis.show { animation: crisis-pop .65s both; }
.panel {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 38px;
  text-align: center;
  background: linear-gradient(180deg, rgba(8,15,10,.25), rgba(8,15,10,.84));
  transition: opacity .25s ease;
}
.panel.hidden { opacity: 0; pointer-events: none; }
.panel h1, .panel h2 {
  margin: 4px 0 12px;
  font-family: "Yuanti SC", "YouYuan", "STYuanti", "PingFang SC", sans-serif;
  font-size: clamp(44px, 12vw, 66px);
  line-height: 1.05;
  text-shadow: 0 5px 0 rgba(65,34,18,.72);
}
.panel p { max-width: 330px; margin: 0 0 23px; font-size: 17px; line-height: 1.65; color: #fff3cf; }
.panel .kicker { margin: 0; color: #ffcf64; font-size: 18px; font-weight: 900; letter-spacing: .28em; }
.primary, .secondary { border: 0; border-radius: 18px; padding: 15px 25px; font-size: 19px; font-weight: 1000; }
.primary { color: #2b1d14; background: linear-gradient(180deg,#ffe077,#f5a33a); box-shadow: 0 6px 0 #85452d; }
.secondary { color: #2c1b2a; background: #f4dff1; box-shadow: 0 6px 0 #7b4f76; }
.story-panel { background: radial-gradient(circle, rgba(239,148,65,.25), rgba(5,10,7,.9)); }
.story-panel h2 { font-size: 48px; }
/* 结算页改暖色黄昏调，与主视觉同一世界 */
.result-panel { background: linear-gradient(165deg, rgba(58,33,19,.93), rgba(133,60,31,.95)); color: #fff3dc; }
.result-panel p { color: #ffe9c4; }
.result-panel .kicker { color: #ffd98a; }
.result-panel h2 { text-shadow: none; }
.score-row { display: flex; gap: 10px; margin: 4px 0 14px; }
.score-row span { min-width: 88px; padding: 12px 8px; border-radius: 16px; background: rgba(255,255,255,.13); font-size: 12px; }
.score-row b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.best-line { min-height: 22px; margin: 0 0 20px !important; font-size: 14px !important; color: #ffd98a !important; }
.best-line.record { color: #ffe275; font-weight: 800; }
.result-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.result-actions .primary { flex: 1 1 100%; }
.result-actions .secondary { flex: 1 1 0; text-align: center; }
.share-hint { min-height: 20px; margin: 16px 0 0 !important; font-size: 14px !important; color: #ffd98a !important; }
.share-hint.ok { color: #b8f2a4 !important; }

.landscape-tip {
  position: fixed;
  z-index: 40;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 22, 14, .85);
  color: #ffe9b0;
  font-size: 13px;
  white-space: nowrap;
}
@keyframes heartbeat { to { transform: scale(1.12); color: #fff; } }
@keyframes mama-ready { to { filter: brightness(1.18); box-shadow: 0 7px 0 #773b32, 0 0 28px rgba(255,218,87,.8); } }
@keyframes crisis-pop { 25% { opacity: 1; transform: scale(1.1) rotate(2deg); } 70% { opacity: 1; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.3); } }
@media (min-width: 700px) { .game-frame { border-radius: 30px; border: 2px solid rgba(255,224,134,.34); } }
/* 横屏矮窗：竖版游戏居中留黑边即可，提示玩家转回来 */
@media (orientation: landscape) and (max-height: 500px) {
  .landscape-tip { display: block; }
  .game-frame { width: min(100vw, calc(100dvh * 9 / 16), 520px); height: auto; }
  .hud { transform: scale(.86); transform-origin: top left; right: auto; width: 118%; }
}
