/* --- 新デザイン: チュートリアル全体の見た目を美しく再設計 --- */

/* 背景の扱いは既存のまま（半透明で画面を覆う）。z-index を確保 */
.tutorial-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6,10,14,0.36); /* 透過を増やして背後のパノラマが見えるように */
  z-index: 15000;
  pointer-events: auto;
  backdrop-filter: blur(6px);      /* 背景を少しぼかして奥行きを出す */
}

/* 表示時はフレックスで中央配置 */
.tutorial-backdrop.visible,
.tutorial-backdrop[aria-hidden="false"] {
  display: flex;
}

/* モーダルの基礎 */
.tutorial-modal {
  width: 720px;
  max-width: calc(100% - 40px);
  background: rgba(255,255,255,0.88); /* 背景をやや透過 */
  color: #0f1720;
  border-radius: 16px;
  box-shadow: 0 28px 64px rgba(3,12,24,0.60), inset 0 1px 0 rgba(255,255,255,0.8);
  overflow: visible;
  position: relative;
  /* ヘッダー領域（ツールバー）分の余白を上部に確保 */
  padding: 86px 30px 44px 30px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  border: 1px solid rgba(20,30,36,0.06);
  transition: transform 220ms cubic-bezier(.2,.9,.3,1), opacity 180ms ease;
}

/* モバイルでは幅を柔軟に */
@media (max-width: 520px) {
  .tutorial-modal {
    width: calc(100% - 24px);
    padding: 72px 14px 28px 14px;
    border-radius: 12px;
  }
}

/* 上部に薄いヘッダー風の領域を想定し、ツールバーを配置する */
.tutorial-toolbar {
  position: absolute;
  left: 22px;
  top: 16px;
  z-index: 1450;
  display:flex;
  align-items:center;
  gap:12px;
}

/* ヘッダーの logo を使わないため該当スタイルを無害化（必要なら削除） */
.tutorial-logo { display: none; }

/* 右上コントロール（オートロテート）とページ言語切替の位置（index.html の inline style をここへ移動） */
#topRightControls { position: fixed; right:12px; top:12px; display:flex; gap:8px; align-items:center; z-index:1300; }
#languageToggle {
  position: fixed;
  right: 12px;
  top: 72px; /* autorotate の下へ（少し余裕） */
  z-index: 1290;
  display:flex;
  gap:6px;
  background: rgba(6,12,24,0.44);
  padding:6px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 22px rgba(6,12,18,0.45);
}
#languageToggle .lang-btn { color: #eaf6ff; background: transparent; border: none; padding:6px 10px; border-radius:8px; font-weight:700; }
#languageToggle .lang-btn.active { background: linear-gradient(180deg,#1f6fe8,#165fcf); color: #fff; }

/* tutorial-toolbar 内の lang-btn をページ右上のボタンと同じ見た目にする */
.tutorial-toolbar .lang-btn {
  color: #eaf6ff;
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}
.tutorial-toolbar .lang-btn.active {
  background: linear-gradient(180deg,#1f6fe8,#165fcf);
  color: #fff;
  box-shadow: 0 10px 26px rgba(22,86,240,0.18);
  transform: translateY(-1px);
}
/* hover/focus の統一 */
.tutorial-toolbar .lang-btn:hover { background: rgba(31,111,207,0.06); }
.tutorial-toolbar .lang-btn:focus { outline: 3px solid rgba(22,90,220,0.12); outline-offset: 2px; }

/* ツールバーのラップ */
.tutorial-toolbar .tutorial-lang-wrap {
  display:flex;
  align-items:center;
  gap:8px;
  background: rgba(12,24,48,0.06);
  padding:6px 8px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 8px 22px rgba(6,14,20,0.28);
}

/* 言語ボタン: 青基調だが active は控えめな塗り＋境界線に変更 */
.tutorial-lang-btn {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
  background: transparent;
  color: rgba(12,20,28,0.95);
  font-weight:700;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease, border-color 0.12s;
}
.tutorial-lang-btn.active {
  background: rgba(31,111,207,0.08); /* 薄い青背景で視認性を確保 */
  color: #165fcf;                       /* 青基調のテキスト */
  border-color: rgba(22,90,220,0.18);   /* 控えめな青の枠線 */
  box-shadow: none;                     /* 強い影は付けない */
  transform: translateY(0);
}

/* focus 時のスタイル */
.tutorial-lang-btn:focus {
  outline: 3px solid rgba(22,90,220,0.12);
  outline-offset: 2px;
}

/* ホバー効果 */
.tutorial-lang-btn:hover { background: rgba(31,111,207,0.06); }

/* スキップボタンを目立たせつつ本文とかぶらないよう右上に配置 */
.tutorial-skip.top-right {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(18,24,30,0.9);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  z-index: 1500;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(2,8,23,0.45);
}

/* チュートリアルページ本体は中身の整理を行う */
.tutorial-page {
  display: none;
  max-width: 100%;
  margin: 0 auto;
}

/* visible 管理 */
.tutorial-page.visible { display: block; }

/* タイトル */
.tutorial-modal .title {
  margin: 0 0 10px 0;
  font-size: 24px;
  font-weight: 800;
  color: #042028;
  letter-spacing: -0.3px;
}

/* 説明文 */
.tutorial-modal p {
  margin: 0 0 12px 0;
  color: #31474f;
  font-size: 15px;
  line-height: 1.6;
}

/* アイコン行の見た目調整（既存のルールを継承しつつ美しく） */
.tutorial-icons-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 18px;
  margin-top: 14px;
  align-items: start;
  justify-items: center;
}

/* アイコンブロック */
.tutorial-icon {
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  padding: 10px 8px;
  background: rgba(255,255,255,0.0);
  border-radius: 10px;
}

/* アイコン画像はカード風に */
.tutorial-icon img {
  display:block;
  width:48px;
  height:48px;
  margin-bottom:10px;
  padding:10px;
  border-radius:12px;
  background: linear-gradient(180deg,#22343a,#142026);
  box-shadow: 0 10px 28px rgba(7,20,24,0.36);
  filter: none; /* 元の反転は不要 */
}

/* アイコン説明 */
.tutorial-icon-text {
  font-size: 14px;
  color: #33454e;
  text-align: center;
  line-height:1.35;
}

/* 下部の操作ボタン群 */
.tutorial-skip.inline,
.tutorial-confirm,
.tutorial-start {
  display:inline-block;
  margin: 0 6px;
  background: linear-gradient(180deg,#2e7be8,#1b5fd6); /* ボタンを青系に統一 */
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(20,60,60,0.22);
  transition: transform .12s ease, box-shadow .12s ease;
}

/* Start ボタンは強調色 */
.tutorial-start {
  background: linear-gradient(180deg,#1565d8,#0d47a1);
}

/* ホバー効果 */
.tutorial-skip.inline:hover,
.tutorial-confirm:hover,
.tutorial-start:hover,
.tutorial-lang-btn:hover { transform: translateY(-3px); }

/* 矢印系は以前のままだが z-index を高める */
.tutorial-arrow { z-index: 1400; }

/* レスポンシブ調整 */
@media (max-width: 520px) {
  .tutorial-icons-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap:10px; }
  /* モバイルでは右上ではなく画面の左下にコンパクトに配置（safe-area に対応） */
  #languageToggle {
    position: fixed;
    left: calc(var(--sidebar-left-offset, 12px) + env(safe-area-inset-left, 8px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    top: auto;
    right: auto;
    z-index: 14020;
    display: flex;
    flex-direction: column; /* 縦積みでコンパクトに */
    gap: 6px;
    padding: 6px;
    border-radius: 10px;
    background: rgba(6,12,24,0.44);
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 8px 20px rgba(6,12,18,0.35);
  }
  .tutorial-logo { width:48px; height:48px; padding:4px; }
  .tutorial-toolbar { left:12px; top:12px; gap:8px; }
  .tutorial-skip.top-right { top: 10px; right: 10px; padding:6px 8px; border-radius:8px; font-size:14px; }
  .tutorial-modal { padding:72px 14px 28px 14px; border-radius:12px; }
}

/* 言語ボタン: hover の可読性を改善
   - 非アクティブ: 薄い青背景 + 濃い文字（読みやすく）
   - アクティブ: 濃い青背景 + 白文字（選択状態を明確に）
   - ページ右上とチュートリアル内の両方をカバー */
#languageToggle .lang-btn:not(.active):hover,
.tutorial-toolbar .lang-btn:not(.active):hover {
  background: rgba(31,111,207,0.10); /* 少しだけ濃いめにして十分なコントラストを確保 */
  color: #072028;                     /* 濃い文字色で可読性を確保 */
  text-decoration: none;
}

#languageToggle .lang-btn.active:hover,
.tutorial-toolbar .lang-btn.active:hover {
  background: linear-gradient(180deg,#165fcf,#0f4fc0); /* アクティブの hover は濃い青に */
  color: #fff;                                       /* 白文字を維持 */
  box-shadow: 0 10px 26px rgba(13,71,161,0.20);
}

/* フォーカス時も同様にコントラストが確保されるように */
#languageToggle .lang-btn:focus,
.tutorial-toolbar .lang-btn:focus {
  background: rgba(31,111,207,0.12);
  color: #072028;
  outline: none;
  box-shadow: 0 6px 18px rgba(6,12,24,0.18), 0 0 0 3px rgba(22,90,220,0.08);
}

/* 既存のより弱い hover ルールを上書き（安全のため強度を上げて優先させる） */
.tutorial-lang-btn:hover { background: rgba(31,111,207,0.06) !important; }

/* --- 修正: 右上(#languageToggle) と チュートリアル(.tutorial-toolbar) を分離して制御 --- */

/* 画面右上の言語トグル: 非選択・hover いずれも白文字で可読性確保 */
#languageToggle .lang-btn {
  color: #fff !important;
  background: transparent !important;
  border-color: transparent !important;
}
#languageToggle .lang-btn:not(.active):hover {
  background: rgba(31,111,207,0.10) !important; /* 蛍光ペン風の背景と太字を与える */
  color: #fff !important;                        /* 文字は白を維持 */
  text-decoration: none !important;
}
#languageToggle .lang-btn.active,
#languageToggle .lang-btn.active:hover {
  background: linear-gradient(180deg,#1f6fe8,#165fcf) !important;
  color: #fff !important;
  box-shadow: 0 10px 26px rgba(22,86,240,0.18) !important;
}

/* チュートリアル内ツールバーの言語ボタンは別扱い（濃い文字で可読） */
.tutorial-toolbar .lang-btn {
  color: #072028 !important;
  background: transparent !important;
  border-color: transparent !important;
}
.tutorial-toolbar .lang-btn:not(.active):hover {
  background: rgba(31,111,207,0.10) !important;
  color: #072028 !important;
}
.tutorial-toolbar .lang-btn.active,
.tutorial-toolbar .lang-btn.active:hover {
  background: linear-gradient(180deg,#1f6fe8,#165fcf) !important;
  color: #fff !important;
  box-shadow: 0 10px 26px rgba(22,86,240,0.18) !important;
}

/* フォーカス時のコントラスト確保 */
#languageToggle .lang-btn:focus,
.tutorial-toolbar .lang-btn:focus {
  outline: none !important;
  box-shadow: 0 6px 18px rgba(6,12,24,0.18), 0 0 0 3px rgba(22,90,220,0.08) !important;
}

/* 他の弱い hover ルールの上書き（安全マージン） */
.tutorial-lang-btn:hover { background: rgba(31,111,207,0.06) !important; }

/* ハイライト（蛍光ペン風）: 背景を黄色にして文字を太字にする */
.highlight {
  display: inline-block;              /* 幅を文字に合わせ、背景が段落に広がらないようにする */
  background: #fff176;                /* 蛍光イエロー */
  color: inherit;
  font-weight: 800;                   /* 太字に */
  padding: 0 6px;                     /* 左右の余白で蛍光ペン幅を表現 */
  border-radius: 3px;
  line-height: 1.2;
  box-decoration-break: clone;        /* 複数行ハイライトを分断しない */
}
/* モバイルで若干パディングを控えめに */
@media (max-width: 520px) {
  .highlight { padding: 0 4px; border-radius: 2px; }
}