/* Itsy Bitsy Spider — styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #14101c;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  position: fixed; inset: 0;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* soft vignette over the world */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 55%, rgba(8,4,16,.45) 100%);
}
/* storm darkening, driven from JS via opacity */
#stormTint {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(180deg, rgba(10,14,40,.85) 0%, rgba(10,14,40,.35) 45%, rgba(10,14,40,.15) 100%);
  opacity: 0; transition: opacity .35s linear;
}
#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: #cfe6ff; opacity: 0;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; inset: 0; pointer-events: none; z-index: 10;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
           10px calc(12px + env(safe-area-inset-left));
  display: flex; align-items: flex-start; gap: 10px;
}
#staminaWrap {
  display: flex; align-items: center; gap: 6px;
  background: rgba(10,8,18,.55); border-radius: 12px; padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.12);
}
.hud-ico { font-size: 16px; filter: drop-shadow(0 1px 1px #000); }
#staminaTrack {
  width: min(34vw, 190px); height: 14px; border-radius: 8px;
  background: rgba(0,0,0,.55); overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
}
#staminaBar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #57d977, #b7e95a);
  border-radius: 8px;
  transition: width .12s linear;
}
#staminaWrap.low #staminaBar { background: linear-gradient(90deg, #e04b3a, #f3a13c); }
#staminaWrap.low { animation: pulse .5s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 rgba(255,60,40,0);} to { box-shadow: 0 0 14px rgba(255,60,40,.9);} }

#scoreWrap {
  margin-left: auto; text-align: right;
  background: rgba(10,8,18,.55); border-radius: 12px; padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.12); color: #fff;
}
#score { font-size: clamp(18px, 4.5vw, 26px); font-weight: 800; letter-spacing: 1px; text-shadow: 0 2px 3px #000; }
#best { font-size: clamp(10px, 2.6vw, 12px); opacity: .75; letter-spacing: 1px; }

#forecast {
  display: flex; align-items: center; gap: 6px;
  background: rgba(10,8,18,.55); border-radius: 12px; padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.12);
}
#cloudIcon { font-size: 16px; filter: saturate(0) brightness(2.4); }
#forecast.warn #cloudIcon { filter: none; animation: shakeIcon .3s infinite; }
@keyframes shakeIcon { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-2px)} 75%{transform:translateX(2px)} }
#forecastTrack { width: min(20vw, 90px); height: 10px; border-radius: 6px; background: rgba(0,0,0,.55); overflow: hidden; border: 1px solid rgba(255,255,255,.18); }
#forecastFill { height: 100%; width: 0%; background: linear-gradient(90deg, #6db6ff, #3d6fe0); }
#forecast.warn #forecastFill { background: #ff5340; }

#muteBtn {
  pointer-events: auto; cursor: pointer;
  width: 46px; height: 46px; border-radius: 12px;
  font-size: 20px; line-height: 1;
  background: rgba(10,8,18,.55); color: #fff;
  border: 1px solid rgba(255,255,255,.2);
}
#muteBtn:active { transform: scale(.92); }

/* ---------- banner / toast ---------- */
#banner {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 11; pointer-events: none;
  background: rgba(160,20,20,.85); color: #fff; font-weight: 800;
  padding: 10px 18px; border-radius: 14px; border: 2px solid #ff8a70;
  font-size: clamp(13px, 3.6vw, 19px); letter-spacing: 1px; text-align: center;
  animation: bannerPulse .35s infinite alternate;
  max-width: 92vw;
}
@keyframes bannerPulse { from { transform: translateX(-50%) scale(1);} to { transform: translateX(-50%) scale(1.05);} }

#toast {
  position: fixed;   bottom: calc(186px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 11; pointer-events: none;
  background: rgba(12,10,24,.8); color: #ffe9a8;
  padding: 8px 16px; border-radius: 12px; border: 1px solid rgba(255,230,150,.35);
  font-size: clamp(13px, 3.4vw, 16px); text-align: center; max-width: 88vw;
}

/* ---------- joystick ---------- */
#joystick {
  position: fixed; z-index: 12;
  left: calc(22px + env(safe-area-inset-left));
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 132px; height: 132px;
}
#joyBase {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(20,16,34,.45);
  border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 6px rgba(0,0,0,.15), inset 0 0 24px rgba(0,0,0,.4);
}
#joyKnob {
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #8f7bd8, #4a3a80 70%);
  border: 2px solid rgba(255,255,255,.55);
  box-shadow: 0 3px 8px rgba(0,0,0,.5);
}
#kbHint {
  position: fixed; z-index: 9; right: 14px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  color: rgba(255,255,255,.55); font-size: 12px; letter-spacing: .5px;
  background: rgba(10,8,18,.4); padding: 5px 10px; border-radius: 8px;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,5,16,.72);
  backdrop-filter: blur(3px);
  padding: 16px;
}
.panel {
  text-align: center; color: #f2ecff;
  background: linear-gradient(160deg, #241c38, #171126);
  border: 2px solid rgba(160,130,255,.35);
  border-radius: 22px; padding: clamp(18px, 4vw, 34px) clamp(18px, 5vw, 44px);
  box-shadow: 0 18px 60px rgba(0,0,0,.6);
  max-width: min(92vw, 460px);
  max-height: 92vh; overflow-y: auto;
}
.panel h1 {
  font-size: clamp(26px, 7vw, 40px); line-height: 1.1; letter-spacing: 2px;
  color: #ffd76e; text-shadow: 0 3px 0 #7a4b12, 0 6px 14px rgba(0,0,0,.6);
  margin-bottom: 8px;
}
.tagline { opacity: .85; margin-bottom: 14px; font-size: clamp(13px, 3.6vw, 16px); }
.howto { list-style: none; text-align: left; margin: 0 auto 18px; max-width: 330px; }
.howto li { margin: 7px 0; font-size: clamp(13px, 3.6vw, 15px); line-height: 1.35; }
.bigbtn {
  pointer-events: auto; cursor: pointer;
  font-family: inherit; font-weight: 800; letter-spacing: 2px;
  font-size: clamp(16px, 4.5vw, 21px); color: #2a1608;
  background: linear-gradient(180deg, #ffd76e, #f5a83c);
  border: none; border-radius: 16px; padding: 14px 34px;
  box-shadow: 0 5px 0 #a86a17, 0 10px 22px rgba(0,0,0,.5);
  min-width: min(70vw, 260px); min-height: 52px;
}
.bigbtn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a86a17, 0 6px 14px rgba(0,0,0,.5); }
.best-line { margin-top: 12px; font-size: 14px; opacity: .85; letter-spacing: 1px; }
.best-line.dim { opacity: .5; font-size: 12px; }
#finalScore { font-size: clamp(38px, 11vw, 58px); font-weight: 800; color: #ffd76e; text-shadow: 0 3px 0 #7a4b12; margin: 6px 0; }
#newBest { color: #7dffa8; font-weight: 800; font-size: 18px; letter-spacing: 2px; margin-bottom: 4px; animation: bannerPulse2 .4s infinite alternate; }
@keyframes bannerPulse2 { from { transform: scale(1);} to { transform: scale(1.08);} }

.hidden { display: none !important; }
