/* ═══════════════════════════════════════
   2-7 おばけやしき — Mobile-First CSS
   ═══════════════════════════════════════ */

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

:root {
  --bg: #101014;
  --bg-soft: #191923;
  --card: rgba(255, 255, 255, 0.92);
  --text: #f7f2ea;
  --text-dark: #1b1b20;
  --muted: #bdb6c9;
  --accent: #e9d47a;
  --danger: #b8172d;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.26);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(120, 74, 160, 0.26), transparent 36rem),
    linear-gradient(180deg, #171720 0%, #0d0d11 100%);
  color: var(--text);
  animation: none;
  /* 下部ナビの分だけ余白 */
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

a { color: inherit; }

/* ─────────────────────────────────────
   ヘッダー（モバイル: ロゴのみ上部）
   ───────────────────────────────────── */
.site-header {
  width: calc(100% - 32px);
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-logo {
  text-decoration: none;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

/* ─────────────────────────────────────
   下部ナビゲーション（モバイルデフォルト）
   ───────────────────────────────────── */
.site-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(18, 18, 26, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.site-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 4px;
  transition: color 160ms ease;
  /* 最小タッチ 44px */
  min-height: 44px;
}

.site-nav a:active,
.site-nav a.is-active {
  color: var(--accent);
}

.nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* ─────────────────────────────────────
   ホーム
   ───────────────────────────────────── */
.home-layout {
  min-height: calc(100vh - 56px - var(--nav-h));
  min-height: calc(100dvh - 56px - var(--nav-h));
  display: grid;
  place-items: center;
  padding: 16px;
}

.hero {
  width: 100%;
  max-width: 820px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 12vw, 7rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
}

h2 {
  margin: 0 0 12px;
}

.haunted-house-placeholder {
  width: min(280px, 65vw);
  height: min(200px, 44vw);
  margin: 28px auto 24px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(0, 0, 0, 0.18);
  box-shadow: var(--shadow);
  animation: floatHouse 3.6s ease-in-out infinite;
}

.haunted-house-placeholder span {
  font-size: 5rem;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
}

.home-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
}

.menu-button {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 15px 20px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-dark);
  text-decoration: none;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.menu-button:active {
  transform: scale(0.97);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.lost-message {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0 0 20px;
}

/* ─────────────────────────────────────
   ページ共通レイアウト
   ───────────────────────────────────── */
.page-layout {
  width: calc(100% - 24px);
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 0 32px;
}

.page-title {
  margin-bottom: 16px;
}

.page-title h1 {
  font-size: clamp(2.2rem, 9vw, 5rem);
}

/* ─────────────────────────────────────
   カード
   ───────────────────────────────────── */
.content-card,
.game-card {
  background: var(--card);
  color: var(--text-dark);
  border-radius: 20px;
  padding: clamp(18px, 5vw, 36px);
  margin: 14px 0;
  box-shadow: var(--shadow);
}

.content-card p,
.game-card p {
  line-height: 1.75;
  font-size: 0.95rem;
}

.note {
  color: #5d5d66;
  font-size: 0.88rem;
}

.map-placeholder {
  min-height: 200px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.04);
  color: #5d5d66;
  font-weight: 700;
}

/* ─────────────────────────────────────
   ゲーム一覧
   ───────────────────────────────────── */
.game-list {
  display: grid;
  gap: 14px;
}

.game-card {
  display: block;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
  /* タッチしやすい最小高 */
  min-height: 80px;
}

.game-card:active {
  transform: scale(0.98);
}

.game-icon {
  display: inline-block;
  font-size: 2.6rem;
  animation: floatGhost 2.4s ease-in-out infinite;
}

/* ─────────────────────────────────────
   ゲーム画面
   ───────────────────────────────────── */
.instruction-desktop { display: none; }
.instruction-mobile  { display: inline; }

.game-instruction {
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.game-area {
  position: relative;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 10px auto 0;
  border-radius: 14px;
  background: #111;
  border: 2px solid rgba(0, 0, 0, 0.18);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-status {
  text-align: center;
  font-weight: 700;
  font-size: 0.92rem;
  min-height: 1.6em;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.hud-timer {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  filter: brightness(0.65);
}

/* ジョイスティック */
.joystick-zone {
  position: relative;
  width: 100%;
  height: 140px;
  margin: 8px auto 0;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.05);
  border: 2px dashed rgba(0, 0, 0, 0.1);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.joystick-base {
  position: absolute;
  width: 100px;
  height: 100px;
  margin-left: -50px;
  margin-top: -50px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  border: 2px solid rgba(0, 0, 0, 0.14);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  left: 50%;
  top: 50%;
}

.joystick-base.visible {
  opacity: 1;
}

.joystick-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
  transition: transform 40ms ease-out;
}

/* ─────────────────────────────────────
   ボタン共通
   ───────────────────────────────────── */
.small-button {
  display: inline-block;
  min-height: 44px;
  padding: 11px 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-dark);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  transition: transform 140ms ease;
}

.small-button:active {
  transform: scale(0.96);
}

/* ─────────────────────────────────────
   アニメーション
   ───────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(14px);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 460ms ease, transform 460ms ease;
}

@keyframes pageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── ページ登場（ふわっとフェードイン） ── */
body.is-entering {
  opacity: 0;
  transform: scale(1.03);
}

body {
  transition: opacity 340ms ease, transform 340ms ease;
}

/* ── タイル遷移エフェクト（退場のみ） ── */
.tile-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), 1fr);
  grid-template-rows: repeat(var(--rows, 24), 1fr);
  pointer-events: none;
}

.tile {
  background: #0a0a0f;
  opacity: 0;
}

.tile.is-visible {
  opacity: 1;
}

@keyframes floatHouse {
  0%, 100% { transform: translateY(0) rotate(-0.8deg); }
  50%      { transform: translateY(-8px) rotate(0.8deg); }
}

@keyframes floatGhost {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ═══════════════════════════════════════
   デスクトップ（769px〜）
   ═══════════════════════════════════════ */
@media (min-width: 769px) {
  body {
    padding-bottom: 0;
  }

  .site-header {
    justify-content: space-between;
    padding: 22px 0;
  }

  /* ナビを上部ヘッダーに戻す */
  .site-nav {
    position: static;
    height: auto;
    padding-bottom: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 0;
    justify-content: flex-end;
    gap: 6px;
  }

  .site-nav a {
    flex-direction: row;
    flex: unset;
    gap: 6px;
    font-size: 0.92rem;
    padding: 8px 14px;
    border-radius: 999px;
    transition: background 180ms ease, color 180ms ease;
  }

  .site-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .nav-icon {
    font-size: 1.1rem;
  }

  .home-nav {
    flex-direction: row;
    justify-content: center;
    max-width: none;
  }

  .menu-button {
    width: auto;
    min-width: 160px;
    border-radius: 999px;
  }

  .menu-button:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.24);
    background: #fff;
  }

  .haunted-house-placeholder {
    width: min(360px, 70vw);
    height: min(260px, 48vw);
  }

  .page-layout {
    width: min(920px, calc(100% - 48px));
    padding: 40px 0 80px;
  }

  .content-card,
  .game-card {
    border-radius: 24px;
  }

  .game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 52px rgba(0, 0, 0, 0.3);
  }

  .instruction-desktop { display: inline; }
  .instruction-mobile  { display: none; }

  .joystick-zone { display: none; }

  .joystick-zone { display: none; }
}
