* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #0A0C16; color: #fff;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

/* ---------- 全体 ---------- */
#app {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud-stage {
  position: absolute; left: 20px; top: 20px;
  font-size: 20px; font-weight: bold; letter-spacing: 2px; color: #00E5FF;
}
#hud-skills { position: absolute; left: 20px; bottom: 20px; }
.skill-buttons { display: flex; gap: 10px; }
.skill {
  pointer-events: auto;
  width: 60px; height: 60px; border-radius: 12px;
  font-size: 11px; font-weight: bold;
  color: #9E9E9E; border: 2px solid #9E9E9E; background: rgba(158, 158, 158, 0.25);
}
.skill.freeze.ready { color: #00E5FF; border-color: #00E5FF; background: rgba(0, 229, 255, 0.25); }
.skill.shield.ready { color: #FF9100; border-color: #FF9100; background: rgba(255, 145, 0, 0.25); }
.skill.shield.armed { color: #FF6E40; border-color: #FF6E40; background: rgba(255, 110, 64, 0.4); }
#gauge { width: 130px; height: 4px; margin-top: 6px; }
#gauge-fill { height: 100%; width: 0; background: #9E9E9E; }
#gauge-fill.ready { background: #fff; }
#hud-hint {
  position: absolute; left: 20px; bottom: 104px;
  background: rgba(255, 145, 0, 0.9); color: #000;
  font-size: 12px; font-weight: bold; padding: 6px 12px; border-radius: 16px;
}
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#flash.on { opacity: 1; }

/* ---------- 各画面 ---------- */
.screen {
  position: absolute; inset: 0; overflow-y: auto;
  display: flex; flex-direction: column; padding: 24px 16px;
}
.screen-inner {
  margin: auto; width: 100%; max-width: 340px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.screen-inner.wide { max-width: 440px; }
#title-screen { background: rgba(0, 0, 0, 0.87); }
#result-screen { background: rgba(0, 0, 0, 0.9); }
#gameover-screen { background: rgba(0, 0, 0, 0.85); }

.title { font-size: clamp(26px, 9vw, 38px); color: #00E5FF; letter-spacing: 2px; }
.credits { font-size: 17px; font-weight: bold; color: #FFD54F; margin-bottom: 4px; }
#upgrades { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.upgrade {
  width: 100%; height: 48px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.08); border: 1.5px solid rgba(255, 255, 255, 0.24);
  font-size: 14px; font-weight: 600;
}
.upgrade:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  width: 280px; height: 45px; border-radius: 25px; margin-top: 16px;
  background: #00E5FF; color: #000; font-size: 18px; font-weight: bold;
}
.btn-amber {
  width: 280px; min-height: 40px; border-radius: 8px; padding: 4px 8px;
  background: #FFA000; color: #000; font-size: 13px; font-weight: bold;
}
.btn-green {
  width: 260px; height: 45px; border-radius: 8px;
  background: #43A047; color: #fff; font-size: 15px; font-weight: bold;
}
.btn-ghost {
  width: 200px; height: 45px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.24); color: #fff; font-size: 18px; font-weight: 600;
}
.howto { font-size: 12px; color: rgba(255, 255, 255, 0.6); line-height: 1.7; margin-top: 4px; }

.clear-title { font-size: clamp(28px, 9vw, 38px); color: #FFD54F; letter-spacing: 2px; }
.score { font-size: 20px; font-weight: 600; }
.reward { font-size: 18px; font-weight: bold; color: #00E5FF; }
.stats { font-size: 12px; color: rgba(255, 255, 255, 0.7); line-height: 1.6; white-space: pre-line; }
#graph { width: 100%; height: 130px; display: block; }
.legend { font-size: 11px; }
.go-title { font-size: clamp(34px, 11vw, 46px); color: #FF1744; letter-spacing: 4px; margin-bottom: 40px; }

/* ---------- 広告 ---------- */
#ad-sp-inline {
  flex-shrink: 0; min-height: 50px; margin-top: 8px;
  display: flex; justify-content: center; align-items: flex-end; width: 100%;
}
#ad-sp-inline iframe, #ad-sp-inline img { display: block; vertical-align: bottom; }
.ad-side { position: fixed; top: 50%; transform: translateY(-50%); width: 160px; z-index: 5; }
.ad-side.left { left: 10px; }
.ad-side.right { right: 10px; }
body.has-side-ads #app { left: 180px; right: 180px; }
.ad-side iframe { display: block; width: 160px; height: 600px; border: 0; }
.ad-slot { margin-top: 28px; display: flex; justify-content: center; width: 100%; }
.ad-slot:empty { display: none; }
.ad-slot iframe { display: block; border: 0; }
