/* リセットと基本設定 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background-color: #f5f5f5;
  min-height: 100vh;
  color: #333;
}
/* 検索パネル */
.search-panel {
  background-color: white;
  border-bottom: 1px solid #e5e5e5;
  padding: 1.5rem 0;
}

.search-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4b5563;
}

.search-input,
.search-select {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background-color: white;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.search-input:focus,
.search-select:focus {
  outline: none;
  border-color: #3b82f6;
}

/* 色選択ボタンのコンテナ */
.color-buttons {
  display: flex;
  gap: 0.5rem;
  position: relative;
  flex-wrap: wrap; /* 折り返しを許可 */
  max-width: 100%;
  overflow-x: auto; /* 念のためスクロール可能に */
  padding: 0.25rem 0; /* 上下に少し余白 */
}

.color-btn {
  width: 48px;
  height: 48px;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-btn:hover:not(.selected) {
  transform: scale(1.05);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25);
}

.color-btn.selected {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
  border: 2px solid #2563eb;
  z-index: 10;
  animation: selectPulse 2s ease-in-out infinite;
}

.color-btn.selected::after {
  content: "✓";
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: #2563eb;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.color-btn.blue {
  background-color: #3b82f6;
}
.color-btn.red {
  background-color: #ef4444;
}
.color-btn.green {
  background-color: #10b981;
}
.color-btn.yellow {
  background-color: #f59e0b;
  color: #1f2937;
}
.color-btn.black {
  background-color: #1f2937;
}
.color-btn.white {
  background-color: #f9fafb;
  border: 2px solid #d1d5db;
  color: #4b5563;
}

/* ボタングループ */
.button-group {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

.search-btn,
.reset-btn {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.search-btn {
  background-color: #3b82f6;
  color: white;
}

.search-btn:hover {
  background-color: #2563eb;
}

.reset-btn {
  background-color: #e5e7eb;
  color: #4b5563;
}

.reset-btn:hover {
  background-color: #d4d4d8;
}

.view-toggle {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  padding: 0.5rem;
  border: none;
  background-color: #e5e5e5;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: background-color 0.2s, color 0.2s;
}

.view-btn:hover {
  background-color: #d4d4d8;
}

.view-btn.active {
  background-color: #3b82f6;
  color: white;
}

/* メインコンテンツ */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

@media (max-width: 768px) {
  .main-content {
    padding: 0.25rem;
    margin: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* グリッド列数切り替えボタンを小さく */
  .grid-columns-toggle {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .columns-label {
    font-size: 0.75rem;
  }

  .column-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
    min-width: 36px;
  }
}

/* グリッドビュー */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 768px) {
  /* 古い設定（削除済み - 新しい設定で統合） */

  /* グリッドの最後の列のカード対策 */
  .card-grid.grid-cols-3 .card:nth-child(3n),
  .card-grid.grid-cols-4 .card:nth-child(4n) {
    /* 最後の列のカードのカウンターを少し内側に */
    .owned-counter {
      right: 6px;
    }
  }

  /* スクロールバーの見た目をカスタマイズ（Webkit系ブラウザ） */
  .card-grid::-webkit-scrollbar {
    width: 6px;
  }

  .card-grid::-webkit-scrollbar-track {
    background: transparent;
  }

  .card-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
  }

  /* Firefox用 */
  .card-grid {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
  }
}

.card {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  border: 3px solid transparent;
  padding: 0;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* カードの色による枠線 */
.card.color-青 {
  border-color: #3b82f6;
}
.card.color-赤 {
  border-color: #ef4444;
}
.card.color-緑 {
  border-color: #10b981;
}
.card.color-黄 {
  border-color: #f59e0b;
}
.card.color-黒 {
  border-color: #1f2937;
}
.card.color-白 {
  border-color: #9ca3af;
}

.card-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  background-color: #f0f0f0;
}

/* 所持カウンターの位置調整 */
.owned-counter {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card.not-owned {
  opacity: 0.6;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-menu {
  display: flex;
  gap: 1rem;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* カードの色による枠線 */
.card.color-青 {
  border-color: #3b82f6;
}
.card.color-赤 {
  border-color: #ef4444;
}
.card.color-緑 {
  border-color: #10b981;
}
.card.color-黄 {
  border-color: #f59e0b;
}
.card.color-黒 {
  border-color: #1f2937;
}
.card.color-白 {
  border-color: #9ca3af;
}

@media (max-width: 500px) {
  .card.wide-card {
    grid-column: span 1;
  }
}

.counter-btn {
  width: 24px;
  height: 24px;
  border: none;
  background-color: #3b82f6;
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  transition: background-color 0.2s;
}

.counter-btn:hover {
  background-color: #2563eb;
}

.counter-value {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  color: #333;
}

.card-info {
  padding: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.card-number {
  font-size: 0.75rem;
  color: #666;
}

.rarity-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

/* レアリティの色 */
.rarity-UR {
  background-color: #fef3c7;
  color: #d97706;
}
.rarity-SRP {
  background-color: #fef3c7;
  color: #d97706;
}
.rarity-SR {
  background-color: #fee2e2;
  color: #dc2626;
}
.rarity-R {
  background-color: #dbeafe;
  color: #2563eb;
}
.rarity-C {
  background-color: #e5e7eb;
  color: #4b5563;
}
.rarity-CP {
  background-color: #fef3c7;
  color: #d97706;
}
.rarity-RP {
  background-color: #fee2e2;
  color: #dc2626;
}
.rarity-SEC {
  background-color: #fef3c7;
  color: #d97706;
}
.rarity-D {
  background-color: #e5e7eb;
  color: #4b5563;
}
.rarity-PR {
  background-color: #dbeafe;
  color: #2563eb;
}
.rarity-SRCP {
  background-color: #fbbf24;
  color: #78350f;
}
.rarity-MR {
  background-color: #ec4899;
  color: #831843;
}
.rarity-MRP {
  background-color: #f97316;
  color: #7c2d12;
}
.rarity-MRCP {
  background-color: #fbbf24;
  color: #78350f;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 列数別のグリッドスタイル */
.main-content .card-grid.grid-cols-1 {
  grid-template-columns: minmax(200px, 400px) !important;
}

.main-content .card-grid.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(200px, 1fr)) !important;
}

.main-content .card-grid.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(180px, 1fr)) !important;
}

.main-content .card-grid.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(160px, 1fr)) !important;
}

.main-content .card-grid.grid-cols-5 {
  grid-template-columns: repeat(5, minmax(140px, 1fr)) !important;
}

/* 列数切り替えボタン */
.grid-columns-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* PC版では5列ボタンのみ表示、モバイル版では5列ボタンを非表示 */
@media (max-width: 1024px) {
  .column-btn:nth-child(5) {
    display: none;
  }
}

@media (min-width: 1025px) {
  .column-btn:nth-child(1),
  .column-btn:nth-child(2),
  .column-btn:nth-child(3),
  .column-btn:nth-child(4) {
    display: none;
  }
}

.columns-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4b5563;
  white-space: nowrap;
}

.columns-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.column-btn {
  padding: 0.375rem 0.75rem;
  border: 1px solid #e5e7eb;
  background: white;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 44px;
}

.column-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.column-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* 1列表示時の調整 */
@media (max-width: 768px) {
  .card-grid.grid-cols-1 .card {
    display: flex;
    align-items: center;
    padding: 0.75rem;
  }

  .card-grid.grid-cols-1 .card-image {
    width: 100px;
    height: 140px;
    flex-shrink: 0;
    margin-right: 1rem;
  }

  .card-grid.grid-cols-1 .card-info {
    flex: 1;
  }

  .card-grid.grid-cols-1 .owned-counter {
    position: static;
    margin-left: auto;
    background: transparent;
    box-shadow: none;
  }
}

/* リストビュー */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.list-item {
  background-color: white;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow 0.2s;
  border: 2px solid transparent;
}

.list-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.list-item.color-青 {
  border-color: #3b82f6;
}
.list-item.color-赤 {
  border-color: #ef4444;
}
.list-item.color-緑 {
  border-color: #10b981;
}
.list-item.color-黄 {
  border-color: #f59e0b;
}
.list-item.color-黒 {
  border-color: #1f2937;
}
.list-item.color-白 {
  border-color: #9ca3af;
}

.list-item-image {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  background-color: #f0f0f0;
  flex-shrink: 0;
}

.list-item-info {
  flex: 1;
}

.list-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.list-item-title {
  font-weight: 600;
  color: #333;
}

.list-item-details {
  font-size: 0.875rem;
  color: #666;
}

/* デッキ検索ボタン */
.deck-search-control {
  margin-top: 1rem;
}

.deck-search-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: #10b981;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.deck-search-btn:hover {
  background-color: #059669;
}

.deck-search-btn:active {
  transform: scale(0.98);
}

/* グリッドビューのカードにホバー時に表示するボタン（オプション） */
.card-overlay-buttons {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  padding: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  gap: 0.5rem;
}

.card:hover .card-overlay-buttons {
  opacity: 1;
}

.quick-deck-search-btn {
  flex: 1;
  padding: 0.5rem;
  background-color: rgba(16, 185, 129, 0.9);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.quick-deck-search-btn:hover {
  background-color: rgba(5, 150, 105, 0.9);
}

@media (max-width: 1024px) {
  .main-content .card-grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(160px, 1fr)) !important;
  }

  .main-content .card-grid.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(140px, 1fr)) !important;
  }

  .main-content .card-grid.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(120px, 1fr)) !important;
  }
}

/* 1列表示 */
.card-list .owned-counter {
  display: none !important;
}

/* モバイルでの列数別スタイル */
/* モバイル専用グリッド設定 */
@media (max-width: 768px) {
  /* 共通設定 */
  .card-grid {
    gap: 2px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
  }

  .card-grid[class*="grid-cols-"] {
    gap: 2px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .card-grid[class*="grid-cols-"] .card {
    padding: 0 !important;
    margin: 0;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  /* 2列表示 */
  .main-content .card-grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  .card-grid.grid-cols-2 .card-image {
    height: auto;
    aspect-ratio: 0.72;
    width: 100%;
    object-fit: contain;
    background: #f0f0f0;
  }

  .card-grid.grid-cols-2 .card-info {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .card-grid.grid-cols-2 .card-title {
    font-size: 0.75rem;
  }

  /* 3列表示 - 画像のみ */
  .main-content .card-grid.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card-grid.grid-cols-3 .card {
    position: relative;
    background: #000;
  }

  .card-grid.grid-cols-3 .card-image {
    height: auto;
    aspect-ratio: 0.72;
    width: 100%;
    object-fit: contain;
  }

  .card-grid.grid-cols-3 .card-info {
    display: none !important;
  }

  .card-grid.grid-cols-3 .owned-counter {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.85);
    padding: 0 0.25rem;
    border-radius: 10px;
    gap: 2px;
  }

  .card-grid.grid-cols-3 .counter-btn {
    width: 18px;
    height: 18px;
    font-size: 0.625rem;
  }

  .card-grid.grid-cols-3 .counter-value {
    min-width: 20px;
    font-size: 0.625rem;
    color: white;
  }

  /* 4列表示 - 画像のみ、最小化 */
  .main-content .card-grid.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card-grid.grid-cols-4 .card {
    position: relative;
    background: #000;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
  }

  .card-grid.grid-cols-4 .card-image {
    height: auto;
    aspect-ratio: 0.72;
    width: 100%;
    object-fit: contain;
  }

  .card-grid.grid-cols-4 .card-info {
    display: none !important;
  }

  .card-grid.grid-cols-4 .owned-counter {
    position: absolute;
    bottom: 1px;
    right: 1px;
    background: rgba(0, 0, 0, 0.9);
    padding: 0 3px;
    border-radius: 6px;
    gap: 1px;
    transform: scale(0.85);
  }

  .card-grid.grid-cols-4 .counter-btn {
    width: 14px;
    height: 14px;
    font-size: 0.5rem;
  }

  .card-grid.grid-cols-4 .counter-value {
    min-width: 16px;
    font-size: 0.5rem;
    color: white;
  }

  /* ホバー効果を簡略化 */
  .card-grid[class*="grid-cols-"] .card:hover {
    transform: none;
    z-index: 10;
  }

  .card-grid[class*="grid-cols-"] .card:active {
    opacity: 0.8;
  }

  /* 3列以上でのホバー効果を簡略化 */
  .card-grid.grid-cols-3 .card:hover,
  .card-grid.grid-cols-4 .card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  /* タップ時のフィードバック */
  .card-grid.grid-cols-3 .card:active,
  .card-grid.grid-cols-4 .card:active {
    transform: scale(0.95);
  }
}

/* 画面の高さに合わせて調整 */
@media (max-width: 768px) and (max-height: 700px) {
  .main-content {
    padding: 0.25rem;
  }

  .grid-columns-toggle {
    padding: 0.375rem;
    margin-bottom: 0.375rem;
  }
}

/* iPhone SE等の小さい画面 */
@media (max-width: 375px) {
  .card-grid.grid-cols-4 {
    gap: 1px !important;
  }

  .card-grid.grid-cols-4 .owned-counter {
    display: none; /* 4列の場合は非表示も検討 */
  }

  /* または極小表示 */
  .card-grid.grid-cols-4.show-counters .owned-counter {
    display: flex;
    transform: scale(0.7);
  }
}

/* アコーディオン修正 */
@media (max-width: 768px) {
  .search-accordion-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
  }

  .search-accordion-content {
    max-height: 0;
    opacity: 0;
    padding: 0;
    transition: all 0.3s ease;
    overflow: hidden;
  }

  .search-accordion-content.show {
    max-height: 2000px;
    opacity: 1;
    padding: 1rem;
  }

  .search-accordion-icon {
    transition: transform 0.3s ease;
  }

  .search-accordion-header.active .search-accordion-icon {
    transform: rotate(180deg);
  }
}

/* 横向き対応 */
@media (max-width: 812px) and (orientation: landscape) {
  .main-content {
    padding: 0.25rem;
  }

  .card-grid[class*="grid-cols-"] {
    gap: 2px !important;
  }

  /* 横向きでは最大3列まで */
  .card-grid.grid-cols-4 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ビューポート高さを考慮した調整 */
.main-wrapper {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .main-wrapper {
    min-height: calc(100vh - 50px);
  }

  /* カードグリッドを画面いっぱいに */
  .card-search-component.mode-view {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .card-search-component.mode-view .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: white;
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.close-btn:hover {
  background-color: #f5f5f5;
}

.modal-body {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.modal-images {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-image {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-details {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.detail-badges {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.color-badge {
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  border: 2px solid transparent;
}

.owned-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #f3f4f6;
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

.owned-control label {
  font-weight: 600;
  color: #4b5563;
}

.detail-table {
  border-top: 1px solid #e5e5e5;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e5e5e5;
}

.detail-label {
  color: #666;
  font-size: 0.875rem;
}

.detail-value {
  font-weight: 600;
  color: #333;
}

.feature-section,
.categories-section {
  margin-top: 1rem;
}

.feature-title,
.categories-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
}

.feature-text {
  background-color: #f9fafb;
  padding: 1rem;
  border-radius: 8px;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #333;
  font-size: 0.875rem;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-tag {
  background-color: #e5e7eb;
  color: #4b5563;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
}

/* ローディング */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes selectPulse {
  0% {
    transform: scale(1.15);
  }
  50% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1.15);
  }
}

.loading-text {
  margin-top: 1rem;
  color: #666;
}

/* エラー */
.error {
  text-align: center;
  padding: 4rem 2rem;
}

.error-icon {
  font-size: 3rem;
  color: #ef4444;
  margin-bottom: 1rem;
}

.error-message {
  color: #333;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.error-details {
  color: #666;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* 検索結果なし */
.no-results {
  text-align: center;
  padding: 4rem 2rem;
  color: #666;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .search-grid {
    grid-template-columns: 1fr;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  /* .card-grid の汎用設定はコメントアウト（個別設定を優先） */
  /* .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  } */

  .card-image {
    height: 200px;
  }

  color-buttons {
    gap: 0.375rem; /* 間隔を少し狭く */
  }

  .color-btn {
    width: 42px; /* 少し小さく */
    height: 42px;
    font-size: 0.75rem; /* 文字も少し小さく */
    flex-shrink: 0; /* 縮小させない */
  }

  /* スクロールバーのスタイル（Webkit系） */
  .color-buttons::-webkit-scrollbar {
    height: 4px;
  }

  .color-buttons::-webkit-scrollbar-track {
    background: transparent;
  }

  .color-buttons::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
  }
}

/* アニメーション */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.list-item {
  animation: fadeIn 0.3s ease-out;
}

/* アコーディオンヘッダー（デフォルトは非表示） */
.search-accordion-header {
  display: none;
  padding: 1rem;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

/* 小さいスマホ（iPhone SE等）での追加調整 */
@media (max-width: 375px) {
  .card-grid.grid-cols-3 {
    gap: 1px !important;
  }

  .card-grid.grid-cols-4 {
    gap: 1px !important;
  }

  .card-grid.grid-cols-4 .card {
    border-width: 0;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1);
  }

  .card-grid.grid-cols-4 .owned-counter {
    transform: scale(0.7);
  }
}

/* タブレット（iPadなど）では通常表示を維持 */
@media (min-width: 769px) and (max-width: 1024px) {
  /* タブレットでは情報も含めて表示 */
  .card-grid[class*="grid-cols-"] .card-info {
    display: block !important;
  }

  .card-grid[class*="grid-cols-"] .card {
    padding: 1rem !important;
  }

  .card-grid[class*="grid-cols-"] .owned-counter {
    position: absolute !important;
    top: 0.5rem !important;
    right: 0.5rem !important;
    background-color: rgba(255, 255, 255, 0.95) !important;
    padding: 0.25rem 0.5rem !important;
  }

  .card-grid[class*="grid-cols-"] .counter-btn {
    width: 24px !important;
    height: 24px !important;
  }

  .card-grid[class*="grid-cols-"] .counter-value {
    color: #333 !important;
  }
}

/* アニメーション最適化 */
@media (max-width: 768px) {
  .card-grid.grid-cols-3 .card,
  .card-grid.grid-cols-4 .card {
    /* モバイルでのパフォーマンス向上 */
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
  }
}
#back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0;
  pointer-events: none;
}

#back-to-top.show {
  opacity: 1;
  pointer-events: auto;
}

#back-to-top:hover {
  background-color: #2563eb;
}

/* PC版では列数切り替えを表示し、デフォルトは5列 */
@media (min-width: 1025px) {
  .grid-columns-toggle {
    display: none !important; /* PC版では非表示 */
  }

  /* 5列ボタンをデフォルトでアクティブに */
  .column-btn:nth-child(5) {
    display: inline-block !important;
  }

  /* モバイル用の1-4列ボタンは非表示 */
  .column-btn:nth-child(1),
  .column-btn:nth-child(2),
  .column-btn:nth-child(3),
  .column-btn:nth-child(4) {
    display: none !important;
  }

  /* デフォルトで5列表示 */
  .card-grid {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}

/* タブレット・モバイル */
@media (max-width: 1024px) {
  /* 5列ボタンを非表示 */
  .column-btn:nth-child(5) {
    display: none !important;
  }

  /* 1-4列ボタンを表示 */
  .column-btn:nth-child(1),
  .column-btn:nth-child(2),
  .column-btn:nth-child(3),
  .column-btn:nth-child(4) {
    display: inline-block !important;
  }
}

/* いいねボタンスタイル */
.like-control {
  margin: 1rem 0;
}

.like-card-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.like-card-btn:before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.like-card-btn:hover:before {
  left: 100%;
}

.like-card-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.like-card-btn:active {
  transform: translateY(0);
}

.like-card-btn.liked {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
  animation: likeAnimation 0.5s ease;
}

.like-card-btn.liked:hover {
  box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5);
}

.like-icon {
  font-size: 1.2rem;
  display: inline-block;
  transition: transform 0.3s ease;
}

.like-card-btn:hover .like-icon {
  transform: scale(1.2) rotate(10deg);
}

.like-card-btn.liked .like-icon {
  animation: heartBeat 0.5s ease;
}

@keyframes likeAnimation {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(0.95);
  }
  50% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes heartBeat {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1);
  }
  75% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* フィルタードロップダウン追加スタイル */
.search-group .filter-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4b5563;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.filter-label .filter-icon {
  color: #f5576c;
  font-size: 1rem;
}

/* アニメーション */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 販売サイトリンクセクション */
.market-links-section {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 12px;
}

.market-links-section .section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
}

.market-links-section .section-title .icon {
  font-size: 1.2rem;
}

.market-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.market-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 0.875rem;
  background: white;
  color: #333;
  text-decoration: none;
  border-radius: 8px;
  border: 2px solid var(--link-color, #e0e0e0);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.market-link-btn:before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transition: left 0.5s ease;
}

.market-link-btn:hover:before {
  left: 100%;
}

.market-link-btn:hover {
  background: var(--link-color, #f5f5f5);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.market-link-btn .link-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.market-link-btn .link-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-link-btn .link-arrow {
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.market-link-btn:hover .link-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* アクティブ時のエフェクト */
.market-link-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* モバイル対応 */
@media (max-width: 768px) {
  .market-links-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .market-link-btn {
    padding: 0.5rem 0.625rem;
    font-size: 0.75rem;
  }

  .market-link-btn .link-icon {
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .market-links-grid {
    grid-template-columns: 1fr;
  }

  .market-link-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* ダークモード対応（オプション） */
@media (prefers-color-scheme: dark) {
  .market-links-section {
    background: #1a1a1a;
  }

  .market-link-btn {
    background: #2a2a2a;
    color: #e0e0e0;
  }

  .market-link-btn:hover {
    color: white;
  }
}
