/* ===== CSS変数とベーススタイル ===== */
:root {
  /* カラーパレット：アンティーク調の温かみのある色合い */
  --bg: #dcd7cf;      /* 背景色：ベージュ */
  --ink: #6e6a63;     /* テキスト色：グレー */
  --accent: #8B7355;  /* アクセント色：ブラウン */
  --light: #e8e3dc;   /* ライト色：薄いベージュ */
  --transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1); /* 統一トランジション */
}

/* === 基本リセットとベーススタイル === */
html {
  scroll-behavior: smooth; /* スムーズスクロール */
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* 等幅フォント：ゲームらしい雰囲気を演出 */
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.6;
  overflow-x: clip; /* 横スクロールを無効化 */
}

/* ===== 共通コンポーネント ===== */

/* スティッキーコンテナ：スクロール時に固定される */
.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: clip;
  background: var(--light);
}

/* セクションタイトル共通スタイル */
.section-title {
  position: absolute;
  top: var(--section-title-top, clamp(6%, 9vh, 12%));
  left: var(--section-title-left, clamp(8%, 12vw, 16%));
  transform: translate(
    var(--section-title-translate-x, 0),
    var(--section-title-translate-y, 0)
  );
  max-width: var(--section-title-max-width, clamp(20rem, 28vw, 26rem));
  text-align: var(--section-title-text-align, left);
  display: flex;
  flex-direction: column;
  gap: var(--section-title-gap, 0.6rem);
  opacity: 0; /* 初期状態で非表示 */
  z-index: 5;
  
  /* タイトルの縦位置を統一するための調整 */
  align-items: flex-start;
  min-height: 5rem; /* 最小の高さを確保 */
}

.section-title h2 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--section-title-heading-color, var(--ink));
  /* 改行禁止 - 必要に応じてメディアクエリで解除 */
  white-space: nowrap;
  width: 100%; /* 幅を親要素に合わせる */
}

.section-title p {
  margin: 0;
  font-size: clamp(1rem, 1.4vw, 1.3rem);
  line-height: var(--section-title-body-line-height, 1.7);
  color: var(--section-title-body-color, var(--ink));
  opacity: 0.85;
  width: 100%; /* 幅を親要素に合わせる */
}

/* 中央揃えのセクションタイトルの調整 */
.section-title[data-align="center"],
.section-title.is-center {
  --section-title-left: 50%;
  --section-title-translate-x: -50%;
  --section-title-text-align: center;
  align-items: center; /* 中央揃えの場合は子要素も中央に */
}

/* SVG共通スタイル */
svg {
  width: 100%;
  height: 100%;
}

/* 線の基本スタイル */
.line {
  stroke: var(--ink);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round; /* 線の端を丸く */
}

/* ラベル（説明テキスト）の基本スタイル */
.label {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 500;
  opacity: 0; /* 初期状態で非表示 */
}

/* ===== 線アニメーションセクション ===== */
/* 単純な線が描画されるデモセクション */
.feature-section {
  height: 300vh; /* 3倍の高さでスクロール余裕を作る */
  position: relative;
  background: var(--bg);
}

/* 線描画エリア */
.line-container {
  width: 80%;
  height: 400px;
  position: relative;
}

/* ===== 説明書ダウンロードセクション ===== */
.rulebook-section {
  position: relative;
  padding: clamp(4rem, 10vw, 7rem) 0 clamp(3rem, 7vw, 6rem);
  background: var(--light);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12vh;
}

.rulebook-container {
  max-width: clamp(16rem, 90vw, 30rem);
  margin: 0 auto;
  padding: 0 clamp(1rem, 6vw, 2rem);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 2.6vw, 1.6rem);
  text-wrap: balance;
}

.rulebook-title {
  margin: 0;
  font-size: clamp(1.6rem, 2.7vw, 2.3rem);
  letter-spacing: 0.03em;
  word-break: keep-all;
}

.rulebook-description {
  margin: 0;
  font-size: clamp(1.2rem, 1.2vw, 5rem);
  line-height: 1.75;
  opacity: 0.82;
  word-break: normal;
}

.rulebook-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 1.2vw, 0.9rem) clamp(2.2rem, 4.4vw, 2.7rem);
  border-radius: 999px;
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: #f6f2ea;
  background: var(--accent);
  box-shadow: 0 0.75rem 1.8rem rgba(0, 0, 0, 0.12);
  transition: var(--transition);
  white-space: nowrap;
}

.rulebook-button:hover,
.rulebook-button:focus-visible {
  background: #a3825d;
  transform: translateY(-2px);
  box-shadow: 0 1rem 2.2rem rgba(0, 0, 0, 0.18);
}

.rulebook-button:focus-visible {
  outline: 3px solid #c6b59d;
  outline-offset: 4px;
}



/* ===== レスポンシブ対応（共通要素） ===== */

/* === 大型デスクトップ（1200px以上） === */
@media (min-width: 1200px) {
  .line {
    stroke-width: 3;
  }

  .label {
    font-size: 20px;
  }

  .line-container {
    width: 70%;
    height: 450px;
  }
}

/* === タブレット（768px以下） === */
@media (max-width: 768px) {
  .section-title h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    letter-spacing: 0.03em;
  }

  .line {
    stroke-width: 4;
  }

  .label {
    font-size: 16px;
  }

  .line-container {
    width: 90%;
    height: 300px;
  }

  .rulebook-title {
    font-size: clamp(1.35rem, 4.6vw, 1.8rem);
  }

  .rulebook-description {
    font-size: clamp(0.84rem, 2.6vw, 0.95rem);
    line-height: 1.7;
  }

  .rulebook-button {
    font-size: clamp(0.84rem, 2.4vw, 0.95rem);
    padding: clamp(0.64rem, 2.5vw, 0.78rem) clamp(1.8rem, 6vw, 2.2rem);
  }
}

/* === スマートフォン（480px以下） === */
@media (max-width: 480px) {
  .section-title {
    min-height: 4rem; /* スマホでは高さを少し小さく */
  }
  
  .section-title h2 {
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    letter-spacing: 0.02em;
  }

  .line {
    stroke-width: 5;
  }

  .label {
    font-size: 14px;
  }

  .line-container {
    width: 95%;
    height: 250px;
  }

  .rulebook-section {
    padding: clamp(3.2rem, 18vw, 4.2rem) clamp(1rem, 6vw, 1.5rem);
    min-height: calc(100vh - 12vh);
  }

  .rulebook-container {
    padding: 0;
    gap: clamp(0.85rem, 4vw, 1.2rem);
  }

  .rulebook-title {

    font-size: clamp(1.2rem, 6.2vw, 1.1rem);
  }

  .rulebook-description {
    font-size: clamp(0.82rem, 3.5vw, 0.9rem);
    line-break: strict;
    word-break: normal;
  }

  .rulebook-button {
    font-size: clamp(0.82rem, 3.4vw, 0.9rem);
    padding: clamp(0.6rem, 3vw, 0.75rem) clamp(1.7rem, 7vw, 2.1rem);
  }
}

/* === 極小スマートフォン（360px以下） === */
@media (max-width: 360px) {
  .section-title {
    min-height: 3.5rem; /* 極小スマホではさらに小さく */
  }
  
  .section-title h2 {
    font-size: clamp(1.2rem, 6vw, 2rem);
    letter-spacing: 0.01em;
  }

  .line {
    stroke-width: 6;
  }

  .label {
    font-size: 12px;
  }

  .line-container {
    width: 98%;
    height: 200px;
  }

  .rulebook-title {
    font-size: clamp(0.8rem, 7vw, 1rem);
  }

  .rulebook-description,
  .rulebook-button {
    font-size: clamp(0.76rem, 4.2vw, 0.85rem);
  }
}

/* ===== 共通ユーティリティ ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== 固定リンクボタン ===== */
.fixed-link-button {
  position: fixed;
  bottom: clamp(1rem, 3vh, 1.8rem);
  right: clamp(0.8rem, 3vw, 1.6rem);
  width: clamp(2.6rem, 5vw, 3rem);
  height: clamp(2.6rem, 5vw, 3rem);
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(110, 106, 99, 0.45);
  color: #f6f2ea;
  text-decoration: none;
  border: 1px solid rgba(139, 115, 85, 0.35);
  backdrop-filter: blur(8px);
  box-shadow: none;
  transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  z-index: 60;
}

.fixed-link-button:hover {
  background: rgba(139, 115, 85, 0.65);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.fixed-link-button:focus-visible {
  outline: none;
  background: rgba(139, 115, 85, 0.75);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(234, 225, 210, 0.85), 0 6px 18px rgba(0, 0, 0, 0.18);
}

.fixed-link-button__icon {
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  line-height: 1;
}

@media (pointer: coarse) {
  .fixed-link-button {
    width: clamp(3rem, 10vw, 3.4rem);
    height: clamp(3rem, 10vw, 3.4rem);
  }
}
