/* 奶蛙跳一跳 · 样式（和系列其它游戏共用同一套配色/布局规范） */
:root {
  --ink: #4a3325;
  --ink-soft: #8a7566;
  --cream: #fff7ec;
  --brand: #ff6b6b;
  --brand-dark: #e14b4b;
  --card: rgba(255, 255, 255, .74);
  --shadow: 0 18px 50px rgba(126, 84, 44, .18);
  --gold: #e79a1f;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
html, body { touch-action: manipulation; }      /* 全页禁止双击缩放（舞台自己再设成 none） */

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background-color: #fff9f1;
  background-image:
    radial-gradient(1200px 700px at 8% -12%, #ffe9bd 0%, transparent 60%),
    radial-gradient(900px 600px at 104% -6%, #d5f0ff 0%, transparent 55%),
    radial-gradient(1000px 780px at 50% 118%, #ffdbe6 0%, transparent 62%);
  background-attachment: fixed;
  overflow: hidden;                       /* 整个游戏一屏内完整可玩，不出现整页滚动 */
  overscroll-behavior: none;              /* 禁止下拉刷新 / 橡皮筋 */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- 布局 */
.app {
  height: 100vh; height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: stretch;
  gap: 18px;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0; min-height: 0;
  border-radius: 24px;
  overflow: hidden;
  background: #fff3df;
  box-shadow: 0 26px 64px rgba(122, 80, 40, .3);
  touch-action: none;                     /* 舞台上不触发缩放/滚动/下拉刷新 */
  cursor: pointer;
}
.stage canvas {
  display: block;
  width: 100%; height: 100%;
  touch-action: none;
  outline: none;
}

/* ---------------------------------------------------------------- 开局提示 */
.hint {
  position: absolute; left: 50%; bottom: 7%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(126, 84, 44, .18);
  white-space: nowrap;
  pointer-events: none;                   /* 不挡住按压 */
  transition: opacity .35s ease, transform .35s ease;
  animation: hint-float 2.4s ease-in-out infinite;
}
.hint.gone { opacity: 0; transform: translateX(-50%) translateY(14px); animation: none; }
.hint-text { display: flex; flex-direction: column; line-height: 1.25; }
.hint-text b { font-size: 15px; letter-spacing: .02em; }
.hint-text small { font-size: 11.5px; color: var(--ink-soft); }
.press { position: relative; width: 38px; height: 38px; flex: none; }
.press .dot, .press .ring { position: absolute; border-radius: 50%; }
.press .dot {
  left: 9px; top: 9px; width: 20px; height: 20px;
  background: linear-gradient(135deg, #ff8a5b, #ff6b6b 55%, #e14b4b);
  box-shadow: 0 3px 8px rgba(225, 75, 75, .45);
  animation: press-dot 1.8s ease-in-out infinite;
}
.press .ring {
  left: 0; top: 0; right: 0; bottom: 0; border: 2px solid rgba(255, 107, 107, .65);
  animation: press-ring 1.8s ease-out infinite;
}
@keyframes hint-float { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }
@keyframes press-dot { 0%, 15% { transform: scale(1); } 45%, 70% { transform: scale(.68, .55) translateY(3px); } 100% { transform: scale(1); } }
@keyframes press-ring { 0%, 40% { transform: scale(.55); opacity: 0; } 55% { opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }

/* ---------------------------------------------------------------- 连击徽章 */
.combo {
  position: absolute; left: 14px; top: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 900; font-size: 16px; letter-spacing: .03em;
  color: #fff;
  background: linear-gradient(100deg, #ff7a59, #ff4d6d 55%, #b13bff);
  box-shadow: 0 8px 20px rgba(255, 77, 109, .35);
  pointer-events: none;
  opacity: 0; transform: translateY(-8px) scale(.8);
  transition: opacity .25s ease, transform .25s ease;
}
.combo.show { opacity: 1; transform: none; }
.combo.pop { animation: combo-pop .38s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes combo-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ---------------------------------------------------------------- 结束浮层 */
.overlay {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(255, 247, 236, .52);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s ease;
  cursor: default;
}
.overlay[hidden] { display: none; }
.overlay.show { opacity: 1; }
.ov-card {
  width: min(100%, 330px);
  padding: 18px 22px 22px;
  text-align: center;
  border-radius: 24px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow);
  transform: scale(.82) translateY(24px);
  transition: transform .5s cubic-bezier(.2, 1.5, .4, 1);
}
.overlay.show .ov-card { transform: none; }
.ov-frog {
  display: block; margin: -6px auto -4px;
  width: 112px; height: auto;
  filter: drop-shadow(0 8px 10px rgba(126, 84, 44, .22));
  animation: ov-laugh .55s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes ov-laugh { from { transform: rotate(-5deg) scale(1); } to { transform: rotate(5deg) scale(1.05, .97); } }
.ov-card h2 {
  margin: 4px 0 0;
  font-size: 34px; font-weight: 900; letter-spacing: .04em;
  color: var(--ink);
}
.ov-laugh { margin: 2px 0 12px; font-size: 13px; color: var(--ink-soft); letter-spacing: .1em; }
.ov-score { display: flex; gap: 10px; justify-content: center; margin-bottom: 4px; }
.ov-score > div {
  flex: 1; padding: 8px 6px;
  border-radius: 16px; background: rgba(255, 255, 255, .9);
  box-shadow: inset 0 0 0 1px rgba(138, 117, 102, .15);
}
.ov-score span { display: block; font-size: 11px; letter-spacing: .12em; color: var(--ink-soft); }
.ov-score b { display: block; font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ov-score b.gold { color: var(--gold); }
.ov-new {
  display: inline-block; margin: 8px 0 2px;
  padding: 4px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 800; letter-spacing: .08em; color: #fff;
  background: linear-gradient(135deg, #ffb13b, #ff7a59);
  box-shadow: 0 6px 16px rgba(255, 122, 89, .35);
  animation: new-pop .6s cubic-bezier(.2, 1.6, .4, 1) both .25s;
}
.ov-new[hidden] { display: none; }
@keyframes new-pop { from { transform: scale(0) rotate(-12deg); } to { transform: none; } }
.btn.big { margin-top: 12px; width: 100%; padding: 13px 18px; font-size: 18px; letter-spacing: .06em; }

/* ---------------------------------------------------------------- 侧栏 */
.panel {
  flex: 0 0 300px;
  min-height: 0;
  display: flex; flex-direction: column; gap: 16px;
  padding: 22px 20px 16px;
  border-radius: 24px;
  background: var(--card);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow);
}
.head h1 {
  margin: 0;
  font-size: 26px; font-weight: 900; letter-spacing: .02em; line-height: 1.15;
  background: linear-gradient(100deg, #ff7a59, #ff4d6d 55%, #b13bff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  padding: 10px 14px 9px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .82);
  box-shadow: inset 0 0 0 1px rgba(138, 117, 102, .12);
}
.stat .label { display: block; font-size: 11px; letter-spacing: .12em; color: var(--ink-soft); }
.stat .value { display: block; font-size: 26px; line-height: 1.25; font-weight: 800; font-variant-numeric: tabular-nums; transform-origin: 0 60%; }
.stat.best .value { color: var(--gold); }
.stat.combo-stat { grid-column: 1 / -1; }
.value.bump { animation: bump .32s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#btnRestart { grid-column: 1 / -1; order: -1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 10px 14px;
  border: 0; border-radius: 14px;
  font: 700 15px/1 var(--font); color: var(--ink);
  text-decoration: none; white-space: nowrap;
  background: rgba(255, 255, 255, .88);
  box-shadow: inset 0 0 0 1px rgba(138, 117, 102, .18), 0 3px 10px rgba(126, 84, 44, .08);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px rgba(138, 117, 102, .22), 0 6px 14px rgba(126, 84, 44, .14); }
.btn:active { transform: translateY(1px) scale(.97); }
.btn:focus-visible { outline: 3px solid rgba(255, 107, 107, .45); outline-offset: 2px; }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #ff8a5b, #ff6b6b 55%, #e14b4b);
  box-shadow: 0 8px 20px rgba(225, 75, 75, .35);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 10px 24px rgba(225, 75, 75, .42); }

.tips {
  margin: 0; padding: 12px 14px 12px 28px;
  border-radius: 16px; background: rgba(255, 247, 236, .75);
  font-size: 12.5px; line-height: 1.65; color: var(--ink-soft);
}
.tips b { color: var(--ink); }
.foot { margin-top: auto; font-size: 11.5px; text-align: center; color: var(--ink-soft); opacity: .85; }

/* ---------------------------------------------------------------- 窄屏：上下排列、侧栏精简 */
@media (max-width: 719px) {
  .app {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .stage { flex: 1 1 0; }
  .panel { flex: 0 0 auto; width: 100%; gap: 8px; padding: 12px 14px 8px; }
  .head h1 { font-size: 22px; }
  .sub { margin-top: 2px; font-size: 11.5px; line-height: 1.4; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 6px 10px 5px; border-radius: 14px; }
  .stat .label { font-size: 10.5px; }
  .stat .value { font-size: 22px; line-height: 1.2; }
  .stat.combo-stat { grid-column: auto; }
  .actions { grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; }
  #btnRestart { grid-column: auto; order: 0; }
  .btn { min-height: 40px; padding: 9px 4px; font-size: 14px; }
  .tips { display: none; }
  .foot { margin-top: 0; font-size: 10.5px; }
  .hint { bottom: 5%; padding: 8px 14px 8px 10px; }
  .hint-text b { font-size: 14px; }
  .combo { left: 10px; top: 10px; font-size: 14px; padding: 6px 12px; }
}

/* 矮屏（比如手机横屏）：保持左右排列，侧栏压到最精简 */
@media (max-height: 520px) and (orientation: landscape) {
  .app { flex-direction: row; gap: 10px; padding: 8px; }
  .stage { flex: 1 1 auto; }
  .panel { flex: 0 0 190px; width: auto; gap: 8px; padding: 10px 12px 8px; }
  .head h1 { font-size: 18px; }
  .sub, .tips { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat.combo-stat { grid-column: 1 / -1; }
  .stat .value { font-size: 20px; }
  .actions { grid-template-columns: 1fr 1fr; gap: 6px; }
  #btnRestart { grid-column: 1 / -1; order: -1; }
  .btn { min-height: 34px; font-size: 13px; }
  .foot { font-size: 10px; }
  .ov-frog { width: 70px; }
  .ov-card h2 { font-size: 26px; }
  .ov-score b { font-size: 22px; }
}

/* 桌面端窗口不高时，收起说明文字，保证侧栏不撑破一屏 */
@media (min-width: 720px) and (max-height: 640px) {
  .tips { display: none; }
}

/* 触屏设备上没有键盘，提示里的「空格键」那行就不显示了 */
@media (hover: none) {
  .hint-text small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hint, .press .dot, .press .ring, .ov-frog { animation: none; }
}
