.ya-service-flow {
  padding: 20px 60px;
  position: relative;
  overflow: hidden;
}

.ya-service-flow::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.ya-flow-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 2;
}

.ya-section-title {
  text-align: center;
  font-size: 3rem;
  font-weight: 200;
  color: #2c3e50;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.ya-section-subtitle {
  text-align: center;
  font-size: 1.2rem;
  color: #7f8c8d;
  margin-bottom: 80px;
  font-weight: 300;
}

/* フレキシブルグリッドレイアウト - ステップ数に応じて自動調整 */
.ya-flow-container {
  display: grid;
  gap: 40px;
  margin-bottom: 60px;
}

/* 1-2ステップ: 中央寄せで1列 */
.ya-flow-container:has(.ya-flow-step:nth-child(1):last-child),
.ya-flow-container:has(.ya-flow-step:nth-child(2):last-child) {
  grid-template-columns: repeat(auto-fit, minmax(320px, 500px));
  justify-content: center;
}

/* 3ステップ: 3列 */
.ya-flow-container:has(.ya-flow-step:nth-child(3):last-child) {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* 4ステップ: 4列（デスクトップ）、2列（タブレット） */
.ya-flow-container:has(.ya-flow-step:nth-child(4):last-child) {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* 5ステップ以上: 自動調整 */
.ya-flow-container:has(.ya-flow-step:nth-child(5)) {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.ya-flow-step {
  position: relative;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.8s ease forwards;
}

.ya-flow-step:nth-child(1) { animation-delay: 0.1s; }
.ya-flow-step:nth-child(2) { animation-delay: 0.3s; }
.ya-flow-step:nth-child(3) { animation-delay: 0.5s; }
.ya-flow-step:nth-child(4) { animation-delay: 0.7s; }
.ya-flow-step:nth-child(5) { animation-delay: 0.9s; }
.ya-flow-step:nth-child(6) { animation-delay: 1.1s; }
.ya-flow-step:nth-child(7) { animation-delay: 1.3s; }
.ya-flow-step:nth-child(8) { animation-delay: 1.5s; }

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ya-step-number {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #018091, #7ab6a1);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(52, 152, 219, 0.3);
  z-index: 2;
  transition: all 0.3s ease;
}

.ya-step-content {
  background: white;
  padding: 40px 30px 0px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: all 0.4s ease;
  height: 100%;
  position: relative;
}

.ya-flow-step:hover .ya-step-content {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.ya-flow-step:hover .ya-step-number {
  transform: scale(1.1);
  box-shadow: 0 12px 25px rgba(52, 152, 219, 0.4);
}

.ya-step-icon {
  text-align: center;
  margin-bottom: 25px;
  color: #018091;
}

.ya-step-icon svg {
  transition: all 0.3s ease;
}

.ya-flow-step:hover .ya-step-icon svg {
  transform: scale(1.1);
  filter: drop-shadow(0 4px 8px rgba(52, 152, 219, 0.3));
}

.ya-step-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #018091;
  margin-bottom: 15px;
  text-align: center;
}

.ya-step-description {
  font-size: 1rem;
  line-height: 1.7;
  color: #5a6c7d;
  margin-bottom: 20px;
  text-align: center;
}

.ya-step-detail {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ya-detail-tag, .ya-detail-time {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.ya-detail-tag {
  background: #f6e3bb;
  color: #1c8c95;
  border: 1px solid rgba(52, 152, 219, 0.2);
}

.ya-detail-time {
  background: rgba(155, 89, 182, 0.1);
  color: #d37ef4;
  border: 1px solid rgba(155, 89, 182, 0.2);
}

.ya-flow-step:hover .ya-detail-tag {
  background: #f0daaa;
  border-color: #1c8c95;
}

.ya-flow-step:hover .ya-detail-time {
  background: rgba(155, 89, 182, 0.2);
  border-color: rgba(155, 89, 182, 0.4);
}

.ya-flow-arrow {
  position: absolute;
  right: -30px;
  top: 50%;
  transform: translateY(-50%);
  color: #0076c5;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.ya-flow-step:hover .ya-flow-arrow {
  color: #3498db;
  opacity: 1;
  transform: translateY(-50%) translateX(5px);
}

.ya-flow-step:last-child .ya-flow-arrow {
  display: none;
}

.ya-flow-cta {
  text-align: center;
  margin-top: 120px;
}

.ya-cta-button {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 18px 40px;
  border-radius: 50px;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
  transition: all 0.4s ease;
  border: none;
  cursor: pointer;
}

.ya-cta-button:hover {
  color: #7ab6a1;
  transform: translateY(-3px);
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.ya-cta-button svg {
  transition: all 0.3s ease;
}

.ya-cta-button:hover svg {
  transform: translateX(5px);
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
  /* 4ステップ以上は3列に */
  .ya-flow-container:has(.ya-flow-step:nth-child(4)) {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

@media (max-width: 1024px) {
  /* すべて2列に */
  .ya-flow-container,
  .ya-flow-container:has(.ya-flow-step:nth-child(1):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(2):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(3):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(4):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(5)) {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
  }
  
  .ya-flow-arrow {
    display: none;
  }
}

@media (max-width: 768px) {
  .ya-service-flow {
    padding: 60px 0;
  }
  
  .ya-section-title {
    font-size: 2.5rem;
  }
  
  .ya-section-subtitle {
    font-size: 1.1rem;
    margin-bottom: 50px;
  }
  
  /* すべて1列に */
  .ya-flow-container,
  .ya-flow-container:has(.ya-flow-step:nth-child(1):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(2):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(3):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(4):last-child),
  .ya-flow-container:has(.ya-flow-step:nth-child(5)) {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  
  .ya-step-content {
    padding: 30px 20px 25px;
  }
  
  .ya-step-title {
    font-size: 1.3rem;
  }
  
  .ya-step-description {
    font-size: 0.95rem;
  }
  
  .ya-step-detail {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  
  .ya-detail-tag, .ya-detail-time {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
  
  .ya-cta-button {
    padding: 15px 30px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .ya-section-title {
    font-size: 2rem;
    margin-bottom: 15px;
  }
  
  .ya-section-subtitle {
    font-size: 1rem;
    margin-bottom: 40px;
    padding: 0 10px;
  }
  
  .ya-step-number {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    top: -8px;
    left: -8px;
  }
  
  .ya-step-content {
    padding: 25px 15px 20px;
  }
  
  .ya-step-title {
    font-size: 1.2rem;
  }
  
  .ya-step-description {
    font-size: 0.9rem;
    line-height: 1.6;
  }
  
  .ya-step-icon svg {
    width: 40px;
    height: 40px;
  }
  
  .ya-cta-button {
    padding: 12px 25px;
    font-size: 0.95rem;
    gap: 10px;
  }
  
  .ya-cta-button svg {
    width: 16px;
    height: 16px;
  }
}

/* 大画面での最適化 */
@media (min-width: 1400px) {
  /* 4ステップ: しっかり4列 */
  .ya-flow-container:has(.ya-flow-step:nth-child(4):last-child) {
    grid-template-columns: repeat(4, 1fr);
    gap: 50px;
  }
  
  /* 5ステップ以上: 最大4列で折り返し */
  .ya-flow-container:has(.ya-flow-step:nth-child(5)) {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 50px;
  }
  
  .ya-flow-arrow {
    right: -40px;
  }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
  .ya-flow-step {
    animation: none;
    opacity: 1;
    transform: none;
  }
  
  .ya-step-content,
  .ya-step-icon svg,
  .ya-flow-arrow,
  .ya-cta-button,
  .ya-cta-button svg,
  .ya-step-number,
  .ya-detail-tag,
  .ya-detail-time {
    transition: none;
  }
  
  .ya-flow-step:hover .ya-step-content {
    transform: none;
  }
  
  .ya-flow-step:hover .ya-step-icon svg {
    transform: none;
  }
  
  .ya-flow-step:hover .ya-flow-arrow {
    transform: translateY(-50%);
  }
  
  .ya-cta-button:hover {
    transform: none;
  }
  
  .ya-cta-button:hover svg {
    transform: none;
  }
  
  .ya-flow-step:hover .ya-step-number {
    transform: none;
  }
}

/* ハイコントラストモード対応 */
@media (prefers-contrast: high) {
  .ya-step-number {
    background: #000;
    color: #fff;
    border: 2px solid #fff;
  }
  
  .ya-step-content {
    border: 2px solid #333;
  }
  
  .ya-step-title {
    color: #000;
  }
  
  .ya-step-description {
    color: #333;
  }
  
  .ya-detail-tag {
    background: #000;
    color: #fff;
    border: 1px solid #000;
  }
  
  .ya-detail-time {
    background: #333;
    color: #fff;
    border: 1px solid #333;
  }
  
  .ya-cta-button {
    background: #000;
    color: #fff;
    border: 2px solid #000;
  }
}

/* フォーカス状態のスタイル */
.ya-cta-button:focus {
  outline: 3px solid rgba(102, 126, 234, 0.5);
  outline-offset: 3px;
}

.ya-cta-button:focus:not(:focus-visible) {
  outline: none;
}

.ya-cta-button:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.5);
  outline-offset: 3px;
}