/* 兔兔合成 · 卡通合成小游戏（移动端优先，竖屏铺满） */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E96A17;
  --brown: #4B2A16;
  --brown-2: #7A5540;
  --muted: #A5826A;
  --cream: #FFF7EA;
  --line: rgba(229, 170, 116, .45);
  --shadow: 0 8px 22px rgba(196, 120, 60, .14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #FFEFD9;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--brown);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

button { font-family: inherit; }

#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; }

#stage {
  position: absolute;
  inset: 0;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, #FFF8ED 0%, #FFEFDA 52%, #FFE3C4 100%);
}

@media (min-width: 600px) {
  #stage { box-shadow: 0 0 80px rgba(150, 88, 38, .22); }
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#safeProbe, #safeBottom {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  visibility: hidden;
  pointer-events: none;
}
#safeProbe { height: env(safe-area-inset-top, 0px); }
#safeBottom { height: env(safe-area-inset-bottom, 0px); }

/* ---------------- HUD ---------------- */
.hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 7px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .26s ease, transform .26s ease;
  pointer-events: none;
}
.hud.on { opacity: 1; transform: none; pointer-events: auto; }

.chip {
  height: 46px;
  border-radius: 16px;
  background: rgba(255, 252, 246, .93);
  border: 1px solid rgba(255, 185, 130, .62);
  box-shadow: 0 6px 16px rgba(197, 116, 55, .13), inset 0 1px 0 #fff;
  display: flex;
  align-items: center;
  padding: 0 11px;
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

.chip-score {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-width: 66px;
  padding: 0 11px;
}
.chip-label {
  font-size: 9px;
  line-height: 1;
  color: #B08A70;
  letter-spacing: .12em;
  white-space: nowrap;
}
.chip strong {
  font-size: 19px;
  line-height: 1.1;
  font-weight: 900;
  color: #54321D;
  font-variant-numeric: tabular-nums;
}

.chip-next {
  gap: 3px;
  padding: 0 6px 0 10px;
  min-width: 0;
}
#nextCanvas {
  width: 34px;
  height: 34px;
  display: block;
  margin-left: 2px;
}

.chip-coins {
  margin-left: auto;
  gap: 4px;
  padding: 0 12px 0 10px;
}
.chip-coins strong { font-size: 18px; color: #B06410; }
.coin-ico { width: 19px; height: 19px; display: inline-flex; flex: 0 0 auto; }
.coin-ico svg { width: 100%; height: 100%; display: block; }

.chip-coins.pop { animation: coinPop .42s ease; }
@keyframes coinPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.13); }
  100% { transform: scale(1); }
}

.hud-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  margin-left: 1px;
  padding: 0;
  border: 1px solid rgba(255, 185, 130, .62);
  border-radius: 15px;
  background: rgba(255, 252, 246, .93);
  box-shadow: 0 6px 16px rgba(197, 116, 55, .13), inset 0 1px 0 #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease;
}
.hud-btn:active { transform: scale(.93); }
.pause-bars { display: flex; gap: 4px; }
.pause-bars i {
  display: block;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: #A9724B;
}

/* ---------------- 浮层提示 ---------------- */
.combo {
  position: absolute;
  left: 0;
  right: 0;
  top: 29%;
  z-index: 15;
  text-align: center;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: .03em;
  color: #fff;
  text-shadow: 0 3px 0 #E5651B, 0 10px 22px rgba(229, 101, 27, .45);
  opacity: 0;
  pointer-events: none;
  transform: scale(.6);
}
.combo.show { animation: comboIn 1.05s ease-out forwards; }
@keyframes comboIn {
  0% { opacity: 0; transform: scale(.45) rotate(-9deg); }
  18% { opacity: 1; transform: scale(1.16) rotate(-3deg); }
  62% { opacity: 1; transform: scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: scale(1.06) translateY(-18px) rotate(-1deg); }
}

.danger-hint {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 50%;
  z-index: 18;
  padding: 7px 15px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FF7A6B, #F0473A);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(240, 71, 58, .36);
  opacity: 0;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.danger-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: dangerBlink .9s ease-in-out infinite;
}
@keyframes dangerBlink {
  0%, 100% { box-shadow: 0 8px 18px rgba(240, 71, 58, .34); }
  50% { box-shadow: 0 8px 26px rgba(240, 71, 58, .7); }
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  z-index: 70;
  max-width: 82%;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(58, 33, 17, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition: opacity .24s ease, transform .24s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 全屏画面 ---------------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .3s ease, visibility .3s ease;
}
.screen.show { opacity: 1; visibility: visible; pointer-events: auto; }
.screen::-webkit-scrollbar { display: none; }

#startScreen {
  background:
    radial-gradient(92% 46% at 50% -6%, rgba(255, 193, 120, .85) 0%, rgba(255, 193, 120, 0) 68%),
    radial-gradient(70% 42% at 108% 104%, rgba(255, 157, 101, .38) 0%, rgba(255, 157, 101, 0) 70%),
    radial-gradient(60% 36% at -10% 92%, rgba(255, 205, 140, .48) 0%, rgba(255, 205, 140, 0) 70%),
    linear-gradient(180deg, #FFFCF6 0%, #FFF4E4 46%, #FFE6C7 100%);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
}
#startScreen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(214, 150, 90, .17) 1.1px, transparent 1.2px);
  background-size: 19px 19px;
  opacity: .6;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 72%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 72%);
  pointer-events: none;
}

.screen-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(30px); opacity: .55; }
.b1 { width: 220px; height: 220px; background: #FFD3A0; left: -74px; top: 6%; }
.b2 { width: 180px; height: 180px; background: #E7C8FF; right: -64px; top: 34%; opacity: .42; }
.b3 { width: 250px; height: 250px; background: #FFE0AE; left: 50%; bottom: -130px; transform: translateX(-50%); }

.start-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  margin: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 22px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.mascot {
  position: relative;
  width: clamp(148px, 39vh, 204px);
  margin: 4px 0 0;
  filter: drop-shadow(0 16px 20px rgba(199, 112, 43, .18));
  animation: floaty 4.2s ease-in-out infinite;
}
.mascot-svg { display: block; width: 100%; height: auto; overflow: visible; }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-9px) rotate(1deg); }
}
.float-coin {
  position: absolute;
  z-index: 2;
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 4px 7px rgba(200, 120, 20, .32));
  animation: coinFloat 3.2s ease-in-out infinite;
}
.float-coin svg { width: 100%; height: 100%; display: block; }
.float-coin.c1 { left: -4px; top: 17%; }
.float-coin.c2 { right: -2px; top: 58%; width: 26px; height: 26px; animation-delay: -1.4s; }
@keyframes coinFloat {
  0%, 100% { transform: translateY(0) rotate(-11deg); }
  50% { transform: translateY(-11px) rotate(9deg); }
}

.game-title {
  margin: 8px 0 0;
  font-size: clamp(38px, 11vw, 48px);
  line-height: 1.06;
  font-weight: 900;
  letter-spacing: .06em;
  color: #4B2A16;
  text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(214, 140, 80, .16);
}
.game-title b {
  position: relative;
  color: #FF7A28;
  font-weight: 900;
  background-image: linear-gradient(90deg, rgba(255, 190, 130, 0), rgba(255, 154, 80, .5), rgba(255, 190, 130, 0));
  background-repeat: no-repeat;
  background-size: 100% 9px;
  background-position: 0 92%;
}

.game-sub {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.72;
  font-weight: 500;
  color: #967055;
}

.start-stats { display: flex; gap: 10px; margin: 18px 0 20px; }
.stat {
  min-width: 104px;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(255, 253, 248, .86);
  border: 1px solid rgba(255, 186, 132, .58);
  box-shadow: 0 6px 14px rgba(198, 120, 60, .09), inset 0 1px 0 #fff;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat span { font-size: 10px; letter-spacing: .1em; color: #B08A70; }
.stat strong {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
  color: #54321D;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 按钮 ---------------- */
.btn {
  width: 100%;
  max-width: 330px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
  -webkit-appearance: none;
  touch-action: manipulation;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn-primary {
  background: linear-gradient(180deg, #FFAE63 0%, #FF8A3D 40%, #FF741F 100%);
  color: #fff;
  box-shadow: 0 7px 0 #DE5F13, 0 14px 26px rgba(255, 122, 40, .32), inset 0 1px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 1px 0 rgba(180, 70, 10, .35);
}
.btn-primary:active {
  box-shadow: 0 3px 0 #DE5F13, 0 8px 16px rgba(255, 122, 40, .28);
  transform: translateY(4px);
}
.btn-start { height: 60px; font-size: 20px; margin-top: 0; }

.btn-soft {
  height: 50px;
  font-size: 16px;
  color: #8A5A38;
  background: #FFFDF8;
  border: 1.5px solid rgba(255, 183, 128, .72);
  box-shadow: 0 5px 14px rgba(190, 115, 55, .12);
}
.btn-ghost {
  height: 42px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #A07C63;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(160, 124, 99, .38);
  box-shadow: none;
}
.btn-ad {
  height: 52px;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(180deg, #63D6A8, #2FB37F);
  box-shadow: 0 6px 0 #1E8D63, 0 12px 22px rgba(47, 179, 127, .3);
  text-shadow: 0 1px 0 rgba(0, 90, 60, .3);
}
.btn-ad:active { transform: translateY(3px); box-shadow: 0 3px 0 #1E8D63, 0 7px 14px rgba(47, 179, 127, .26); }
.btn:disabled { opacity: .68; filter: saturate(.7); }

.hidden { display: none !important; }

.start-hint {
  margin: 12px 0 0;
  font-size: 12px;
  letter-spacing: .02em;
  color: #AD876C;
}

/* ---------------- 进化路线 ---------------- */
.ladder {
  width: 100%;
  margin-top: 18px;
  padding: 9px 8px 7px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .55);
  border: 1px dashed rgba(228, 165, 110, .62);
}
.ladder-title {
  font-size: 10px;
  letter-spacing: .16em;
  color: #B08A70;
  margin-bottom: 4px;
}
.ladder-row { display: flex; align-items: center; justify-content: center; }
.ladder-item {
  width: 32px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.ladder-item canvas { width: 32px; height: 32px; display: block; }
.ladder-arrow {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  margin: 0 1px;
  border-top: 2px solid rgba(190, 130, 80, .5);
  border-right: 2px solid rgba(190, 130, 80, .5);
  transform: rotate(45deg);
}

.brand-line {
  margin: 12px 0 0;
  font-size: 10px;
  letter-spacing: .18em;
  color: rgba(150, 106, 76, .62);
}

@media (max-width: 350px) {
  .chip-next .chip-label { display: none; }
  .chip-score { min-width: 60px; padding: 0 9px; }
  .chip { height: 44px; }
  .hud-btn { width: 42px; height: 42px; }
}

@media (max-width: 340px) {
  .ladder-item { width: 27px; height: 30px; }
  .ladder-item canvas { width: 27px; height: 27px; }
  .ladder-arrow { margin: 0; }
}

/* ---------------- 弹窗 ---------------- */
.screen-dim {
  z-index: 50;
  align-items: center;
  justify-content: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: radial-gradient(90% 60% at 50% 18%, rgba(86, 45, 21, .38), rgba(52, 26, 11, .66));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.dialog {
  position: relative;
  width: 100%;
  max-width: 356px;
  margin: auto;
  padding: 16px 20px 18px;
  border-radius: 30px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF3E2 100%);
  border: 1px solid rgba(255, 255, 255, .85);
  box-shadow: 0 26px 60px rgba(46, 20, 6, .34), inset 0 1px 0 #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  text-align: center;
}
.screen.show .dialog { animation: dialogPop .4s cubic-bezier(.2, 1.28, .42, 1); }
@keyframes dialogPop {
  0% { opacity: 0; transform: translateY(18px) scale(.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.dialog h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .03em;
  color: #4B2A16;
}
.dialog-sub { margin: -5px 0 3px; font-size: 13px; color: #A07C63; }
.dialog .btn { max-width: none; }

.dialog-bunny {
  width: 112px;
  height: 112px;
  margin: -6px 0 -2px;
  filter: drop-shadow(0 8px 12px rgba(190, 110, 50, .2));
}
.dialog-bunny canvas { width: 100%; height: 100%; display: block; }
.over-bunny { width: 120px; height: 120px; animation: overBob 3.2s ease-in-out infinite; }
@keyframes overBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.dialog-over { gap: 10px; }
.over-tag {
  margin-top: -2px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #FFE7CE;
  color: #C06A22;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
}
.over-title { font-size: 22px; margin-top: -2px; }

.final-score {
  position: relative;
  width: 100%;
  padding: 10px 0 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 190, 135, .62);
  box-shadow: inset 0 1px 0 #fff;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.final-score span { font-size: 10px; letter-spacing: .14em; color: #B08A70; }
.final-score strong {
  font-size: 44px;
  line-height: 1.02;
  font-weight: 900;
  color: #FF7A28;
  text-shadow: 0 2px 0 #FFF1DE;
  font-variant-numeric: tabular-nums;
}
.record {
  position: absolute;
  right: 9px;
  top: 9px;
  padding: 4px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFD86B, #FFB020);
  color: #7A4B00;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: .06em;
  box-shadow: 0 3px 8px rgba(220, 150, 20, .3);
  transform: rotate(4deg);
}

.final-reward {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: #8A6148;
}
.final-reward b { font-size: 20px; font-weight: 900; color: #E18A16; font-variant-numeric: tabular-nums; }

@media (max-height: 700px) {
  .mascot { width: clamp(122px, 30vh, 160px); }
  .game-sub { margin-top: 8px; font-size: 13px; }
  .start-stats { margin: 12px 0 14px; }
  .ladder { margin-top: 12px; }
  .btn-start { height: 54px; font-size: 19px; }
  .start-inner { padding-top: calc(env(safe-area-inset-top, 0px) + 10px); }
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(1.04); }
  .hud-btn:hover { background: #fff; }
}
