/* 有機的なフォントの適用 */
body {
  font-family: 'Comfortaa', 'Noto Sans JP', sans-serif;
  font-weight: 400;
}

/* タイトルに流れるような筆記体 */
h1, h2 {
  font-family: 'Kaushan Script', 'Caveat', cursive;
  font-weight: 400;
  letter-spacing: 1px;
}

/* 用語名に手書き風フォント */
.term-name, th {
  font-family: 'Kalam', 'Comfortaa', cursive;
  font-weight: 700;
}

/* 説明文は読みやすい有機的フォント */
.glossary-description, td {
  font-family: 'Comfortaa', 'Noto Sans JP', sans-serif;
  line-height: 1.8;
}

/* カテゴリタグに遊び心のあるフォント */
.category-tag, .term-id {
  font-family: 'Amatic SC', 'Kalam', cursive;
  font-weight: 700;
  font-size: 16px;
}

/* 有機的なアニメーション */
@keyframes organic-float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33% { transform: translateY(-5px) rotate(-1deg); }
  66% { transform: translateY(3px) rotate(1deg); }
}

@keyframes leaf-sway {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

/* 見出しのアニメーション */
h1 {
  animation: organic-float 6s ease-in-out infinite;
  color: #2e7d32;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

/* ホバー効果 */
tr {
  transition: all 0.3s ease;
}

tr:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

/* 検索ボタンの有機的デザイン */
.search-button {
  background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
  border: none;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  font-family: 'Kalam', 'Comfortaa', cursive;
}

.search-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(76, 175, 80, 0.3);
  background: linear-gradient(135deg, #388e3c 0%, #66bb6a 100%);
}

/* カテゴリタグの装飾 */
.category-tag {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.category-tag::before {
  content: '🌱';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: all 0.3s ease;
}

.category-tag:hover::before {
  left: 5px;
  opacity: 1;
}

.category-tag:hover {
  padding-left: 25px;
  transform: scale(1.05);
}

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

.filter-container {
  background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
  padding: 15px;
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.15);
  border: 1px solid #c8e6c9;
  position: relative;
  overflow: hidden;
}

/* フィルターコンテナの装飾 */
.filter-container::before {
  content: '🌿';
  position: absolute;
  top: -10px;
  right: 20px;
  font-size: 40px;
  opacity: 0.3;
  transform: rotate(15deg);
  animation: leaf-sway 4s ease-in-out infinite;
}

.search-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

input[type='text'] {
  flex-grow: 1;
  padding: 10px 15px;
  border: 2px solid #c8e6c9;
  border-radius: 25px;
  font-size: 16px;
  font-family: 'Comfortaa', sans-serif;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
}

input[type='text']:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  transform: scale(1.02);
}

select {
  padding: 10px 15px;
  border: 2px solid #c8e6c9;
  border-radius: 25px;
  background-color: white;
  font-size: 16px;
  min-width: 200px;
  font-family: 'Comfortaa', sans-serif;
  transition: all 0.3s ease;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.search-button {
  padding: 10px 20px;
  background-color: #0366d6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.search-button:hover {
  background-color: #0353b4;
}

.term-table-container {
  margin-top: 30px;
  border: 1px solid #c8e6c9;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.1);
  background: rgba(255, 255, 255, 0.95);
  position: relative;
  z-index: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* 固定レイアウトを追加 */
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
  word-wrap: break-word; /* 長い単語の折り返し */
  overflow-wrap: break-word; /* 長い単語の折り返し */
}

/* 説明カラムの最小幅を確保 */
td:nth-child(4) {
  min-width: 40%;
  line-height: 1.6;
}

th {
  background-color: #f5f5f5;
  font-weight: 600;
  position: sticky;
  top: 0;
}

tr:hover {
  background-color: #f9f9f9;
}

.term-id {
  display: inline-block;
  min-width: 30px;
  padding: 2px 8px;
  background-color: #e7f3ff;
  color: #0366d6;
  border-radius: 12px;
  font-weight: bold;
  text-align: center;
}

.pagination {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}

.pagination a, .pagination span {
  display: inline-block;
  padding: 8px 16px;
  margin: 0 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #0366d6;
}

.pagination a:hover {
  background-color: #e7f3ff;
}

.pagination .active {
  background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 3px 6px rgba(76, 175, 80, 0.3);
  animation: leaf-sway 3s ease-in-out infinite;
}

.pagination .disabled {
  color: #aaa;
  cursor: not-allowed;
}

/* モバイル最適化スタイル */
@media (max-width: 768px) {
  /* コンテナの調整 */
  .glossary-container {
    padding: 10px;
    position: relative;
  }
  
  /* モバイルでも背景の四葉を表示（やや小さく） */
  .clover-1 { width: 400px; height: 400px; }
  .clover-2 { width: 300px; height: 300px; }
  .clover-3 { width: 200px; height: 200px; }
  .clover-4 { width: 350px; height: 350px; }
  .clover-5 { width: 250px; height: 250px; }
  
  .clover {
    opacity: 0.02;
  }
  
  /* ヘッダーの調整 */
  .glossary-header h1 {
    font-size: 24px;
    text-align: center;
  }
  
  .glossary-description {
    font-size: 14px;
    text-align: center;
  }
  
  /* 検索フォームを縦並びに */
  .search-form {
    flex-direction: column;
    width: 100%;
  }
  
  input[type='text'], select {
    width: 100%;
    font-size: 16px; /* iOS対策 */
    padding: 12px 15px;
  }
  
  select {
    min-width: auto;
  }
  
  .search-button {
    width: 100%;
    padding: 12px 20px;
    font-size: 18px;
    font-family: 'Kalam', 'Comfortaa', cursive;
  }
  
  /* テーブルをカード形式に変更 */
  .term-table-container {
    border: none;
    box-shadow: none;
  }
  
  table, thead, tbody, th, td, tr {
    display: block;
  }
  
  thead tr {
    display: none;
  }
  
  tr {
    margin-bottom: 15px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
  }
  
  /* 有機的な背景パターン */
  tr::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 150%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(76, 175, 80, 0.05) 0%, transparent 50%);
    transform: rotate(45deg);
  }
  
  /* カードのホバー効果 */
  tr:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  }
  
  td {
    border: none;
    padding: 8px 0;
    position: relative;
    z-index: 1;
  }
  
  /* IDを右上に配置 */
  td:nth-child(1) {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 0;
  }
  
  /* 用語名を大きく表示 */
  td:nth-child(2) {
    font-size: 20px;
    font-weight: 700;
    color: #2e7d32;
    margin-bottom: 10px;
    padding-right: 60px;
    font-family: 'Kalam', cursive;
    letter-spacing: 0.5px;
  }
  
  /* カテゴリタグのスタイル調整 */
  td:nth-child(3) {
    margin-bottom: 10px;
  }
  
  .category-tag {
    background: linear-gradient(135deg, #81c784 0%, #4caf50 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  /* 説明文のスタイル */
  td:nth-child(4) {
    color: #555;
    line-height: 1.8;
    font-size: 15px;
  }
  
  /* IDバッジのスタイル変更 */
  .term-id {
    background: linear-gradient(135deg, #64b5f6 0%, #1976d2 100%);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
  }
  
  /* ページネーションの調整 */
  .pagination {
    flex-wrap: wrap;
    gap: 5px;
  }
  
  .pagination a, .pagination span {
    padding: 10px 14px;
    margin: 2px;
    font-family: 'Comfortaa', sans-serif;
    border-radius: 8px;
  }
  
  .pagination .active {
    background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
    border-color: transparent;
  }
  
  /* 結果サマリーの調整 */
  .result-summary {
    text-align: center;
    margin: 15px 0;
  }
  
  .result-summary h2 {
    font-size: 22px;
    color: #2e7d32;
  }
  
  /* パンくずリストの調整 */
  .breadcrumbs {
    font-size: 12px;
    padding: 0 10px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  /* フィルターコンテナの装飾 */
  .filter-container {
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
    border: 1px solid #c8e6c9;
    border-radius: 16px;
    padding: 20px 15px;
  }
  
  /* フッターのモバイル対応 */
  .site-footer .footer-links {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    line-height: 2.5 !important;
  }
  
  .site-footer .footer-links a {
    margin: 0 !important;
    padding: 8px 16px !important;
    display: block !important;
    font-size: 16px !important;
    font-family: 'Comfortaa', sans-serif;
  }
  
  .site-footer .separator {
    display: none !important;
  }
}

/* タブレット向けの調整 */
@media (min-width: 769px) and (max-width: 1024px) {
  .glossary-container {
    padding: 15px;
  }
  
  .search-form {
    flex-wrap: wrap;
  }
  
  input[type='text'] {
    width: 100%;
    margin-bottom: 10px;
  }
}

.glossary-header {
  margin-bottom: 30px;
  text-align: center;
  position: relative;
}

.glossary-header h1 {
  font-size: 28px;
  color: #333;
  margin-bottom: 10px;
}

.glossary-description {
  color: #666;
  font-size: 16px;
  line-height: 1.6;
}

.result-summary {
  margin: 20px 0;
  font-size: 16px;
  color: #555;
}

.category-tag {
  display: inline-block;
  background-color: #e7f3ff;
  color: #0366d6;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 14px;
}

.breadcrumbs {
  margin-bottom: 20px;
  font-size: 14px;
  color: #777;
}

.breadcrumbs a {
  color: #0366d6;
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

/* 巨大な四葉の背景 */
.clover-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

/* 各四葉のクローバー */
.clover {
  position: absolute;
  opacity: 0.03;
}

.clover-1 {
  width: 600px;
  height: 600px;
  top: -100px;
  left: -200px;
  animation: rotate-clover-1 80s linear infinite;
}

.clover-2 {
  width: 400px;
  height: 400px;
  top: 50%;
  right: -100px;
  animation: rotate-clover-2 60s linear infinite reverse;
}

.clover-3 {
  width: 300px;
  height: 300px;
  bottom: -50px;
  left: 20%;
  animation: rotate-clover-3 90s linear infinite;
}

.clover-4 {
  width: 500px;
  height: 500px;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  animation: rotate-clover-4 70s linear infinite;
}

.clover-5 {
  width: 350px;
  height: 350px;
  bottom: 10%;
  right: 10%;
  animation: rotate-clover-5 100s linear infinite reverse;
}

@keyframes rotate-clover-1 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotate-clover-2 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotate-clover-3 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotate-clover-4 {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}

@keyframes rotate-clover-5 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 頭文字フィルターのスタイル */
.initial-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.initial-label {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  color: #2e7d32;
  margin-right: 10px;
}

.initial-link {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #c8e6c9;
  border-radius: 20px;
  text-decoration: none;
  color: #2e7d32;
  font-family: 'Comfortaa', sans-serif;
  font-size: 14px;
  transition: all 0.3s ease;
  background: white;
}

.initial-link:hover {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.initial-link.active {
  background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 3px 6px rgba(76, 175, 80, 0.3);
}

.initial-group {
  display: flex;
  gap: 5px;
  align-items: center;
}

.initial-separator {
  margin: 0 10px;
  color: #c8e6c9;
}

/* A8広告の中央配置 */
.ad-container {
  text-align: center;
  margin: 20px auto;
  padding: 10px 0;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.ad-container a {
  display: inline-block;
}