body {
  margin: 0;
  background: #05040A;
  color: white;
  font-family: sans-serif;
}

/* --- レイアウト --- */
.layout {
  display: flex;
  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;
  overflow-y: auto;
  background-color: #05040A;
  transition: margin-left 0.3s ease;
}

/* --- キャラクターグリッド --- */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0px;
  /* キャラカード間の余白 */
  justify-content: flex-start;
  padding-left: 10px;
  /* 左右余白 */
  padding-right: 10px;
}

/* --- キャラカード --- */
.character-card {
  width: 120px;
  flex-shrink: 0;
  margin: 10px;
  text-align: center;
  position: relative;
  display: inline-block;
  text-decoration: none;
  color: #E9E5DC;
}

.character-img-wrapper {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

/* 星背景 */
.five-star {
  background: linear-gradient(180deg, #945c2c, #b27330);
}

.four-star {
  background: linear-gradient(180deg, #5e5789, #9c75b7);
}

.character-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

/* 元素アイコン */
.element-icon {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
}

/* キャラ名 */
.character-name {
  text-align: center;
  padding: 8px 0;
  font-size: 14px;
  background: #E9E5DC;
  color: black;
  border-radius: 0 0 8px 8px;
}

/* フィルターのボタンを横並びに */
#filters {
  display: flex;
  /* 横並び */
  flex-wrap: wrap;
  /* 画面が狭いときは折り返す */
  gap: 8px;
  /* ボタン間の隙間を少し広げる */
  margin-bottom: 20px;
  /* 下に余白 */
  align-items: center;
  /* ボタンを縦方向中央揃え */
  padding-left: 20px;
  /* 左に余白を追加 */
}

.filter-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  background-color: #111;
  /* 透明ではなく暗めの背景 */
  cursor: pointer;
  padding: 4px;
  /* 画像とボタン端の隙間 */
  border-radius: 6px;
  /* 角丸で違和感なく */
  transition: all 0.15s ease-in-out;
}

.filter-btn img {
  width: 40px;
  height: 40px;
  display: block;
}

.filter-btn.active {
  background-color: #333;
  /* 選択中は少し明るめ */
}

.filter-btn.active img {
  outline: 2px solid #ffffff;
  border-radius: 5px;
  transform: scale(1.15);
}


.overlay {
  display: none; /* 通常は非表示 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 900; /* サイドバー(1000)より下 */
}

.overlay.active {
  display: block;
}

/* トランジション（動き）を滑らかにするための共通設定 */
.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;
  }
}

/* --- [2] スマホ画面 (768px以下) --- */
@media (max-width: 768px) {
  /* サイドバーを画面外（左側）へ飛ばす */
  .sidebar {
    position: fixed;
    left: -100%;
    top: 60px;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - 60px);
    z-index: 1000;
  }

  .sidebar.active {
    left: 0;
  }

  .sidebar .logo.sidebar-logo {
    display: none; /* サイドバー内のロゴはスマホでは不要 */
  }

  .main {
    margin-left: 0 !important;
    padding-top: 80px;
  }

  /* スマホ用ヘッダーの表示 */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: #0D0A21;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 1100;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  /* 三本線ボタンのデザイン */
  .menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background: white;
    border-radius: 3px;
    transition: 0.3s;
  }
  
  /* メニュー展開時の三本線アニメーション（任意） */
  .menu-toggle.open span:nth-child(1) { transform: translateY(10.5px) rotate(45deg); }
  .menu-toggle.open span:nth-child(2) { opacity: 0; }
  .menu-toggle.open span:nth-child(3) { transform: translateY(-10.5px) rotate(-45deg); }
}

/* PCではスマホ用ヘッダーを隠す */
@media (min-width: 769px) {
  .mobile-header {
    display: none;
  }
}