/* ===== 小小历险记 全局样式（柔和圆角 HUD 风） ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ui-ink: #2a3236;
  --ui-soft: rgba(48, 54, 58, 0.78);
  --leaf: #7bc96f;
  --leaf-deep: #4a9a45;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 50% 100%, #1a2e22 0%, transparent 55%),
    #0c1210;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  background: #8ecae6;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
  outline: none;
}

/* ===== 手机虚拟键盘 ===== */
#mobileControls {
  display: none;
  position: fixed;
  inset: auto 0 max(12px, env(safe-area-inset-bottom)) 0;
  z-index: 20;
  justify-content: space-between;
  align-items: end;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.touch-pad, .touch-actions {
  display: grid;
  gap: 8px;
  pointer-events: auto;
}
.touch-pad {
  width: 148px;
  height: 132px;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 40px);
  justify-content: center;
  align-items: center;
}
.touch-left { grid-column: 1; grid-row: 2; }
.touch-right { grid-column: 3; grid-row: 2; }
.touch-down { grid-column: 2; grid-row: 3; }
.touch-up { grid-column: 2; grid-row: 1; }
.touch-actions {
  grid-template-columns: repeat(2, 52px);
  grid-template-rows: repeat(2, 52px);
  margin-bottom: 4px;
}
.touch-btn {
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 16px;
  color: #fffbe2;
  background: linear-gradient(180deg, rgba(43, 87, 82, .88), rgba(24, 54, 54, .9));
  box-shadow: 0 5px 12px rgba(18, 39, 39, .3), inset 0 1px 0 rgba(255,255,255,.24);
  font: 400 29px/1 "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  min-width: 44px;
  min-height: 40px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.touch-action { font-size: 19px; }
.touch-jump { background: linear-gradient(180deg, #e9ae55, #bd6937); font-size: 18px; }
.touch-btn.is-pressed, .touch-btn:active {
  transform: translateY(2px) scale(.96);
  filter: brightness(1.16);
  box-shadow: 0 2px 6px rgba(18, 39, 39, .25), inset 0 1px 0 rgba(255,255,255,.18);
}

@media (hover: none) and (pointer: coarse), (max-width: 720px) {
  #mobileControls { display: flex; }
  #game { max-height: 100dvh; }
  .overlay { padding: 16px 12px 170px; gap: 13px; }
  #startScreen h1 { font-size: clamp(38px, 12vw, 64px); letter-spacing: 5px; }
  #startScreen .help { font-size: 13px; line-height: 1.7; padding: 12px 14px; }
  #startScreen .help p:nth-child(3), #startScreen .help p:nth-child(4) { display: none; }
}

@media (orientation: landscape) and (max-height: 560px) and (hover: none) {
  #mobileControls { bottom: max(8px, env(safe-area-inset-bottom)); }
  .touch-pad { transform: scale(.78); transform-origin: left bottom; }
  .touch-actions { transform: scale(.78); transform-origin: right bottom; }
  .overlay { padding-bottom: 88px; }
  #startScreen .help { display: none; }
}

/* ===== 覆盖层 ===== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: #fff;
  text-align: center;
  z-index: 10;
  background:
    radial-gradient(ellipse 800px 300px at 50% 110%, rgba(90, 150, 100, 0.28), transparent 70%),
    linear-gradient(180deg, rgba(18, 24, 28, 0.88), rgba(12, 16, 20, 0.94));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.overlay.hidden { display: none; }

/* ===== 首页封面：沿用游戏内的白天森林视觉 ===== */
#startScreen {
  isolation: isolate;
  overflow: hidden;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#startScreen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(182, 224, 214, 0.06) 0%, rgba(255, 239, 192, 0.10) 54%, rgba(45, 91, 72, 0.28) 100%),
    url("../assets/forest-background-day-clean.png") center / cover no-repeat;
  transform: scale(1.03);
}
#startScreen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle 150px at 79% 20%, rgba(255, 212, 124, .88) 0 42%, rgba(255, 212, 124, .16) 43%, transparent 72%),
    linear-gradient(180deg, rgba(28, 94, 104, .08), rgba(255, 245, 205, .04) 47%, rgba(20, 56, 43, .45));
}
#startScreen h1 {
  color: #fff8d9;
  text-shadow:
    0 3px 0 rgba(43, 87, 77, .58),
    0 7px 0 rgba(43, 87, 77, .22),
    0 14px 30px rgba(28, 67, 58, .42);
  letter-spacing: 10px;
}
#startScreen > .sub:first-of-type {
  color: #fff8df;
  text-shadow: 0 2px 8px rgba(22, 72, 64, .55);
}
#startScreen .help {
  background: linear-gradient(180deg, rgba(34, 78, 78, .72), rgba(24, 59, 57, .76));
  border-color: rgba(255, 255, 255, .34);
  box-shadow:
    0 16px 40px rgba(23, 66, 56, .32),
    inset 0 1px 0 rgba(255, 255, 255, .25);
}
#startScreen button {
  padding-left: 64px;
  padding-right: 64px;
  background: linear-gradient(180deg, #f6c967 0%, #e99b3f 55%, #d97832 100%);
  box-shadow:
    0 9px 22px rgba(119, 73, 33, .34),
    inset 0 1px 0 rgba(255, 255, 255, .5);
}
#startScreen button:hover { filter: brightness(1.08) saturate(1.08); }

/* 大标题：快乐体只用 400，避免合成粗体糊字 */
.overlay h1 {
  font-weight: 400;
  font-size: clamp(44px, 8vw, 84px);
  letter-spacing: 8px;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.18),
    0 10px 28px rgba(0,0,0,0.35);
  animation: titleFloat 3.2s ease-in-out infinite;
}
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.overlay h1.bad { color: #ff8a80; }
.overlay h1.good { color: #a5e07a; }

.overlay .sub {
  font-size: clamp(15px, 2.1vw, 20px);
  color: rgba(255,255,255,0.82);
  max-width: 640px;
  line-height: 1.75;
  text-shadow: 0 1px 6px rgba(0,0,0,.4);
  padding: 0 20px;
}

/* 操作说明：炭灰半透明圆角卡片 */
.overlay .help {
  background: linear-gradient(180deg, rgba(55, 62, 68, 0.82), rgba(36, 40, 46, 0.88));
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 22px;
  padding: 18px 36px;
  font-size: clamp(14px, 1.8vw, 17px);
  line-height: 2.1;
  color: rgba(255,255,255,0.9);
  box-shadow:
    0 14px 36px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.1);
  max-width: min(640px, 92vw);
}
.overlay .help b {
  font-weight: 400;
  display: inline-block;
  color: #fff;
  background: rgba(255,255,255,0.16);
  padding: 1px 10px;
  border-radius: 7px;
  margin: 0 2px;
  font-size: 0.92em;
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: none;
}

.overlay .keyhint {
  font-size: clamp(13px, 1.6vw, 15px);
  opacity: .55;
  margin-top: -10px;
}

/* 柔和圆角按钮 */
.overlay button {
  margin-top: 4px;
  font-family: inherit;
  font-size: clamp(17px, 2.5vw, 24px);
  letter-spacing: 3px;
  padding: 14px 52px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #8fd47a 0%, #5fb85a 55%, #4a9a45 100%);
  box-shadow:
    0 8px 20px rgba(40, 100, 50, 0.35),
    inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.overlay button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}
.overlay button:active {
  transform: translateY(2px);
  box-shadow:
    0 3px 10px rgba(40, 100, 50, 0.3),
    inset 0 1px 0 rgba(255,255,255,.25);
}

@media (max-width: 720px) {
  .overlay .help { padding: 14px 18px; }
  .overlay button { padding: 12px 36px; letter-spacing: 2px; }
}
