/* Spider Run — mobile-first styles */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1021;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app, #stage {
  position: absolute;
  inset: 0;
}

#stage {
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #12152b;
  touch-action: none;
}

/* HUD */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 0;
  pointer-events: none;
  z-index: 5;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 8px; }
.hud-row { display: flex; gap: 8px; }
.hud-chip {
  background: rgba(13, 16, 33, 0.72);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.hud-chip.hearts { font-size: 13px; }
#hud-score { color: #ffd166; }

/* Touch pad: invisible region = left half bottom for joystick */
#touchpad {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
}
#joy {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
#joy-base {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
}
#joy-stick {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* Icon buttons */
.icon-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 14px;
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(13,16,33,0.72);
  color: #fff;
  font-size: 20px;
  z-index: 6;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(0.94); }

/* Screens */
.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 22, 0.82);
  backdrop-filter: blur(4px);
  z-index: 10;
  padding: 20px;
  animation: fadein 0.22s ease;
}
.screen.hidden { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.panel {
  text-align: center;
  max-width: 460px;
  width: 100%;
  background: linear-gradient(180deg, rgba(30, 34, 63, 0.95), rgba(18, 21, 43, 0.95));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}

.title-big {
  font-size: clamp(30px, 7vw, 46px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #ff6b9d, #c084fc, #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}
.title-med {
  font-size: clamp(24px, 5.5vw, 34px);
  font-weight: 900;
  margin-bottom: 6px;
}
.subtitle {
  font-size: clamp(14px, 3.8vw, 17px);
  color: #c9cede;
  margin-bottom: 16px;
}
.howto {
  list-style: none;
  text-align: left;
  margin: 0 auto 20px;
  max-width: 330px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: clamp(13px, 3.6vw, 16px);
  color: #dfe4f0;
}
.btn {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 800;
  padding: 16px 34px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  color: #14122b;
  background: linear-gradient(180deg, #ffd166, #ffb703);
  box-shadow: 0 8px 22px rgba(255, 183, 3, 0.35), inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.95); }
.best {
  margin-top: 16px;
  font-size: 14px;
  color: #8f96b5;
  min-height: 18px;
}
