* {
  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: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

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

.category-menu {
  position: relative;
  margin-left: auto;
}

.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;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-direction: row;
  writing-mode: horizontal-tb;
}

.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;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-direction: row;
  writing-mode: horizontal-tb;
}

.menu-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.6);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.category-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.6);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

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

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

.category-item {
  display: block;
  padding: 12px 20px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s;
}

.category-item:hover {
  background: #f0f0f0;
}

.container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.back-link {
  margin-bottom: 20px;
}

.back-link a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
}

.back-link a:hover {
  text-decoration: underline;
}

.page-title {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 30px;
}

.category-section {
  margin-bottom: 60px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.category-title {
  font-size: 28px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 12px;
}

.more-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.more-link:hover {
  text-decoration: underline;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

@media (max-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* スマホでカテゴリボタンのサイズ調整 */
  .menu-btn,
  .category-btn {
    padding: 10px 20px;
    font-size: 14px;
    gap: 6px;
    border-radius: 10px;
  }

  h1 {
    font-size: 18px;
  }

  .header-content {
    padding: 15px;
  }

  /* スマホで広告エリアを横長に制限 */
  .ad-container {
    margin: 15px auto;
    min-height: 60px;
    max-height: 100px;
    padding: 8px;
  }

  .detail-image-container {
    margin-bottom: 15px;
  }

  .detail-actions {
    margin: 15px 0 20px 0;
  }
}

.image-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.image-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.image-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.empty {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* 詳細ページ */
.detail-page {
  max-width: 1200px;
  margin: 0 auto;
}

.detail-content {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.back-link {
  display: inline-block;
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 20px;
}

.back-link:hover {
  text-decoration: underline;
}

.detail-image-container {
  width: 100%;
  margin-bottom: 20px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.detail-image {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  display: block;
  background: #f5f5f5;
}

.image-container {
  text-align: center;
  margin-bottom: 30px;
}

.detail-actions {
  text-align: center;
  margin: 20px 0 30px 0;
}

.ad-container {
  margin: 20px auto;
  max-width: 100%;
  min-height: 90px;
  max-height: 120px;
  background: #f8f9fa;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border: 1px dashed #e0e0e0;
  overflow: hidden;
}

/* 広告が読み込まれていない場合でもスペースを確保 */
.ad-container:empty::before {
  content: '';
  display: block;
}

/* 横長広告用の推奨サイズ */
.ad-container ins {
  display: block;
  width: 100%;
  min-height: 50px;
  max-height: 100px;
  overflow: hidden;
}

/* スマホでの広告サイズ制限 */
@media (max-width: 768px) {
  .ad-container ins {
    min-height: 50px;
    max-height: 90px;
  }
}

.download-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  padding: 16px 48px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

footer {
  background: #333;
  color: white;
  text-align: center;
  padding: 30px 20px;
  margin-top: 60px;
}
