/* カード表示用オーバーレイ（スクロール対応） */
#card-display-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* 上端に合わせることでスクロールを容易にする */
  padding: 20px 0;         /* 上下の余白 */
  overflow-y: auto;        /* 画面からはみ出た場合にスクロール可能にする */
  perspective: 1000px;
}

/* ポケモンカード風 高品質デザイン（高さ可変・レスポンシブ対応） */
.monster-card {
  --card-hue: 200; 
  --base-color: hsl(var(--card-hue), 70%, 50%);
  --dark-color: hsl(var(--card-hue), 80%, 15%);
  --light-color: hsl(var(--card-hue), 90%, 70%);
  --accent-color: hsl(calc(var(--card-hue) + 40), 100%, 60%);

  width: 90%;             /* 横幅は画面の90% */
  max-width: 340px;       /* 最大幅を制限 */
  min-height: 480px;      /* 最小の高さ */
  max-height: calc(100vh - 40px); /* 画面内に収める最大値 */
  
  padding: 12px;
  border-radius: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  color: #111;
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
  transition: transform 0.1s ease;
  box-sizing: border-box; /* パディングを幅に含める */

  /* カードの枠 */
  background: linear-gradient(145deg, #f0d060, #a08030);
  border: 2px solid #604010;
}

/* カードの内側（メインコンテンツエリア） */
.card-inner {
  flex: 1;
  background: linear-gradient(180deg, #fff, #ddd);
  border-radius: 12px;
  border: 3px solid #000;
  padding: 10px;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
  overflow: hidden; /* 子要素が内枠からはみ出さないようにする */
}

/* ヘッダー */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  padding: 0 4px;
}

.monster-name {
  margin: 0;
  font-size: 1.3rem;
  font-weight: bold;
  color: #000;
  text-shadow: 1px 1px 0 #fff;
  letter-spacing: -1px;
}

.monster-level {
  font-size: 0.8rem;
  font-weight: bold;
  background: #333;
  color: #fff;
  padding: 2px 6px;
  border-radius: 8px;
}

/* モンスター画像エリア（ホログラム） */
.monster-image-area {
  height: 160px; /* 少し高さを抑えて情報の入り口を増やす */
  flex-shrink: 0; /* 縮まないように固定 */
  border: 3px solid #777;
  background: #000;
  position: relative;
  overflow: hidden;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.4);
}

.monster-image-area img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 2;
}

.monster-image-area::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  z-index: 1;
  background: linear-gradient(
    110deg,
    hsla(0, 100%, 70%, 0) 0%,
    hsla(60, 100%, 70%, 0.2) 15%,
    hsla(120, 100%, 70%, 0.2) 30%,
    hsla(180, 100%, 70%, 0) 45%,
    hsla(240, 100%, 70%, 0.2) 60%,
    hsla(300, 100%, 70%, 0.2) 75%,
    hsla(360, 100%, 70%, 0) 100%
  );
}

@keyframes holoSheen {
  0% { transform: translate(-20%, -20%) rotate(10deg); }
  100% { transform: translate(20%, 20%) rotate(10deg); }
}

/* バトル統計 */
.battle-stats {
  background: rgba(255, 255, 255, 0.7);
  margin: 8px 0;
  padding: 4px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--dark-color);
  border-left: 4px solid var(--base-color);
  text-align: center;
}

/* 履歴エリア（スクロール可能） */
.history-section {
  flex: 1; /* 余ったスペースをすべて使い、自動でサイズ調整 */
  display: flex;
  flex-direction: column;
  margin-bottom: 5px;
  overflow: hidden;
}

.history-section h3 {
  font-size: 0.7rem;
  color: #666;
  margin: 0 0 3px 0;
  text-transform: uppercase;
}

.history-section ul {
  list-style: none;
  padding: 5px;
  margin: 0;
  font-size: 0.75rem;
  flex: 1;
  overflow-y: auto; 
  background: rgba(0,0,0,0.05);
  border-radius: 5px;
}

.history-section ul::-webkit-scrollbar { width: 4px; }
.history-section ul::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

.history-section li {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  border-bottom: 1px dashed rgba(0,0,0,0.1);
  color: #333;
}

/* ボタン */
.get-btn-container {
  margin-top: auto; 
  padding-top: 5px;
  flex-shrink: 0;
}

.get-btn {
  width: 100%;
  padding: 10px;
  background: linear-gradient(180deg, var(--light-color), var(--base-color));
  color: #fff;
  border: 2px solid #000;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.9rem;
  cursor: pointer;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 3px 0 #000;
}

.get-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000;
}

/* フレーバーテキスト */
.card-footer {
  font-size: 0.55rem;
  color: #666;
  text-align: center;
  margin-top: 4px;
  border-top: 1px solid #ccc;
  flex-shrink: 0;
}

/* カード一覧のグリッド設定 */
#card-collection-grid, #all-showcase-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); /* 少し幅を広げて見やすく */
    gap: 12px;
    padding: 15px;
    align-items: start;
}

/* カード自体のスタイル */
.card-thumb {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%); /* 高級感のあるグラデーション */
    border-radius: 10px;
    padding: 6px;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    border: 1px solid #444;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.card-thumb:hover {
    transform: translateY(-5px);
    border-color: #fff; /* ホバー時は白く光らせる */
    box-shadow: 0 8px 15px rgba(0,0,0,0.5);
}

/* 画像コンテナ：アスペクト比を維持してきれいに収める */
.thumb-img-container {
    width: 100%;
    aspect-ratio: 1 / 1; /* 正方形に固定 */
    background: #000;
    border-radius: 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.card-thumb img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.8)); /* モンスターを浮かび上がらせる */
}

/* モンスター名 */
.card-thumb .thumb-name {
    font-size: 0.75rem;
    font-weight: bold;
    color: #eee;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* レベルやタイムなどの情報 */
.thumb-info div {
    font-size: 0.6rem;
    line-height: 1.2;
}

/* 空メッセージのスタイル */
.empty-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: #888;
    padding: 40px 0;
    font-style: italic;
}

/* アコーディオンの開閉用（必要に応じて） */
.panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: rgba(0, 0, 0, 0.2);
}

.panel.open {
  max-height: 800px; /* 十分な高さを設定 */
  overflow-y: auto;
}