* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

header {
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-content {
  max-width: 1790px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.site-subtitle {
  font-size: 12px;
  color: #888;
  margin: 0;
  padding-left: 2px;
}

h1 {
  font-size: 24px;
  color: #333;
}

h1 a {
  text-decoration: none;
  color: inherit;
  transition: color 0.3s ease;
}

h1 a:hover {
  color: #667eea;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-menu {
  position: relative;
}

.language-menu {
  position: relative;
}

.menu-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  white-space: nowrap;
}

.language-btn,
.category-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; /* 国旗絵文字対応 */
}

.menu-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.language-btn:hover,
.category-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.category-dropdown,
.language-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  margin-top: 8px;
  min-width: 200px;
  overflow: hidden;
  z-index: 1001;
}

.category-dropdown.show,
.language-dropdown.show {
  display: block;
}

.category-item,
.language-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: #333;
  text-decoration: none;
  transition: background 0.3s ease;
  font-size: 15px;
  cursor: pointer;
}

.category-item:hover,
.language-item:hover {
  background: #f5f5f5;
}

.language-dropdown {
  max-height: 400px;
  overflow-y: auto;
}

/* ========================================
   タグフィルターバー（Pexels風）
   ======================================== */

.tags-filter-bar {
  background: white;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 76px;
  z-index: 999;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* タグバーラッパー（矢印を右左端に配置） */
.tags-filter-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1790px;
  padding: 0 20px;
}

/* 矢印ボタン */
.scroll-arrow {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  color: #667eea;
  font-size: 18px;
  font-weight: bold;
  z-index: 10;
  margin: 0 10px;
}

.scroll-arrow:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.scroll-arrow:active {
  transform: scale(0.95);
}

.scroll-left {
  /* margin-left: 10px; 削除 */
}

.scroll-right {
  /* margin-left: 10px; 削除 */
}

/* 横スクロールコンテナ */
.tags-scroll-container {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  position: relative;
  /* max-width を削除して親幅いっぱいに表示 */
  margin: 0;
  padding: 12px 0;  /* 上下のパディングを追加 */
}

.tags-scroll-container::-webkit-scrollbar {
  display: none;
}

/* タグボタンコンテナ */
#tagsButtons {
  display: flex;
  gap: 10px;
  padding: 15px 0;
  white-space: nowrap;
  min-width: min-content;
}

/* タグフィルターボタン（絵文字のみ） */
.tag-filter-btn {
  padding: 10px 16px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 20px;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #333;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tag-filter-btn:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

/* アクティブなタグボタン */
.tag-filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tag-filter-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* ========================================
   メインコンテンツ
   ======================================== */

.container {
  max-width: 1790px;
  margin: 0 auto;
  padding: 30px 20px;
  min-height: 400px;
}

.page-title {
  font-size: 32px;
  margin-bottom: 30px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-section {
  margin-bottom: 50px;
  transition: opacity 0.3s ease;
}

/* トップページ: カテゴリを横に4つ並べる */
body.index-page #categoriesContainer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
}

body.index-page .category-section {
  margin-bottom: 0;
}

body.index-page .category-title {
  font-size: 20px;
  margin-bottom: 15px;
}

.category-section.hidden {
  display: none;
}

.category-title {
  font-size: 28px;
  margin-bottom: 20px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.category-title:hover {
  color: #667eea;
  text-decoration: underline;
}

.more-link {
  font-size: 16px;
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
  white-space: nowrap;
}

body.index-page .more-link {
  font-size: 14px;
}

.more-link:hover {
  color: #764ba2;
  text-decoration: underline;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 25px;
  margin-bottom: 30px;
}

/* トップページ: 1枚表示 */
body.index-page .image-grid {
  grid-template-columns: 1fr;
  max-width: 600px;
}

.image-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.image-card a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.image-card:hover {
  transform: translateY(-8px) rotate(-1deg);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.image-card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  min-height: 280px; /* 縦長に合わせて調整 */
  /* background: #f0f0f0; 削除：背景色が画像を隠す原因 */
}

.loading {
  text-align: center;
  padding: 50px;
  font-size: 18px;
  color: #999;
}

.empty {
  text-align: center;
  padding: 50px;
  font-size: 18px;
  color: #999;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* ========================================
   フッター
   ======================================== */

footer {
  text-align: center;
  padding: 30px 20px;
  background: white;
  border-top: 1px solid #e0e0e0;
  color: #666;
  font-size: 14px;
}

/* ========================================
   レスポンシブ対応
   ======================================== */

@media (max-width: 768px) {
  /* トップページ: モバイルでは2列 */
  body.index-page #categoriesContainer {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  
  .header-content {
    padding: 15px;
  }
  
  h1 {
    font-size: 18px;
  }
  
  .menu-btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .tags-filter-bar {
    top: 63px;
    padding: 0 10px;
  }
  
  .tags-filter-wrapper {
    padding: 0; /* モバイルで左右の余白を削除 */
  }
  
  .tags-scroll-container {
    padding: 4px 0; /* 上下スペースを3分の1に */
  }
  
  .scroll-arrow {
    width: 35px;
    height: 35px;
    font-size: 16px;
    margin: 0; /* 左右端に配置 */
  }
  
  .scroll-arrow:first-child {
    margin-left: 0; /* 左端に寄せる */
  }
  
  .scroll-arrow:last-child {
    margin-right: 0; /* 右端に寄せる */
  }
  
  .scroll-left {
    margin-right: 8px;
  }
  
  .scroll-right {
    margin-left: 8px;
  }
  
  .tags-buttons {
    gap: 8px;
    padding: 4px 0; /* 上下スペースを3分の1に */
  }
  
  .tag-filter-btn {
    padding: 8px 14px;
    font-size: 20px;
    min-width: 45px;
  }
  
  .container {
    padding: 20px 15px;
  }
  
  .page-title {
    font-size: 24px;
    margin-bottom: 20px;
  }
  
  .category-title {
    font-size: 22px;
    margin-bottom: 15px;
  }
  
  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
  }
  
  /* トップページ: 1枚表示 */
  body.index-page .image-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 16px;
  }
  
  .menu-btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .scroll-arrow {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .tag-filter-btn {
    padding: 6px 12px;
    font-size: 18px;
    min-width: 42px;
  }
  
  .page-title {
    font-size: 20px;
  }
  
  .category-title {
    font-size: 18px;
  }
  
  .image-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

/* ========================================
   カテゴリヘッダー
   ======================================== */

.category-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
  padding: 20px 0;
  border-bottom: 2px solid #667eea;
}

.category-header span {
  font-size: 48px;
}

.category-header h2 {
  font-size: 32px;
  color: #333;
  margin: 0;
  font-weight: 600;
}

@media (max-width: 768px) {
  .category-header {
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px 0;
  }
  
  .category-header span {
    font-size: 36px;
  }
  
  .category-header h2 {
    font-size: 24px;
  }
}

/* ========================================
   詳細ページ（detail.html）
   ======================================== */

.detail-page {
  max-width: 1790px;
  margin: 0 auto;
  padding: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #667eea;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.back-link:before {
  content: '←';
  font-size: 20px;
}

.back-link:hover {
  color: #764ba2;
  transform: translateX(-5px);
}

/* 画像ナビゲーション */
/* Navigation controls container */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  flex-shrink: 0;
}

.nav-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.nav-btn-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-btn-back {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

.nav-btn-back:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(245, 87, 108, 0.6);
}

.nav-btn-back:active {
  transform: translateY(0);
}

/* 画像コンテナ */
.detail-image-container {
  width: 100%;
  max-width: 1790px;
  margin: 0 auto 30px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.detail-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* 広告コンテナ */
.ad-container {
  max-width: 1790px;
  margin: 30px auto;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 12px;
  text-align: center;
  min-height: 90px;
}

/* ダウンロードボタン */
.detail-actions {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0;
  flex-wrap: wrap;
}

.action-buttons {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

/* Goodボタン */
.vote-btn {
  background: white;
  color: #ff6b6b;
  border: 2px solid #ff6b6b;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.2);
  min-width: 200px;
}

.vote-btn:hover {
  background: #ff6b6b;
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

.vote-btn:active {
  transform: translateY(-1px);
}

.vote-btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.download-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  min-width: 200px;
}

.download-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

.download-btn:active {
  transform: translateY(-1px);
}

.download-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.download-btn-pc {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  width: 240px; /* PCとスマホのボタン幅を完全に統一 */
  flex-shrink: 0; /* 縮小を防ぐ */
}

.download-btn-phone {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  width: 240px; /* PCとスマホのボタン幅を完全に統一 */
  flex-shrink: 0; /* 縮小を防ぐ */
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .detail-page {
    padding: 15px;
  }
  
  .back-link {
    font-size: 14px;
    margin-bottom: 15px;
  }
  
  .nav-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .detail-image-container {
    margin-bottom: 20px;
    border-radius: 12px;
  }
  
  .ad-container {
    margin: 20px auto;
    padding: 15px;
  }
  
  .detail-actions {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }
  
  .nav-controls {
    justify-content: center;
    width: 100%;
  }
  
  .action-buttons {
    width: 100%;
    justify-content: center;
  }
  
  .nav-btn-back {
    padding: 10px 20px;
    font-size: 13px;
  }
  
  .download-btn {
    width: 100%;
    min-width: auto;
    padding: 14px 24px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .detail-page {
    padding: 10px;
  }
  
  .back-link {
    font-size: 13px;
  }
  
  .nav-btn {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }
  
  .detail-image-container {
    border-radius: 8px;
  }
  
  .download-btn {
    padding: 12px 20px;
    font-size: 15px;
  }
}

/* ========================================
   利用規約ページ
   ======================================== */

.terms-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

.terms-page h1 {
  font-size: 36px;
  color: #333;
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 3px solid #667eea;
}

.terms-section {
  margin-bottom: 40px;
  padding: 30px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.terms-section h2 {
  font-size: 24px;
  color: #667eea;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.terms-section h2:before {
  content: '📋';
  font-size: 28px;
}

.terms-section p {
  font-size: 16px;
  line-height: 1.8;
  color: #555;
  margin-bottom: 15px;
}

.terms-section ul {
  list-style: none;
  padding-left: 0;
  margin-top: 15px;
}

.terms-section ul li {
  font-size: 16px;
  line-height: 1.8;
  color: #555;
  padding: 10px 0;
  padding-left: 30px;
  position: relative;
}

.terms-back {
  text-align: center;
  margin-top: 50px;
}

.back-btn {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  padding: 15px 40px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.back-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .terms-page {
    padding: 30px 15px;
  }
  
  .terms-page h1 {
    font-size: 28px;
    margin-bottom: 30px;
  }
  
  .terms-section {
    padding: 20px;
    margin-bottom: 30px;
  }
  
  .terms-section h2 {
    font-size: 20px;
  }
  
  .terms-section p,
  .terms-section ul li {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .terms-page h1 {
    font-size: 24px;
  }
  
  .terms-section {
    padding: 15px;
  }
  
  .terms-section h2 {
    font-size: 18px;
  }
  
  .terms-section p,
  .terms-section ul li {
    font-size: 14px;
  }
}

/* ヘッダーに利用規約リンクを追加 */
.terms-link,
.popular-link,
.privacy-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #667eea;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: rgba(102, 126, 234, 0.1);
}

.terms-link:hover,
.popular-link:hover,
.privacy-link:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: translateY(-2px);
}

/* ===== 画像の遅延読み込み & アニメーション ===== */
.image-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.image-card.loaded {
  opacity: 1;
  transform: translateY(0);
}

.image-card img {
  width: 100%;
  height: auto;
  display: block;
  min-height: 280px; /* 縦長に合わせて調整 */
  object-fit: contain;
  opacity: 1 !important;
  visibility: visible !important;
  position: relative;
  z-index: 1;
  transition: opacity 0.4s ease;
}

.image-card img.loaded {
  opacity: 1 !important;
  display: block !important;
}

/* 人気ランキングページ用（詳細度を上げる） */
.popular-card img {
  width: 100% !important;
  height: auto !important;
  min-height: 280px !important; /* 縦長に合わせて調整 */
  object-fit: contain !important;
  display: block !important;
}

.popular-card img.loaded {
  opacity: 1 !important;
  display: block !important;
  visibility: visible !important;
}

/* デバッグ用：強制表示 */
.image-card.popular-card img {
  opacity: 1 !important;
}

/* ===== カテゴリページ: 12枚ごとに挿入するAdSense枠 ===== */
.ad-container-grid {
  grid-column: 1 / -1; /* グリッド全幅 */
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 728pxが入らない端末では縮めて表示 */
.ad-container-grid ins.adsbygoogle {
  max-width: 100%;
}

/* ===== 人気ランキングページ専用スタイル ===== */
.rank-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  color: white;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.rank-badge.rank-gold {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #333;
}

.rank-badge.rank-silver {
  background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
  color: #333;
}

.rank-badge.rank-bronze {
  background: linear-gradient(135deg, #cd7f32, #e8b87d);
  color: white;
}

.vote-info {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
  z-index: 10;
  backdrop-filter: blur(5px);
}

/* 画像カードのリンクを relative にして、バッジと投票情報を配置 */
.popular-card a {
  position: relative;
  display: block;
}

/* 画像が確実に表示されるように、z-index を下げる */
.popular-card img {
  position: relative;
  z-index: 1;
}

/* ===== 人気ランキング専用：カードの opacity を強制的に 1 に ===== */
.popular-card {
  opacity: 1 !important;
  transform: translateY(0) !important;
}


/* ===== モバイル用ヘッダー改善 ===== */
@media (max-width: 768px) {
  /* ヘッダー全体を縮小 */
  header {
    padding: 10px 0;
  }
  
  .header-content {
    flex-direction: column;
    gap: 10px;
    padding: 10px 15px;
  }
  
  .header-left {
    text-align: center;
    width: 100%;
  }
  
  .header-left h1 {
    font-size: 16px;
    margin-bottom: 5px;
  }
  
  .site-subtitle {
    font-size: 11px;
  }
  
  .header-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }
  
  .popular-link,
  .terms-link,
  .privacy-link {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .language-menu,
  .category-menu {
    position: relative;
  }
  
  .language-btn,
  .category-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .language-dropdown,
  .category-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 150px;
  }
}
/* ===== 共有ボタンのスタイル（アイコンのみ） ===== */
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: white;
  margin: 5px;
  width: 48px;
  height: 48px;
  min-width: 48px;
}

.share-btn svg {
  width: 24px;
  height: 24px;
}

.share-pinterest {
  background: #E60023;
}

.share-pinterest:hover {
  background: #ad081b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(230, 0, 35, 0.3);
}

.share-x {
  background: #000000;
}

.share-x:hover {
  background: #333333;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.share-copy {
  background: #667eea;
}

.share-copy:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* モバイル対応 */
@media (max-width: 768px) {
  .share-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 10px;
  }
  
  .share-btn svg {
    width: 20px;
    height: 20px;
  }
}

/* ===== モバイルでヘッダーボタンをアイコンのみに変更 ===== */
@media (max-width: 768px) {
  /* ヘッダーのリンクテキストを非表示 */
  .popular-link span,
  .terms-link span,
  .privacy-link span {
    display: none;
  }
  
  /* アイコンのみ表示 */
  .popular-link,
  .terms-link,
  .privacy-link {
    padding: 8px 12px;
    font-size: 18px;
    min-width: auto;
  }
  
  /* 言語ボタンのテキストを非表示 */
  .language-btn {
    padding: 8px 12px;
    font-size: 18px;
    min-width: auto;
  }
  
  /* カテゴリボタンのテキストを非表示 */
  .category-btn {
    padding: 8px 12px;
    font-size: 18px;
    min-width: auto;
  }
}

/* ===== モバイルでヘッダーボタンを1行表示 ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
  }
  
  .header-left {
    flex: 0 0 auto;
    text-align: left;
  }
  
  .header-left h1 {
    font-size: 14px;
    margin-bottom: 2px;
  }
  
  .site-subtitle {
    font-size: 10px;
  }
  
  .header-actions {
    flex: 1;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 5px;
  }
  
  .popular-link,
  .terms-link,
  .privacy-link,
  .language-btn,
  .category-btn {
    padding: 6px 8px;
    font-size: 16px;
    min-width: 32px;
  }
  
  /* 言語ボタンの span を非表示 */
  .language-btn span {
    display: none;
  }
}

/* ===== AdSense 広告の最適化 ===== */
.ad-container,
.ad-container-grid {
  width: 100%;
  max-width: 1790px;
  margin: 20px auto;
  padding: 15px;
  overflow: hidden;
}

.ad-container ins.adsbygoogle,
.ad-container-grid ins.adsbygoogle {
  display: block;
  width: 100%;
}

/* モバイルでの高さ制限 */
@media (max-width: 768px) {
  .ad-container,
  .ad-container-grid {
    max-height: 300px;
    overflow: hidden;
  }
  
  .ad-container ins.adsbygoogle,
  .ad-container-grid ins.adsbygoogle {
    max-height: 250px;
  }
}

/* ヘッダータイトル行の横並び */
.header-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.header-title-row h1 {
  margin: 0;
}

.header-title-row .site-subtitle {
  font-size: 14px;
  color: #888;
  white-space: nowrap;
}

/* モバイル: タイトルとサブタイトルを横並び維持 */
@media (max-width: 768px) {
  .header-title-row {
    gap: 8px;
  }
  
  .header-title-row h1 {
    font-size: 16px;
  }
  
  .header-title-row .site-subtitle {
    font-size: 11px;
  }
}

/* モバイルヘッダーボタンの超コンパクト化 */
@media (max-width: 768px) {
  .header-actions {
    gap: 4px !important;
    padding: 0 !important;
  }
  
  .popular-link,
  .terms-link,
  .privacy-link,
  .language-btn,
  .category-btn {
    padding: 6px 8px !important;
    font-size: 16px !important;
    min-width: auto !important;
  }
  
  .language-btn {
    min-width: 36px !important;
  }
  
  .category-btn {
    min-width: 36px !important;
  }
}

/* モバイル: カテゴリページを2列表示 */
@media (max-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 15px;
  }
  
  /* 画像詳細ページの _phone 画像を75%サイズに */
  .detail-image {
    max-width: 75% !important;
    height: auto;
  }
}

/* モバイル: ダウンロードボタンとGoodボタンを1行に */
@media (max-width: 768px) {
  .action-buttons {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    justify-content: space-between !important;
  }
  
  .action-buttons button {
    flex: 1 !important;
    padding: 10px 8px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    min-width: 0 !important;
  }
  
  /* ボタンのテキストを調整 */
  #voteBtn {
    flex: 0.8 !important;
  }
  
  #downloadBtnPC,
  #downloadBtnPhone {
    flex: 1.1 !important;
  }
}

/* モバイル: ヘッダーのボタンをタイトルの下の行に配置 */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  
  .header-left {
    width: 100% !important;
    margin-bottom: 0 !important;
  }
  
  .header-actions {
    width: 100% !important;
    justify-content: space-around !important;
    padding: 8px 0 !important;
    gap: 6px !important;
  }
}

/* モバイル: スクロールボタンを画面端に配置 */
@media (max-width: 768px) {
  .scroll-left {
    margin-left: 0 !important;
    position: absolute;
    left: 5px;
    z-index: 100;
  }
  
  .scroll-right {
    margin-right: 0 !important;
    position: absolute;
    right: 5px;
    z-index: 100;
  }
  
  .tags-filter-bar {
    position: relative;
  }
}

/* モバイル: 画像詳細ページの黒い部分を削除 */
@media (max-width: 768px) {
  .detail-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: white !important;
    width: 100%;
    overflow: hidden;
  }
  
  .detail-image {
    max-width: 75% !important;
    width: 75% !important;
    height: auto;
    display: block;
    margin: 0 auto;
  }
}

/* ヘッダー折りたたみボタン（モバイルのみ） */
.header-toggle-btn {
  display: none; /* デフォルトは非表示 */
}

@media (max-width: 768px) {
  .header-toggle-btn {
    display: block;
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
  }
  
  .header-toggle-btn:hover {
    background: #5568d3;
    transform: scale(1.1);
  }
  
  .header-toggle-btn:active {
    transform: scale(0.95);
  }
  
  /* ヘッダーが折りたたまれた状態 */
  .header-collapsed .header-content {
    display: none;
  }
  
  .header-collapsed {
    padding: 0 !important;
    min-height: 0 !important;
  }
}

/* モバイル: ヘッダーとフィルターの間のスペースを削除 */
@media (max-width: 768px) {
  header {
    margin-bottom: 0 !important;
    padding-bottom: 10px !important;
  }
  
  .tags-filter-bar {
    top: auto !important;
    margin-top: 0 !important;
  }
}

/* モバイル: 折りたたみボタンを最前面に表示 */
@media (max-width: 768px) {
  .header-toggle-btn {
    z-index: 9999 !important;
    position: fixed !important;
    top: 10px !important;
    right: 10px !important;
    display: block !important;
  }
}

/* モバイル: 画像詳細ページの _phone 画像を100%表示 + 上下100pxトリミング */
@media (max-width: 768px) {
  .detail-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: white !important;
    width: 100vw; /* ビューポート幅いっぱいに表示 */
    margin-left: calc(-1 * (100vw - 100%) / 2); /* 左右の余白を打ち消す */
    margin-right: calc(-1 * (100vw - 100%) / 2);
    padding: 0 !important;
  }
  
  .detail-image {
    max-width: 100% !important;
    width: 100% !important; /* 画面左右端まで表示 */
    max-height: none !important;
    height: auto;
    display: block;
    margin: 0;
    object-fit: contain;
    object-position: center;
  }
}

/* モバイル: 3行レイアウト / デスクトップ: 従来のレイアウト */
.mobile-button-layout {
  display: none; /* デフォルトは非表示 */
}

.desktop-button-layout {
  display: flex; /* デフォルトは表示 */
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 768px) {
  /* モバイル: 3行レイアウトを表示 */
  .mobile-button-layout {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }
  
  .desktop-button-layout {
    display: none !important;
  }
  
  /* 各行のスタイル */
  .button-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  
  /* 1行目: ナビゲーション */
  .nav-row {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
  }
  
  .nav-row .nav-btn,
  .nav-row .nav-btn-back {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    text-align: center;
  }
  
  /* 2行目: Good + ダウンロード */
  .download-row {
    gap: 6px;
  }
  
  .download-row button {
    flex: 1;
    padding: 10px 8px;
    font-size: 12px;
    white-space: nowrap;
  }
  
  .download-row .vote-btn {
    flex: 0.8;
  }
  
  /* 3行目: 共有 */
  .share-row {
    justify-content: space-around;
    gap: 12px;
  }
  
  .share-row .share-btn {
    flex: 1;
    max-width: 100px;
  }
}

/* 画像詳細ページの新しいレイアウト */
.detail-image-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

/* オーバーレイボタン（画像の上に配置） */
.overlay-btn {
  position: absolute;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* カテゴリに戻るボタン（左上） */
.back-to-category-btn {
  top: 15px;
  left: 15px;
  background: #667eea;
  color: white;
  text-decoration: none;
  display: inline-block;
}

.back-to-category-btn:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

/* Goodボタン（右上） */
.vote-btn-overlay {
  top: 15px;
  right: 15px;
  background: white;
  color: #333;
  border: 2px solid #e0e0e0;
  padding: 8px 12px !important;
  width: auto !important;
  min-width: 60px;
}

.vote-btn-overlay:hover {
  border-color: #667eea;
  transform: translateY(-2px);
}

/* ダウンロードと共有ボタンエリア */
.detail-actions-new {
  margin: 20px 0;
}

/* デスクトップ: ダウンロード + 共有 を同じ行 */
.desktop-download-share {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  position: relative;
}

.download-buttons-group {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.share-buttons-group {
  display: flex;
  gap: 10px;
  position: absolute;
  right: 0;
}

/* モバイル用レイアウト（デフォルトは非表示） */
.mobile-download-share {
  display: none;
}

/* モバイル: ダウンロード（1行目）+ 共有（2行目） */
@media (max-width: 768px) {
  .desktop-download-share {
    display: none !important;
  }
  
  .mobile-download-share {
    display: flex !important;
    flex-direction: column;
    gap: 15px;
  }
  
  .download-buttons-group-mobile {
    display: flex;
    gap: 8px;
    justify-content: center;
  }
  
  .download-buttons-group-mobile button {
    flex: 1;
    padding: 12px 10px;
    font-size: 13px;
  }
  
  .share-buttons-group-mobile {
    display: flex;
    justify-content: center;
    gap: 15px;
  }
  
  .share-buttons-group-mobile .share-btn {
    flex: 0;
    width: 48px;
    height: 48px;
  }
  
  /* オーバーレイボタンのモバイル調整 */
  .overlay-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .back-to-category-btn {
    top: 10px;
    left: 10px;
  }
  
  .vote-btn-overlay {
    top: 10px;
    right: 10px;
  }
}

/* 関連画像セクション */
.related-images-section {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 2px solid #e0e0e0;
}

.related-images-section h3 {
  font-size: 24px;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

/* 画像詳細ページのナビゲーションボタンを画像の左右端に配置 */
.detail-image-wrapper {
    position: relative;
}

.prev-btn-detail,
.next-btn-detail {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.prev-btn-detail {
    left: 10px;
}

.next-btn-detail {
    right: 10px;
}

.prev-btn-detail:hover,
.next-btn-detail:hover {
    background: #667eea;
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.prev-btn-detail:active,
.next-btn-detail:active {
    transform: translateY(-50%) scale(0.95);
}

/* モバイルでのボタンサイズ調整 */
@media (max-width: 768px) {
    .prev-btn-detail,
    .next-btn-detail {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .prev-btn-detail {
        left: 5px;
    }
    
    .next-btn-detail {
        right: 5px;
    }
}
