/* ---------------------------------------------------------------
   スライム退治。ページの末尾まで読んだ人へのおまけ。動きは slime-hunt.js。

   本文のデザイン規則をそのまま使う。枠線は押せるもの、塗りは押せないもの。
   色・間隔・文字の大きさは style.css のスケールから選ぶ。
   --------------------------------------------------------------- */

/* --- 末尾のステージ。ページの一番下が地面で、草の上にキャラが立っていて、触ると始まる --- */

.sh-stage { margin-top: var(--s4); background: var(--paper); }
.sh-stage__lead {
  margin: 0;
  padding: 0 var(--gutter) var(--s2);
  background: var(--paper);
  text-align: center;
  font-size: var(--t-meta);
  color: var(--muted);
}
.sh-stage__start {
  position: relative;
  display: block;
  width: 100%;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  border: 0;
  /* 端末下端の safe-area の帯だけ土の色にして地面に見せる。全体を土にすると、
     高解像度の端末で canvas の上端に小数ピクセルの隙間が出て、線に見える */
  background: linear-gradient(#6b4a2e, #6b4a2e) bottom / 100% env(safe-area-inset-bottom, 0px) no-repeat, var(--paper);
  cursor: pointer;
  font: inherit;
}
/* 遊んでいる間はステージを丸ごと隠す。絵の更新が止まった最後の 1 コマや案内文が、闘技場の背景に残らないように */
html.sh-playing .sh-stage__lead,
html.sh-playing .sh-stage__hint,
html.sh-playing .sh-stage__scene { visibility: hidden; }
.sh-stage__start:focus-visible { outline: 2px solid var(--route); outline-offset: -2px; }
/* 高さは slime-hunt.js が画面高から決める。これは読み込み直後の仮の値 */
.sh-stage__scene { display: block; width: 100%; height: 280px; image-rendering: pixelated; }
.sh-stage__hint {
  position: absolute;
  left: 50%;
  top: var(--s2);
  transform: translateX(-50%);
  padding: 2px 10px;
  background: var(--fill);
  color: var(--ink-2);
  font-size: var(--t-label);
  white-space: nowrap;
}

/* --- 遊んでいる間 --- */

/* ページのスクロールはゲームが握る。指やホイールでは動かさない */
html.sh-playing { overflow: hidden; }

/* canvas は inset だけだと固有サイズのまま置かれるので、画面いっぱいに広げる */
.sh-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  touch-action: none;
  cursor: pointer;
}
.sh-ui {
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
  font-family: var(--sans);
  font-size: var(--t-meta);
  line-height: 1.6;
}
.sh-ui > * { pointer-events: auto; }

/* 体力・燃料・ウェーブ・得点・ベスト・やめる。掲載情報に被らないよう、地面の上に置く。
   --sh-ground は地面の高さで、slime-hunt.js が入れる */
.sh-hud {
  position: absolute;
  bottom: calc(var(--sh-ground, 180px) - 48px);
  right: var(--gutter);
  left: var(--gutter);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s1);
}
.sh-hearts { display: inline-flex; gap: 3px; margin-right: auto; }
.sh-heart { display: inline-flex; color: #ff3b3b; }
.sh-heart.is-lost { color: var(--rule); }
.sh-heart svg { display: block; fill: currentColor; }
.sh-stat {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
  background: var(--fill);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.sh-quit,
.sh-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.sh-quit:hover,
.sh-retry:hover { border-color: var(--ink); color: var(--ink); }
.sh-retry { border-color: var(--route); color: var(--route); min-height: 48px; padding: 0 var(--s3); }
.sh-retry:hover { background: var(--route); color: var(--route-ink); }

/* ウェーブの表示。箱は付けず、文字だけを短く出して消す。
   切り替わりはセクションが動くことで伝わるので、文字は添えるだけにする。
   背景の上でも読めるよう、紙色の縁取りだけ付ける */
.sh-banner {
  position: absolute;
  left: 50%;
  top: 22%;
  margin: 0;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -50%) translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.sh-banner.is-shown { opacity: 1; transform: translate(-50%, -50%); }
.sh-banner__wave {
  display: block;
  font-family: var(--serif);
  font-size: var(--t-lead);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
  text-shadow: 0 0 2px var(--paper), 0 0 6px var(--paper), 0 0 12px var(--paper);
}
.sh-banner__note {
  display: block;
  margin-top: var(--s1);
  color: var(--ink-2);
  white-space: nowrap;
  text-shadow: 0 0 2px var(--paper), 0 0 6px var(--paper);
}
/* HUD の WAVE はウェーブが変わる瞬間に一度だけ跳ねる */
.sh-stat.is-bump { animation: sh-bump 0.5s ease-out; }
@keyframes sh-bump {
  0% { transform: translateY(0); background: var(--route); color: var(--route-ink); }
  30% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .sh-stat.is-bump { animation: none; } }

/* スマホの操作盤。画面の中央下にスティック。ジャンプは上に倒すか、画面をタップ */
.sh-pad {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--s3) + env(safe-area-inset-bottom, 0px));
  justify-content: center;
}
.sh-ui.is-touch .sh-pad { display: flex; }
.sh-stick {
  position: relative;
  width: 96px;
  height: 96px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: rgba(255, 253, 246, 0.75);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sh-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--fill);
  pointer-events: none;
}
/* 狭い画面では HUD を 1 行に収める */
@media (max-width: 720px) {
  .sh-hud { bottom: calc(var(--sh-ground, 180px) - 44px); gap: 4px; }
  .sh-stat, .sh-hud .sh-quit { min-height: 32px; padding: 0 8px; font-size: var(--t-label); }
}

/* やられたとき。得点・ベスト・もう一回 */
.sh-over {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  min-width: min(320px, calc(100vw - 2 * var(--gutter)));
  padding: var(--s4);
  border: 1px solid var(--rule);
  background: var(--card);
  text-align: center;
}
.sh-over__title { margin: 0; font-size: var(--t-sub); font-weight: 700; color: var(--ink); }
.sh-over__score { margin: var(--s2) 0 0; font-size: 26px; font-weight: 700; color: var(--route); line-height: 1.4; font-variant-numeric: tabular-nums; }
.sh-over__best { margin: 2px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.sh-over__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s3); }

/* --- 撃たれた側 --- */

/* 当たった瞬間。レイアウトを動かさないよう outline で光らせる */
.sh-hit { outline: 2px solid #ff3b3b; outline-offset: -1px; }
/* 壊れたもの。場所は残して見えなくする。やめたときに戻す */
.sh-gone { visibility: hidden !important; }
