/*全体・基本設定 */
body {
  margin: 0;
  background: #05040A;
  color: white;
  font-family: sans-serif;
}

/*レイアウト全体 */
.layout {
  display: flex;
  min-height: 100vh;
}

/*サイドバー*/
.sidebar {
  position: fixed;
  /* 画面に固定 */
  top: 0;
  /* 上端に固定 */
  left: 0;
  /* 左端に固定 */
  width: 220px;
  height: 100vh;
  /* 画面の高さいっぱい */
  background: #0D0A21;
  padding: 20px;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  gap: 20px;

  overflow-y: auto;
  /* サイドバー内が長くてもスクロール可能 */
}

/* メニュー全体 */
.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

/* 各ボタン */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px;
  border-radius: 12px;

  text-decoration: none;
  color: white;

  transition: 0.2s ease;
}

/* 画像サイズ */
.menu-item img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
}

/* ホバー時 */
.menu-item:hover {
  background-color: #5752EC;
}

/* サイドバーロゴ全体 */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  /* 下線消す */
}

/* ロゴ画像サイズ */
.logo img {
  width: 45px;
  /* ←ここで大きさ調整 */
  height: 45px;
}

/* LUNABASE文字 */
.logo span {
  font-size: 20px;
  font-weight: bold;

  /* シルバーグラデーション */
  background: linear-gradient(135deg,
      #f5f5f5 0%,
      #d6d6d6 30%,
      #a8b0b8 50%,
      #eaeaea 70%,
      #c2c8cf 100%);

  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

  background-clip: text;
  color: transparent;
}

.menu-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #ccc;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.menu-btn.active {
  color: white;
  background: #222;
}

/*メインエリア*/
.main {
  flex: 1;
  margin-left: 240px;
  padding: 20px;
  box-sizing: border-box;
  background-color: #070610;
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* 追加: これでメインエリアが画面幅を超えなくなる */
  min-width: 0; 
  overflow-x: hidden; 
}

/*キャラトップ（画像＋右カラム）*/
.char-top {
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.char-left {
  flex: 1;
  max-width: 1200px;
  height: auto;
  /* 高さを固定せず自動に */
  max-height: 750px;
  background: #0D0D0D;
  border: 1px solid #3D3D3C;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.char-left img {
  height: 100%;
  width: auto;
  object-fit: contain;
  max-height: 750px;
  border-radius: 0;
  display: block;
  flex-shrink: 0;
}

/* キャラクター説明文のスタイル（統一カードデザイン） */
.char-description {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  margin-top: 0;
  background: rgba(13, 13, 13, 0.8);
  border: 1px solid #3D3D3C;
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

#char-description-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.8;
  color: #D1D1D1;
  white-space: pre-wrap;
}

.char-right {
  flex: 1 1 300px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* レベルスライダー */
label[for="level-range"] {
  font-weight: bold;
}

#level-display {
  margin-left: 5px;
  font-weight: bold;
}

#level-range {
  width: 100%;
}

/* ステータスリスト */
#stat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 20px;
  line-height: 1.4;
  border-bottom: 1px solid #ccc;
  padding: 5px 0;
}

.stat-row span.label {
  font-weight: bold;
}

.stat-row span.value {
  text-align: right;
}

#char-name {
  font-size: 48px;
  font-weight: bold;
  margin: 0;
}

.stat-wrapper {
  background-color: #0D0D0D;
  /* 背景色 */
  border: 2px solid rgba(255, 255, 255, 0.2);
  /* 枠線 */
  border-radius: 12px;
  /* 角丸 */
  padding: 12px;
  margin-bottom: 20px;
}

/* アイコンを横に並べるコンテナ */
.tag-container {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

/* アイコン自体のスタイル */
.tag-icon {
  width: 24px; 
  height: 24px;
  object-fit: contain;
  cursor: help;
  transition: transform 0.2s;
}

.tag-icon:hover {
  transform: scale(1.2);
}

/* 親要素（アイコンとツールチップを包む） */
.tag-wrapper {
  position: relative;
  display: inline-block;
}

/* 1. ツールチップが親要素に切り取られないようにする */
#stat-list, 
.stat-row {
  overflow: visible !important; 
  position: relative;
}

/* 2. value欄の中でアイコンを正しく右寄せにする */
.stat-row .value {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  overflow: visible; /* ここも重要 */
}

/*天賦ゾーン*/
#talent-zone {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.talent-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.talent-card {
  flex: 0 0 calc(50% - 10px);
  background-color: #0D0D0D;
  border-radius: 18px;
  padding: 20px;
  border: 1px solid #3D3D3C;
  box-sizing: border-box;
}

.talent-card h3 {
  margin: 0 0 5px 0;
}

.talent-card p {
  font-size: 14px;
  margin: 0 0 10px 0;
  color: #BBBBBB
}

.talent-card .talent-multiplier {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.talent-card label {
  font-weight: bold;
}

.talent-card input[type="range"] {
  width: 100%;
}

.mult-name {
  color: #BBBBBB;
  /* 左側の文字色 */
}

.tooltip {
  position: absolute;
  background-color: rgb(0, 0, 0);
  border: 1px solid #ffffffab;
  /* 白枠 */
  border-radius: 10px;
  /* 角丸 */
  padding: 10px 12px;
  max-width: 320px;
  z-index: 9999;
  color: #fff;
  display: none;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-family: sans-serif;
}

.tooltip .effect-name {
  color: #FFD780FF;
  /* 名前の色 */
  font-size: 18px;
  /* 名前を大きく */
  font-weight: bold;
  margin-bottom: 6px;
}

.tooltip .effect-desc {
  font-size: 14px;
  line-height: 1.4;
}

.skill-link {
  position: relative;
  cursor: pointer;
  text-decoration: none;
  /* デフォルトの下線を消す */
  font-weight: bold;
  border-bottom: 2px dotted rgba(255, 255, 255, 0.779);
  /* 点線の下線 */
}

/* 天賦行（talent-row）の下に余白をつける */
.talent-row {
  display: flex;
  gap: 20px;
  /* 横の間隔はそのまま */
  margin-bottom: 16px;
  /* 下に余白を追加 */
}


/*レスポンシブ*/
@media screen and (max-width: 1024px) {
  .char-left {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .char-right {
    flex: 0 0 100%;
  }

  #elemental-burst {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media screen and (max-width: 768px) {
  .sidebar {
    width: 60px;
    padding: 8px;
  }

  #char-name {
    font-size: 36px;
  }

  .main {
    margin-left: 80px;
    /* サイドバー(60px) + 余白(20px) に合わせる */
    padding: 10px;
  }
}


/*Materials Section*/
.materials-wrapper {
  display: flex;
  justify-content: space-between;
  gap: 20px; /* 40pxだと広すぎるので少し調整 */
  margin: 40px 0;
  font-size: 20px;
  flex-wrap: wrap; /* 狭くなったら折り返すように */
}

.material-column {
  flex: 1; /* width: 48% より flex: 1 の方が安全 */
  min-width: 300px; /* これ以下になったら下の行に回る */
  background: #0D0D0D;
  border: 1px solid #3D3D3C;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.material-column {
  width: 48%;
}

.material-title {
  font-weight: bold;
  margin-bottom: 10px;
  text-align: left;
}

.material-row {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.material-item {
  text-align: center;
}

.material-item img {
  width: 50px;
  /* ← サイズここで調整 */
  height: 50px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.612);
  background: #2a2a2a;
  padding: 5px;
}

.material-count {
  margin-top: 4px;
  font-size: 14px;
}

.material-column {
  width: 48%;
  background: #0D0D0D;
  border: 1px solid #3D3D3C;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.talent-book-info {
  align-self: center;
  margin-left: 20px;
  font-weight: 700;
  font-size: 20px;
  white-space: nowrap;
}

.material-calculator {
  margin-top: 60px;
}

.mc-wrapper {
  display: flex;
  gap: 40px;
  background: #0D0D0D;
  border: 1px solid #3D3D3C;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  /* 追加: 親要素からはみ出さないように */
  max-width: 100%;
  box-sizing: border-box;
}

.mc-left {
  flex: 1; /* 固定幅ではなく、比率で指定（1） */
  max-width: 500px;
  min-width: 0; /* これを入れると、中身に合わせて縮むようになる */
}

/* もし500px以下で表示が崩れるなら、メディアクエリで縦並びに切り替える */
@media screen and (max-width: 1200px) {
  .mc-wrapper {
    flex-direction: column;
    /* 横並びから縦並びに */
  }

  .mc-left,
  .mc-right {
    width: 100%;
    min-width: 100%;
  }
}

.mc-right {
  flex: 1.5; /* 左より少し広め（1.5） */
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.mc-block {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-block input[type="range"] {
  width: 100%;
}

.mc-block h3 {
  margin-bottom: 8px;
}

#mc-result {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.mc-item {
  width: 80px;
  text-align: center;
}

.mc-item img {
  width: 64px;
  height: 64px;
  border: 2px solid;
  background: #2a2a2a;
  border-radius: 12px;

}

/* レアリティ別に img の枠の色を変える */
.mc-item.rarity-1 img {
  border-color: #888888;
}

/* 灰色 */
.mc-item.rarity-2 img {
  border-color: #0F5329;
}

/* 緑 */
.mc-item.rarity-3 img {
  border-color: #1B396C;
}

/* 青 */
.mc-item.rarity-4 img {
  border-color: #452465;
}

/* 紫 */
.mc-item.rarity-5 img {
  border-color: #612F0C;
}

/* 金色 */

/* 数字は枠の外に表示される */
.mc-item span {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: #fff;
}

.level-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* 現在／目標バーを左右に並べる */
.level-wrapper {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

/* 左側＝現在、右側＝目標 */
.level-wrapper>span,
.level-wrapper>input {
  vertical-align: middle;
}

/* 現在用のラッパー */
.level-wrapper .current-level,
.level-wrapper .target-level {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* レンジスライダーの幅 */
.level-wrapper input[type="range"] {
  width: 100%;
}


/* 命の星座全体のコンテナ */
#constellations {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 各行の設定 */
.const-row {
  display: flex;
  gap: 20px;
  align-items: stretch;
}

/* 行の中のカード設定 */
.const-row .talent-card {
  flex: 0 0 calc(50% - 10px);
  margin: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* カード内のテキストが少なくても背景を埋めるための設定 */
.const-row .talent-card p {
  flex-grow: 1;
}

/* ストーリー&ボイスボタン */
.story-voice-btn {
  width: 100%;
  padding: 12px;
  background-color: #1a1a1a;
  color: white;
  border: 1px solid #5752EC;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: 0.2s;
  margin-top: 10px;
}

.story-voice-btn:hover {
  background-color: #5752EC;
  /* 指定の色 */
}

/* ストーリー・ボイス表示用カード */
.info-display-card {
  background: #0D0D0D;
  border: 1px solid #3D3D3C;
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.info-display-card h3 {
  color: #FFD780FF;
  margin-top: 0;
  border-bottom: 1px solid #3D3D3C;
  padding-bottom: 10px;
}

.info-display-card p {
  line-height: 1.8;
  color: #D1D1D1;
  white-space: pre-wrap;
}

.unlock-condition {
  font-size: 0.85em;
  color: #888;
  margin-top: 10px;
  font-style: italic;
}

/* ストーリー・ボイス用のナビゲーションヘッダー */
.story-nav-header {
  position: sticky;
  top: -20px;
  /* mainのpadding分を調整 */
  background-color: #070610;
  /* 背景と同色にして透けないように */
  padding: 20px 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 15px;
  border-bottom: 1px solid #3D3D3C;
  margin-bottom: 20px;
}

/* 戻るボタン */
.back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  padding: 0;
}

/* ストーリー・ボイス切り替えボタンのコンテナ */
.toggle-container {
  display: flex;
  gap: 10px;
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  background: #1a1a1a;
  border: 1px solid #3D3D3C;
  color: #888;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

/* 押されている時のスタイル */
.toggle-btn.active {
  background: #5752EC;
  color: white;
  border-color: #5752EC;
}

/* コンテンツエリアの制御 */
.view-section {
  display: none;
  /* 基本は非表示 */
}

.view-section.active {
  display: block;
  /* activeクラスがついたものだけ表示 */
}

/* トランジション（動き）を滑らかにするための共通設定 */
.sidebar {
  transition: width 0.3s ease, padding 0.3s ease;
  z-index: 1000;
}

.menu-item span {
  transition: opacity 0.2s ease;
  white-space: nowrap; /* 文字の折り返しを防ぐ */
}

/* --- [1] デスクトップ中画面 (1300px以下) --- */
@media (min-width: 769px) and (max-width: 1300px) {
  .sidebar {
    width: 70px; /* アイコン分の幅に縮小 */
    padding: 20px 10px;
    overflow: hidden; /* はみ出た文字を隠す */
  }

  /* サイドバー内の文字とロゴテキストを隠す */
  .sidebar .logo span,
  .sidebar .menu-item span {
    opacity: 0;
    pointer-events: none;
  }

  /* ホバーした時にシュッと出てくる挙動 */
  .sidebar:hover {
    width: 220px; /* 元の幅に戻る */
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar:hover .logo span,
  .sidebar:hover .menu-item span {
    opacity: 1;
    pointer-events: auto;
  }

  /* メインエリアの余白を狭まったサイドバーに合わせる */
  .main {
    margin-left: 70px;
    transition: margin-left 0.3s ease;
  }
}