* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #FFE9D2;
  color: #3A2415;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.stage {
  position: fixed; inset: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #FFD9A8 0%, #FFC98A 38%, #FFB877 62%, #FF9F5A 100%);
}
.sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255,255,255,.85) 0%, rgba(255,255,255,0) 60%),
    radial-gradient(60% 40% at 85% 12%, rgba(255,255,255,.55) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
}
.cloud {
  position: absolute;
  background: rgba(255,255,255,.72);
  border-radius: 999px;
  filter: blur(1px);
  pointer-events: none;
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: inherit; border-radius: 999px;
}
.cloud::before { width: 60%; height: 150%; left: 12%; top: -70%; }
.cloud::after { width: 45%; height: 120%; right: 10%; top: -50%; }
.c1 { width: 96px; height: 34px; left: 6%; top: 12%; animation: drift 26s linear infinite; }
.c2 { width: 74px; height: 26px; left: 58%; top: 22%; animation: drift 34s linear infinite reverse; }
.c3 { width: 120px; height: 40px; left: 30%; top: 5%; opacity: .8; animation: drift 44s linear infinite; }
@keyframes drift {
  0% { transform: translateX(-14px); }
  50% { transform: translateX(14px); }
  100% { transform: translateX(-14px); }
}
.hills {
  position: absolute; left: -10%; right: -10%; bottom: 0; height: 46%;
  background:
    radial-gradient(70% 100% at 18% 100%, #8FD06A 0%, #6FBE55 60%, #5CAB48 100%),
    radial-gradient(80% 100% at 82% 100%, #7FCB60 0%, #63B44C 60%, #55A342 100%);
  background-repeat: no-repeat;
  background-size: 62% 88%, 66% 100%;
  background-position: 0% 100%, 100% 100%;
  pointer-events: none;
}
.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 22%;
  background: linear-gradient(180deg, #6FBE55 0%, #57A845 40%, #3F8A34 100%);
  border-top: 3px solid rgba(255,255,255,.35);
  pointer-events: none;
}
.ground::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.10) 0 2px, transparent 2px 26px);
  opacity: .7;
}

/* HUD */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; pointer-events: none; z-index: 5;
}
.hud-left { display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px 0 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 6px 14px rgba(160, 84, 20, .22);
  font-size: 15px; font-weight: 800; color: #6B3A12;
  letter-spacing: .2px;
}
.chip .mp-icon { width: 18px; height: 18px; color: #FF8A3D; }
.chip-score { color: #E2621B; }
.chip-level { font-size: 13px; font-weight: 700; color: #8A5A2B; height: 28px; padding: 0 12px; }
.chip-time { color: #C2410C; }
.chip-time.warn { background: #FFE1D6; border-color: #FFB59A; color: #D92D20; animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.progress-wrap {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 56px);
  left: 16px; right: 16px; z-index: 5; pointer-events: none;
}
.progress-bar {
  height: 10px; border-radius: 999px;
  background: rgba(255,255,255,.55);
  border: 2px solid rgba(255,255,255,.8);
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(160,84,20,.16);
}
.progress-fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFB347 0%, #FF8A3D 55%, #F26419 100%);
  transition: width .28s ease;
}
.progress-text {
  margin-top: 5px; text-align: center;
  font-size: 12px; font-weight: 700; color: #8A5A2B;
  text-shadow: 0 1px 0 rgba(255,255,255,.7);
}

canvas#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 3;
}

.hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  padding: 8px 16px; border-radius: 999px;
  background: rgba(58, 36, 21, .72);
  color: #FFF3E4; font-size: 13px; font-weight: 600;
  white-space: nowrap; z-index: 6; pointer-events: none;
  transition: opacity .3s ease;
}
.hint.hide { opacity: 0; }

/* Overlay */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(80% 60% at 50% 40%, rgba(58,36,21,.42) 0%, rgba(58,36,21,.72) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity .25s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.panel {
  width: 100%; max-width: 340px;
  padding: 26px 22px 22px;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF3E2 100%);
  border: 3px solid #FFFFFF;
  box-shadow: 0 22px 44px rgba(90, 44, 8, .34), inset 0 -6px 0 rgba(255, 190, 130, .35);
  text-align: center;
  animation: pop .32s cubic-bezier(.2,1.4,.5,1) both;
}
@keyframes pop { from { transform: scale(.86) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.panel-badge {
  display: inline-block; padding: 5px 14px; border-radius: 999px;
  background: #FFE7D2; color: #D2600F;
  font-size: 12px; font-weight: 800; letter-spacing: .5px;
}
.panel-title {
  margin: 12px 0 8px; font-size: 24px; font-weight: 900; color: #4A2A12;
  letter-spacing: -.5px;
}
.panel-desc {
  margin: 0; font-size: 14px; line-height: 1.65; color: #8A6A4C;
}
.panel-stats {
  display: flex; justify-content: center; gap: 10px; margin: 16px 0 4px;
  flex-wrap: wrap;
}
.stat {
  min-width: 84px; padding: 10px 12px; border-radius: 16px;
  background: #FFF6EA; border: 1.5px solid #FFE0C2;
}
.stat b { display: block; font-size: 20px; font-weight: 900; color: #E2621B; line-height: 1.2; }
.stat span { font-size: 11px; color: #A98A6C; font-weight: 700; }
.btn-primary {
  margin-top: 18px; width: 100%; height: 52px;
  border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #FFA45C 0%, #FF8A3D 45%, #F26A1B 100%);
  color: #FFF; font-size: 17px; font-weight: 900; letter-spacing: 1px;
  box-shadow: 0 10px 20px rgba(242, 106, 27, .38), inset 0 -4px 0 rgba(180, 70, 10, .35);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:active {
  transform: translateY(3px) scale(.985);
  box-shadow: 0 4px 10px rgba(242, 106, 27, .32), inset 0 -2px 0 rgba(180, 70, 10, .35);
}
