* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #16211a;
  font-family: "Comic Sans MS", "Chalkboard SE", sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

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

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#stage-chip {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  background: rgba(20, 28, 45, .72);
  color: #ffe9a8;
  padding: 7px 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: bold;
  border: 2px solid rgba(255, 233, 168, .35);
}

#objective {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(93, 166, 65, .92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: bold;
  border: 3px solid rgba(255, 255, 255, .55);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
  max-width: 72vw;
  text-align: center;
  z-index: 6;
}

#bossbar {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 28, 45, .8);
  border: 3px solid rgba(255, 233, 168, .4);
  border-radius: 18px;
  padding: 10px 22px;
  text-align: center;
  min-width: 260px;
}
#boss-name { display: block; color: #fff; font-size: 17px; letter-spacing: 1px; }
#boss-hp { display: block; font-size: 22px; letter-spacing: 3px; margin-top: 2px; }

#banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(26px, 6vw, 52px);
  font-weight: bold;
  color: #ffe9a8;
  text-shadow: 0 4px 0 rgba(0,0,0,.5), 0 0 24px rgba(255,220,120,.4);
  white-space: nowrap;
}
@keyframes bannerPop {
  0% { opacity: 0; transform: translateX(-50%) scale(.4); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.12); }
  20% { transform: translateX(-50%) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.04); }
}

#toast {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 233, 168, .95);
  color: #22304e;
  font-weight: bold;
  font-size: 17px;
  padding: 9px 18px;
  border-radius: 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}

#hint {
  position: absolute;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(20, 28, 45, .72);
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 15px;
  max-width: 86vw;
  text-align: center;
}

#use-hint {
  position: absolute;
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: #5da641;
  padding: 8px 20px;
  border-radius: 16px;
  font-size: 19px;
  font-weight: bold;
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
}

#controls-chip {
  position: absolute;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: calc(12px + env(safe-area-inset-left));
  color: rgba(255,255,255,.75);
  font-size: 12px;
  background: rgba(0,0,0,.35);
  padding: 6px 12px;
  border-radius: 10px;
}

#crawl-chip {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(34, 48, 78, .85);
  border: 2px solid rgba(255, 233, 168, .4);
  padding: 7px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: bold;
}

#mute {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 30;
  font-size: 22px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  background: rgba(20,28,45,.72);
  color: #fff;
  cursor: pointer;
}

/* ---------- touch controls ---------- */

#touch-ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#stick {
  position: absolute;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(255,255,255,.09);
  border: 2px solid rgba(255,255,255,.25);
  left: 64px;
  top: calc(50vh - 54px);
  transform: translate(-50%, -50%);
  opacity: .55;
  transition: opacity .15s;
}
#stick.active { opacity: .95; }
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,233,168,.85);
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 0 rgba(0,0,0,.3);
}

.tbtn {
  position: absolute;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4);
  background: rgba(34,48,78,.82);
  color: #fff;
  font-size: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
}
.tbtn span { font-size: 10px; font-weight: bold; letter-spacing: 1px; margin-top: 1px; }
.tbtn:active { background: rgba(93,166,65,.9); }

#btn-jump {
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(34px + env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  font-size: 32px;
}
#btn-use {
  right: calc(126px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
}
#btn-shoot {
  right: calc(118px + env(safe-area-inset-right));
  bottom: calc(126px + env(safe-area-inset-bottom));
  background: rgba(93,140,65,.85);
  width: 84px;
  height: 84px;
}

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: linear-gradient(160deg, #1d3a2a, #16211a);
  color: #e8ecf4;
  overflow-y: auto;
}

#title h1, #end h1 {
  font-size: clamp(34px, 8vw, 64px);
  color: #ffe9a8;
  text-shadow: 0 4px 0 rgba(0,0,0,.45);
  text-align: center;
  line-height: 1.1;
}

#title-art { width: 150px; height: 200px; }

.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.screen button {
  font-family: inherit;
  border: 3px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 16px;
  padding: 10px 26px;
  font-size: 17px;
  cursor: pointer;
  min-width: 220px;
}
.screen button.big {
  font-size: 22px;
  font-weight: bold;
  padding: 14px 34px;
  background: rgba(255,233,168,.16);
  border-color: #ffe9a8;
}
.screen button:active { transform: translateY(2px); }

.note { color: #7d8aa5; font-size: 14px; }

#howto h2 { color: #ffe9a8; font-size: 30px; }
.cards { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 760px; }
.card {
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 18px 16px;
  width: 164px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.card .big-emoji { font-size: 44px; }
.card b { color: #ffe9a8; }
.card span { font-size: 13px; color: #b7c2cd; }

#end-stats {
  background: rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 18px 26px;
  font-size: 18px;
  line-height: 1.75;
  text-align: center;
  color: #dfe6ee;
}
#end-stats b { color: #ffe9a8; }

.hidden { display: none !important; }

/* friendly rotate hint — never blocks play */
#rotate-hint {
  display: none;
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(255, 233, 168, .95);
  color: #22304e;
  font-weight: bold;
  font-size: 15px;
  padding: 9px 18px;
  border-radius: 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
  pointer-events: none;
}
@media (orientation: portrait) {
  #rotate-hint { display: block; }
}
