* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #15151d;
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #f0ead9;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}

#staminaWrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(38vw, 220px);
}
#staminaIcon { font-size: 16px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
#staminaBar {
  flex: 1;
  height: 16px;
  background: rgba(0,0,0,.45);
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 10px;
  overflow: hidden;
}
#staminaFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #9fe65f, #5cb82e);
  border-radius: 7px;
  transition: width .12s linear;
}
#staminaFill.mid { background: linear-gradient(180deg, #ffd75e, #e6a32e); }
#staminaFill.low { background: linear-gradient(180deg, #ff7a5e, #d8442e); animation: pulse .5s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

#score {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0,0,0,.7);
  letter-spacing: .5px;
}

#hudRight { display: flex; align-items: center; gap: 10px; }
#best {
  font-size: 13px;
  opacity: .85;
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
}
#muteBtn {
  pointer-events: auto;
  width: 44px; height: 44px;
  font-size: 20px;
  background: rgba(0,0,0,.45);
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  line-height: 1;
}
#muteBtn:active { transform: scale(.93); }

/* ---------- Banner ---------- */
#banner {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 14px;
  font-size: clamp(16px, 4.5vw, 22px);
  font-weight: 800;
  white-space: nowrap;
  z-index: 6;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
#banner.warn {
  background: rgba(160, 30, 30, .85);
  border: 2px solid #ffb3a0;
  animation: bannerFlash .4s infinite alternate;
}
@keyframes bannerFlash { from { box-shadow: 0 0 0 0 rgba(255,80,60,.7); } to { box-shadow: 0 0 22px 4px rgba(255,80,60,.7); } }
#banner.info {
  background: rgba(40, 90, 160, .85);
  border: 2px solid #a8d4ff;
}
#banner.gold {
  background: rgba(170, 130, 20, .9);
  border: 2px solid #ffe9a0;
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 22, .55);
  z-index: 10;
  padding: 16px;
}
.panel {
  background: rgba(28, 26, 38, .92);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 22px;
  padding: 26px 26px 20px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 50px rgba(0,0,0,.6);
}
.bigSpider { font-size: 54px; line-height: 1; margin-bottom: 6px; }
h1 {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 900;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.tag { font-size: 14px; opacity: .85; margin-bottom: 16px; }
.howto {
  list-style: none;
  text-align: left;
  margin: 0 auto 18px;
  max-width: 330px;
  display: grid;
  gap: 9px;
  font-size: 14px;
}
.howto .ic { display: inline-block; width: 26px; }
.bigbtn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 19px;
  font-weight: 900;
  font-family: inherit;
  letter-spacing: 1px;
  color: #1c1408;
  background: linear-gradient(180deg, #ffd75e, #f0a830);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 #a06a10, 0 8px 18px rgba(0,0,0,.4);
}
.bigbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a06a10; }
.hint { font-size: 12px; opacity: .6; margin-top: 12px; }

#overScore {
  font-size: 18px;
  margin-bottom: 18px;
  line-height: 1.6;
}
#overScore .big { font-size: 34px; font-weight: 900; display: block; }
#overScore .newbest {
  color: #ffd75e;
  font-weight: 900;
  animation: pulse .5s infinite alternate;
}
