/* ==========================================================
   時間停止忍者：時空駆け - style.css
   ========================================================== */

:root {
  --color-bg-top: #0b1030;
  --color-bg-bottom: #1c0c33;
  --color-primary: #2fe6ff;
  --color-primary-2: #ff3fb0;
  --color-accent: #ffd23f;
  --color-danger: #ff3d63;
  --color-text: #eaf6ff;
  --color-text-muted: #8b93c4;
  --color-border: #34407a;
  --color-panel: #131a3d;
  --header-h: 56px;
  --score-h: 52px;
  --ad-h: 64px;
  --ad-gap-h: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--color-bg-top), var(--color-bg-bottom));
  color: var(--color-text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.7rem;
  background: rgba(19, 26, 61, 0.75);
  border-bottom: 2px solid var(--color-border);
  z-index: 20;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  flex: 0 0 auto;
}

.back-link:active {
  transform: translateY(2px);
}

.game-title {
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  margin: 0 0.4rem;
  color: var(--color-primary);
  text-shadow: 0 0 10px rgba(47, 230, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text);
  font-size: 1.02rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  transform: translateY(2px);
}

.icon-btn.is-muted {
  color: var(--color-text-muted);
  opacity: 0.65;
}

/* ---------- スコアバー ---------- */
.score-bar {
  height: var(--score-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  z-index: 15;
  flex-wrap: wrap;
}

.stat-box {
  background: rgba(19, 26, 61, 0.75);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.2rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-box__label {
  font-size: 0.64rem;
  font-weight: bold;
  color: var(--color-text-muted);
}

.stat-box__value {
  font-size: 1rem;
  font-weight: 900;
  color: var(--color-primary);
}

.stat-box__value small {
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 0.1rem;
}

.stat-box__value--accent {
  color: var(--color-accent);
}

/* ---------- 難易度チップ ---------- */
.difficulty-chip {
  position: absolute;
  /* 時空エネルギーバー（top:10px / 高さ16px）の真下に置いて重なりを避ける */
  top: 34px;
  left: 10px;
  z-index: 6;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 14, 36, 0.8);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  pointer-events: none;
}

.difficulty-chip[data-difficulty="easy"] {
  color: #6ef7c2;
  border-color: rgba(110, 247, 194, 0.55);
}

.difficulty-chip[data-difficulty="normal"] {
  color: var(--color-primary);
  border-color: rgba(47, 230, 255, 0.55);
}

.difficulty-chip[data-difficulty="hard"] {
  color: var(--color-primary-2);
  border-color: rgba(255, 63, 176, 0.6);
}

/* ---------- 到達バッジ ---------- */
.milestone-badge {
  position: absolute;
  top: 34px;
  right: 10px;
  z-index: 6;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 14, 36, 0.85);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.35);
  pointer-events: none;
}

.milestone-badge[hidden] {
  display: none;
}

.milestone-badge.is-new {
  /* 右端に置いているので、拡大は内側（左）へ向かわせて画面外にはみ出させない */
  transform-origin: right center;
  animation: milestone-pop 0.6s ease-out;
}

@keyframes milestone-pop {
  0% { transform: scale(0.5); opacity: 0; }
  45% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- ゲームステージ ---------- */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background: radial-gradient(ellipse at 50% 30%, #1a2050 0%, #0b0e24 70%);
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- 時空エネルギーゲージ ---------- */
.energy-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(80%, 320px);
  height: 16px;
  z-index: 6;
  background: rgba(11, 14, 36, 0.75);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(47, 230, 255, 0.25);
}

.energy-bar__fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-primary-2), var(--color-primary));
  box-shadow: 0 0 10px rgba(47, 230, 255, 0.8);
  transition: width 0.1s linear;
}

.energy-bar.is-low .energy-bar__fill {
  background: linear-gradient(90deg, #ff7a1a, var(--color-danger));
  box-shadow: 0 0 10px rgba(255, 61, 99, 0.9);
  animation: energy-low-pulse 0.6s ease-in-out infinite;
}

@keyframes energy-low-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.energy-bar__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.74rem;
  font-weight: bold;
  color: var(--color-text);
  background: rgba(19, 26, 61, 0.85);
  border: 1px dashed var(--color-primary);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.control-hint.is-hidden {
  opacity: 0;
}

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 20, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay__box {
  text-align: center;
  padding: 1.8rem 2rem;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 26px;
  max-width: 85%;
  box-shadow: 0 0 40px rgba(47, 230, 255, 0.15), 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay__box--wide {
  max-width: min(92%, 460px);
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay__title {
  font-size: 1.4rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
  color: var(--color-primary);
  text-shadow: 0 0 12px rgba(47, 230, 255, 0.5);
}

.overlay__desc {
  color: var(--color-text-muted);
  margin: 0 0 1.3rem;
  font-size: 1rem;
  font-weight: bold;
}

.overlay__milestone {
  margin: -0.9rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--color-accent);
  text-shadow: 0 0 14px rgba(255, 210, 63, 0.55);
}

.overlay__milestone[hidden] {
  display: none;
}

.overlay__sub {
  color: var(--color-text-muted);
  margin: 0 0 1.3rem;
  font-size: 0.8rem;
  font-weight: bold;
}

/* ---------- 難易度選択 ---------- */
.difficulty-select {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.55rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: rgba(11, 14, 36, 0.6);
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.diff-btn__name {
  font-size: 0.92rem;
  font-weight: 900;
}

.diff-btn__desc {
  font-size: 0.72rem;
  line-height: 1.4;
  opacity: 0.85;
}

.diff-btn:active {
  transform: translateY(2px);
}

.diff-btn.is-selected {
  color: var(--color-text);
  border-color: var(--color-primary);
  background: linear-gradient(135deg, rgba(255, 63, 176, 0.22), rgba(47, 230, 255, 0.22));
  box-shadow: 0 0 16px rgba(47, 230, 255, 0.28);
}

.diff-btn.is-selected .diff-btn__name {
  color: var(--color-primary);
}

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary-2), var(--color-primary));
  color: #0b0e24;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #7a1a5c, 0 0 20px rgba(255, 63, 176, 0.4);
}

.overlay__btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #7a1a5c;
}

/* ---------- ガイド画面 ---------- */
.guide-section {
  text-align: left;
  margin: 1rem 0;
}

.guide-section__title {
  font-size: 0.92rem;
  color: var(--color-primary);
  margin: 0 0 0.4rem;
}

.guide-section__text {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.6;
}

.guide-section__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.7;
}

.guide-section__list li {
  margin-bottom: 0.3rem;
}

/* ---------- 広告スペース ---------- */
.ad-gap {
  flex: 0 0 var(--ad-gap-h);
  background: var(--color-bg-bottom);
}

.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px dashed var(--color-border);
  background: rgba(19, 26, 61, 0.6);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  z-index: 20;
  overflow: hidden;
}

@media (max-height: 640px) {
  .ad-slot {
    --ad-h: 44px;
    font-size: 0.65rem;
  }
  .ad-gap {
    --ad-gap-h: 10px;
  }
}

@media (max-width: 360px) {
  .game-title {
    font-size: 0.74rem;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}
